Bug 1256038: Remove special NotifyDataArrived handling in the DirectShow reader. r=cpearce

Following bug 1223599, NotifyDataArrived is called extremely often (every 32kB block downloaded). The combination of pinning the MediaResource with small cache reads while reading on another thread can causes incorrect read.
While this issue needs to be addressed, the special handling of NotifyDataArrived with DirectShow ultimately serves no purpose. By the time we have read the metadata, we have already identified if the MP3 has a known duration. If not, the duration will be amended as data is being returned to the MDSM.

Continually feeding new data to the MP3FrameParser only allow to account for the new data downloaded ahead of the last decoded sample and to get a slightly more accurate buffered range and duration.

The new MP3Demuxer doesn't do it, and ultimately this makes the DirectShowReader behaves like the new MP3Demuxer and gives us consistency across the readers.

MozReview-Commit-ID: HKNWWrofIqV

--HG--
extra : rebase_source : 88d8ef9206e8a16097b2d493681e88b4c174d0c5
This commit is contained in:
Jean-Yves Avenard 2016-03-22 22:59:50 +11:00
Родитель ca8c96a592
Коммит a8b76dc318
2 изменённых файлов: 1 добавлений и 49 удалений

Просмотреть файл

@ -33,8 +33,7 @@ DirectShowReader::DirectShowReader(AbstractMediaDecoder* aDecoder)
#endif
mNumChannels(0),
mAudioRate(0),
mBytesPerSample(0),
mDuration(0)
mBytesPerSample(0)
{
MOZ_ASSERT(NS_IsMainThread(), "Must be on main thread.");
MOZ_COUNT_CTOR(DirectShowReader);
@ -362,43 +361,4 @@ DirectShowReader::SeekInternal(int64_t aTargetUs)
return NS_OK;
}
void
DirectShowReader::NotifyDataArrivedInternal()
{
MOZ_ASSERT(OnTaskQueue());
if (!mMP3FrameParser.NeedsData()) {
return;
}
AutoPinned<MediaResource> resource(mDecoder->GetResource());
MediaByteRangeSet byteRanges;
nsresult rv = resource->GetCachedRanges(byteRanges);
if (NS_FAILED(rv)) {
return;
}
if (byteRanges == mLastCachedRanges) {
return;
}
MediaByteRangeSet intervals = byteRanges - mLastCachedRanges;
mLastCachedRanges = byteRanges;
for (const auto& interval : intervals) {
RefPtr<MediaByteBuffer> bytes =
resource->MediaReadAt(interval.mStart, interval.Length());
NS_ENSURE_TRUE_VOID(bytes);
mMP3FrameParser.Parse(bytes->Elements(), interval.Length(), interval.mStart);
if (!mMP3FrameParser.IsMP3()) {
return;
}
}
int64_t duration = mMP3FrameParser.GetDuration();
if (duration != mDuration) {
MOZ_ASSERT(mDecoder);
mDuration = duration;
mDecoder->DispatchUpdateEstimatedMediaDuration(mDuration);
}
}
} // namespace mozilla

Просмотреть файл

@ -60,9 +60,6 @@ public:
RefPtr<SeekPromise>
Seek(SeekTarget aTarget, int64_t aEndTime) override;
protected:
void NotifyDataArrivedInternal() override;
private:
// Notifies the filter graph that playback is complete. aStatus is
// the code to send to the filter graph. Always returns false, so
@ -104,11 +101,6 @@ private:
// Number of bytes per sample. Can be either 1 or 2.
uint32_t mBytesPerSample;
// Duration of the stream, in microseconds.
int64_t mDuration;
MediaByteRangeSet mLastCachedRanges;
};
} // namespace mozilla