This source file includes following definitions.
- m_numberOfInputChannels
- initialize
- uninitialize
- createDestination
- startRendering
- maxChannelCount
- setChannelCount
#include "config.h"
#if ENABLE(WEB_AUDIO)
#include "modules/webaudio/DefaultAudioDestinationNode.h"
#include "bindings/v8/ExceptionMessages.h"
#include "bindings/v8/ExceptionState.h"
#include "core/dom/ExceptionCode.h"
#include "platform/Logging.h"
#include "wtf/MainThread.h"
namespace WebCore {
DefaultAudioDestinationNode::DefaultAudioDestinationNode(AudioContext* context)
: AudioDestinationNode(context, AudioDestination::hardwareSampleRate())
, m_numberOfInputChannels(0)
{
m_channelCount = 2;
m_channelCountMode = Explicit;
m_channelInterpretation = AudioBus::Speakers;
}
DefaultAudioDestinationNode::~DefaultAudioDestinationNode()
{
uninitialize();
}
void DefaultAudioDestinationNode::initialize()
{
ASSERT(isMainThread());
if (isInitialized())
return;
createDestination();
AudioNode::initialize();
}
void DefaultAudioDestinationNode::uninitialize()
{
ASSERT(isMainThread());
if (!isInitialized())
return;
m_destination->stop();
m_numberOfInputChannels = 0;
AudioNode::uninitialize();
}
void DefaultAudioDestinationNode::createDestination()
{
float hardwareSampleRate = AudioDestination::hardwareSampleRate();
WTF_LOG(WebAudio, ">>>> hardwareSampleRate = %f\n", hardwareSampleRate);
m_destination = AudioDestination::create(*this, m_inputDeviceId, m_numberOfInputChannels, channelCount(), hardwareSampleRate);
}
void DefaultAudioDestinationNode::startRendering()
{
ASSERT(isInitialized());
if (isInitialized())
m_destination->start();
}
unsigned long DefaultAudioDestinationNode::maxChannelCount() const
{
return AudioDestination::maxChannelCount();
}
void DefaultAudioDestinationNode::setChannelCount(unsigned long channelCount, ExceptionState& exceptionState)
{
ASSERT(isMainThread());
if (!maxChannelCount() || channelCount > maxChannelCount()) {
exceptionState.throwDOMException(
IndexSizeError,
ExceptionMessages::indexOutsideRange<unsigned>("channel count", channelCount, 1, ExceptionMessages::InclusiveBound, maxChannelCount(), ExceptionMessages::InclusiveBound));
return;
}
unsigned long oldChannelCount = this->channelCount();
AudioNode::setChannelCount(channelCount, exceptionState);
if (!exceptionState.hadException() && this->channelCount() != oldChannelCount && isInitialized()) {
m_destination->stop();
createDestination();
m_destination->start();
}
}
}
#endif