| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Ericsson AB. All rights reserved. | 2 * Copyright (C) 2011 Ericsson AB. All rights reserved. |
| 3 * Copyright (C) 2013 Google Inc. All rights reserved. | 3 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 | 52 |
| 53 MediaStreamComponent::MediaStreamComponent(const String& id, PassRefPtr<MediaStr
eamSource> source) | 53 MediaStreamComponent::MediaStreamComponent(const String& id, PassRefPtr<MediaStr
eamSource> source) |
| 54 : m_source(source) | 54 : m_source(source) |
| 55 , m_id(id) | 55 , m_id(id) |
| 56 , m_enabled(true) | 56 , m_enabled(true) |
| 57 , m_muted(false) | 57 , m_muted(false) |
| 58 { | 58 { |
| 59 ASSERT(m_id.length()); | 59 ASSERT(m_id.length()); |
| 60 } | 60 } |
| 61 | 61 |
| 62 #if ENABLE(WEB_AUDIO) | |
| 63 void MediaStreamComponent::AudioSourceProviderImpl::wrap(blink::WebAudioSourcePr
ovider* provider) | 62 void MediaStreamComponent::AudioSourceProviderImpl::wrap(blink::WebAudioSourcePr
ovider* provider) |
| 64 { | 63 { |
| 65 MutexLocker locker(m_provideInputLock); | 64 MutexLocker locker(m_provideInputLock); |
| 66 m_webAudioSourceProvider = provider; | 65 m_webAudioSourceProvider = provider; |
| 67 } | 66 } |
| 68 | 67 |
| 69 void MediaStreamComponent::AudioSourceProviderImpl::provideInput(AudioBus* bus,
size_t framesToProcess) | 68 void MediaStreamComponent::AudioSourceProviderImpl::provideInput(AudioBus* bus,
size_t framesToProcess) |
| 70 { | 69 { |
| 71 ASSERT(bus); | 70 ASSERT(bus); |
| 72 if (!bus) | 71 if (!bus) |
| 73 return; | 72 return; |
| 74 | 73 |
| 75 MutexTryLocker tryLocker(m_provideInputLock); | 74 MutexTryLocker tryLocker(m_provideInputLock); |
| 76 if (!tryLocker.locked() || !m_webAudioSourceProvider) { | 75 if (!tryLocker.locked() || !m_webAudioSourceProvider) { |
| 77 bus->zero(); | 76 bus->zero(); |
| 78 return; | 77 return; |
| 79 } | 78 } |
| 80 | 79 |
| 81 // Wrap the AudioBus channel data using WebVector. | 80 // Wrap the AudioBus channel data using WebVector. |
| 82 size_t n = bus->numberOfChannels(); | 81 size_t n = bus->numberOfChannels(); |
| 83 blink::WebVector<float*> webAudioData(n); | 82 blink::WebVector<float*> webAudioData(n); |
| 84 for (size_t i = 0; i < n; ++i) | 83 for (size_t i = 0; i < n; ++i) |
| 85 webAudioData[i] = bus->channel(i)->mutableData(); | 84 webAudioData[i] = bus->channel(i)->mutableData(); |
| 86 | 85 |
| 87 m_webAudioSourceProvider->provideInput(webAudioData, framesToProcess); | 86 m_webAudioSourceProvider->provideInput(webAudioData, framesToProcess); |
| 88 } | 87 } |
| 89 #endif // #if ENABLE(WEB_AUDIO) | |
| 90 | 88 |
| 91 } // namespace blink | 89 } // namespace blink |
| 92 | 90 |
| OLD | NEW |