| 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 are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 WebAudioDestinationConsumer* m_consumer; | 189 WebAudioDestinationConsumer* m_consumer; |
| 190 }; | 190 }; |
| 191 | 191 |
| 192 void ConsumerWrapper::setFormat(size_t numberOfChannels, float sampleRate) | 192 void ConsumerWrapper::setFormat(size_t numberOfChannels, float sampleRate) |
| 193 { | 193 { |
| 194 m_consumer->setFormat(numberOfChannels, sampleRate); | 194 m_consumer->setFormat(numberOfChannels, sampleRate); |
| 195 } | 195 } |
| 196 | 196 |
| 197 void ConsumerWrapper::consumeAudio(AudioBus* bus, size_t numberOfFrames) | 197 void ConsumerWrapper::consumeAudio(AudioBus* bus, size_t numberOfFrames) |
| 198 { | 198 { |
| 199 #if ENABLE(WEB_AUDIO) | |
| 200 if (!bus) | 199 if (!bus) |
| 201 return; | 200 return; |
| 202 | 201 |
| 203 // Wrap AudioBus. | 202 // Wrap AudioBus. |
| 204 size_t numberOfChannels = bus->numberOfChannels(); | 203 size_t numberOfChannels = bus->numberOfChannels(); |
| 205 WebVector<const float*> busVector(numberOfChannels); | 204 WebVector<const float*> busVector(numberOfChannels); |
| 206 for (size_t i = 0; i < numberOfChannels; ++i) | 205 for (size_t i = 0; i < numberOfChannels; ++i) |
| 207 busVector[i] = bus->channel(i)->data(); | 206 busVector[i] = bus->channel(i)->data(); |
| 208 | 207 |
| 209 m_consumer->consumeAudio(busVector, numberOfFrames); | 208 m_consumer->consumeAudio(busVector, numberOfFrames); |
| 210 #endif | |
| 211 } | 209 } |
| 212 | 210 |
| 213 void WebMediaStreamSource::addAudioConsumer(WebAudioDestinationConsumer* consume
r) | 211 void WebMediaStreamSource::addAudioConsumer(WebAudioDestinationConsumer* consume
r) |
| 214 { | 212 { |
| 215 ASSERT(isMainThread()); | 213 ASSERT(isMainThread()); |
| 216 ASSERT(!m_private.isNull() && consumer); | 214 ASSERT(!m_private.isNull() && consumer); |
| 217 | 215 |
| 218 m_private->addAudioConsumer(ConsumerWrapper::create(consumer)); | 216 m_private->addAudioConsumer(ConsumerWrapper::create(consumer)); |
| 219 } | 217 } |
| 220 | 218 |
| 221 bool WebMediaStreamSource::removeAudioConsumer(WebAudioDestinationConsumer* cons
umer) | 219 bool WebMediaStreamSource::removeAudioConsumer(WebAudioDestinationConsumer* cons
umer) |
| 222 { | 220 { |
| 223 ASSERT(isMainThread()); | 221 ASSERT(isMainThread()); |
| 224 ASSERT(!m_private.isNull() && consumer); | 222 ASSERT(!m_private.isNull() && consumer); |
| 225 | 223 |
| 226 const HeapHashSet<Member<AudioDestinationConsumer>>& consumers = m_private->
audioConsumers(); | 224 const HeapHashSet<Member<AudioDestinationConsumer>>& consumers = m_private->
audioConsumers(); |
| 227 for (HeapHashSet<Member<AudioDestinationConsumer>>::const_iterator it = cons
umers.begin(); it != consumers.end(); ++it) { | 225 for (HeapHashSet<Member<AudioDestinationConsumer>>::const_iterator it = cons
umers.begin(); it != consumers.end(); ++it) { |
| 228 ConsumerWrapper* wrapper = static_cast<ConsumerWrapper*>(it->get()); | 226 ConsumerWrapper* wrapper = static_cast<ConsumerWrapper*>(it->get()); |
| 229 if (wrapper->consumer() == consumer) { | 227 if (wrapper->consumer() == consumer) { |
| 230 m_private->removeAudioConsumer(wrapper); | 228 m_private->removeAudioConsumer(wrapper); |
| 231 return true; | 229 return true; |
| 232 } | 230 } |
| 233 } | 231 } |
| 234 return false; | 232 return false; |
| 235 } | 233 } |
| 236 | 234 |
| 237 } // namespace blink | 235 } // namespace blink |
| OLD | NEW |