зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1175768 - Dispatch UpdateEstimatedMediaDuration. r=jya
NotifyDataArrived will soon run off-main-thread, so the assumptions here won't hold.
This commit is contained in:
Родитель
3494aeaedb
Коммит
a269ea96b4
|
@ -74,10 +74,16 @@ public:
|
|||
|
||||
virtual AbstractCanonical<media::NullableTimeUnit>* CanonicalDurationOrNull() { return nullptr; };
|
||||
|
||||
// Sets the duration of the media in microseconds. The MediaDecoder
|
||||
// fires a durationchange event to its owner (e.g., an HTML audio
|
||||
// tag).
|
||||
virtual void UpdateEstimatedMediaDuration(int64_t aDuration) = 0;
|
||||
protected:
|
||||
virtual void UpdateEstimatedMediaDuration(int64_t aDuration) {};
|
||||
public:
|
||||
void DispatchUpdateEstimatedMediaDuration(int64_t aDuration)
|
||||
{
|
||||
nsCOMPtr<nsIRunnable> r =
|
||||
NS_NewRunnableMethodWithArg<int64_t>(this, &AbstractMediaDecoder::UpdateEstimatedMediaDuration,
|
||||
aDuration);
|
||||
NS_DispatchToMainThread(r);
|
||||
}
|
||||
|
||||
// Set the media as being seekable or not.
|
||||
virtual void SetMediaSeekable(bool aMediaSeekable) = 0;
|
||||
|
|
|
@ -1099,6 +1099,8 @@ void MediaDecoder::DurationChanged()
|
|||
|
||||
void MediaDecoder::UpdateEstimatedMediaDuration(int64_t aDuration)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
if (mPlayState <= PLAY_STATE_LOADING) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -454,6 +454,7 @@ public:
|
|||
// Call on the main thread only.
|
||||
virtual bool IsEndedOrShutdown() const;
|
||||
|
||||
protected:
|
||||
// Updates the media duration. This is called while the media is being
|
||||
// played, calls before the media has reached loaded metadata are ignored.
|
||||
// The duration is assumed to be an estimate, and so a degree of
|
||||
|
@ -463,6 +464,7 @@ public:
|
|||
// changed, this causes a durationchanged event to fire to the media
|
||||
// element.
|
||||
void UpdateEstimatedMediaDuration(int64_t aDuration) override;
|
||||
public:
|
||||
|
||||
// Set a flag indicating whether seeking is supported
|
||||
virtual void SetMediaSeekable(bool aMediaSeekable) override;
|
||||
|
|
|
@ -543,9 +543,8 @@ AppleMP3Reader::NotifyDataArrived(const char* aBuffer,
|
|||
if (duration != mDuration) {
|
||||
LOGD("Updating media duration to %lluus\n", duration);
|
||||
MOZ_ASSERT(mDecoder);
|
||||
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
|
||||
mDuration = duration;
|
||||
mDecoder->UpdateEstimatedMediaDuration(duration);
|
||||
mDecoder->DispatchUpdateEstimatedMediaDuration(duration);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -416,9 +416,8 @@ DirectShowReader::NotifyDataArrived(const char* aBuffer, uint32_t aLength, int64
|
|||
int64_t duration = mMP3FrameParser.GetDuration();
|
||||
if (duration != mDuration) {
|
||||
MOZ_ASSERT(mDecoder);
|
||||
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
|
||||
mDuration = duration;
|
||||
mDecoder->UpdateEstimatedMediaDuration(mDuration);
|
||||
mDecoder->DispatchUpdateEstimatedMediaDuration(mDuration);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1292,9 +1292,8 @@ void GStreamerReader::NotifyDataArrived(const char *aBuffer,
|
|||
int64_t duration = mMP3FrameParser.GetDuration();
|
||||
if (duration != mLastParserDuration && mUseParserDuration) {
|
||||
MOZ_ASSERT(mDecoder);
|
||||
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
|
||||
mLastParserDuration = duration;
|
||||
mDecoder->UpdateEstimatedMediaDuration(mLastParserDuration);
|
||||
mDecoder->DispatchUpdateEstimatedMediaDuration(mLastParserDuration);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -178,12 +178,6 @@ SourceBufferDecoder::Trim(int64_t aDuration)
|
|||
mTrimmedOffset = (double)aDuration / USECS_PER_S;
|
||||
}
|
||||
|
||||
void
|
||||
SourceBufferDecoder::UpdateEstimatedMediaDuration(int64_t aDuration)
|
||||
{
|
||||
MSE_DEBUG("UNIMPLEMENTED");
|
||||
}
|
||||
|
||||
void
|
||||
SourceBufferDecoder::SetMediaSeekable(bool aMediaSeekable)
|
||||
{
|
||||
|
|
|
@ -54,7 +54,6 @@ public:
|
|||
virtual void QueueMetadata(int64_t aTime, nsAutoPtr<MediaInfo> aInfo, nsAutoPtr<MetadataTags> aTags) final override;
|
||||
virtual void RemoveMediaTracks() final override;
|
||||
virtual void SetMediaSeekable(bool aMediaSeekable) final override;
|
||||
virtual void UpdateEstimatedMediaDuration(int64_t aDuration) final override;
|
||||
virtual bool HasInitializationData() final override;
|
||||
|
||||
// SourceBufferResource specific interface below.
|
||||
|
|
|
@ -652,8 +652,7 @@ MediaCodecReader::ParseDataSegment(const char* aBuffer,
|
|||
|
||||
if (durationUpdateRequired) {
|
||||
MOZ_ASSERT(mDecoder);
|
||||
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
|
||||
mDecoder->UpdateEstimatedMediaDuration(duration);
|
||||
mDecoder->DispatchUpdateEstimatedMediaDuration(duration);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -489,9 +489,8 @@ void MediaOmxReader::NotifyDataArrived(const char* aBuffer, uint32_t aLength, in
|
|||
|
||||
int64_t duration = mMP3FrameParser.GetDuration();
|
||||
if (duration != mLastParserDuration) {
|
||||
ReentrantMonitorAutoEnter mon(decoder->GetReentrantMonitor());
|
||||
mLastParserDuration = duration;
|
||||
decoder->UpdateEstimatedMediaDuration(mLastParserDuration);
|
||||
decoder->DispatchUpdateEstimatedMediaDuration(mLastParserDuration);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -85,12 +85,6 @@ BufferDecoder::NotifyDecodedFrames(uint32_t aParsed, uint32_t aDecoded,
|
|||
// ignore
|
||||
}
|
||||
|
||||
void
|
||||
BufferDecoder::UpdateEstimatedMediaDuration(int64_t aDuration)
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
|
||||
void
|
||||
BufferDecoder::SetMediaSeekable(bool aMediaSeekable)
|
||||
{
|
||||
|
|
|
@ -45,8 +45,6 @@ public:
|
|||
virtual void NotifyDecodedFrames(uint32_t aParsed, uint32_t aDecoded,
|
||||
uint32_t aDropped) final override;
|
||||
|
||||
virtual void UpdateEstimatedMediaDuration(int64_t aDuration) final override;
|
||||
|
||||
virtual void SetMediaSeekable(bool aMediaSeekable) final override;
|
||||
|
||||
virtual VideoFrameContainer* GetVideoFrameContainer() final override;
|
||||
|
|
Загрузка…
Ссылка в новой задаче