eleven: Fix crash when unplugging headphones
* Don't crash if the handler was never created.
Change-Id: I22aedbf5e912e086db04bbb0dc09d7434dba99b9
diff --git a/src/com/cyanogenmod/eleven/MusicPlaybackService.java b/src/com/cyanogenmod/eleven/MusicPlaybackService.java
index 64a131e..9a064d1 100644
--- a/src/com/cyanogenmod/eleven/MusicPlaybackService.java
+++ b/src/com/cyanogenmod/eleven/MusicPlaybackService.java
@@ -2502,7 +2502,9 @@
public void pause() {
if (D) Log.d(TAG, "Pausing playback");
synchronized (this) {
- mPlayerHandler.removeMessages(FADEUP);
+ if (mPlayerHandler != null) {
+ mPlayerHandler.removeMessages(FADEUP);
+ }
if (mIsSupposedToBePlaying) {
final Intent intent = new Intent(
AudioEffect.ACTION_CLOSE_AUDIO_EFFECT_CONTROL_SESSION);
@@ -2510,7 +2512,9 @@
intent.putExtra(AudioEffect.EXTRA_PACKAGE_NAME, getPackageName());
sendBroadcast(intent);
- mPlayer.pause();
+ if (mPlayer != null) {
+ mPlayer.pause();
+ }
setIsSupposedToBePlaying(false, true);
stopShakeDetector(false);
}