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:
ByteHamster 2019-05-07 15:21:54 +02:00
parent c16bbdfc96
commit 5a99580985
1 changed files with 11 additions and 19 deletions

View File

@ -1088,9 +1088,8 @@ public class LocalPSMP extends PlaybackServiceMediaPlayer {
mp -> genericSeekCompleteListener(); mp -> genericSeekCompleteListener();
private void genericSeekCompleteListener() { private void genericSeekCompleteListener() {
Runnable r = () -> {
Log.d(TAG, "genericSeekCompleteListener"); Log.d(TAG, "genericSeekCompleteListener");
if(seekLatch != null) { if (seekLatch != null) {
seekLatch.countDown(); seekLatch.countDown();
} }
playerLock.lock(); playerLock.lock();
@ -1101,12 +1100,5 @@ public class LocalPSMP extends PlaybackServiceMediaPlayer {
setPlayerStatus(statusBeforeSeeking, media, getPosition()); setPlayerStatus(statusBeforeSeeking, media, getPosition());
} }
playerLock.unlock(); playerLock.unlock();
};
if (useCallerThread) {
r.run();
} else {
executor.submit(r);
}
} }
} }