| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 #include "WebMediaPlayerClientImpl.h" | 6 #include "WebMediaPlayerClientImpl.h" |
| 7 | 7 |
| 8 #include "InbandTextTrackPrivateImpl.h" | 8 #include "InbandTextTrackPrivateImpl.h" |
| 9 #include "WebAudioSourceProvider.h" | 9 #include "WebAudioSourceProvider.h" |
| 10 #include "WebDocument.h" | 10 #include "WebDocument.h" |
| (...skipping 823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 834 , m_preload(MediaPlayer::MetaData) | 834 , m_preload(MediaPlayer::MetaData) |
| 835 , m_videoLayer(0) | 835 , m_videoLayer(0) |
| 836 , m_opaque(false) | 836 , m_opaque(false) |
| 837 , m_needsWebLayerForVideo(false) | 837 , m_needsWebLayerForVideo(false) |
| 838 { | 838 { |
| 839 } | 839 } |
| 840 | 840 |
| 841 #if ENABLE(WEB_AUDIO) | 841 #if ENABLE(WEB_AUDIO) |
| 842 void WebMediaPlayerClientImpl::AudioSourceProviderImpl::wrap(WebAudioSourceProvi
der* provider) | 842 void WebMediaPlayerClientImpl::AudioSourceProviderImpl::wrap(WebAudioSourceProvi
der* provider) |
| 843 { | 843 { |
| 844 MutexLocker locker(provideInputLock); |
| 845 |
| 846 if (m_webAudioSourceProvider && provider != m_webAudioSourceProvider) |
| 847 m_webAudioSourceProvider->setClient(0); |
| 848 |
| 844 m_webAudioSourceProvider = provider; | 849 m_webAudioSourceProvider = provider; |
| 845 if (m_webAudioSourceProvider) | 850 if (m_webAudioSourceProvider) |
| 846 m_webAudioSourceProvider->setClient(m_client.get()); | 851 m_webAudioSourceProvider->setClient(m_client.get()); |
| 847 } | 852 } |
| 848 | 853 |
| 849 void WebMediaPlayerClientImpl::AudioSourceProviderImpl::setClient(AudioSourcePro
viderClient* client) | 854 void WebMediaPlayerClientImpl::AudioSourceProviderImpl::setClient(AudioSourcePro
viderClient* client) |
| 850 { | 855 { |
| 856 MutexLocker locker(provideInputLock); |
| 857 |
| 851 if (client) | 858 if (client) |
| 852 m_client = adoptPtr(new WebMediaPlayerClientImpl::AudioClientImpl(client
)); | 859 m_client = adoptPtr(new WebMediaPlayerClientImpl::AudioClientImpl(client
)); |
| 853 else | 860 else |
| 854 m_client.clear(); | 861 m_client.clear(); |
| 855 | 862 |
| 856 if (m_webAudioSourceProvider) | 863 if (m_webAudioSourceProvider) |
| 857 m_webAudioSourceProvider->setClient(m_client.get()); | 864 m_webAudioSourceProvider->setClient(m_client.get()); |
| 858 } | 865 } |
| 859 | 866 |
| 860 void WebMediaPlayerClientImpl::AudioSourceProviderImpl::provideInput(AudioBus* b
us, size_t framesToProcess) | 867 void WebMediaPlayerClientImpl::AudioSourceProviderImpl::provideInput(AudioBus* b
us, size_t framesToProcess) |
| 861 { | 868 { |
| 862 ASSERT(bus); | 869 ASSERT(bus); |
| 863 if (!bus) | 870 if (!bus) |
| 864 return; | 871 return; |
| 865 | 872 |
| 866 if (!m_webAudioSourceProvider) { | 873 MutexTryLocker tryLocker(provideInputLock); |
| 874 if (!tryLocker.locked() || !m_webAudioSourceProvider || !m_client.get()) { |
| 867 bus->zero(); | 875 bus->zero(); |
| 868 return; | 876 return; |
| 869 } | 877 } |
| 870 | 878 |
| 871 // Wrap the AudioBus channel data using WebVector. | 879 // Wrap the AudioBus channel data using WebVector. |
| 872 size_t n = bus->numberOfChannels(); | 880 size_t n = bus->numberOfChannels(); |
| 873 WebVector<float*> webAudioData(n); | 881 WebVector<float*> webAudioData(n); |
| 874 for (size_t i = 0; i < n; ++i) | 882 for (size_t i = 0; i < n; ++i) |
| 875 webAudioData[i] = bus->channel(i)->mutableData(); | 883 webAudioData[i] = bus->channel(i)->mutableData(); |
| 876 | 884 |
| 877 m_webAudioSourceProvider->provideInput(webAudioData, framesToProcess); | 885 m_webAudioSourceProvider->provideInput(webAudioData, framesToProcess); |
| 878 } | 886 } |
| 879 | 887 |
| 880 void WebMediaPlayerClientImpl::AudioClientImpl::setFormat(size_t numberOfChannel
s, float sampleRate) | 888 void WebMediaPlayerClientImpl::AudioClientImpl::setFormat(size_t numberOfChannel
s, float sampleRate) |
| 881 { | 889 { |
| 882 if (m_client) | 890 if (m_client) |
| 883 m_client->setFormat(numberOfChannels, sampleRate); | 891 m_client->setFormat(numberOfChannels, sampleRate); |
| 884 } | 892 } |
| 885 | 893 |
| 886 #endif | 894 #endif |
| 887 | 895 |
| 888 } // namespace WebKit | 896 } // namespace WebKit |
| OLD | NEW |