зеркало из https://github.com/mozilla/gecko-dev.git
bug 1391482 move AudioBuffer parameter checking to constructor r=padenot
for sharing with a new factory method in a future patch. MozReview-Commit-ID: LAtbRVttMh8 --HG-- extra : rebase_source : 72283c49fd713d0aef3add0eae344da0733149a1
This commit is contained in:
Родитель
580aed4daa
Коммит
1cd9d48de3
|
@ -159,10 +159,22 @@ AudioBufferMemoryTracker::CollectReports(nsIHandleReportCallback* aHandleReport,
|
|||
AudioBuffer::AudioBuffer(nsPIDOMWindowInner* aWindow,
|
||||
uint32_t aNumberOfChannels,
|
||||
uint32_t aLength,
|
||||
float aSampleRate)
|
||||
float aSampleRate,
|
||||
ErrorResult& aRv)
|
||||
: mOwnerWindow(do_GetWeakReference(aWindow)),
|
||||
mSampleRate(aSampleRate)
|
||||
{
|
||||
// Note that a buffer with zero channels is permitted here for the sake of
|
||||
// AudioProcessingEvent, where channel counts must match parameters passed
|
||||
// to createScriptProcessor(), one of which may be zero.
|
||||
if (aSampleRate < WebAudioUtils::MinSampleRate ||
|
||||
aSampleRate > WebAudioUtils::MaxSampleRate ||
|
||||
aNumberOfChannels > WebAudioUtils::MaxChannelCount ||
|
||||
!aLength || aLength > INT32_MAX) {
|
||||
aRv.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
|
||||
return;
|
||||
}
|
||||
|
||||
mSharedChannels.mDuration = aLength;
|
||||
mJSChannels.SetLength(aNumberOfChannels);
|
||||
mozilla::HoldJSObjects(this);
|
||||
|
@ -222,21 +234,12 @@ AudioBuffer::Create(nsPIDOMWindowInner* aWindow, uint32_t aNumberOfChannels,
|
|||
ErrorResult& aRv)
|
||||
{
|
||||
RefPtr<ThreadSharedFloatArrayBufferList> initialContents = aInitialContents;
|
||||
|
||||
// Note that a buffer with zero channels is permitted here for the sake of
|
||||
// AudioProcessingEvent, where channel counts must match parameters passed
|
||||
// to createScriptProcessor(), one of which may be zero.
|
||||
if (aSampleRate < WebAudioUtils::MinSampleRate ||
|
||||
aSampleRate > WebAudioUtils::MaxSampleRate ||
|
||||
aNumberOfChannels > WebAudioUtils::MaxChannelCount ||
|
||||
!aLength || aLength > INT32_MAX) {
|
||||
aRv.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
|
||||
RefPtr<AudioBuffer> buffer =
|
||||
new AudioBuffer(aWindow, aNumberOfChannels, aLength, aSampleRate, aRv);
|
||||
if (aRv.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<AudioBuffer> buffer =
|
||||
new AudioBuffer(aWindow, aNumberOfChannels, aLength, aSampleRate);
|
||||
|
||||
if (initialContents) {
|
||||
MOZ_ASSERT(initialContents->GetChannels() == aNumberOfChannels);
|
||||
buffer->SetSharedChannels(initialContents.forget());
|
||||
|
|
|
@ -113,7 +113,7 @@ public:
|
|||
|
||||
protected:
|
||||
AudioBuffer(nsPIDOMWindowInner* aWindow, uint32_t aNumberOfChannels,
|
||||
uint32_t aLength, float aSampleRate);
|
||||
uint32_t aLength, float aSampleRate, ErrorResult& aRv);
|
||||
~AudioBuffer();
|
||||
|
||||
void
|
||||
|
|
Загрузка…
Ссылка в новой задаче