| 444 | } |
| 445 | |
| 446 | void AudioNode::processIfNecessary(ContextRenderLock & r, int bufferSize) |
| 447 | { |
| 448 | if (!isInitialized()) |
| 449 | return; |
| 450 | |
| 451 | auto ac = r.context(); |
| 452 | if (!ac) |
| 453 | return; |
| 454 | |
| 455 | // outputs cache results in their busses. |
| 456 | // if the scheduler's recorded epoch is the same as the context's, the node |
| 457 | // shall bail out as it has been processed once already this epoch. |
| 458 | |
| 459 | if (!_scheduler.update(r, bufferSize)) |
| 460 | return; |
| 461 | |
| 462 | ProfileScope selfScope(totalTime); |
| 463 | graphTime.zero(); |
| 464 | |
| 465 | if (isScheduledNode() && |
| 466 | (_scheduler._playbackState < SchedulingState::FADE_IN || |
| 467 | _scheduler._playbackState == SchedulingState::FINISHED)) |
| 468 | { |
| 469 | silenceOutputs(r); |
| 470 | return; |
| 471 | } |
| 472 | |
| 473 | |
| 474 | // there may need to be silence at the beginning or end of the current quantum. |
| 475 | |
| 476 | int start_zero_count = _scheduler._renderOffset; |
| 477 | int final_zero_start = _scheduler._renderOffset + _scheduler._renderLength; |
| 478 | int final_zero_count = bufferSize - final_zero_start; |
| 479 | |
| 480 | // if the input counts need to match the output counts, |
| 481 | // do it here before pulling inputs |
| 482 | conformChannelCounts(); |
| 483 | |
| 484 | // get inputs in preparation for processing |
| 485 | { |
| 486 | ProfileScope scope(graphTime); |
| 487 | pullInputs(r, bufferSize); |
| 488 | scope.finalize(); // ensure the scope is not prematurely destructed |
| 489 | } |
| 490 | |
| 491 | // ensure all requested channel count updates have been resolved |
| 492 | for (auto& out : m_outputs) |
| 493 | out->updateRenderingState(r); |
| 494 | |
| 495 | // initialize the busses with start and final zeroes. |
| 496 | if (start_zero_count) |
| 497 | { |
| 498 | for (auto & out : m_outputs) |
| 499 | for (int i = 0; i < out->numberOfChannels(); ++i) |
| 500 | memset(out->bus(r)->channel(i)->mutableData(), 0, sizeof(float) * start_zero_count); |
| 501 | } |
| 502 | |
| 503 | if (final_zero_count) |
no test coverage detected