Loading media/java/android/media/PlayerBase.java +7 −0 Original line number Original line Diff line number Diff line Loading @@ -102,6 +102,13 @@ public abstract class PlayerBase { mState = AudioPlaybackConfiguration.PLAYER_STATE_IDLE; mState = AudioPlaybackConfiguration.PLAYER_STATE_IDLE; }; }; /** @hide */ public int getPlayerIId() { synchronized (mLock) { return mPlayerIId; } } /** /** * Call from derived class when instantiation / initialization is successful * Call from derived class when instantiation / initialization is successful */ */ Loading packages/SystemUI/src/com/android/systemui/media/NotificationPlayer.java +17 −3 Original line number Original line Diff line number Diff line Loading @@ -139,7 +139,7 @@ public class NotificationPlayer implements OnCompletionListener, OnErrorListener + " with ducking", e); + " with ducking", e); } } player.start(); player.start(); if (DEBUG) { Log.d(mTag, "player.start"); } if (DEBUG) { Log.d(mTag, "player.start piid:" + player.getPlayerIId()); } } catch (Exception e) { } catch (Exception e) { if (player != null) { if (player != null) { player.release(); player.release(); Loading @@ -155,7 +155,13 @@ public class NotificationPlayer implements OnCompletionListener, OnErrorListener mPlayer = player; mPlayer = player; } } if (mp != null) { if (mp != null) { if (DEBUG) { Log.d(mTag, "mPlayer.release"); } if (DEBUG) { Log.d(mTag, "mPlayer.pause+release piid:" + player.getPlayerIId()); } mp.pause(); try { Thread.sleep(100); } catch (InterruptedException ie) { } mp.release(); mp.release(); } } this.notify(); this.notify(); Loading Loading @@ -244,6 +250,10 @@ public class NotificationPlayer implements OnCompletionListener, OnErrorListener try { try { mp.stop(); mp.stop(); } catch (Exception e) { } } catch (Exception e) { } if (DEBUG) { Log.i(mTag, "About to release MediaPlayer piid:" + mp.getPlayerIId() + " due to notif cancelled"); } mp.release(); mp.release(); synchronized(mQueueAudioFocusLock) { synchronized(mQueueAudioFocusLock) { if (mAudioManagerWithAudioFocus != null) { if (mAudioManagerWithAudioFocus != null) { Loading Loading @@ -284,7 +294,7 @@ public class NotificationPlayer implements OnCompletionListener, OnErrorListener public void onCompletion(MediaPlayer mp) { public void onCompletion(MediaPlayer mp) { synchronized(mQueueAudioFocusLock) { synchronized(mQueueAudioFocusLock) { if (mAudioManagerWithAudioFocus != null) { if (mAudioManagerWithAudioFocus != null) { if (DEBUG) Log.d(mTag, "onCompletion() abandonning AudioFocus"); if (DEBUG) Log.d(mTag, "onCompletion() abandoning AudioFocus"); mAudioManagerWithAudioFocus.abandonAudioFocus(null); mAudioManagerWithAudioFocus.abandonAudioFocus(null); mAudioManagerWithAudioFocus = null; mAudioManagerWithAudioFocus = null; } else { } else { Loading @@ -310,6 +320,10 @@ public class NotificationPlayer implements OnCompletionListener, OnErrorListener } } } } if (mp != null) { if (mp != null) { if (DEBUG) { Log.i("NotificationPlayer", "About to release MediaPlayer piid:" + mp.getPlayerIId() + " due to onCompletion"); } mp.release(); mp.release(); } } } } Loading Loading
media/java/android/media/PlayerBase.java +7 −0 Original line number Original line Diff line number Diff line Loading @@ -102,6 +102,13 @@ public abstract class PlayerBase { mState = AudioPlaybackConfiguration.PLAYER_STATE_IDLE; mState = AudioPlaybackConfiguration.PLAYER_STATE_IDLE; }; }; /** @hide */ public int getPlayerIId() { synchronized (mLock) { return mPlayerIId; } } /** /** * Call from derived class when instantiation / initialization is successful * Call from derived class when instantiation / initialization is successful */ */ Loading
packages/SystemUI/src/com/android/systemui/media/NotificationPlayer.java +17 −3 Original line number Original line Diff line number Diff line Loading @@ -139,7 +139,7 @@ public class NotificationPlayer implements OnCompletionListener, OnErrorListener + " with ducking", e); + " with ducking", e); } } player.start(); player.start(); if (DEBUG) { Log.d(mTag, "player.start"); } if (DEBUG) { Log.d(mTag, "player.start piid:" + player.getPlayerIId()); } } catch (Exception e) { } catch (Exception e) { if (player != null) { if (player != null) { player.release(); player.release(); Loading @@ -155,7 +155,13 @@ public class NotificationPlayer implements OnCompletionListener, OnErrorListener mPlayer = player; mPlayer = player; } } if (mp != null) { if (mp != null) { if (DEBUG) { Log.d(mTag, "mPlayer.release"); } if (DEBUG) { Log.d(mTag, "mPlayer.pause+release piid:" + player.getPlayerIId()); } mp.pause(); try { Thread.sleep(100); } catch (InterruptedException ie) { } mp.release(); mp.release(); } } this.notify(); this.notify(); Loading Loading @@ -244,6 +250,10 @@ public class NotificationPlayer implements OnCompletionListener, OnErrorListener try { try { mp.stop(); mp.stop(); } catch (Exception e) { } } catch (Exception e) { } if (DEBUG) { Log.i(mTag, "About to release MediaPlayer piid:" + mp.getPlayerIId() + " due to notif cancelled"); } mp.release(); mp.release(); synchronized(mQueueAudioFocusLock) { synchronized(mQueueAudioFocusLock) { if (mAudioManagerWithAudioFocus != null) { if (mAudioManagerWithAudioFocus != null) { Loading Loading @@ -284,7 +294,7 @@ public class NotificationPlayer implements OnCompletionListener, OnErrorListener public void onCompletion(MediaPlayer mp) { public void onCompletion(MediaPlayer mp) { synchronized(mQueueAudioFocusLock) { synchronized(mQueueAudioFocusLock) { if (mAudioManagerWithAudioFocus != null) { if (mAudioManagerWithAudioFocus != null) { if (DEBUG) Log.d(mTag, "onCompletion() abandonning AudioFocus"); if (DEBUG) Log.d(mTag, "onCompletion() abandoning AudioFocus"); mAudioManagerWithAudioFocus.abandonAudioFocus(null); mAudioManagerWithAudioFocus.abandonAudioFocus(null); mAudioManagerWithAudioFocus = null; mAudioManagerWithAudioFocus = null; } else { } else { Loading @@ -310,6 +320,10 @@ public class NotificationPlayer implements OnCompletionListener, OnErrorListener } } } } if (mp != null) { if (mp != null) { if (DEBUG) { Log.i("NotificationPlayer", "About to release MediaPlayer piid:" + mp.getPlayerIId() + " due to onCompletion"); } mp.release(); mp.release(); } } } } Loading