This source file includes following definitions.
- initialize
- uninitialize
- process
- pullInputs
- checkNumberOfChannelsForInput
- numberOfChannels
- tailTime
- latencyTime
#include "config.h"
#if ENABLE(WEB_AUDIO)
#include "modules/webaudio/AudioBasicProcessorNode.h"
#include "platform/audio/AudioBus.h"
#include "platform/audio/AudioProcessor.h"
#include "modules/webaudio/AudioContext.h"
#include "modules/webaudio/AudioNodeInput.h"
#include "modules/webaudio/AudioNodeOutput.h"
namespace WebCore {
AudioBasicProcessorNode::AudioBasicProcessorNode(AudioContext* context, float sampleRate)
: AudioNode(context, sampleRate)
{
addInput(adoptPtr(new AudioNodeInput(this)));
addOutput(adoptPtr(new AudioNodeOutput(this, 1)));
}
void AudioBasicProcessorNode::initialize()
{
if (isInitialized())
return;
ASSERT(processor());
processor()->initialize();
AudioNode::initialize();
}
void AudioBasicProcessorNode::uninitialize()
{
if (!isInitialized())
return;
ASSERT(processor());
processor()->uninitialize();
AudioNode::uninitialize();
}
void AudioBasicProcessorNode::process(size_t framesToProcess)
{
AudioBus* destinationBus = output(0)->bus();
if (!isInitialized() || !processor() || processor()->numberOfChannels() != numberOfChannels())
destinationBus->zero();
else {
AudioBus* sourceBus = input(0)->bus();
if (!input(0)->isConnected())
sourceBus->zero();
processor()->process(sourceBus, destinationBus, framesToProcess);
}
}
void AudioBasicProcessorNode::pullInputs(size_t framesToProcess)
{
input(0)->pull(output(0)->bus(), framesToProcess);
}
void AudioBasicProcessorNode::checkNumberOfChannelsForInput(AudioNodeInput* input)
{
ASSERT(context()->isAudioThread() && context()->isGraphOwner());
ASSERT(input == this->input(0));
if (input != this->input(0))
return;
ASSERT(processor());
if (!processor())
return;
unsigned numberOfChannels = input->numberOfChannels();
if (isInitialized() && numberOfChannels != output(0)->numberOfChannels()) {
uninitialize();
}
if (!isInitialized()) {
output(0)->setNumberOfChannels(numberOfChannels);
processor()->setNumberOfChannels(numberOfChannels);
initialize();
}
AudioNode::checkNumberOfChannelsForInput(input);
}
unsigned AudioBasicProcessorNode::numberOfChannels()
{
return output(0)->numberOfChannels();
}
double AudioBasicProcessorNode::tailTime() const
{
return m_processor->tailTime();
}
double AudioBasicProcessorNode::latencyTime() const
{
return m_processor->latencyTime();
}
}
#endif