Bug 806754. Part 2: Fix bogus assertions. r=cpearce

SendStreamAudio gets called by SendStreamData which can be called
on the state machine thread since bug 794426 was fixed.
At the same time PlayFromAudioQueuec can no longer guarantee that
mAudioCaptured is false. It could be true and we're waiting for
the audio thread to shut down. We can just remove that assertion;
the logic in SendStreamData guarantees that we don't try to pass
audio to MediaStreams until the audio thread has actually stopped.

--HG--
extra : rebase_source : 431b4af63710ef13a57f7560aeec553b8aae6139
This commit is contained in:
Robert O'Callahan 2013-01-30 17:20:03 +13:00
parent 64761035c5
commit e22d4a92b6
3 changed files with 49 additions and 3 deletions

View File

@ -506,7 +506,8 @@ void MediaDecoderStateMachine::SendStreamAudio(AudioData* aAudio,
DecodedStreamData* aStream,
AudioSegment* aOutput)
{
NS_ASSERTION(OnDecodeThread(), "Should be on decode thread.");
NS_ASSERTION(OnDecodeThread() ||
OnStateMachineThread(), "Should be on decode thread or state machine thread");
mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
if (aAudio->mTime <= aStream->mLastAudioPacketTime) {
@ -1218,7 +1219,6 @@ uint32_t MediaDecoderStateMachine::PlayFromAudioQueue(uint64_t aFrameOffset,
{
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
NS_WARN_IF_FALSE(IsPlaying(), "Should be playing");
NS_ASSERTION(!mAudioCaptured, "Audio cannot be captured here!");
// Awaken the decode loop if it's waiting for space to free up in the
// audio queue.
mDecoder->GetReentrantMonitor().NotifyAll();

View File

@ -133,6 +133,7 @@ MOCHITEST_FILES = \
test_media_sniffer.html \
contentType.sjs \
test_streams_srcObject.html \
test_streams_gc.html \
$(filter disabled-for-intermittent-failures--bug-608634, test_error_in_video_document.html) \
$(NULL)

View File

@ -0,0 +1,45 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test garbage collection of captured stream (bug 806754)</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
<script type="text/javascript" src="manifest.js"></script>
</head>
<body onload="doTest()">
<audio id="a"></audio>
<pre id="test">
<script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
var a = document.getElementById('a');
a.src = getPlayableAudio(gSmallTests).name;
function forceGC() {
SpecialPowers.gc();
SpecialPowers.forceGC();
SpecialPowers.forceCC();
}
function doTest() {
a.mozCaptureStreamUntilEnded();
a.addEventListener("seeked", function() {
a.play();
a.addEventListener("play", function() {
a.addEventListener("ended", function() {
ok(true, "GC completed OK");
SimpleTest.finish();
}, false);
}, false);
}, false);
a.currentTime = a.duration;
setTimeout(forceGC, 0);
}
</script>
</pre>
</body>
</html>