Bug 1423465. P7 - GetOwner()->DownloadProgressed() should be called after updating mCanPlayThrough.
GetOwner()->DownloadProgressed() will update readyState of the media element
which will need to read mCanPlayThrough.
MozReview-Commit-ID: EDHlLJjKDoL
--- a/dom/media/ChannelMediaDecoder.cpp
+++ b/dom/media/ChannelMediaDecoder.cpp
@@ -360,18 +360,16 @@ ChannelMediaDecoder::DurationChanged()
MOZ_DIAGNOSTIC_ASSERT(NS_SUCCEEDED(rv));
}
void
ChannelMediaDecoder::DownloadProgressed()
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_DIAGNOSTIC_ASSERT(!IsShutdown());
- AbstractThread::AutoEnter context(AbstractMainThread());
- GetOwner()->DownloadProgressed();
using StatsPromise = MozPromise<MediaStatistics, bool, true>;
InvokeAsync(GetStateMachine()->OwnerThread(),
__func__,
[
playbackStats = mPlaybackStatistics,
res = RefPtr<BaseMediaResource>(mResource),
duration = mDuration,
@@ -387,16 +385,18 @@ ChannelMediaDecoder::DownloadProgressed(
__func__,
[ =, self = RefPtr<ChannelMediaDecoder>(this) ](MediaStatistics aStats) {
if (IsShutdown()) {
return;
}
mCanPlayThrough = aStats.CanPlayThrough();
GetStateMachine()->DispatchCanPlayThrough(mCanPlayThrough);
mResource->ThrottleReadahead(ShouldThrottleDownload(aStats));
+ AbstractThread::AutoEnter context(AbstractMainThread());
+ GetOwner()->DownloadProgressed();
},
[]() { MOZ_ASSERT_UNREACHABLE("Promise not resolved"); });
}
/* static */ ChannelMediaDecoder::PlaybackRateInfo
ChannelMediaDecoder::ComputePlaybackRate(const MediaChannelStatistics& aStats,
BaseMediaResource* aResource,
double aDuration)