Bug 1382780 - part2 : separate the value of actual playback rate and media element's attribute.
According to [1], we should separate the value of actual playback rate and media elemenet's attribute.
But still keep a MAX and MIN threshold to control the highest and lowser playback rate for decoder.
[1] http://w3c-test.org/html/semantics/embedded-content/media-elements/playing-the-media-resource/playbackRate.html
MozReview-Commit-ID: EGCa4yrNXO6
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -6720,28 +6720,32 @@ HTMLMediaElement::SetPlaybackRate(double
{
// Changing the playback rate of a media that has more than two channels is
// not supported.
if (aPlaybackRate < 0) {
aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
return;
}
- mPlaybackRate = ClampPlaybackRate(aPlaybackRate);
+ if (mPlaybackRate == aPlaybackRate) {
+ return;
+ }
+
+ mPlaybackRate = aPlaybackRate;
if (mPlaybackRate != 0.0 &&
(mPlaybackRate > THRESHOLD_HIGH_PLAYBACKRATE_AUDIO ||
mPlaybackRate < THRESHOLD_LOW_PLAYBACKRATE_AUDIO)) {
SetMutedInternal(mMuted | MUTED_BY_INVALID_PLAYBACK_RATE);
} else {
SetMutedInternal(mMuted & ~MUTED_BY_INVALID_PLAYBACK_RATE);
}
if (mDecoder) {
- mDecoder->SetPlaybackRate(mPlaybackRate);
+ mDecoder->SetPlaybackRate(ClampPlaybackRate(mPlaybackRate));
}
DispatchAsyncEvent(NS_LITERAL_STRING("ratechange"));
}
NS_IMETHODIMP HTMLMediaElement::SetPlaybackRate(double aPlaybackRate)
{
ErrorResult rv;
SetPlaybackRate(aPlaybackRate, rv);