Bug 469628 - Playing 8-bit Wave files can block writing to the audio backend - r=doublec sr=roc
authorMatthew Gregan <kinetik@flim.org
Tue, 16 Dec 2008 12:37:42 +1300
changeset 22824 29a24a645864b959a227a14fecd36261d91bf52a
parent 22823 64d08af481747091022b50e6ac69d563fe748191
child 22825 884a5c12182ac48a86041b51edbf6ed5f86803ec
push id4203
push usercdouble@mozilla.com
push dateMon, 15 Dec 2008 23:40:31 +0000
treeherdermozilla-central@29a24a645864 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdoublec, roc
bugs469628
milestone1.9.2a1pre
Bug 469628 - Playing 8-bit Wave files can block writing to the audio backend - r=doublec sr=roc
content/media/video/src/nsWaveDecoder.cpp
--- a/content/media/video/src/nsWaveDecoder.cpp
+++ b/content/media/video/src/nsWaveDecoder.cpp
@@ -532,18 +532,19 @@ nsWaveStateMachine::Run()
         // Media stream has ended and there is less data available than a
         // single sample so end playback.
         ChangeState(STATE_ENDED);
       } else {
         // Assuming enough data is available from the network, we aim to
         // completely fill the audio backend's buffers with data.  This
         // allows us plenty of time to wake up and refill the buffers
         // without an underrun occurring.
+        PRUint32 sampleSize = mSampleFormat == nsAudioStream::FORMAT_U8 ? 1 : 2;
         PRUint32 len = RoundDownToSample(NS_MIN(mStream->Available(),
-                                                PRUint32(mAudioStream->Available() * sizeof(short))));
+                                                PRUint32(mAudioStream->Available() * sampleSize)));
         if (len) {
           nsAutoArrayPtr<char> buf(new char[len]);
           PRUint32 got = 0;
 
           monitor.Exit();
           if (NS_FAILED(mStream->Read(buf.get(), len, &got))) {
             NS_WARNING("Stream read failed");
           }