Bug 1494073 - Always clamp playbackrate when setting decoder. r=padenot
We were clamping the playback rate properly if the decoder had been setup already, but not if setting it before playback started. Differential Revision: https://phabricator.services.mozilla.com/D11005
This commit is contained in:
@@ -165,6 +165,23 @@ static const double THRESHOLD_HIGH_PLAYBACKRATE_AUDIO = 4.0;
|
||||
// Threshold under which audio is muted
|
||||
static const double THRESHOLD_LOW_PLAYBACKRATE_AUDIO = 0.5;
|
||||
|
||||
static double
|
||||
ClampPlaybackRate(double aPlaybackRate)
|
||||
{
|
||||
MOZ_ASSERT(aPlaybackRate >= 0.0);
|
||||
|
||||
if (aPlaybackRate == 0.0) {
|
||||
return aPlaybackRate;
|
||||
}
|
||||
if (aPlaybackRate < MIN_PLAYBACKRATE) {
|
||||
return MIN_PLAYBACKRATE;
|
||||
}
|
||||
if (aPlaybackRate > MAX_PLAYBACKRATE) {
|
||||
return MAX_PLAYBACKRATE;
|
||||
}
|
||||
return aPlaybackRate;
|
||||
}
|
||||
|
||||
// Media error values. These need to match the ones in MediaError.webidl.
|
||||
static const unsigned short MEDIA_ERR_ABORTED = 1;
|
||||
static const unsigned short MEDIA_ERR_NETWORK = 2;
|
||||
@@ -2603,7 +2620,7 @@ HTMLMediaElement::LoadResource()
|
||||
this,
|
||||
mMuted ? 0.0 : mVolume,
|
||||
mPreservesPitch,
|
||||
mPlaybackRate,
|
||||
ClampPlaybackRate(mPlaybackRate),
|
||||
mPreloadAction == HTMLMediaElement::PRELOAD_METADATA,
|
||||
mHasSuspendTaint,
|
||||
HasAttr(kNameSpaceID_None, nsGkAtoms::loop),
|
||||
@@ -4942,7 +4959,7 @@ HTMLMediaElement::InitializeDecoderAsClone(ChannelMediaDecoder* aOriginal)
|
||||
MediaDecoderInit decoderInit(this,
|
||||
mMuted ? 0.0 : mVolume,
|
||||
mPreservesPitch,
|
||||
mPlaybackRate,
|
||||
ClampPlaybackRate(mPlaybackRate),
|
||||
mPreloadAction ==
|
||||
HTMLMediaElement::PRELOAD_METADATA,
|
||||
mHasSuspendTaint,
|
||||
@@ -5031,7 +5048,7 @@ HTMLMediaElement::InitializeDecoderForChannel(nsIChannel* aChannel,
|
||||
MediaDecoderInit decoderInit(this,
|
||||
mMuted ? 0.0 : mVolume,
|
||||
mPreservesPitch,
|
||||
mPlaybackRate,
|
||||
ClampPlaybackRate(mPlaybackRate),
|
||||
mPreloadAction ==
|
||||
HTMLMediaElement::PRELOAD_METADATA,
|
||||
mHasSuspendTaint,
|
||||
@@ -7031,23 +7048,6 @@ HTMLMediaElement::MozFragmentEnd()
|
||||
: mFragmentEnd;
|
||||
}
|
||||
|
||||
static double
|
||||
ClampPlaybackRate(double aPlaybackRate)
|
||||
{
|
||||
MOZ_ASSERT(aPlaybackRate >= 0.0);
|
||||
|
||||
if (aPlaybackRate == 0.0) {
|
||||
return aPlaybackRate;
|
||||
}
|
||||
if (aPlaybackRate < MIN_PLAYBACKRATE) {
|
||||
return MIN_PLAYBACKRATE;
|
||||
}
|
||||
if (aPlaybackRate > MAX_PLAYBACKRATE) {
|
||||
return MAX_PLAYBACKRATE;
|
||||
}
|
||||
return aPlaybackRate;
|
||||
}
|
||||
|
||||
void
|
||||
HTMLMediaElement::SetDefaultPlaybackRate(double aDefaultPlaybackRate,
|
||||
ErrorResult& aRv)
|
||||
|
||||
Reference in New Issue
Block a user