Merge for "Backed out changeset: cb9da8789fce"

for
Bug 465498 - HTML5 <audio>: setting 'currentTime' throws exception sometimes; r+sr=roc
as new test fails
This commit is contained in:
Serge Gautherie 2008-12-05 18:41:36 +01:00
commit b5e9ceefde
4 changed files with 7 additions and 172 deletions

View File

@ -378,13 +378,12 @@ void
nsWaveStateMachine::Seek(float aTime)
{
nsAutoMonitor monitor(mMonitor);
mTimeOffset = aTime;
if (mState == STATE_LOADING_METADATA) {
mNextState = STATE_SEEKING;
} else {
mNextState = mState;
ChangeState(STATE_SEEKING);
mNextState = mState;
mTimeOffset = NS_MIN(aTime, BytesToTime(mWaveLength));
if (mTimeOffset < 0.0) {
mTimeOffset = 0.0;
}
ChangeState(STATE_SEEKING);
}
float
@ -444,9 +443,7 @@ nsWaveStateMachine::Run()
if (loaded) {
mMetadataValid = PR_TRUE;
if (mNextState != STATE_SEEKING) {
event = NS_NEW_RUNNABLE_METHOD(nsWaveDecoder, mDecoder, MetadataLoaded);
}
event = NS_NEW_RUNNABLE_METHOD(nsWaveDecoder, mDecoder, MetadataLoaded);
newState = mNextState;
} else {
event = NS_NEW_RUNNABLE_METHOD(nsWaveDecoder, mDecoder, MediaErrorDecode);
@ -575,11 +572,6 @@ nsWaveStateMachine::Run()
break;
}
mTimeOffset = NS_MIN(mTimeOffset, BytesToTime(mWaveLength));
if (mTimeOffset < 0.0) {
mTimeOffset = 0.0;
}
PRInt64 position = RoundDownToSample(TimeToBytes(mTimeOffset)) + mWavePCMOffset;
NS_ABORT_IF_FALSE(position >= 0 && position <= mWaveLength + mWavePCMOffset, "Invalid seek position");
@ -601,16 +593,7 @@ nsWaveStateMachine::Run()
monitor.Enter();
if (mState != STATE_SHUTDOWN) {
State nextState = mNextState;
// Special case: if a seek was requested during metadata load,
// mNextState will have been clobbered. This can only happen when
// we're instantiating a decoder to service a seek request after
// playback has ended, so we know that the clobbered mNextState
// was PAUSED.
if (nextState == STATE_SEEKING) {
nextState = STATE_PAUSED;
}
ChangeState(nextState);
ChangeState(mNextState);
}
}
break;
@ -972,15 +955,10 @@ nsWaveDecoder::GetCurrentTime()
nsresult
nsWaveDecoder::Seek(float aTime)
{
if (!mPlaybackStateMachine) {
Load(mURI, nsnull, nsnull);
}
if (mPlaybackStateMachine) {
mPlaybackStateMachine->Seek(aTime);
return NS_OK;
}
return NS_ERROR_FAILURE;
}

View File

@ -45,7 +45,6 @@ include $(topsrcdir)/config/rules.mk
_TEST_FILES = test_autoplay.html \
test_bug461281.html \
test_bug465498.html \
test_constants.html \
test_controls.html \
test_currentTime.html \
@ -70,7 +69,6 @@ _TEST_FILES = test_autoplay.html \
test_volume.html \
test_wav_8bit.html \
test_wav_ended1.html \
test_wav_onloadedmetadata.html \
test_wav_seek_past_end.html \
test_wav_seek_then_play.html \
320x240.ogg \

View File

@ -1,52 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Wave Media test: Bug 465498 - Seeking after playback ended</title>
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=465498">Mozilla Bug 465498</a>
<audio id='v'
onloadedmetadata='return startTest();'
onended='return playbackEnded();'
onseeked='return endTest();'>
<source type='audio/x-wav' src='r11025_s16_c1.wav'>
</audio>
<pre id="test">
<script class="testbody" type="text/javascript">
var v = document.getElementById('v');
var haveSeeked = false;
function startTest() {
v.play();
return false;
}
function playbackEnded() {
ok(v.currentTime >= 0.9 && v.currentTime <= 1.1,
"Checking currentTime at end: " + v.currentTime);
ok(v.ended, "Checking playback has ended");
v.currentTime = 0;
haveSeeked = true;
return false;
}
function endTest() {
if (!haveSeeked)
return false;
ok(v.currentTime == 0, "Checking currentTime after seek: " + v.currentTime);
ok(!v.ended, "Checking ended is false");
SimpleTest.finish();
return false;
}
SimpleTest.waitForExplicitFinish();
</script>
</pre>
</body>
</html>

View File

@ -1,89 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=467972
-->
<head>
<title>Wav Test for Bug 467972</title>
<script type="application/javascript" src="/MochiKit/MochiKit.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=467972">Mozilla Bug 467972</a>
<video id="v"
src="r11025_s16_c1.wav"
onloadedmetadata="return loadedMetaData();"
onended="playbackEnded();"
onloadedfirstframe="return loadedFirstFrame();"
onseeking="seekStarted();"
onseeked="seekEnded();"
controls></video>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 467972 **/
var gEnded = false;
var gSeekStarted = false;
var gSeekEnded = false;
var gLoadedFirstFrameCount = 0;
var gLoadedMetaDataCount = 0;
function get(id) {
return document.getElementById(id);
}
function video() {
return get('v');
}
function seekStarted() {
gSeekStarted = true;
}
function seekEnded() {
gSeekEnded = true;
video().play();
}
function loadedFirstFrame() {
gLoadedFirstFrameCount++;
ok(gLoadedFirstFrameCount <= 1, "No more than 1 onloadedfirstframe events");
}
function loadedMetaData() {
gLoadedMetaDataCount++;
ok(gLoadedMetaDataCount <= 1, "No more than 1 onloadedmetadata events");
video().play();
return false;
}
function playbackEnded() {
if (!gEnded) {
video().currentTime = 0;
gEnded = true;
} else {
ok(gSeekEnded, "Should have received seekended");
ok(gSeekStarted, "Should have received seekstarted");
ok(gLoadedFirstFrameCount == 1, "Should have 1 onloadedfirstframe event");
ok(gLoadedMetaDataCount == 1, "Should have 1 onloadedmetadata event");
SimpleTest.finish();
}
return false;
}
SimpleTest.waitForExplicitFinish();
</script>
</pre>
</body>
</html>