

#include "config.h"

#if ENABLE(WEB_AUDIO)

#include "DefaultAudioDestinationNode.h"

#include "Logging.h"

namespace WebCore {
    
DefaultAudioDestinationNode::DefaultAudioDestinationNode(AudioContext* context)
    : AudioDestinationNode(context, AudioDestination::hardwareSampleRate())
{
}

DefaultAudioDestinationNode::~DefaultAudioDestinationNode()
{
    uninitialize();
}

void DefaultAudioDestinationNode::initialize()
{
    if (isInitialized())
        return;

    float hardwareSampleRate = AudioDestination::hardwareSampleRate();
    LOG(WebAudio, ">>>> hardwareSampleRate = %f\n", hardwareSampleRate);
    
    m_destination = AudioDestination::create(*this, hardwareSampleRate);
    
    AudioNode::initialize();
}

void DefaultAudioDestinationNode::uninitialize()
{
    if (!isInitialized())
        return;

    m_destination->stop();

    AudioNode::uninitialize();
}

void DefaultAudioDestinationNode::startRendering()
{
    ASSERT(isInitialized());
    if (isInitialized())
        m_destination->start();
}

} // namespace WebCore

#endif // ENABLE(WEB_AUDIO)
