Bug 1168674: [vorbis] P6. Do not tweak first decoded sample time. draft
authorJean-Yves Avenard <jyavenard@mozilla.com>
Mon, 25 Jul 2016 19:14:39 +1000
changeset 394188 4c537cc159fb0df2a7a8841a873970bdd12071a9
parent 394187 d27d05ef4dafc31091c66de34461cf8cf05900ac
child 394189 0473c210b2fc6e3ee02edaa150cdb52f7d453d86
push id24516
push userbmo:jyavenard@mozilla.com
push dateFri, 29 Jul 2016 07:36:49 +0000
bugs1168674
milestone50.0a1
Bug 1168674: [vorbis] P6. Do not tweak first decoded sample time. 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;
     }