Bug 1565838 - don't check timestamp of EOS samples. r=jya, a=RyanVM
authorJohn Lin <jolin@mozilla.com>
Wed, 14 Aug 2019 15:47:52 +0000
changeset 545169 ae6de9d94b5f9ed242dbb4418438fd8871a23851
parent 545168 fd21aed8462aa60060c20059286044a846b2bbe1
child 545170 26469ee275619eb3ee13dc37aae505d2de68d89d
push id2131
push userffxbld-merge
push dateMon, 26 Aug 2019 18:30:20 +0000
treeherdermozilla-release@b19ffb3ca153 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjya, RyanVM
bugs1565838, 1540748
milestone69.0
Bug 1565838 - don't check timestamp of EOS samples. r=jya, a=RyanVM Bug 1540748/D28167 checks the output sample timestamp against the time parsed by demuxer to determine the validness. However, unlike Android builtin MP3 decoder which sets EOS flag in the final valid output, the Samsung MP3 decoder always emit additional EOS sample with invalid timestamp. To address this, the timestamp check should be ignore for EOS samples. Differential Revision: https://phabricator.services.mozilla.com/D41872
dom/media/platforms/android/RemoteDataDecoder.cpp
--- a/dom/media/platforms/android/RemoteDataDecoder.cpp
+++ b/dom/media/platforms/android/RemoteDataDecoder.cpp
@@ -472,30 +472,32 @@ class RemoteAudioDecoder : public Remote
       return;
     }
 
     RenderOrReleaseOutput autoRelease(mJavaDecoder, aSample);
 
     BufferInfo::LocalRef info = aSample->Info();
     MOZ_ASSERT(info);
 
-    int32_t flags;
+    int32_t flags = 0;
     bool ok = NS_SUCCEEDED(info->Flags(&flags));
+    bool isEOS = !!(flags & MediaCodec::BUFFER_FLAG_END_OF_STREAM);
 
     int32_t offset;
     ok &= NS_SUCCEEDED(info->Offset(&offset));
 
     int64_t presentationTimeUs;
     ok &= NS_SUCCEEDED(info->PresentationTimeUs(&presentationTimeUs));
 
     int32_t size;
     ok &= NS_SUCCEEDED(info->Size(&size));
 
     if (!ok ||
-        IsSampleTimeSmallerThanFirstDemuxedSampleTime(presentationTimeUs)) {
+        (IsSampleTimeSmallerThanFirstDemuxedSampleTime(presentationTimeUs) &&
+         !isEOS)) {
       Error(MediaResult(NS_ERROR_DOM_MEDIA_FATAL_ERR, __func__));
       return;
     }
 
     if (size > 0) {
 #ifdef MOZ_SAMPLE_TYPE_S16
       const int32_t numSamples = size / 2;
 #else
@@ -513,17 +515,17 @@ class RemoteAudioDecoder : public Remote
 
       RefPtr<AudioData> data =
           new AudioData(0, TimeUnit::FromMicroseconds(presentationTimeUs),
                         std::move(audio), mOutputChannels, mOutputSampleRate);
 
       UpdateOutputStatus(std::move(data));
     }
 
-    if ((flags & MediaCodec::BUFFER_FLAG_END_OF_STREAM) != 0) {
+    if (isEOS) {
       DrainComplete();
     }
   }
 
   void ProcessOutputFormatChange(int32_t aChannels, int32_t aSampleRate) {
     if (!mTaskQueue->IsCurrentThreadIn()) {
       nsresult rv = mTaskQueue->Dispatch(NewRunnableMethod<int32_t, int32_t>(
           "RemoteAudioDecoder::ProcessOutputFormatChange", this,