b=916422 make OfflineAudioContext::StartRendering() throw if called more than once r=ehsan

--HG--
extra : transplant_source : %B6T%C0C%F0/%03%A3C%25%9B%EF%A8%C41%8E%86%E9%FCr
This commit is contained in:
Karl Tomlinson 2013-09-16 17:14:45 +12:00
Родитель 8a595afe28
Коммит 83c991e4d3
4 изменённых файлов: 15 добавлений и 3 удалений

Просмотреть файл

@ -59,6 +59,7 @@ AudioContext::AudioContext(nsPIDOMWindow* aWindow,
aLength, aSampleRate))
, mNumberOfChannels(aNumberOfChannels)
, mIsOffline(aIsOffline)
, mIsStarted(!aIsOffline)
{
// Actually play audio
mDestination->Stream()->AddAudioOutput(&gWebAudioOutputKey);
@ -595,10 +596,15 @@ AudioContext::GetJSContext() const
}
void
AudioContext::StartRendering()
AudioContext::StartRendering(ErrorResult& aRv)
{
MOZ_ASSERT(mIsOffline, "This should only be called on OfflineAudioContext");
if (mIsStarted) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
return;
}
mIsStarted = true;
mDestination->StartRendering();
}

Просмотреть файл

@ -205,7 +205,7 @@ public:
const Optional<OwningNonNull<DecodeErrorCallback> >& aFailureCallback);
// OfflineAudioContext methods
void StartRendering();
void StartRendering(ErrorResult& aRv);
IMPL_EVENT_HANDLER(complete)
bool IsOffline() const { return mIsOffline; }
@ -251,6 +251,7 @@ private:
// Number of channels passed in the OfflineAudioContext ctor.
uint32_t mNumberOfChannels;
bool mIsOffline;
bool mIsStarted;
};
}

Просмотреть файл

@ -54,6 +54,10 @@ addLoadEvent(function() {
compareBuffers(e.renderedBuffer.getChannelData(0), buf.getChannelData(0));
compareBuffers(e.renderedBuffer.getChannelData(1), buf.getChannelData(1));
expectException(function() {
ctx.startRendering();
}, DOMException.INVALID_STATE_ERR);
SimpleTest.finish();
}, false);
});

Просмотреть файл

@ -1,4 +1,4 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
@ -16,6 +16,7 @@ callback OfflineRenderSuccessCallback = void (AudioBuffer renderedData);
PrefControlled]
interface OfflineAudioContext : AudioContext {
[Throws]
void startRendering();
attribute EventHandler oncomplete;