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 15 matching lines...) Expand all Loading... |
26 | 26 |
27 #if ENABLE(WEB_AUDIO) | 27 #if ENABLE(WEB_AUDIO) |
28 | 28 |
29 #include "modules/webaudio/MediaElementAudioSourceNode.h" | 29 #include "modules/webaudio/MediaElementAudioSourceNode.h" |
30 | 30 |
31 #include "core/html/HTMLMediaElement.h" | 31 #include "core/html/HTMLMediaElement.h" |
32 #include "modules/webaudio/AudioContext.h" | 32 #include "modules/webaudio/AudioContext.h" |
33 #include "modules/webaudio/AudioNodeOutput.h" | 33 #include "modules/webaudio/AudioNodeOutput.h" |
34 #include "platform/Logging.h" | 34 #include "platform/Logging.h" |
35 #include "platform/audio/AudioUtilities.h" | 35 #include "platform/audio/AudioUtilities.h" |
| 36 #include "platform/graphics/media/MediaPlayer.h" |
| 37 #include "platform/weborigin/SecurityOrigin.h" |
36 #include "wtf/Locker.h" | 38 #include "wtf/Locker.h" |
37 | 39 |
38 namespace blink { | 40 namespace blink { |
39 | 41 |
40 MediaElementAudioSourceNode* MediaElementAudioSourceNode::create(AudioContext* c
ontext, HTMLMediaElement* mediaElement) | 42 MediaElementAudioSourceNode* MediaElementAudioSourceNode::create(AudioContext* c
ontext, HTMLMediaElement* mediaElement) |
41 { | 43 { |
42 return new MediaElementAudioSourceNode(context, mediaElement); | 44 return new MediaElementAudioSourceNode(context, mediaElement); |
43 } | 45 } |
44 | 46 |
45 MediaElementAudioSourceNode::MediaElementAudioSourceNode(AudioContext* context,
HTMLMediaElement* mediaElement) | 47 MediaElementAudioSourceNode::MediaElementAudioSourceNode(AudioContext* context,
HTMLMediaElement* mediaElement) |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 outputBus->zero(); | 112 outputBus->zero(); |
111 return; | 113 return; |
112 } | 114 } |
113 | 115 |
114 // Use a tryLock() to avoid contention in the real-time audio thread. | 116 // Use a tryLock() to avoid contention in the real-time audio thread. |
115 // If we fail to acquire the lock then the HTMLMediaElement must be in the m
iddle of | 117 // If we fail to acquire the lock then the HTMLMediaElement must be in the m
iddle of |
116 // reconfiguring its playback engine, so we output silence in this case. | 118 // reconfiguring its playback engine, so we output silence in this case. |
117 MutexTryLocker tryLocker(m_processLock); | 119 MutexTryLocker tryLocker(m_processLock); |
118 if (tryLocker.locked()) { | 120 if (tryLocker.locked()) { |
119 if (AudioSourceProvider* provider = mediaElement()->audioSourceProvider(
)) { | 121 if (AudioSourceProvider* provider = mediaElement()->audioSourceProvider(
)) { |
| 122 // Grab data from the provider so that the element continues to make
progress, even if |
| 123 // we're going to output silence anyway. |
120 if (m_multiChannelResampler.get()) { | 124 if (m_multiChannelResampler.get()) { |
121 ASSERT(m_sourceSampleRate != sampleRate()); | 125 ASSERT(m_sourceSampleRate != sampleRate()); |
122 m_multiChannelResampler->process(provider, outputBus, numberOfFr
ames); | 126 m_multiChannelResampler->process(provider, outputBus, numberOfFr
ames); |
123 } else { | 127 } else { |
124 // Bypass the resampler completely if the source is at the conte
xt's sample-rate. | 128 // Bypass the resampler completely if the source is at the conte
xt's sample-rate. |
125 ASSERT(m_sourceSampleRate == sampleRate()); | 129 ASSERT(m_sourceSampleRate == sampleRate()); |
126 provider->provideInput(outputBus, numberOfFrames); | 130 provider->provideInput(outputBus, numberOfFrames); |
127 } | 131 } |
| 132 // Output silence if we don't have access to the element. |
| 133 if (!(mediaElement()->webMediaPlayer()->didPassCORSAccessCheck() |
| 134 || context()->securityOrigin()->canRequest(mediaElement()->curre
ntSrc()))) { |
| 135 outputBus->zero(); |
| 136 } |
128 } else { | 137 } else { |
129 // Either this port doesn't yet support HTMLMediaElement audio strea
m access, | 138 // Either this port doesn't yet support HTMLMediaElement audio strea
m access, |
130 // or the stream is not yet available. | 139 // or the stream is not yet available. |
131 outputBus->zero(); | 140 outputBus->zero(); |
132 } | 141 } |
133 } else { | 142 } else { |
134 // We failed to acquire the lock. | 143 // We failed to acquire the lock. |
135 outputBus->zero(); | 144 outputBus->zero(); |
136 } | 145 } |
137 } | 146 } |
(...skipping 11 matching lines...) Expand all Loading... |
149 void MediaElementAudioSourceNode::trace(Visitor* visitor) | 158 void MediaElementAudioSourceNode::trace(Visitor* visitor) |
150 { | 159 { |
151 visitor->trace(m_mediaElement); | 160 visitor->trace(m_mediaElement); |
152 AudioSourceNode::trace(visitor); | 161 AudioSourceNode::trace(visitor); |
153 AudioSourceProviderClient::trace(visitor); | 162 AudioSourceProviderClient::trace(visitor); |
154 } | 163 } |
155 | 164 |
156 } // namespace blink | 165 } // namespace blink |
157 | 166 |
158 #endif // ENABLE(WEB_AUDIO) | 167 #endif // ENABLE(WEB_AUDIO) |
OLD | NEW |