mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-25 11:15:34 +00:00
Bug 1120282: Do not fire durationchange during call to ReadMetadata. r=mattwoodrow
--HG-- extra : rebase_source : cf8bdb932aac0661de21c7fa4eba7d50b14b3dbc
This commit is contained in:
parent
eb3a3abff9
commit
59151e0b1c
@ -218,9 +218,7 @@ MediaSourceDecoder::SetDecodedDuration(int64_t aDuration)
|
||||
if (aDuration >= 0) {
|
||||
duration /= USECS_PER_S;
|
||||
}
|
||||
// No need to call Range Removal algorithm as this is called following
|
||||
// ReadMetadata and nothing has been added to the source buffers yet.
|
||||
SetMediaSourceDuration(duration, MSRangeRemovalAction::SKIP);
|
||||
DoSetMediaSourceDuration(duration);
|
||||
}
|
||||
|
||||
void
|
||||
@ -228,6 +226,13 @@ MediaSourceDecoder::SetMediaSourceDuration(double aDuration, MSRangeRemovalActio
|
||||
{
|
||||
ReentrantMonitorAutoEnter mon(GetReentrantMonitor());
|
||||
double oldDuration = mMediaSourceDuration;
|
||||
DoSetMediaSourceDuration(aDuration);
|
||||
ScheduleDurationChange(oldDuration, aDuration, aAction);
|
||||
}
|
||||
|
||||
void
|
||||
MediaSourceDecoder::DoSetMediaSourceDuration(double aDuration)
|
||||
{
|
||||
if (aDuration >= 0) {
|
||||
mDecoderStateMachine->SetDuration(aDuration * USECS_PER_S);
|
||||
mMediaSourceDuration = aDuration;
|
||||
@ -235,19 +240,27 @@ MediaSourceDecoder::SetMediaSourceDuration(double aDuration, MSRangeRemovalActio
|
||||
mDecoderStateMachine->SetDuration(INT64_MAX);
|
||||
mMediaSourceDuration = PositiveInfinity<double>();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
MediaSourceDecoder::ScheduleDurationChange(double aOldDuration,
|
||||
double aNewDuration,
|
||||
MSRangeRemovalAction aAction)
|
||||
{
|
||||
if (aAction == MSRangeRemovalAction::SKIP) {
|
||||
if (NS_IsMainThread()) {
|
||||
MediaDecoder::DurationChanged();
|
||||
} else {
|
||||
nsCOMPtr<nsIRunnable> task = NS_NewRunnableMethod(this, &MediaDecoder::DurationChanged);
|
||||
nsCOMPtr<nsIRunnable> task =
|
||||
NS_NewRunnableMethod(this, &MediaDecoder::DurationChanged);
|
||||
NS_DispatchToMainThread(task);
|
||||
}
|
||||
} else {
|
||||
if (NS_IsMainThread()) {
|
||||
DurationChanged(oldDuration, mMediaSourceDuration);
|
||||
DurationChanged(aOldDuration, aNewDuration);
|
||||
} else {
|
||||
nsRefPtr<nsIRunnable> task =
|
||||
new DurationChangedRunnable(this, oldDuration, mMediaSourceDuration);
|
||||
new DurationChangedRunnable(this, aOldDuration, aNewDuration);
|
||||
NS_DispatchToMainThread(task);
|
||||
}
|
||||
}
|
||||
|
@ -80,6 +80,11 @@ public:
|
||||
bool IsActiveReader(MediaDecoderReader* aReader);
|
||||
|
||||
private:
|
||||
void DoSetMediaSourceDuration(double aDuration);
|
||||
void ScheduleDurationChange(double aOldDuration,
|
||||
double aNewDuration,
|
||||
MSRangeRemovalAction aAction);
|
||||
|
||||
// The owning MediaSource holds a strong reference to this decoder, and
|
||||
// calls Attach/DetachMediaSource on this decoder to set and clear
|
||||
// mMediaSource.
|
||||
|
Loading…
Reference in New Issue
Block a user