Bug 1020176 - AudioOffloadPlayer: Avoid calling ResumeStateMachine from multiple paths. r=roc
authorVasanthakumar Pandurangan <vasanth@codeaurora.org>
Wed, 04 Jun 2014 14:25:21 +0530
changeset 206293 f627995bd6faf00ac5939dc9d99cd662b7dfc71c
parent 206292 5ddd73f7562ee2f72a7876d47504a0c06119cf01
child 206294 74f5be69e4c9df83f25cd1028513da267becc26e
push id3741
push userasasaki@mozilla.com
push dateMon, 21 Jul 2014 20:25:18 +0000
treeherdermozilla-beta@4d6f46f5af68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs1020176
milestone32.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1020176 - AudioOffloadPlayer: Avoid calling ResumeStateMachine from multiple paths. r=roc
content/media/omx/MediaOmxDecoder.cpp
--- a/content/media/omx/MediaOmxDecoder.cpp
+++ b/content/media/omx/MediaOmxDecoder.cpp
@@ -119,46 +119,49 @@ void MediaOmxDecoder::ResumeStateMachine
   mNextState = mPlayState;
   ChangeState(PLAY_STATE_LOADING);
   mDecoderStateMachine->SetDormant(false);
 }
 
 void MediaOmxDecoder::AudioOffloadTearDown()
 {
   MOZ_ASSERT(NS_IsMainThread());
-  PlaybackPositionChanged();
   DECODER_LOG(PR_LOG_DEBUG, ("%s", __PRETTY_FUNCTION__));
-  {
+
+  // mAudioOffloadPlayer can be null here if ResumeStateMachine was called
+  // just before because of some other error.
+  if (mAudioOffloadPlayer) {
     // Audio offload player sent tear down event. Fallback to state machine
+    PlaybackPositionChanged();
     ResumeStateMachine();
   }
 }
 
 void MediaOmxDecoder::AddOutputStream(ProcessedMediaStream* aStream,
                                       bool aFinishWhenEnded)
 {
   MOZ_ASSERT(NS_IsMainThread());
-  PlaybackPositionChanged();
 
   if (mAudioOffloadPlayer) {
     // Offload player cannot handle MediaStream. Fallback
+    PlaybackPositionChanged();
     ResumeStateMachine();
   }
 
   MediaDecoder::AddOutputStream(aStream, aFinishWhenEnded);
 }
 
 void MediaOmxDecoder::SetPlaybackRate(double aPlaybackRate)
 {
   MOZ_ASSERT(NS_IsMainThread());
-  PlaybackPositionChanged();
 
   if (mAudioOffloadPlayer &&
       ((aPlaybackRate != 0.0) || (aPlaybackRate != 1.0))) {
     // Offload player cannot handle playback rate other than 1/0. Fallback
+    PlaybackPositionChanged();
     ResumeStateMachine();
   }
 
   MediaDecoder::SetPlaybackRate(aPlaybackRate);
 }
 
 void MediaOmxDecoder::ChangeState(PlayState aState)
 {