cancel chapter loader thread if service receives shutdown notification

This commit is contained in:
daniel oeh 2012-09-25 14:12:59 +02:00
parent e206d1571f
commit 6904ea23a6
1 changed files with 9 additions and 1 deletions

View File

@ -134,6 +134,8 @@ public class PlaybackService extends Service {
private SleepTimer sleepTimer;
private Future sleepTimerFuture;
private Thread chapterLoader;
private static final int SCHED_EX_POOL_SIZE = 3;
private ScheduledThreadPoolExecutor schedExecutor;
@ -556,7 +558,10 @@ public class PlaybackService extends Service {
}
if (shouldStream && media.getItem().getChapters() == null) {
// load chapters if available
Thread chapterLoader = new Thread() {
if (chapterLoader != null) {
chapterLoader.interrupt();
}
chapterLoader = new Thread() {
@Override
public void run() {
@ -1004,6 +1009,9 @@ public class PlaybackService extends Service {
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(ACTION_SHUTDOWN_PLAYBACK_SERVICE)) {
schedExecutor.shutdownNow();
if (chapterLoader != null) {
chapterLoader.interrupt();
}
stop();
media = null;
feed = null;