summaryrefslogtreecommitdiff
path: root/core/src/main
diff options
context:
space:
mode:
authorByteHamster <info@bytehamster.com>2019-05-07 15:21:54 +0200
committerByteHamster <info@bytehamster.com>2019-05-07 15:32:48 +0200
commit5a9958098564a38513ace68aac92c235aab3d65e (patch)
treeb4aea6f44c07712d9efea7b003461daed957c8cf /core/src/main
parentc16bbdfc9691b663cf11c6269fef296e6d189a8f (diff)
downloadAntennaPod-5a9958098564a38513ace68aac92c235aab3d65e.zip
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.
Diffstat (limited to 'core/src/main')
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/service/playback/LocalPSMP.java30
1 files changed, 11 insertions, 19 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/playback/LocalPSMP.java b/core/src/main/java/de/danoeh/antennapod/core/service/playback/LocalPSMP.java
index d0ad45f1c..a4099bf94 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/service/playback/LocalPSMP.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/service/playback/LocalPSMP.java
@@ -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();
}
}