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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 // Make a note if we need to print a console message and save the |curentSrc
| for use in the | 128 // Make a note if we need to print a console message and save the |curentSrc
| for use in the |
129 // message. Need to wait until later to print the message in case HTMLMedia
Element allows | 129 // message. Need to wait until later to print the message in case HTMLMedia
Element allows |
130 // access. | 130 // access. |
131 m_maybePrintCORSMessage = !m_passesCurrentSrcCORSAccessCheck; | 131 m_maybePrintCORSMessage = !m_passesCurrentSrcCORSAccessCheck; |
132 m_currentSrcString = currentSrc.getString(); | 132 m_currentSrcString = currentSrc.getString(); |
133 } | 133 } |
134 | 134 |
135 bool MediaElementAudioSourceHandler::passesCurrentSrcCORSAccessCheck(const KURL&
currentSrc) | 135 bool MediaElementAudioSourceHandler::passesCurrentSrcCORSAccessCheck(const KURL&
currentSrc) |
136 { | 136 { |
137 ASSERT(isMainThread()); | 137 ASSERT(isMainThread()); |
138 return context()->securityOrigin() && context()->securityOrigin()->canReques
t(currentSrc); | 138 return context()->getSecurityOrigin() && context()->getSecurityOrigin()->can
Request(currentSrc); |
139 } | 139 } |
140 | 140 |
141 void MediaElementAudioSourceHandler::printCORSMessage(const String& message) | 141 void MediaElementAudioSourceHandler::printCORSMessage(const String& message) |
142 { | 142 { |
143 if (context()->executionContext()) { | 143 if (context()->getExecutionContext()) { |
144 context()->executionContext()->addConsoleMessage( | 144 context()->getExecutionContext()->addConsoleMessage( |
145 ConsoleMessage::create(SecurityMessageSource, InfoMessageLevel, | 145 ConsoleMessage::create(SecurityMessageSource, InfoMessageLevel, |
146 "MediaElementAudioSource outputs zeroes due to CORS access restr
ictions for " + message)); | 146 "MediaElementAudioSource outputs zeroes due to CORS access restr
ictions for " + message)); |
147 } | 147 } |
148 } | 148 } |
149 | 149 |
150 void MediaElementAudioSourceHandler::process(size_t numberOfFrames) | 150 void MediaElementAudioSourceHandler::process(size_t numberOfFrames) |
151 { | 151 { |
152 AudioBus* outputBus = output(0).bus(); | 152 AudioBus* outputBus = output(0).bus(); |
153 | 153 |
154 // Use a tryLock() to avoid contention in the real-time audio thread. | 154 // Use a tryLock() to avoid contention in the real-time audio thread. |
155 // If we fail to acquire the lock then the HTMLMediaElement must be in the m
iddle of | 155 // If we fail to acquire the lock then the HTMLMediaElement must be in the m
iddle of |
156 // reconfiguring its playback engine, so we output silence in this case. | 156 // reconfiguring its playback engine, so we output silence in this case. |
157 MutexTryLocker tryLocker(m_processLock); | 157 MutexTryLocker tryLocker(m_processLock); |
158 if (tryLocker.locked()) { | 158 if (tryLocker.locked()) { |
159 if (!mediaElement() || !m_sourceNumberOfChannels || !m_sourceSampleRate)
{ | 159 if (!mediaElement() || !m_sourceNumberOfChannels || !m_sourceSampleRate)
{ |
160 outputBus->zero(); | 160 outputBus->zero(); |
161 return; | 161 return; |
162 } | 162 } |
163 AudioSourceProvider& provider = mediaElement()->audioSourceProvider(); | 163 AudioSourceProvider& provider = mediaElement()->getAudioSourceProvider()
; |
164 // Grab data from the provider so that the element continues to make pro
gress, even if | 164 // Grab data from the provider so that the element continues to make pro
gress, even if |
165 // we're going to output silence anyway. | 165 // we're going to output silence anyway. |
166 if (m_multiChannelResampler.get()) { | 166 if (m_multiChannelResampler.get()) { |
167 ASSERT(m_sourceSampleRate != sampleRate()); | 167 ASSERT(m_sourceSampleRate != sampleRate()); |
168 m_multiChannelResampler->process(&provider, outputBus, numberOfFrame
s); | 168 m_multiChannelResampler->process(&provider, outputBus, numberOfFrame
s); |
169 } else { | 169 } else { |
170 // Bypass the resampler completely if the source is at the context's
sample-rate. | 170 // Bypass the resampler completely if the source is at the context's
sample-rate. |
171 ASSERT(m_sourceSampleRate == sampleRate()); | 171 ASSERT(m_sourceSampleRate == sampleRate()); |
172 provider.provideInput(outputBus, numberOfFrames); | 172 provider.provideInput(outputBus, numberOfFrames); |
173 } | 173 } |
174 // Output silence if we don't have access to the element. | 174 // Output silence if we don't have access to the element. |
175 if (!passesCORSAccessCheck()) { | 175 if (!passesCORSAccessCheck()) { |
176 if (m_maybePrintCORSMessage) { | 176 if (m_maybePrintCORSMessage) { |
177 // Print a CORS message, but just once for each change in the cu
rrent media | 177 // Print a CORS message, but just once for each change in the cu
rrent media |
178 // element source, and only if we have a document to print to. | 178 // element source, and only if we have a document to print to. |
179 m_maybePrintCORSMessage = false; | 179 m_maybePrintCORSMessage = false; |
180 if (context()->executionContext()) { | 180 if (context()->getExecutionContext()) { |
181 context()->executionContext()->postTask(BLINK_FROM_HERE, | 181 context()->getExecutionContext()->postTask(BLINK_FROM_HERE, |
182 createCrossThreadTask(&MediaElementAudioSourceHandler::p
rintCORSMessage, | 182 createCrossThreadTask(&MediaElementAudioSourceHandler::p
rintCORSMessage, |
183 this, | 183 this, |
184 m_currentSrcString)); | 184 m_currentSrcString)); |
185 } | 185 } |
186 } | 186 } |
187 outputBus->zero(); | 187 outputBus->zero(); |
188 } | 188 } |
189 } else { | 189 } else { |
190 // We failed to acquire the lock. | 190 // We failed to acquire the lock. |
191 outputBus->zero(); | 191 outputBus->zero(); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 mediaElementAudioSourceHandler().lock(); | 246 mediaElementAudioSourceHandler().lock(); |
247 } | 247 } |
248 | 248 |
249 void MediaElementAudioSourceNode::unlock() | 249 void MediaElementAudioSourceNode::unlock() |
250 { | 250 { |
251 mediaElementAudioSourceHandler().unlock(); | 251 mediaElementAudioSourceHandler().unlock(); |
252 } | 252 } |
253 | 253 |
254 } // namespace blink | 254 } // namespace blink |
255 | 255 |
OLD | NEW |