Bug 607838 - Don't drain audio stream when it's paused, it won't finish. r=kinetik a=blocking2.0:final
authorChris Pearce <chris@pearce.org.nz>
Thu, 03 Feb 2011 12:44:40 +1300
changeset 61821 59bcb91cc3489dde592d03e7e7a4968998166243
parent 61820 ee00364d30927ea8981eaac56dcb6e14a343bb77
child 61822 81dec7f81e693de6acffbcb50d2a0da26f7ff6be
push idunknown
push userunknown
push dateunknown
reviewerskinetik, blocking2
bugs607838
milestone2.0b12pre
Bug 607838 - Don't drain audio stream when it's paused, it won't finish. r=kinetik a=blocking2.0:final
content/media/nsAudioStream.cpp
content/media/nsBuiltinDecoderStateMachine.cpp
--- a/content/media/nsAudioStream.cpp
+++ b/content/media/nsAudioStream.cpp
@@ -507,16 +507,18 @@ void nsAudioStreamLocal::SetVolume(doubl
   }
 #else
   mVolume = aVolume;
 #endif
 }
 
 void nsAudioStreamLocal::Drain()
 {
+  NS_ASSERTION(!mPaused, "Don't drain audio when paused, it won't finish!");
+
   if (mInError)
     return;
 
   // Write any remaining unwritten sound data in the overflow buffer
   if (!mBufferOverflow.IsEmpty()) {
     if (sa_stream_write(static_cast<sa_stream_t*>(mAudioHandle),
                         mBufferOverflow.Elements(),
                         mBufferOverflow.Length() * sizeof(short)) != SA_SUCCESS)
--- a/content/media/nsBuiltinDecoderStateMachine.cpp
+++ b/content/media/nsBuiltinDecoderStateMachine.cpp
@@ -527,17 +527,17 @@ void nsBuiltinDecoderStateMachine::Audio
           oldPosition = position;
           position = GetMediaTime();
         }
         if (mState == DECODER_STATE_SEEKING) {
           seeking = PR_TRUE;
         }
       }
 
-      if (!seeking && mAudioStream) {
+      if (!seeking && mAudioStream && !mAudioStream->IsPaused()) {
         mAudioStream->Drain();
 
         // Fire one last event for any extra samples that didn't fill a framebuffer.
         mEventManager.Drain(mAudioEndTime);
       }
     }
     LOG(PR_LOG_DEBUG, ("%p Reached audio stream end.", mDecoder));
   }