summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordaniel oeh <daniel.oeh@gmail.com>2014-02-15 13:57:19 +0100
committerdaniel oeh <daniel.oeh@gmail.com>2014-02-15 13:57:19 +0100
commit7d44c471f293d49652e70a277e89a4f99823ab92 (patch)
treed73dbe540052c417e4eab4717329d177321f255e
parent65a2313751b218d25384615ef2be12eeaeca26b9 (diff)
downloadAntennaPod-7d44c471f293d49652e70a277e89a4f99823ab92.zip
Added RejectedExecutionHandler to Runnable
-rw-r--r--src/de/danoeh/antennapod/service/playback/PlaybackServiceMediaPlayer.java17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/de/danoeh/antennapod/service/playback/PlaybackServiceMediaPlayer.java b/src/de/danoeh/antennapod/service/playback/PlaybackServiceMediaPlayer.java
index 52cde2718..20e2f703b 100644
--- a/src/de/danoeh/antennapod/service/playback/PlaybackServiceMediaPlayer.java
+++ b/src/de/danoeh/antennapod/service/playback/PlaybackServiceMediaPlayer.java
@@ -18,8 +18,10 @@ import de.danoeh.antennapod.util.playback.Playable;
import de.danoeh.antennapod.util.playback.VideoPlayer;
import java.io.IOException;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
+import java.util.concurrent.LinkedBlockingDeque;
+import java.util.concurrent.RejectedExecutionHandler;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.locks.ReentrantLock;
@@ -56,7 +58,7 @@ public class PlaybackServiceMediaPlayer {
private final PSMPCallback callback;
private final Context context;
- private final ExecutorService executor;
+ private final ThreadPoolExecutor executor;
public PlaybackServiceMediaPlayer(Context context, PSMPCallback callback) {
if (context == null)
@@ -69,7 +71,14 @@ public class PlaybackServiceMediaPlayer {
this.audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
this.playerLock = new ReentrantLock();
this.startWhenPrepared = new AtomicBoolean(false);
- executor = Executors.newSingleThreadExecutor();
+ executor = new ThreadPoolExecutor(1, 1, 5, TimeUnit.MINUTES, new LinkedBlockingDeque<Runnable>(),
+ new RejectedExecutionHandler() {
+ @Override
+ public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
+ if (AppConfig.DEBUG) Log.d(TAG, "Rejected execution of runnable");
+ }
+ });
+
mediaPlayer = null;
statusBeforeSeeking = null;
pausedBecauseOfTransientAudiofocusLoss = false;