зеркало из https://github.com/mozilla/gecko-dev.git
Bug 876024 - Sanity check all of the time values passed to Web Audio; r=roc
This commit is contained in:
Родитель
aded29394c
Коммит
2942a374d2
|
@ -0,0 +1,5 @@
|
|||
<script>
|
||||
o1 = new window.AudioContext(2, 8, 44100);
|
||||
o4 = o1.createBiquadFilter();
|
||||
o4.detune.setValueAtTime(0.0843, 1.7976931348623157e+308);
|
||||
</script>
|
|
@ -0,0 +1,17 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<script>
|
||||
|
||||
function boom()
|
||||
{
|
||||
var bufferSource = AudioContext().createScriptProcessor().context.createBufferSource();
|
||||
bufferSource.noteGrainOn(0, 0, 0);
|
||||
bufferSource.noteOff(562949953421313);
|
||||
}
|
||||
|
||||
</script></head>
|
||||
|
||||
<body onload="boom();"></body>
|
||||
</html>
|
|
@ -22,6 +22,8 @@ load 874952.html
|
|||
load 875144.html
|
||||
load 875596.html
|
||||
load 875911.html
|
||||
load 876024-1.html
|
||||
load 876024-2.html
|
||||
load 876118.html
|
||||
load 876207.html
|
||||
load 876215.html
|
||||
|
|
|
@ -480,6 +480,12 @@ void
|
|||
AudioBufferSourceNode::Start(double aWhen, double aOffset,
|
||||
const Optional<double>& aDuration, ErrorResult& aRv)
|
||||
{
|
||||
if (!WebAudioUtils::IsTimeValid(aWhen) ||
|
||||
(aDuration.WasPassed() && !WebAudioUtils::IsTimeValid(aDuration.Value()))) {
|
||||
aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
|
||||
return;
|
||||
}
|
||||
|
||||
if (mStartCalled) {
|
||||
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
return;
|
||||
|
@ -567,6 +573,11 @@ AudioBufferSourceNode::SendOffsetAndDurationParametersToStream(AudioNodeStream*
|
|||
void
|
||||
AudioBufferSourceNode::Stop(double aWhen, ErrorResult& aRv, bool aShuttingDown)
|
||||
{
|
||||
if (!WebAudioUtils::IsTimeValid(aWhen)) {
|
||||
aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mStartCalled) {
|
||||
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
return;
|
||||
|
|
|
@ -72,21 +72,38 @@ public:
|
|||
}
|
||||
void SetValueAtTime(float aValue, double aStartTime, ErrorResult& aRv)
|
||||
{
|
||||
if (!WebAudioUtils::IsTimeValid(aStartTime)) {
|
||||
aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
|
||||
return;
|
||||
}
|
||||
AudioParamTimeline::SetValueAtTime(aValue, aStartTime, aRv);
|
||||
mCallback(mNode);
|
||||
}
|
||||
void LinearRampToValueAtTime(float aValue, double aEndTime, ErrorResult& aRv)
|
||||
{
|
||||
if (!WebAudioUtils::IsTimeValid(aEndTime)) {
|
||||
aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
|
||||
return;
|
||||
}
|
||||
AudioParamTimeline::LinearRampToValueAtTime(aValue, aEndTime, aRv);
|
||||
mCallback(mNode);
|
||||
}
|
||||
void ExponentialRampToValueAtTime(float aValue, double aEndTime, ErrorResult& aRv)
|
||||
{
|
||||
if (!WebAudioUtils::IsTimeValid(aEndTime)) {
|
||||
aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
|
||||
return;
|
||||
}
|
||||
AudioParamTimeline::ExponentialRampToValueAtTime(aValue, aEndTime, aRv);
|
||||
mCallback(mNode);
|
||||
}
|
||||
void SetTargetAtTime(float aTarget, double aStartTime, double aTimeConstant, ErrorResult& aRv)
|
||||
{
|
||||
if (!WebAudioUtils::IsTimeValid(aStartTime) ||
|
||||
!WebAudioUtils::IsTimeValid(aTimeConstant)) {
|
||||
aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
|
||||
return;
|
||||
}
|
||||
AudioParamTimeline::SetTargetAtTime(aTarget, aStartTime, aTimeConstant, aRv);
|
||||
mCallback(mNode);
|
||||
}
|
||||
|
@ -94,8 +111,12 @@ public:
|
|||
{
|
||||
SetTargetAtTime(aTarget, aStartTime, aTimeConstant, aRv);
|
||||
}
|
||||
void CancelScheduledValues(double aStartTime)
|
||||
void CancelScheduledValues(double aStartTime, ErrorResult& aRv)
|
||||
{
|
||||
if (!WebAudioUtils::IsTimeValid(aStartTime)) {
|
||||
aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
|
||||
return;
|
||||
}
|
||||
AudioParamTimeline::CancelScheduledValues(aStartTime);
|
||||
mCallback(mNode);
|
||||
}
|
||||
|
|
|
@ -104,6 +104,11 @@ struct WebAudioUtils {
|
|||
return 1.0 - std::exp(-1.0 / (sampleRate * timeConstant));
|
||||
}
|
||||
|
||||
static bool IsTimeValid(double aTime)
|
||||
{
|
||||
return aTime >= 0 && aTime <= (MEDIA_TIME_MAX >> MEDIA_TIME_FRAC_BITS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a stream position into the time coordinate of the destination
|
||||
* stream.
|
||||
|
|
|
@ -34,6 +34,7 @@ interface AudioParam {
|
|||
void setValueCurveAtTime(Float32Array values, double startTime, double duration);
|
||||
|
||||
// Cancels all scheduled parameter changes with times greater than or equal to startTime.
|
||||
[Throws]
|
||||
void cancelScheduledValues(double startTime);
|
||||
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче