Bug 1168674: [vorbis] P6. Do not tweak first decoded sample time. r=cpearce
authorJean-Yves Avenard <jyavenard@mozilla.com>
Mon, 25 Jul 2016 19:14:39 +1000
changeset 332474 864104ba08a648137660176cca3618ec183c31e8
parent 332473 3db6ca9dc9cd2801fb77225a169984259a5a422d
child 332475 435bf9dd44f33169ca3111608b1d43aacdd92496
push id9858
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 14:37:10 +0000
treeherdermozilla-aurora@203106ef6cb6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce
bugs1168674
milestone50.0a1
Bug 1168674: [vorbis] P6. Do not tweak first decoded sample time. r=cpearce r?cpearce A hack was in place to ensure that the first returned sample would have a time of 0 so that the media start time would be 0. This was incorrect for two primary reasons: - The media start time is adjusted according to the first sample anyway. - When seeking to 0, the first sample would have a time different to the first sample decoded (when we want them to have the same time). MozReview-Commit-ID: IyuT9O2F4EZ
dom/media/platforms/agnostic/VorbisDecoder.cpp
--- a/dom/media/platforms/agnostic/VorbisDecoder.cpp
+++ b/dom/media/platforms/agnostic/VorbisDecoder.cpp
@@ -163,42 +163,31 @@ VorbisDataDecoder::DoDecode(MediaRawData
 
   if (!mLastFrameTime || mLastFrameTime.ref() != aSample->mTime) {
     // We are starting a new block.
     mFrames = 0;
     mLastFrameTime = Some(aSample->mTime);
   }
 
   ogg_packet pkt = InitVorbisPacket(aData, aLength, false, false, -1, mPacketCount++);
-  bool first_packet = mPacketCount == 4;
 
   if (vorbis_synthesis(&mVorbisBlock, &pkt) != 0) {
     return -1;
   }
 
   if (vorbis_synthesis_blockin(&mVorbisDsp,
                                &mVorbisBlock) != 0) {
     return -1;
   }
 
   VorbisPCMValue** pcm = 0;
   int32_t frames = vorbis_synthesis_pcmout(&mVorbisDsp, &pcm);
-  // If the first packet of audio in the media produces no data, we
-  // still need to produce an AudioData for it so that the correct media
-  // start time is calculated.  Otherwise we'd end up with a media start
-  // time derived from the timecode of the first packet that produced
-  // data.
-  if (frames == 0 && first_packet) {
-    mCallback->Output(new AudioData(aOffset,
-                                    aTstampUsecs,
-                                    0,
-                                    0,
-                                    AlignedAudioBuffer(),
-                                    mVorbisDsp.vi->channels,
-                                    mVorbisDsp.vi->rate));
+  if (frames == 0) {
+    mCallback->InputExhausted();
+    return 0;
   }
   while (frames > 0) {
     uint32_t channels = mVorbisDsp.vi->channels;
     uint32_t rate = mVorbisDsp.vi->rate;
     AlignedAudioBuffer buffer(frames*channels);
     if (!buffer) {
       return -1;
     }