| 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 12 matching lines...) Expand all Loading... |
| 23 */ | 23 */ |
| 24 | 24 |
| 25 #include "config.h" | 25 #include "config.h" |
| 26 #if ENABLE(WEB_AUDIO) | 26 #if ENABLE(WEB_AUDIO) |
| 27 #include "modules/webaudio/MediaElementAudioSourceNode.h" | 27 #include "modules/webaudio/MediaElementAudioSourceNode.h" |
| 28 | 28 |
| 29 #include "core/dom/CrossThreadTask.h" | 29 #include "core/dom/CrossThreadTask.h" |
| 30 #include "core/frame/ConsoleTypes.h" | 30 #include "core/frame/ConsoleTypes.h" |
| 31 #include "core/html/HTMLMediaElement.h" | 31 #include "core/html/HTMLMediaElement.h" |
| 32 #include "core/inspector/ConsoleMessage.h" | 32 #include "core/inspector/ConsoleMessage.h" |
| 33 #include "modules/webaudio/AudioContext.h" | 33 #include "modules/webaudio/AbstractAudioContext.h" |
| 34 #include "modules/webaudio/AudioNodeOutput.h" | 34 #include "modules/webaudio/AudioNodeOutput.h" |
| 35 #include "platform/Logging.h" | 35 #include "platform/Logging.h" |
| 36 #include "platform/audio/AudioUtilities.h" | 36 #include "platform/audio/AudioUtilities.h" |
| 37 #include "platform/graphics/media/MediaPlayer.h" | 37 #include "platform/graphics/media/MediaPlayer.h" |
| 38 #include "platform/weborigin/SecurityOrigin.h" | 38 #include "platform/weborigin/SecurityOrigin.h" |
| 39 #include "wtf/Locker.h" | 39 #include "wtf/Locker.h" |
| 40 #include "wtf/MainThread.h" | 40 #include "wtf/MainThread.h" |
| 41 | 41 |
| 42 namespace blink { | 42 namespace blink { |
| 43 | 43 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 70 | 70 |
| 71 void MediaElementAudioSourceHandler::dispose() | 71 void MediaElementAudioSourceHandler::dispose() |
| 72 { | 72 { |
| 73 m_mediaElement->setAudioSourceNode(nullptr); | 73 m_mediaElement->setAudioSourceNode(nullptr); |
| 74 AudioHandler::dispose(); | 74 AudioHandler::dispose(); |
| 75 } | 75 } |
| 76 | 76 |
| 77 void MediaElementAudioSourceHandler::setFormat(size_t numberOfChannels, float so
urceSampleRate) | 77 void MediaElementAudioSourceHandler::setFormat(size_t numberOfChannels, float so
urceSampleRate) |
| 78 { | 78 { |
| 79 if (numberOfChannels != m_sourceNumberOfChannels || sourceSampleRate != m_so
urceSampleRate) { | 79 if (numberOfChannels != m_sourceNumberOfChannels || sourceSampleRate != m_so
urceSampleRate) { |
| 80 if (!numberOfChannels || numberOfChannels > AudioContext::maxNumberOfCha
nnels() || !AudioUtilities::isValidAudioBufferSampleRate(sourceSampleRate)) { | 80 if (!numberOfChannels || numberOfChannels > AbstractAudioContext::maxNum
berOfChannels() || !AudioUtilities::isValidAudioBufferSampleRate(sourceSampleRat
e)) { |
| 81 // process() will generate silence for these uninitialized values. | 81 // process() will generate silence for these uninitialized values. |
| 82 WTF_LOG(Media, "MediaElementAudioSourceNode::setFormat(%u, %f) - unh
andled format change", static_cast<unsigned>(numberOfChannels), sourceSampleRate
); | 82 WTF_LOG(Media, "MediaElementAudioSourceNode::setFormat(%u, %f) - unh
andled format change", static_cast<unsigned>(numberOfChannels), sourceSampleRate
); |
| 83 m_sourceNumberOfChannels = 0; | 83 m_sourceNumberOfChannels = 0; |
| 84 m_sourceSampleRate = 0; | 84 m_sourceSampleRate = 0; |
| 85 return; | 85 return; |
| 86 } | 86 } |
| 87 | 87 |
| 88 m_sourceNumberOfChannels = numberOfChannels; | 88 m_sourceNumberOfChannels = numberOfChannels; |
| 89 m_sourceSampleRate = sourceSampleRate; | 89 m_sourceSampleRate = sourceSampleRate; |
| 90 | 90 |
| 91 // Synchronize with process(). | 91 // Synchronize with process(). |
| 92 Locker<MediaElementAudioSourceHandler> locker(*this); | 92 Locker<MediaElementAudioSourceHandler> locker(*this); |
| 93 | 93 |
| 94 if (sourceSampleRate != sampleRate()) { | 94 if (sourceSampleRate != sampleRate()) { |
| 95 double scaleFactor = sourceSampleRate / sampleRate(); | 95 double scaleFactor = sourceSampleRate / sampleRate(); |
| 96 m_multiChannelResampler = adoptPtr(new MultiChannelResampler(scaleFa
ctor, numberOfChannels)); | 96 m_multiChannelResampler = adoptPtr(new MultiChannelResampler(scaleFa
ctor, numberOfChannels)); |
| 97 } else { | 97 } else { |
| 98 // Bypass resampling. | 98 // Bypass resampling. |
| 99 m_multiChannelResampler.clear(); | 99 m_multiChannelResampler.clear(); |
| 100 } | 100 } |
| 101 | 101 |
| 102 { | 102 { |
| 103 // The context must be locked when changing the number of output cha
nnels. | 103 // The context must be locked when changing the number of output cha
nnels. |
| 104 AudioContext::AutoLocker contextLocker(context()); | 104 AbstractAudioContext::AutoLocker contextLocker(context()); |
| 105 | 105 |
| 106 // Do any necesssary re-configuration to the output's number of chan
nels. | 106 // Do any necesssary re-configuration to the output's number of chan
nels. |
| 107 output(0).setNumberOfChannels(numberOfChannels); | 107 output(0).setNumberOfChannels(numberOfChannels); |
| 108 } | 108 } |
| 109 } | 109 } |
| 110 } | 110 } |
| 111 | 111 |
| 112 bool MediaElementAudioSourceHandler::passesCORSAccessCheck() | 112 bool MediaElementAudioSourceHandler::passesCORSAccessCheck() |
| 113 { | 113 { |
| 114 ASSERT(mediaElement()); | 114 ASSERT(mediaElement()); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 m_processLock.lock(); | 204 m_processLock.lock(); |
| 205 } | 205 } |
| 206 | 206 |
| 207 void MediaElementAudioSourceHandler::unlock() | 207 void MediaElementAudioSourceHandler::unlock() |
| 208 { | 208 { |
| 209 m_processLock.unlock(); | 209 m_processLock.unlock(); |
| 210 } | 210 } |
| 211 | 211 |
| 212 // ---------------------------------------------------------------- | 212 // ---------------------------------------------------------------- |
| 213 | 213 |
| 214 MediaElementAudioSourceNode::MediaElementAudioSourceNode(AudioContext& context,
HTMLMediaElement& mediaElement) | 214 MediaElementAudioSourceNode::MediaElementAudioSourceNode(AbstractAudioContext& c
ontext, HTMLMediaElement& mediaElement) |
| 215 : AudioSourceNode(context) | 215 : AudioSourceNode(context) |
| 216 { | 216 { |
| 217 setHandler(MediaElementAudioSourceHandler::create(*this, mediaElement)); | 217 setHandler(MediaElementAudioSourceHandler::create(*this, mediaElement)); |
| 218 } | 218 } |
| 219 | 219 |
| 220 MediaElementAudioSourceNode* MediaElementAudioSourceNode::create(AudioContext& c
ontext, HTMLMediaElement& mediaElement) | 220 MediaElementAudioSourceNode* MediaElementAudioSourceNode::create(AbstractAudioCo
ntext& context, HTMLMediaElement& mediaElement) |
| 221 { | 221 { |
| 222 return new MediaElementAudioSourceNode(context, mediaElement); | 222 return new MediaElementAudioSourceNode(context, mediaElement); |
| 223 } | 223 } |
| 224 | 224 |
| 225 DEFINE_TRACE(MediaElementAudioSourceNode) | 225 DEFINE_TRACE(MediaElementAudioSourceNode) |
| 226 { | 226 { |
| 227 AudioSourceProviderClient::trace(visitor); | 227 AudioSourceProviderClient::trace(visitor); |
| 228 AudioSourceNode::trace(visitor); | 228 AudioSourceNode::trace(visitor); |
| 229 } | 229 } |
| 230 | 230 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 254 } | 254 } |
| 255 | 255 |
| 256 void MediaElementAudioSourceNode::unlock() | 256 void MediaElementAudioSourceNode::unlock() |
| 257 { | 257 { |
| 258 mediaElementAudioSourceHandler().unlock(); | 258 mediaElementAudioSourceHandler().unlock(); |
| 259 } | 259 } |
| 260 | 260 |
| 261 } // namespace blink | 261 } // namespace blink |
| 262 | 262 |
| 263 #endif // ENABLE(WEB_AUDIO) | 263 #endif // ENABLE(WEB_AUDIO) |
| OLD | NEW |