Bug 1613672 - return `NS_ERROR_DOM_MEDIA_CANCELED` to indicate that track buffer manager has been detached from the demuxer. r=jya

When we shutdown `MediaSourceDecoder`, it would trigger a shutdown for `MDSM` and a detaching for media source.

In the previous one, that would eventually shutdown `MediaFormatReader` via tasks going through different threads (main->MDSM->MFR's supervisor).

In the latter one, it would eventually detach the `TrackBufferManager` from the `MediaSourceTrackDemuxer`. (main->Demuxer's supervisor)

As these two tasks running in different threads, and the latter usually get finished before the former one, which would result in `MediaSourceTrackDemuxer` no longer being able to get a sample.

When that happens, the reader hasn't been shutdown yet, so it's still holding track demuxers and keeps requesting data from them. Then demuxers would return error because their corresponding track managers have been detached.

The reader would report the demuxing error to the console, but that's acutally not a fatal error, because in this situation the reader is going to be shutdown soon. Therefore, return `NS_ERROR_DOM_MEDIA_CANCELED` to allow MFR to treat this error differently.

Differential Revision: https://phabricator.services.mozilla.com/D100153
This commit is contained in:
alwu 2020-12-22 06:06:04 +00:00
Родитель 4be78990c1
Коммит e77464e77c
1 изменённых файлов: 3 добавлений и 3 удалений

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

@ -343,7 +343,7 @@ RefPtr<MediaSourceTrackDemuxer::SeekPromise> MediaSourceTrackDemuxer::DoSeek(
const TimeUnit& aTime) {
if (!mManager) {
return SeekPromise::CreateAndReject(
MediaResult(NS_ERROR_DOM_MEDIA_FATAL_ERR,
MediaResult(NS_ERROR_DOM_MEDIA_CANCELED,
RESULT_DETAIL("manager is detached.")),
__func__);
}
@ -395,7 +395,7 @@ RefPtr<MediaSourceTrackDemuxer::SamplesPromise>
MediaSourceTrackDemuxer::DoGetSamples(int32_t aNumSamples) {
if (!mManager) {
return SamplesPromise::CreateAndReject(
MediaResult(NS_ERROR_DOM_MEDIA_FATAL_ERR,
MediaResult(NS_ERROR_DOM_MEDIA_CANCELED,
RESULT_DETAIL("manager is detached.")),
__func__);
}
@ -451,7 +451,7 @@ MediaSourceTrackDemuxer::DoSkipToNextRandomAccessPoint(
const TimeUnit& aTimeThreadshold) {
if (!mManager) {
return SkipAccessPointPromise::CreateAndReject(
SkipFailureHolder(MediaResult(NS_ERROR_DOM_MEDIA_FATAL_ERR,
SkipFailureHolder(MediaResult(NS_ERROR_DOM_MEDIA_CANCELED,
RESULT_DETAIL("manager is detached.")),
0),
__func__);