#include "DefaultAudioDestinationNode.h"
#include "Logging.h"
+#include <wtf/MainThread.h>
+
+const unsigned EnabledInputChannels = 2;
namespace WebCore {
DefaultAudioDestinationNode::DefaultAudioDestinationNode(AudioContext* context)
: AudioDestinationNode(context, AudioDestination::hardwareSampleRate())
+ , m_numberOfInputChannels(0)
{
}
void DefaultAudioDestinationNode::initialize()
{
+ ASSERT(isMainThread());
if (isInitialized())
return;
- float hardwareSampleRate = AudioDestination::hardwareSampleRate();
- LOG(WebAudio, ">>>> hardwareSampleRate = %f\n", hardwareSampleRate);
-
- m_destination = AudioDestination::create(*this, hardwareSampleRate);
-
+ 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();
+ LOG(WebAudio, ">>>> hardwareSampleRate = %f\n", hardwareSampleRate);
+
+ m_destination = AudioDestination::create(*this, m_numberOfInputChannels, numberOfChannels(), hardwareSampleRate);
+}
+
+void DefaultAudioDestinationNode::enableInput()
+{
+ ASSERT(isMainThread());
+ if (m_numberOfInputChannels != EnabledInputChannels) {
+ m_numberOfInputChannels = EnabledInputChannels;
+
+ if (isInitialized()) {
+ m_destination->stop();
+ createDestination();
+ m_destination->start();
+ }
+ }
+}
+
void DefaultAudioDestinationNode::startRendering()
{
ASSERT(isInitialized());
m_destination->start();
}
+#if ENABLE(TIZEN_WEB_AUDIO)
+void DefaultAudioDestinationNode::pauseRendering()
+{
+ ASSERT(isInitialized());
+ if (isInitialized())
+ m_destination->stop();
+}
+#endif
} // namespace WebCore
#endif // ENABLE(WEB_AUDIO)