Bug 1215003. Part 3 - fix AsyncReadMetadata() and its callers. r=gerald.

This commit is contained in:
JW Wang 2015-10-19 10:52:34 +08:00
parent 84fb1fa3b2
commit c0d2ada691
2 changed files with 10 additions and 8 deletions

View File

@ -94,6 +94,14 @@ public:
// on failure.
virtual nsresult Init() { return NS_OK; }
RefPtr<MetadataPromise> AsyncReadMetadata()
{
return OnTaskQueue() ?
AsyncReadMetadataInternal() :
InvokeAsync(OwnerThread(), this, __func__,
&MediaDecoderReader::AsyncReadMetadataInternal);
}
// Release media resources they should be released in dormant state
// The reader can be made usable again by calling ReadMetadata().
void ReleaseMediaResources()
@ -177,11 +185,6 @@ public:
virtual bool HasAudio() = 0;
virtual bool HasVideo() = 0;
// The default implementation of AsyncReadMetadata is implemented in terms of
// synchronous ReadMetadata() calls. Implementations may also
// override AsyncReadMetadata to create a more proper async implementation.
virtual RefPtr<MetadataPromise> AsyncReadMetadata();
// Fills aInfo with the latest cached data required to present the media,
// ReadUpdatedMetadata will always be called once ReadMetadata has succeeded.
virtual void ReadUpdatedMetadata(MediaInfo* aInfo) { };

View File

@ -2256,11 +2256,10 @@ nsresult MediaDecoderStateMachine::RunStateMachine()
case DECODER_STATE_DECODING_METADATA: {
if (!mMetadataRequest.Exists()) {
DECODER_LOG("Dispatching AsyncReadMetadata");
DECODER_LOG("Calling AsyncReadMetadata");
// Set mode to METADATA since we are about to read metadata.
mResource->SetReadMode(MediaCacheStream::MODE_METADATA);
mMetadataRequest.Begin(InvokeAsync(DecodeTaskQueue(), mReader.get(), __func__,
&MediaDecoderReader::AsyncReadMetadata)
mMetadataRequest.Begin(mReader->AsyncReadMetadata()
->Then(OwnerThread(), __func__, this,
&MediaDecoderStateMachine::OnMetadataRead,
&MediaDecoderStateMachine::OnMetadataNotRead));