Java Code Examples for android.os.Process#THREAD_PRIORITY_AUDIO
The following examples show how to use
android.os.Process#THREAD_PRIORITY_AUDIO .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExoPlayerImplInternal.java From Exoplayer_VLC with Apache License 2.0 | 6 votes |
public ExoPlayerImplInternal(Handler eventHandler, boolean playWhenReady, boolean[] rendererEnabledFlags, int minBufferMs, int minRebufferMs) { this.eventHandler = eventHandler; this.playWhenReady = playWhenReady; this.rendererEnabledFlags = new boolean[rendererEnabledFlags.length]; this.minBufferUs = minBufferMs * 1000L; this.minRebufferUs = minRebufferMs * 1000L; for (int i = 0; i < rendererEnabledFlags.length; i++) { this.rendererEnabledFlags[i] = rendererEnabledFlags[i]; } this.state = ExoPlayer.STATE_IDLE; this.durationUs = TrackRenderer.UNKNOWN_TIME_US; this.bufferedPositionUs = TrackRenderer.UNKNOWN_TIME_US; mediaClock = new MediaClock(); enabledRenderers = new ArrayList<TrackRenderer>(rendererEnabledFlags.length); // Note: The documentation for Process.THREAD_PRIORITY_AUDIO that states "Applications can // not normally change to this priority" is incorrect. internalPlaybackThread = new PriorityHandlerThread(getClass().getSimpleName() + ":Handler", Process.THREAD_PRIORITY_AUDIO); internalPlaybackThread.start(); handler = new Handler(internalPlaybackThread.getLooper(), this); }
Example 2
Source File: MediaPlayer.java From MediaPlayer-Extended with Apache License 2.0 | 6 votes |
public PlaybackThread() { // Give this thread a high priority for more precise event timing super(TAG + "#" + PlaybackThread.class.getSimpleName(), Process.THREAD_PRIORITY_AUDIO); // Init fields mPaused = true; mReleasing = false; mRenderModeApi21 = mVideoRenderTimingMode.isRenderModeApi21(); mRenderingStarted = true; mAVLocked = false; mLastBufferingUpdateTime = 0; mLastCueEventTime = 0; mOnTimelineCueListener = new Timeline.OnCueListener() { @Override public void onCue(Cue cue) { mEventHandler.sendMessage(mEventHandler.obtainMessage(MEDIA_CUE, cue)); } }; }
Example 3
Source File: LiveVideoBroadcaster.java From LiveVideoBroadcaster with Apache License 2.0 | 5 votes |
public void init(Activity activity, GLSurfaceView glView) { try { audioHandlerThread = new HandlerThread("AudioHandlerThread", Process.THREAD_PRIORITY_AUDIO); audioHandlerThread.start(); audioHandler = new AudioHandler(audioHandlerThread.getLooper()); mCameraHandler = new CameraHandler(this); this.context = activity; // Define a handler that receives camera-control messages from other threads. All calls // to Camera must be made on the same thread. Note we create this before the renderer // thread, so we know the fully-constructed object will be visible. mRenderer = new CameraSurfaceRenderer(mCameraHandler, sVideoEncoder); mGLView = glView; mGLView.setRenderer(mRenderer); mGLView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY); mRtmpHandlerThread = new HandlerThread("RtmpStreamerThread"); //, Process.THREAD_PRIORITY_BACKGROUND); mRtmpHandlerThread.start(); mRtmpStreamer = new RTMPStreamer(mRtmpHandlerThread.getLooper()); connectivityManager = (ConnectivityManager) this.getSystemService( Context.CONNECTIVITY_SERVICE); } catch (Exception e) { e.printStackTrace(); } }
Example 4
Source File: ExoPlayerImplInternal.java From K-Sonic with MIT License | 5 votes |
public ExoPlayerImplInternal(Renderer[] renderers, TrackSelector trackSelector, LoadControl loadControl, boolean playWhenReady, Handler eventHandler, PlaybackInfo playbackInfo, ExoPlayer player) { this.renderers = renderers; this.trackSelector = trackSelector; this.loadControl = loadControl; this.playWhenReady = playWhenReady; this.eventHandler = eventHandler; this.state = ExoPlayer.STATE_IDLE; this.playbackInfo = playbackInfo; this.player = player; rendererCapabilities = new RendererCapabilities[renderers.length]; for (int i = 0; i < renderers.length; i++) { renderers[i].setIndex(i); rendererCapabilities[i] = renderers[i].getCapabilities(); } standaloneMediaClock = new StandaloneMediaClock(); enabledRenderers = new Renderer[0]; window = new Timeline.Window(); period = new Timeline.Period(); trackSelector.init(this); // Note: The documentation for Process.THREAD_PRIORITY_AUDIO that states "Applications can // not normally change to this priority" is incorrect. internalPlaybackThread = new PriorityHandlerThread("ExoPlayerImplInternal:Handler", Process.THREAD_PRIORITY_AUDIO); internalPlaybackThread.start(); handler = new Handler(internalPlaybackThread.getLooper(), this); }
Example 5
Source File: ExoPlayerImplInternal.java From MediaSDK with Apache License 2.0 | 4 votes |
public ExoPlayerImplInternal( Renderer[] renderers, TrackSelector trackSelector, TrackSelectorResult emptyTrackSelectorResult, LoadControl loadControl, BandwidthMeter bandwidthMeter, boolean playWhenReady, @Player.RepeatMode int repeatMode, boolean shuffleModeEnabled, Handler eventHandler, Clock clock) { this.renderers = renderers; this.trackSelector = trackSelector; this.emptyTrackSelectorResult = emptyTrackSelectorResult; this.loadControl = loadControl; this.bandwidthMeter = bandwidthMeter; this.playWhenReady = playWhenReady; this.repeatMode = repeatMode; this.shuffleModeEnabled = shuffleModeEnabled; this.eventHandler = eventHandler; this.clock = clock; this.queue = new MediaPeriodQueue(); backBufferDurationUs = loadControl.getBackBufferDurationUs(); retainBackBufferFromKeyframe = loadControl.retainBackBufferFromKeyframe(); seekParameters = SeekParameters.DEFAULT; playbackInfo = PlaybackInfo.createDummy(/* startPositionUs= */ C.TIME_UNSET, emptyTrackSelectorResult); playbackInfoUpdate = new PlaybackInfoUpdate(); rendererCapabilities = new RendererCapabilities[renderers.length]; for (int i = 0; i < renderers.length; i++) { renderers[i].setIndex(i); rendererCapabilities[i] = renderers[i].getCapabilities(); } mediaClock = new DefaultMediaClock(this, clock); pendingMessages = new ArrayList<>(); enabledRenderers = new Renderer[0]; window = new Timeline.Window(); period = new Timeline.Period(); trackSelector.init(/* listener= */ this, bandwidthMeter); // Note: The documentation for Process.THREAD_PRIORITY_AUDIO that states "Applications can // not normally change to this priority" is incorrect. internalPlaybackThread = new HandlerThread("ExoPlayerImplInternal:Handler", Process.THREAD_PRIORITY_AUDIO); internalPlaybackThread.start(); handler = clock.createHandler(internalPlaybackThread.getLooper(), this); deliverPendingMessageAtStartPositionRequired = true; }
Example 6
Source File: ExoPlayerImplInternal.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
public ExoPlayerImplInternal( Renderer[] renderers, TrackSelector trackSelector, TrackSelectorResult emptyTrackSelectorResult, LoadControl loadControl, BandwidthMeter bandwidthMeter, boolean playWhenReady, @Player.RepeatMode int repeatMode, boolean shuffleModeEnabled, Handler eventHandler, ExoPlayer player, Clock clock) { this.renderers = renderers; this.trackSelector = trackSelector; this.emptyTrackSelectorResult = emptyTrackSelectorResult; this.loadControl = loadControl; this.bandwidthMeter = bandwidthMeter; this.playWhenReady = playWhenReady; this.repeatMode = repeatMode; this.shuffleModeEnabled = shuffleModeEnabled; this.eventHandler = eventHandler; this.player = player; this.clock = clock; this.queue = new MediaPeriodQueue(); backBufferDurationUs = loadControl.getBackBufferDurationUs(); retainBackBufferFromKeyframe = loadControl.retainBackBufferFromKeyframe(); seekParameters = SeekParameters.DEFAULT; playbackInfo = PlaybackInfo.createDummy(/* startPositionUs= */ C.TIME_UNSET, emptyTrackSelectorResult); playbackInfoUpdate = new PlaybackInfoUpdate(); rendererCapabilities = new RendererCapabilities[renderers.length]; for (int i = 0; i < renderers.length; i++) { renderers[i].setIndex(i); rendererCapabilities[i] = renderers[i].getCapabilities(); } mediaClock = new DefaultMediaClock(this, clock); pendingMessages = new ArrayList<>(); enabledRenderers = new Renderer[0]; window = new Timeline.Window(); period = new Timeline.Period(); trackSelector.init(/* listener= */ this, bandwidthMeter); // Note: The documentation for Process.THREAD_PRIORITY_AUDIO that states "Applications can // not normally change to this priority" is incorrect. internalPlaybackThread = new HandlerThread("ExoPlayerImplInternal:Handler", Process.THREAD_PRIORITY_AUDIO); internalPlaybackThread.start(); handler = clock.createHandler(internalPlaybackThread.getLooper(), this); }
Example 7
Source File: ExoPlayerImplInternal.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
public ExoPlayerImplInternal( Renderer[] renderers, TrackSelector trackSelector, TrackSelectorResult emptyTrackSelectorResult, LoadControl loadControl, BandwidthMeter bandwidthMeter, boolean playWhenReady, @Player.RepeatMode int repeatMode, boolean shuffleModeEnabled, Handler eventHandler, ExoPlayer player, Clock clock) { this.renderers = renderers; this.trackSelector = trackSelector; this.emptyTrackSelectorResult = emptyTrackSelectorResult; this.loadControl = loadControl; this.bandwidthMeter = bandwidthMeter; this.playWhenReady = playWhenReady; this.repeatMode = repeatMode; this.shuffleModeEnabled = shuffleModeEnabled; this.eventHandler = eventHandler; this.player = player; this.clock = clock; this.queue = new MediaPeriodQueue(); backBufferDurationUs = loadControl.getBackBufferDurationUs(); retainBackBufferFromKeyframe = loadControl.retainBackBufferFromKeyframe(); seekParameters = SeekParameters.DEFAULT; playbackInfo = PlaybackInfo.createDummy(/* startPositionUs= */ C.TIME_UNSET, emptyTrackSelectorResult); playbackInfoUpdate = new PlaybackInfoUpdate(); rendererCapabilities = new RendererCapabilities[renderers.length]; for (int i = 0; i < renderers.length; i++) { renderers[i].setIndex(i); rendererCapabilities[i] = renderers[i].getCapabilities(); } mediaClock = new DefaultMediaClock(this, clock); pendingMessages = new ArrayList<>(); enabledRenderers = new Renderer[0]; window = new Timeline.Window(); period = new Timeline.Period(); trackSelector.init(/* listener= */ this, bandwidthMeter); // Note: The documentation for Process.THREAD_PRIORITY_AUDIO that states "Applications can // not normally change to this priority" is incorrect. internalPlaybackThread = new HandlerThread("ExoPlayerImplInternal:Handler", Process.THREAD_PRIORITY_AUDIO); internalPlaybackThread.start(); handler = clock.createHandler(internalPlaybackThread.getLooper(), this); }
Example 8
Source File: ExoPlayerImplInternal.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
public ExoPlayerImplInternal( Renderer[] renderers, TrackSelector trackSelector, TrackSelectorResult emptyTrackSelectorResult, LoadControl loadControl, BandwidthMeter bandwidthMeter, boolean playWhenReady, @Player.RepeatMode int repeatMode, boolean shuffleModeEnabled, Handler eventHandler, Clock clock) { this.renderers = renderers; this.trackSelector = trackSelector; this.emptyTrackSelectorResult = emptyTrackSelectorResult; this.loadControl = loadControl; this.bandwidthMeter = bandwidthMeter; this.playWhenReady = playWhenReady; this.repeatMode = repeatMode; this.shuffleModeEnabled = shuffleModeEnabled; this.eventHandler = eventHandler; this.clock = clock; this.queue = new MediaPeriodQueue(); backBufferDurationUs = loadControl.getBackBufferDurationUs(); retainBackBufferFromKeyframe = loadControl.retainBackBufferFromKeyframe(); seekParameters = SeekParameters.DEFAULT; playbackInfo = PlaybackInfo.createDummy(/* startPositionUs= */ C.TIME_UNSET, emptyTrackSelectorResult); playbackInfoUpdate = new PlaybackInfoUpdate(); rendererCapabilities = new RendererCapabilities[renderers.length]; for (int i = 0; i < renderers.length; i++) { renderers[i].setIndex(i); rendererCapabilities[i] = renderers[i].getCapabilities(); } mediaClock = new DefaultMediaClock(this, clock); pendingMessages = new ArrayList<>(); enabledRenderers = new Renderer[0]; window = new Timeline.Window(); period = new Timeline.Period(); trackSelector.init(/* listener= */ this, bandwidthMeter); // Note: The documentation for Process.THREAD_PRIORITY_AUDIO that states "Applications can // not normally change to this priority" is incorrect. internalPlaybackThread = new HandlerThread("ExoPlayerImplInternal:Handler", Process.THREAD_PRIORITY_AUDIO); internalPlaybackThread.start(); handler = clock.createHandler(internalPlaybackThread.getLooper(), this); }
Example 9
Source File: AudioEncoderThread.java From LiveMultimedia with Apache License 2.0 | 4 votes |
public AudioEncoderThread(String name) { super(name, Process.THREAD_PRIORITY_AUDIO); }
Example 10
Source File: ExoPlayerImplInternal.java From Telegram with GNU General Public License v2.0 | 4 votes |
public ExoPlayerImplInternal( Renderer[] renderers, TrackSelector trackSelector, TrackSelectorResult emptyTrackSelectorResult, LoadControl loadControl, BandwidthMeter bandwidthMeter, boolean playWhenReady, @Player.RepeatMode int repeatMode, boolean shuffleModeEnabled, Handler eventHandler, Clock clock) { this.renderers = renderers; this.trackSelector = trackSelector; this.emptyTrackSelectorResult = emptyTrackSelectorResult; this.loadControl = loadControl; this.bandwidthMeter = bandwidthMeter; this.playWhenReady = playWhenReady; this.repeatMode = repeatMode; this.shuffleModeEnabled = shuffleModeEnabled; this.eventHandler = eventHandler; this.clock = clock; this.queue = new MediaPeriodQueue(); backBufferDurationUs = loadControl.getBackBufferDurationUs(); retainBackBufferFromKeyframe = loadControl.retainBackBufferFromKeyframe(); seekParameters = SeekParameters.DEFAULT; playbackInfo = PlaybackInfo.createDummy(/* startPositionUs= */ C.TIME_UNSET, emptyTrackSelectorResult); playbackInfoUpdate = new PlaybackInfoUpdate(); rendererCapabilities = new RendererCapabilities[renderers.length]; for (int i = 0; i < renderers.length; i++) { renderers[i].setIndex(i); rendererCapabilities[i] = renderers[i].getCapabilities(); } mediaClock = new DefaultMediaClock(this, clock); pendingMessages = new ArrayList<>(); enabledRenderers = new Renderer[0]; window = new Timeline.Window(); period = new Timeline.Period(); trackSelector.init(/* listener= */ this, bandwidthMeter); // Note: The documentation for Process.THREAD_PRIORITY_AUDIO that states "Applications can // not normally change to this priority" is incorrect. internalPlaybackThread = new HandlerThread("ExoPlayerImplInternal:Handler", Process.THREAD_PRIORITY_AUDIO); internalPlaybackThread.start(); handler = clock.createHandler(internalPlaybackThread.getLooper(), this); }
Example 11
Source File: PlaybackService.java From Cheerleader with Apache License 2.0 | 3 votes |
@Override public void onCreate() { super.onCreate(); mHandlerThread = new HandlerThread(THREAD_NAME, Process.THREAD_PRIORITY_AUDIO); mHandlerThread.start(); mPlayerHandler = new PlayerHandler(mHandlerThread.getLooper()); mMediaPlayer = new MediaPlayer(); initializeMediaPlayer(); mStopServiceHandler = new StopHandler(mHandlerThread.getLooper()); // instantiate target used to load track artwork. mMediaSessionArtworkTarget = new MediaSessionArtworkTarget(); // create handler on the main thread to avoid throwing error // with picasso when bitmap is retrieved and loaded in notification. mMainThreadHandler = new Handler(getApplicationContext().getMainLooper()); mWifiLock = ((WifiManager) getBaseContext().getSystemService(Context.WIFI_SERVICE)) .createWifiLock(WifiManager.WIFI_MODE_FULL, WIFI_LOCK_TAG); mLocalBroadcastManager = LocalBroadcastManager.getInstance(getApplicationContext()); mNotificationManager = NotificationManager.getInstance(this); mPlayerPlaylist = PlayerPlaylist.getInstance(); mHasAlreadyPlayed = false; mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); mMediaSession = new MediaSessionWrapper(this, new MediaSessionCallback(), mAudioManager); }
Example 12
Source File: ThreadUtils.java From cronet with BSD 3-Clause "New" or "Revised" License | 2 votes |
/** * Checks whether Thread priority is THREAD_PRIORITY_AUDIO or not. * @param tid Thread id. * @return true for THREAD_PRIORITY_AUDIO and false otherwise. */ @CalledByNative private static boolean isThreadPriorityAudio(int tid) { return Process.getThreadPriority(tid) == Process.THREAD_PRIORITY_AUDIO; }
Example 13
Source File: ThreadUtils.java From 365browser with Apache License 2.0 | 2 votes |
/** * Checks whether Thread priority is THREAD_PRIORITY_AUDIO or not. * @param tid Thread id. * @return true for THREAD_PRIORITY_AUDIO and false otherwise. */ @CalledByNative private static boolean isThreadPriorityAudio(int tid) { return Process.getThreadPriority(tid) == Process.THREAD_PRIORITY_AUDIO; }