Do not deadlock on seek when using Sonic
Callbacks are called on the thread that created the MediaPlayer. For Sonic, this is the executor. For ExoPlayer, this is the main thread. When calling executor.submit, every thread waiting for the runnable to complete gets blocked. Because the callback is called in the thread that created the player, we can simply remove the call to executor.submit and still be sure that a background thread is used.
This commit is contained in:
parent
c16bbdfc96
commit
5a99580985
|
@ -1088,25 +1088,17 @@ public class LocalPSMP extends PlaybackServiceMediaPlayer {
|
|||
mp -> genericSeekCompleteListener();
|
||||
|
||||
private void genericSeekCompleteListener() {
|
||||
Runnable r = () -> {
|
||||
Log.d(TAG, "genericSeekCompleteListener");
|
||||
if(seekLatch != null) {
|
||||
seekLatch.countDown();
|
||||
}
|
||||
playerLock.lock();
|
||||
if (playerStatus == PlayerStatus.PLAYING) {
|
||||
callback.onPlaybackStart(media, getPosition());
|
||||
}
|
||||
if (playerStatus == PlayerStatus.SEEKING) {
|
||||
setPlayerStatus(statusBeforeSeeking, media, getPosition());
|
||||
}
|
||||
playerLock.unlock();
|
||||
};
|
||||
|
||||
if (useCallerThread) {
|
||||
r.run();
|
||||
} else {
|
||||
executor.submit(r);
|
||||
Log.d(TAG, "genericSeekCompleteListener");
|
||||
if (seekLatch != null) {
|
||||
seekLatch.countDown();
|
||||
}
|
||||
playerLock.lock();
|
||||
if (playerStatus == PlayerStatus.PLAYING) {
|
||||
callback.onPlaybackStart(media, getPosition());
|
||||
}
|
||||
if (playerStatus == PlayerStatus.SEEKING) {
|
||||
setPlayerStatus(statusBeforeSeeking, media, getPosition());
|
||||
}
|
||||
playerLock.unlock();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue