| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011, Google Inc. All rights reserved. | 2 * Copyright (C) 2011, Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 #include "modules/webaudio/DefaultAudioDestinationNode.h" | 29 #include "modules/webaudio/DefaultAudioDestinationNode.h" |
| 30 | 30 |
| 31 #include "bindings/v8/ExceptionState.h" | 31 #include "bindings/v8/ExceptionState.h" |
| 32 #include "core/dom/ExceptionCode.h" | 32 #include "core/dom/ExceptionCode.h" |
| 33 #include "core/platform/Logging.h" | 33 #include "core/platform/Logging.h" |
| 34 #include "wtf/MainThread.h" | 34 #include "wtf/MainThread.h" |
| 35 | 35 |
| 36 const unsigned EnabledInputChannels = 2; | 36 const unsigned EnabledInputChannels = 2; |
| 37 | 37 |
| 38 namespace WebCore { | 38 namespace WebCore { |
| 39 | 39 |
| 40 DefaultAudioDestinationNode::DefaultAudioDestinationNode(AudioContext* context) | 40 DefaultAudioDestinationNode::DefaultAudioDestinationNode(AudioContext* context) |
| 41 : AudioDestinationNode(context, AudioDestination::hardwareSampleRate()) | 41 : AudioDestinationNode(context, AudioDestination::hardwareSampleRate()) |
| 42 , m_numberOfInputChannels(0) | 42 , m_numberOfInputChannels(0) |
| 43 { | 43 { |
| 44 // Node-specific default mixing rules. | 44 // Node-specific default mixing rules. |
| 45 m_channelCount = 2; | 45 m_channelCount = 2; |
| 46 m_channelCountMode = Explicit; | 46 m_channelCountMode = Explicit; |
| 47 m_channelInterpretation = AudioBus::Speakers; | 47 m_channelInterpretation = AudioBus::Speakers; |
| 48 } | 48 } |
| 49 | 49 |
| 50 DefaultAudioDestinationNode::~DefaultAudioDestinationNode() | 50 DefaultAudioDestinationNode::~DefaultAudioDestinationNode() |
| 51 { | 51 { |
| 52 uninitialize(); | 52 uninitialize(); |
| 53 } | 53 } |
| 54 | 54 |
| 55 void DefaultAudioDestinationNode::initialize() | 55 void DefaultAudioDestinationNode::initialize() |
| 56 { | 56 { |
| 57 ASSERT(isMainThread()); | 57 ASSERT(isMainThread()); |
| 58 if (isInitialized()) | 58 if (isInitialized()) |
| 59 return; | 59 return; |
| 60 | 60 |
| 61 createDestination(); | 61 createDestination(); |
| 62 AudioNode::initialize(); | 62 AudioNode::initialize(); |
| 63 } | 63 } |
| 64 | 64 |
| 65 void DefaultAudioDestinationNode::uninitialize() | 65 void DefaultAudioDestinationNode::uninitialize() |
| 66 { | 66 { |
| 67 ASSERT(isMainThread()); | 67 ASSERT(isMainThread()); |
| 68 if (!isInitialized()) | 68 if (!isInitialized()) |
| 69 return; | 69 return; |
| 70 | 70 |
| 71 m_destination->stop(); | 71 m_destination->stop(); |
| 72 m_numberOfInputChannels = 0; | 72 m_numberOfInputChannels = 0; |
| 73 | 73 |
| 74 AudioNode::uninitialize(); | 74 AudioNode::uninitialize(); |
| 75 } | 75 } |
| 76 | 76 |
| 77 void DefaultAudioDestinationNode::createDestination() | 77 void DefaultAudioDestinationNode::createDestination() |
| 78 { | 78 { |
| 79 float hardwareSampleRate = AudioDestination::hardwareSampleRate(); | 79 float hardwareSampleRate = AudioDestination::hardwareSampleRate(); |
| 80 LOG(WebAudio, ">>>> hardwareSampleRate = %f\n", hardwareSampleRate); | 80 LOG(WebAudio, ">>>> hardwareSampleRate = %f\n", hardwareSampleRate); |
| 81 | 81 |
| 82 m_destination = AudioDestination::create(*this, m_inputDeviceId, m_numberOfI
nputChannels, channelCount(), hardwareSampleRate); | 82 m_destination = AudioDestination::create(*this, m_inputDeviceId, m_numberOfI
nputChannels, channelCount(), hardwareSampleRate); |
| 83 } | 83 } |
| 84 | 84 |
| 85 void DefaultAudioDestinationNode::enableInput(const String& inputDeviceId) | 85 void DefaultAudioDestinationNode::enableInput(const String& inputDeviceId) |
| 86 { | 86 { |
| 87 ASSERT(isMainThread()); | 87 ASSERT(isMainThread()); |
| 88 if (m_numberOfInputChannels != EnabledInputChannels) { | 88 if (m_numberOfInputChannels != EnabledInputChannels) { |
| 89 m_numberOfInputChannels = EnabledInputChannels; | 89 m_numberOfInputChannels = EnabledInputChannels; |
| 90 m_inputDeviceId = inputDeviceId; | 90 m_inputDeviceId = inputDeviceId; |
| 91 | 91 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 // Re-create destination. | 130 // Re-create destination. |
| 131 m_destination->stop(); | 131 m_destination->stop(); |
| 132 createDestination(); | 132 createDestination(); |
| 133 m_destination->start(); | 133 m_destination->start(); |
| 134 } | 134 } |
| 135 } | 135 } |
| 136 | 136 |
| 137 } // namespace WebCore | 137 } // namespace WebCore |
| 138 | 138 |
| 139 #endif // ENABLE(WEB_AUDIO) | 139 #endif // ENABLE(WEB_AUDIO) |
| OLD | NEW |