Bug 1364834 - Fix rounding error in WaveDataDecoder::ProcessDecode(). r?jya draft
authorJW Wang <jwwang@mozilla.com>
Mon, 15 May 2017 17:25:26 +0800
changeset 577751 68c8c00a0734d90f9aac857423002e67cc1a5cc6
parent 577603 b847974819b0ebb4c5691718c045375f73c9cbaa
child 628575 483debbbb3d70da6ffcfca0129cd4dda20713246
push id58772
push userjwwang@mozilla.com
push dateMon, 15 May 2017 09:25:51 +0000
reviewersjya
bugs1364834
milestone55.0a1
Bug 1364834 - Fix rounding error in WaveDataDecoder::ProcessDecode(). r?jya The duration is rounded down to 0 if |frames| is smaller than |mInfo.mRate|. We should call FramesToTimeUnit() instead. MozReview-Commit-ID: E7eOQuD48x2
dom/media/platforms/agnostic/WAVDecoder.cpp
--- a/dom/media/platforms/agnostic/WAVDecoder.cpp
+++ b/dom/media/platforms/agnostic/WAVDecoder.cpp
@@ -112,17 +112,17 @@ WaveDataDecoder::ProcessDecode(MediaRawD
           int32_t v = aReader.ReadLE24();
           buffer[i * mInfo.mChannels + j] =
               Int24bitToAudioSample<AudioDataValue>(v);
         }
       }
     }
   }
 
-  auto duration = media::TimeUnit::FromMicroseconds(frames / mInfo.mRate);
+  auto duration = FramesToTimeUnit(frames, mInfo.mRate);
 
   return DecodePromise::CreateAndResolve(
     DecodedData{ new AudioData(aOffset, aSample->mTime, duration, frames,
                                Move(buffer), mInfo.mChannels, mInfo.mRate) },
     __func__);
 }
 
 RefPtr<MediaDataDecoder::DecodePromise>