From 78d33c4c729ef37ea0b17fcf5e84a9b25ea8db1e Mon Sep 17 00:00:00 2001 From: Shelly Lin Date: Fri, 2 Aug 2013 14:59:30 +0800 Subject: [PATCH] Bug 900811 - Fix the hang if closing its tab during recording a fake gUM. r=roc --- content/media/encoder/TrackEncoder.cpp | 12 ++++++++++-- content/media/encoder/TrackEncoder.h | 7 +------ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/content/media/encoder/TrackEncoder.cpp b/content/media/encoder/TrackEncoder.cpp index 4533616f172e..1284b0541dc6 100644 --- a/content/media/encoder/TrackEncoder.cpp +++ b/content/media/encoder/TrackEncoder.cpp @@ -67,16 +67,24 @@ AudioTrackEncoder::NotifyRemoved(MediaStreamGraph* aGraph) { // In case that MediaEncoder does not receive a TRACK_EVENT_ENDED event. LOG("[AudioTrackEncoder]: NotifyRemoved."); + NotifyEndOfStream(); +} +void +AudioTrackEncoder::NotifyEndOfStream() +{ // If source audio chunks are completely silent till the end of encoding, // initialize the encoder with default channel counts and sampling rate, and // append this many null data to the segment of track encoder. - if (!mInitialized && mSilentDuration > 0) { + if (!mCanceled && !mInitialized && mSilentDuration > 0) { Init(DEFAULT_CHANNELS, DEFAULT_SAMPLING_RATE); mRawSegment->AppendNullData(mSilentDuration); mSilentDuration = 0; } - NotifyEndOfStream(); + + ReentrantMonitorAutoEnter mon(mReentrantMonitor); + mEndOfStream = true; + mReentrantMonitor.NotifyAll(); } nsresult diff --git a/content/media/encoder/TrackEncoder.h b/content/media/encoder/TrackEncoder.h index c65898e38d4b..c3cabcd1dc8c 100644 --- a/content/media/encoder/TrackEncoder.h +++ b/content/media/encoder/TrackEncoder.h @@ -130,12 +130,7 @@ protected: * Notifies the audio encoder that we have reached the end of source stream, * and wakes up mReentrantMonitor if encoder is waiting for more track data. */ - void NotifyEndOfStream() - { - ReentrantMonitorAutoEnter mon(mReentrantMonitor); - mEndOfStream = true; - mReentrantMonitor.NotifyAll(); - } + void NotifyEndOfStream(); /** * Interleaves the track data and stores the result into aOutput. Might need