| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012, Google Inc. All rights reserved. | 2 * Copyright (C) 2012, 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 29 matching lines...) Expand all Loading... |
| 40 // block here to avoid anything can cause the crash. | 40 // block here to avoid anything can cause the crash. |
| 41 static const unsigned long kMaxChannelCount = 8; | 41 static const unsigned long kMaxChannelCount = 8; |
| 42 | 42 |
| 43 MediaStreamAudioDestinationHandler::MediaStreamAudioDestinationHandler( | 43 MediaStreamAudioDestinationHandler::MediaStreamAudioDestinationHandler( |
| 44 AudioNode& node, | 44 AudioNode& node, |
| 45 size_t numberOfChannels) | 45 size_t numberOfChannels) |
| 46 : AudioBasicInspectorHandler(NodeTypeMediaStreamAudioDestination, | 46 : AudioBasicInspectorHandler(NodeTypeMediaStreamAudioDestination, |
| 47 node, | 47 node, |
| 48 node.context()->sampleRate(), | 48 node.context()->sampleRate(), |
| 49 numberOfChannels), | 49 numberOfChannels), |
| 50 m_mixBus(AudioBus::create(numberOfChannels, ProcessingSizeInFrames)) { | 50 m_mixBus(AudioBus::create(numberOfChannels, |
| 51 AudioUtilities::kRenderQuantumFrames)) { |
| 51 m_source = MediaStreamSource::create( | 52 m_source = MediaStreamSource::create( |
| 52 "WebAudio-" + createCanonicalUUIDString(), MediaStreamSource::TypeAudio, | 53 "WebAudio-" + createCanonicalUUIDString(), MediaStreamSource::TypeAudio, |
| 53 "MediaStreamAudioDestinationNode", false, | 54 "MediaStreamAudioDestinationNode", false, |
| 54 MediaStreamSource::ReadyStateLive, true); | 55 MediaStreamSource::ReadyStateLive, true); |
| 55 MediaStreamSourceVector audioSources; | 56 MediaStreamSourceVector audioSources; |
| 56 audioSources.append(m_source.get()); | 57 audioSources.append(m_source.get()); |
| 57 MediaStreamSourceVector videoSources; | 58 MediaStreamSourceVector videoSources; |
| 58 m_stream = MediaStream::create( | 59 m_stream = MediaStream::create( |
| 59 node.context()->getExecutionContext(), | 60 node.context()->getExecutionContext(), |
| 60 MediaStreamDescriptor::create(audioSources, videoSources)); | 61 MediaStreamDescriptor::create(audioSources, videoSources)); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 84 // Synchronize with possible dynamic changes to the channel count. | 85 // Synchronize with possible dynamic changes to the channel count. |
| 85 MutexTryLocker tryLocker(m_processLock); | 86 MutexTryLocker tryLocker(m_processLock); |
| 86 | 87 |
| 87 // If we can get the lock, we can process normally by updating the | 88 // If we can get the lock, we can process normally by updating the |
| 88 // mix bus to a new channel count, if needed. If not, just use the | 89 // mix bus to a new channel count, if needed. If not, just use the |
| 89 // old mix bus to do the mixing; we'll update the bus next time | 90 // old mix bus to do the mixing; we'll update the bus next time |
| 90 // around. | 91 // around. |
| 91 if (tryLocker.locked()) { | 92 if (tryLocker.locked()) { |
| 92 unsigned count = channelCount(); | 93 unsigned count = channelCount(); |
| 93 if (count != m_mixBus->numberOfChannels()) { | 94 if (count != m_mixBus->numberOfChannels()) { |
| 94 m_mixBus = AudioBus::create(count, ProcessingSizeInFrames); | 95 m_mixBus = AudioBus::create(count, AudioUtilities::kRenderQuantumFrames); |
| 95 // setAudioFormat has an internal lock. This can cause audio to | 96 // setAudioFormat has an internal lock. This can cause audio to |
| 96 // glitch. This is outside of our control. | 97 // glitch. This is outside of our control. |
| 97 m_source->setAudioFormat(count, context()->sampleRate()); | 98 m_source->setAudioFormat(count, context()->sampleRate()); |
| 98 } | 99 } |
| 99 } | 100 } |
| 100 | 101 |
| 101 m_mixBus->copyFrom(*input(0).bus()); | 102 m_mixBus->copyFrom(*input(0).bus()); |
| 102 | 103 |
| 103 // consumeAudio has an internal lock (also used by setAudioFormat). | 104 // consumeAudio has an internal lock (also used by setAudioFormat). |
| 104 // This can cause audio to glitch. This is outside of our control. | 105 // This can cause audio to glitch. This is outside of our control. |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 } | 157 } |
| 157 | 158 |
| 158 return new MediaStreamAudioDestinationNode(context, numberOfChannels); | 159 return new MediaStreamAudioDestinationNode(context, numberOfChannels); |
| 159 } | 160 } |
| 160 | 161 |
| 161 MediaStream* MediaStreamAudioDestinationNode::stream() const { | 162 MediaStream* MediaStreamAudioDestinationNode::stream() const { |
| 162 return static_cast<MediaStreamAudioDestinationHandler&>(handler()).stream(); | 163 return static_cast<MediaStreamAudioDestinationHandler&>(handler()).stream(); |
| 163 } | 164 } |
| 164 | 165 |
| 165 } // namespace blink | 166 } // namespace blink |
| OLD | NEW |