mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 825329 - Properly implement AudioStream::GetPlaybackRate. r=kinetik
This commit is contained in:
parent
54a3ee7cad
commit
ea63943c0e
@ -1112,7 +1112,6 @@ AudioClock::AudioClock(AudioStream* aStream)
|
||||
mOutRate(0),
|
||||
mInRate(0),
|
||||
mPreservesPitch(true),
|
||||
mPlaybackRate(1.0),
|
||||
mCompensatingLatency(false)
|
||||
{}
|
||||
|
||||
@ -1120,7 +1119,6 @@ void AudioClock::Init()
|
||||
{
|
||||
mOutRate = mAudioStream->GetRate();
|
||||
mInRate = mAudioStream->GetRate();
|
||||
mPlaybackRate = 1.0;
|
||||
mOldOutRate = mOutRate;
|
||||
}
|
||||
|
||||
@ -1190,7 +1188,7 @@ void AudioClock::SetPlaybackRate(double aPlaybackRate)
|
||||
|
||||
double AudioClock::GetPlaybackRate()
|
||||
{
|
||||
return mPlaybackRate;
|
||||
return static_cast<double>(mOutRate) / mInRate;
|
||||
}
|
||||
|
||||
void AudioClock::SetPreservesPitch(bool aPreservesPitch)
|
||||
|
@ -77,8 +77,6 @@ class AudioClock
|
||||
int mInRate;
|
||||
// True if the we are timestretching, false if we are resampling.
|
||||
bool mPreservesPitch;
|
||||
// The current playback rate.
|
||||
double mPlaybackRate;
|
||||
// True if we are playing at the old playbackRate after it has been changed.
|
||||
bool mCompensatingLatency;
|
||||
};
|
||||
|
@ -107,8 +107,42 @@ function onended(e) {
|
||||
ok(!t.muted, "The audio should be muted when playing at high speed, but should not appear as such.");
|
||||
is(t.currentTime, t.duration, "Current time should be equal to the duration (not change by playback rate).");
|
||||
}
|
||||
testResetPlaybackRate(e);
|
||||
}
|
||||
|
||||
function testResetPlaybackRate(e) {
|
||||
var t = e.target;
|
||||
t.addEventListener("timeupdate", ontimeupdate_resetPlabackRate);
|
||||
t.currentTime = 0.0;
|
||||
t.play();
|
||||
t.timeUpdate = 0;
|
||||
}
|
||||
|
||||
function ontimeupdate_resetPlabackRate(e) {
|
||||
var t = e.target;
|
||||
if (t.currentTime == 0.0) {
|
||||
return;
|
||||
}
|
||||
if (t.timeUpdate == 0) {
|
||||
t.playbackRate = 0.5;
|
||||
t.timeUpdate++;
|
||||
} else if (t.timeUpdate == 1){
|
||||
t.playbackRate = 1.0;
|
||||
t.startTimestamp = Date.now();
|
||||
t.oldCurrentTime = t.currentTime;
|
||||
t.timeUpdate++;
|
||||
} else {
|
||||
if (t.currentTime < 3 * t.duration / 4) {
|
||||
return;
|
||||
}
|
||||
var delta = t.currentTime - t.oldCurrentTime,
|
||||
delta_wallclock = (Date.now() - t.startTimestamp - t.bufferingTime) / 1000;
|
||||
|
||||
ok(checkPlaybackRate(delta_wallclock, delta, 1.0, 0.25), "PlaybackRate reset.");
|
||||
t.removeEventListener("timeupdate", ontimeupdate_resetPlabackRate);
|
||||
test_defaultPlaybackRate(e);
|
||||
}
|
||||
}
|
||||
|
||||
function test_defaultPlaybackRate(e) {
|
||||
var t = e.target;
|
||||
@ -135,9 +169,9 @@ function ontimeupdate_defaultPlaybackRate(e) {
|
||||
"The default playback rate shoud be "+SLOW_RATE+"." + t.token);
|
||||
ok(delta_wallclock > delta , "We are effectively slowing down playback. (" + delta_wallclock + ", " + delta + ")");
|
||||
if (t.skippedFastPart) {
|
||||
is(t.ratechangecount, 7, "We should have received 7 \"ratechange\" events.");
|
||||
is(t.ratechangecount, 10, "We should have received 10 \"ratechange\" events.");
|
||||
} else {
|
||||
is(t.ratechangecount, 8, "We should have received 8 \"ratechange\" events.");
|
||||
is(t.ratechangecount, 11, "We should have received 11 \"ratechange\" events.");
|
||||
}
|
||||
finish_test(t);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user