Bug 1429009. P1 - notify 'DownloadProgressed' immediately to preserve the event order.
We also need to call GetOwner()->UpdateReadyState() since mCanPlayThrough might
have changed.
MozReview-Commit-ID: C5djzu1sXqV
--- a/dom/media/ChannelMediaDecoder.cpp
+++ b/dom/media/ChannelMediaDecoder.cpp
@@ -408,16 +408,18 @@ ChannelMediaDecoder::DurationChanged()
}
void
ChannelMediaDecoder::DownloadProgressed()
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_DIAGNOSTIC_ASSERT(!IsShutdown());
+ GetOwner()->DownloadProgressed();
+
using StatsPromise = MozPromise<MediaStatistics, bool, true>;
InvokeAsync(GetStateMachine()->OwnerThread(),
__func__,
[
playbackStats = mPlaybackStatistics,
res = RefPtr<BaseMediaResource>(mResource),
duration = mDuration,
pos = mPlaybackPosition
@@ -433,17 +435,18 @@ ChannelMediaDecoder::DownloadProgressed(
[ =, 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();
+ // Update readyState since mCanPlayThrough might have changed.
+ GetOwner()->UpdateReadyState();
},
[]() { MOZ_ASSERT_UNREACHABLE("Promise not resolved"); });
}
/* static */ ChannelMediaDecoder::PlaybackRateInfo
ChannelMediaDecoder::ComputePlaybackRate(const MediaChannelStatistics& aStats,
BaseMediaResource* aResource,
double aDuration)