This source file includes following definitions.
- create
#include "config.h"
#if ENABLE(WEB_AUDIO)
#include "modules/webaudio/OfflineAudioContext.h"
#include "bindings/v8/ExceptionMessages.h"
#include "bindings/v8/ExceptionState.h"
#include "core/dom/Document.h"
#include "core/dom/ExceptionCode.h"
#include "core/dom/ExecutionContext.h"
namespace WebCore {
PassRefPtr<OfflineAudioContext> OfflineAudioContext::create(ExecutionContext* context, unsigned numberOfChannels, size_t numberOfFrames, float sampleRate, ExceptionState& exceptionState)
{
if (!context || !context->isDocument()) {
exceptionState.throwDOMException(
NotSupportedError,
"Workers are not supported.");
return nullptr;
}
Document* document = toDocument(context);
if (!numberOfFrames) {
exceptionState.throwDOMException(SyntaxError, "number of frames cannot be zero.");
return nullptr;
}
if (numberOfChannels > 10) {
exceptionState.throwDOMException(SyntaxError, "number of channels (" + String::number(numberOfChannels) + ") exceeds maximum (10).");
return nullptr;
}
if (!isSampleRateRangeGood(sampleRate)) {
exceptionState.throwDOMException(SyntaxError, "sample rate (" + String::number(sampleRate) + ") must be in the range 44100-96000 Hz.");
return nullptr;
}
RefPtr<OfflineAudioContext> audioContext(adoptRef(new OfflineAudioContext(document, numberOfChannels, numberOfFrames, sampleRate)));
if (!audioContext->destination()) {
exceptionState.throwDOMException(
NotSupportedError,
"OfflineAudioContext(" + String::number(numberOfChannels)
+ ", " + String::number(numberOfFrames)
+ ", " + String::number(sampleRate)
+ ")");
}
audioContext->suspendIfNeeded();
return audioContext.release();
}
OfflineAudioContext::OfflineAudioContext(Document* document, unsigned numberOfChannels, size_t numberOfFrames, float sampleRate)
: AudioContext(document, numberOfChannels, numberOfFrames, sampleRate)
{
ScriptWrappable::init(this);
}
OfflineAudioContext::~OfflineAudioContext()
{
}
}
#endif