From f2e761c07cd89eaa472be31f4c4c94b68974d63e Mon Sep 17 00:00:00 2001 From: Adam Howard Date: Thu, 17 Dec 2015 18:27:35 +0000 Subject: [PATCH] added reacquisition of CPU lock after resuming --- app/src/main/java/org/schabi/newpipe/BackgroundPlayer.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/BackgroundPlayer.java b/app/src/main/java/org/schabi/newpipe/BackgroundPlayer.java index 03e1eb40b..7c73d4402 100644 --- a/app/src/main/java/org/schabi/newpipe/BackgroundPlayer.java +++ b/app/src/main/java/org/schabi/newpipe/BackgroundPlayer.java @@ -216,11 +216,13 @@ public class BackgroundPlayer extends Service /*implements MediaPlayer.OnPrepare mediaPlayer.pause(); } else { + //reacquire CPU lock after releasing it on pause + mediaPlayer.setWakeMode(getApplicationContext(), PowerManager.PARTIAL_WAKE_LOCK); mediaPlayer.start(); } } else if(action.equals(ACTION_STOP)) { - mediaPlayer.stop(); + mediaPlayer.stop();//this auto-releases CPU lock afterPlayCleanup(); } } @@ -237,7 +239,6 @@ public class BackgroundPlayer extends Service /*implements MediaPlayer.OnPrepare stopForeground(true);//remove foreground status of service; make us killable stopSelf(); - //todo:release cpu lock } private class EndListener implements MediaPlayer.OnCompletionListener {