Bug 1195158. Part 2 - Have OggReader send TimedMetadata events through a event source instead of direct calls to AbstractMediaDecoder::QueueMetadata. r=cpearce.

This commit is contained in:
JW Wang 2015-08-18 11:12:39 +08:00
parent 7de6530d5a
commit 623b3a7a28
2 changed files with 12 additions and 3 deletions

View File

@ -11,6 +11,7 @@
#include "AbstractMediaDecoder.h"
#include "MediaInfo.h"
#include "MediaData.h"
#include "MediaMetadataManager.h"
#include "MediaQueue.h"
#include "MediaTimer.h"
#include "AudioCompactor.h"
@ -327,6 +328,10 @@ public:
virtual void DisableHardwareAcceleration() {}
TimedMetadataEventSource& TimedMetadataEvent() {
return mTimedMetadataEvent;
}
protected:
virtual ~MediaDecoderReader();
@ -418,6 +423,9 @@ protected:
bool mHitAudioDecodeError;
bool mShutdown;
// Used to send TimedMetadata to the listener.
TimedMetadataEventProducer mTimedMetadataEvent;
private:
// Promises used only for the base-class (sync->async adapter) implementation
// of Request{Audio,Video}Data.

View File

@ -814,10 +814,11 @@ bool OggReader::ReadOggChain()
if (chained) {
SetChained(true);
{
nsAutoPtr<MediaInfo> info(new MediaInfo(mInfo));
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
auto t = mDecodedAudioFrames * USECS_PER_S / mInfo.mAudio.mRate;
mDecoder->QueueMetadata(media::TimeUnit::FromMicroseconds(t), info, tags);
mTimedMetadataEvent.Notify(
TimedMetadata(media::TimeUnit::FromMicroseconds(t),
Move(tags),
nsAutoPtr<MediaInfo>(new MediaInfo(mInfo))));
}
return true;
}