OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010, Google Inc. All rights reserved. | 2 * Copyright (C) 2010, 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 } | 94 } |
95 | 95 |
96 // The audio thread can't block on this lock, so we call tryLock() instead. | 96 // The audio thread can't block on this lock, so we call tryLock() instead. |
97 MutexTryLocker tryLocker(m_processLock); | 97 MutexTryLocker tryLocker(m_processLock); |
98 if (tryLocker.locked()) { | 98 if (tryLocker.locked()) { |
99 if (!buffer()) { | 99 if (!buffer()) { |
100 outputBus->zero(); | 100 outputBus->zero(); |
101 return; | 101 return; |
102 } | 102 } |
103 | 103 |
| 104 // After calling setBuffer() with a buffer having a different number of
channels, there can in rare cases be a slight delay |
| 105 // before the output bus is updated to the new number of channels becaus
e of use of tryLocks() in the context's updating system. |
| 106 // In this case, if the the buffer has just been changed and we're not q
uite ready yet, then just output silence. |
| 107 if (numberOfChannels() != buffer()->numberOfChannels()) { |
| 108 outputBus->zero(); |
| 109 return; |
| 110 } |
| 111 |
104 size_t quantumFrameOffset; | 112 size_t quantumFrameOffset; |
105 size_t bufferFramesToProcess; | 113 size_t bufferFramesToProcess; |
106 | 114 |
107 updateSchedulingInfo(framesToProcess, | 115 updateSchedulingInfo(framesToProcess, |
108 outputBus, | 116 outputBus, |
109 quantumFrameOffset, | 117 quantumFrameOffset, |
110 bufferFramesToProcess); | 118 bufferFramesToProcess); |
111 | 119 |
112 if (!bufferFramesToProcess) { | 120 if (!bufferFramesToProcess) { |
113 outputBus->zero(); | 121 outputBus->zero(); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 | 156 |
149 finish(); | 157 finish(); |
150 return true; | 158 return true; |
151 } | 159 } |
152 return false; | 160 return false; |
153 } | 161 } |
154 | 162 |
155 bool AudioBufferSourceNode::renderFromBuffer(AudioBus* bus, unsigned destination
FrameOffset, size_t numberOfFrames) | 163 bool AudioBufferSourceNode::renderFromBuffer(AudioBus* bus, unsigned destination
FrameOffset, size_t numberOfFrames) |
156 { | 164 { |
157 ASSERT(context()->isAudioThread()); | 165 ASSERT(context()->isAudioThread()); |
158 | 166 |
159 // Basic sanity checking | 167 // Basic sanity checking |
160 ASSERT(bus); | 168 ASSERT(bus); |
161 ASSERT(buffer()); | 169 ASSERT(buffer()); |
162 if (!bus || !buffer()) | 170 if (!bus || !buffer()) |
163 return false; | 171 return false; |
164 | 172 |
165 unsigned numberOfChannels = this->numberOfChannels(); | 173 unsigned numberOfChannels = this->numberOfChannels(); |
166 unsigned busNumberOfChannels = bus->numberOfChannels(); | 174 unsigned busNumberOfChannels = bus->numberOfChannels(); |
167 | 175 |
168 bool channelCountGood = numberOfChannels && numberOfChannels == busNumberOfC
hannels; | 176 bool channelCountGood = numberOfChannels && numberOfChannels == busNumberOfC
hannels; |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 void AudioBufferSourceNode::finish() | 503 void AudioBufferSourceNode::finish() |
496 { | 504 { |
497 clearPannerNode(); | 505 clearPannerNode(); |
498 ASSERT(!m_pannerNode); | 506 ASSERT(!m_pannerNode); |
499 AudioScheduledSourceNode::finish(); | 507 AudioScheduledSourceNode::finish(); |
500 } | 508 } |
501 | 509 |
502 } // namespace WebCore | 510 } // namespace WebCore |
503 | 511 |
504 #endif // ENABLE(WEB_AUDIO) | 512 #endif // ENABLE(WEB_AUDIO) |
OLD | NEW |