| 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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 | 156 |
| 157 void OfflineAudioDestinationHandler::doOfflineRendering() | 157 void OfflineAudioDestinationHandler::doOfflineRendering() |
| 158 { | 158 { |
| 159 ASSERT(!isMainThread()); | 159 ASSERT(!isMainThread()); |
| 160 | 160 |
| 161 unsigned numberOfChannels = m_renderTarget->numberOfChannels(); | 161 unsigned numberOfChannels = m_renderTarget->numberOfChannels(); |
| 162 | 162 |
| 163 // Reset the suspend flag. | 163 // Reset the suspend flag. |
| 164 m_shouldSuspend = false; | 164 m_shouldSuspend = false; |
| 165 | 165 |
| 166 // If there is more to process and there is no suspension at the moment, | 166 // If there is more to process and there is no suspension at the moment, do |
| 167 // do continue to render quanta. Then calling OfflineAudioContext.resume() w
ill pick up | 167 // continue to render quanta. Then calling OfflineAudioContext.resume() will |
| 168 // the render loop again from where it was suspended. | 168 // pick up the render loop again from where it was suspended. |
| 169 while (m_framesToProcess > 0 && !m_shouldSuspend) { | 169 while (m_framesToProcess > 0 && !m_shouldSuspend) { |
| 170 | 170 |
| 171 // Suspend the rendering and update m_shouldSuspend if a scheduled | 171 // Suspend the rendering and update m_shouldSuspend if a scheduled |
| 172 // suspend found at the current sample frame. Otherwise render one | 172 // suspend found at the current sample frame. Otherwise render one |
| 173 // quantum and return false. | 173 // quantum and return false. |
| 174 m_shouldSuspend = renderIfNotSuspended(0, m_renderBus.get(), renderQuant
umSize); | 174 m_shouldSuspend = renderIfNotSuspended(0, m_renderBus.get(), renderQuant
umSize); |
| 175 | 175 |
| 176 if (m_shouldSuspend) | 176 if (m_shouldSuspend) |
| 177 return; | 177 return; |
| 178 | 178 |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 } | 264 } |
| 265 | 265 |
| 266 // Take care pre-render tasks at the beginning of each render quantum. Then | 266 // Take care pre-render tasks at the beginning of each render quantum. Then |
| 267 // it will stop the rendering loop if the context needs to be suspended | 267 // it will stop the rendering loop if the context needs to be suspended |
| 268 // at the beginning of the next render quantum. | 268 // at the beginning of the next render quantum. |
| 269 if (context()->handlePreOfflineRenderTasks()) { | 269 if (context()->handlePreOfflineRenderTasks()) { |
| 270 suspendOfflineRendering(); | 270 suspendOfflineRendering(); |
| 271 return true; | 271 return true; |
| 272 } | 272 } |
| 273 | 273 |
| 274 // Prepare the local audio input provider for this render quantum. | 274 // TODO(hongchan): OfflineAudioContext does not care about the live input. |
| 275 if (sourceBus) | 275 // Remove this. |
| 276 m_localAudioInputProvider.set(sourceBus); | 276 // if (sourceBus) |
| 277 // m_localAudioInputProvider.setSourceBus(sourceBus); |
| 277 | 278 |
| 278 ASSERT(numberOfInputs() >= 1); | 279 ASSERT(numberOfInputs() >= 1); |
| 279 if (numberOfInputs() < 1) { | 280 if (numberOfInputs() < 1) { |
| 280 destinationBus->zero(); | 281 destinationBus->zero(); |
| 281 return false; | 282 return false; |
| 282 } | 283 } |
| 284 |
| 283 // This will cause the node(s) connected to us to process, which in turn wil
l pull on their input(s), | 285 // This will cause the node(s) connected to us to process, which in turn wil
l pull on their input(s), |
| 284 // all the way backwards through the rendering graph. | 286 // all the way backwards through the rendering graph. |
| 285 AudioBus* renderedBus = input(0).pull(destinationBus, numberOfFrames); | 287 AudioBus* renderedBus = input(0).pull(destinationBus, numberOfFrames); |
| 286 | 288 |
| 289 // TODO(hongchan): this logic should be a part of AudioNodeInput::pull(). |
| 287 if (!renderedBus) { | 290 if (!renderedBus) { |
| 288 destinationBus->zero(); | 291 destinationBus->zero(); |
| 289 } else if (renderedBus != destinationBus) { | 292 } else if (renderedBus != destinationBus) { |
| 290 // in-place processing was not possible - so copy | 293 // If the destination node has multiple inputs, in-place processing is |
| 294 // not possible. Thus the explicit copy is necessary. |
| 291 destinationBus->copyFrom(*renderedBus); | 295 destinationBus->copyFrom(*renderedBus); |
| 292 } | 296 } |
| 293 | 297 |
| 294 // Process nodes which need a little extra help because they are not connect
ed to anything, but still need to process. | 298 // Process nodes which need a little extra help because they are not connect
ed to anything, but still need to process. |
| 295 context()->deferredTaskHandler().processAutomaticPullNodes(numberOfFrames); | 299 context()->deferredTaskHandler().processAutomaticPullNodes(numberOfFrames); |
| 296 | 300 |
| 297 // Let the context take care of any business at the end of each render quant
um. | 301 // Let the context take care of any business at the end of each render quant
um. |
| 298 context()->handlePostOfflineRenderTasks(); | 302 context()->handlePostOfflineRenderTasks(); |
| 299 | 303 |
| 300 // Advance current sample-frame. | 304 // Advance current sample-frame. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 311 { | 315 { |
| 312 setHandler(OfflineAudioDestinationHandler::create(*this, renderTarget)); | 316 setHandler(OfflineAudioDestinationHandler::create(*this, renderTarget)); |
| 313 } | 317 } |
| 314 | 318 |
| 315 OfflineAudioDestinationNode* OfflineAudioDestinationNode::create(AbstractAudioCo
ntext* context, AudioBuffer* renderTarget) | 319 OfflineAudioDestinationNode* OfflineAudioDestinationNode::create(AbstractAudioCo
ntext* context, AudioBuffer* renderTarget) |
| 316 { | 320 { |
| 317 return new OfflineAudioDestinationNode(*context, renderTarget); | 321 return new OfflineAudioDestinationNode(*context, renderTarget); |
| 318 } | 322 } |
| 319 | 323 |
| 320 } // namespace blink | 324 } // namespace blink |
| OLD | NEW |