@@ -437,8 +437,10 @@ private void updateStates() {
437437
438438 public void postVolumeChanged (int streamType , int flags ) {
439439 if (hasMessages (MSG_VOLUME_CHANGED )) return ;
440- if (mStreamControls == null ) {
441- createSliders ();
440+ synchronized (this ) {
441+ if (mStreamControls == null ) {
442+ createSliders ();
443+ }
442444 }
443445 removeMessages (MSG_FREE_RESOURCES );
444446 obtainMessage (MSG_VOLUME_CHANGED , streamType , flags ).sendToTarget ();
@@ -450,8 +452,10 @@ public void postMasterVolumeChanged(int flags) {
450452
451453 public void postMuteChanged (int streamType , int flags ) {
452454 if (hasMessages (MSG_VOLUME_CHANGED )) return ;
453- if (mStreamControls == null ) {
454- createSliders ();
455+ synchronized (this ) {
456+ if (mStreamControls == null ) {
457+ createSliders ();
458+ }
455459 }
456460 removeMessages (MSG_FREE_RESOURCES );
457461 obtainMessage (MSG_MUTE_CHANGED , streamType , flags ).sendToTarget ();
@@ -471,10 +475,12 @@ protected void onVolumeChanged(int streamType, int flags) {
471475 if (LOGD ) Log .d (TAG , "onVolumeChanged(streamType: " + streamType + ", flags: " + flags + ")" );
472476
473477 if ((flags & AudioManager .FLAG_SHOW_UI ) != 0 ) {
474- if (mActiveStreamType != streamType ) {
475- reorderSliders (streamType );
478+ synchronized (this ) {
479+ if (mActiveStreamType != streamType ) {
480+ reorderSliders (streamType );
481+ }
482+ onShowVolumeChanged (streamType , flags );
476483 }
477- onShowVolumeChanged (streamType , flags );
478484 }
479485
480486 if ((flags & AudioManager .FLAG_PLAY_SOUND ) != 0 && ! mRingIsSilent ) {
0 commit comments