| 619 | |
| 620 | template <typename T> |
| 621 | void PluginProcessor::processBlockInternal(AudioBuffer<T>& buffer, MidiBuffer& midiMessages) { |
| 622 | traceScope(); |
| 623 | |
| 624 | auto traceCtx = TimeTrace::createTraceContext(); |
| 625 | m_processingDurationGlobal.reset(); |
| 626 | m_processingDurationLocal.reset(); |
| 627 | |
| 628 | traceln(" proc: m_bypassWhenNotConnected=" << (int)m_bypassWhenNotConnected.load() |
| 629 | << ", clientOk=" << (int)m_client->isReadyLockFree() |
| 630 | << ", pluginsOk=" << (int)m_loadedPluginsOk); |
| 631 | |
| 632 | if (m_bypassWhenNotConnected && |
| 633 | (!m_client->isReadyLockFree() || !m_loadedPluginsOk || getNumOfLoadedPlugins() == 0)) { |
| 634 | processBlockBypassed(buffer, midiMessages); |
| 635 | return; |
| 636 | } |
| 637 | |
| 638 | traceCtx->add("pb_bypass_chk"); |
| 639 | |
| 640 | ScopedNoDenormals noDenormals; |
| 641 | auto totalNumInputChannels = getTotalNumInputChannels(); |
| 642 | auto totalNumOutputChannels = getTotalNumOutputChannels(); |
| 643 | |
| 644 | if (totalNumInputChannels > buffer.getNumChannels()) { |
| 645 | logln("error in processBlock: buffer has less channels than main input channels"); |
| 646 | totalNumInputChannels = buffer.getNumChannels(); |
| 647 | } |
| 648 | if (totalNumOutputChannels > buffer.getNumChannels()) { |
| 649 | logln("error in processBlock: buffer has less channels than main output channels"); |
| 650 | totalNumOutputChannels = buffer.getNumChannels(); |
| 651 | } |
| 652 | |
| 653 | AudioPlayHead::PositionInfo posInfo; |
| 654 | |
| 655 | if (auto* phead = getPlayHead()) { |
| 656 | if (auto optPosInfo = phead->getPosition()) { |
| 657 | posInfo = *optPosInfo; |
| 658 | } |
| 659 | } |
| 660 | |
| 661 | // buffer to be send |
| 662 | int sendBufChannels = m_activeChannels.getNumActiveChannelsCombined(); |
| 663 | AudioBuffer<T>* sendBuffer; |
| 664 | std::unique_ptr<AudioBuffer<T>> tmpBuffer; |
| 665 | |
| 666 | if (sendBufChannels != buffer.getNumChannels()) { |
| 667 | tmpBuffer = std::make_unique<AudioBuffer<T>>(sendBufChannels, buffer.getNumSamples()); |
| 668 | sendBuffer = tmpBuffer.get(); |
| 669 | } else { |
| 670 | sendBuffer = &buffer; |
| 671 | } |
| 672 | |
| 673 | auto transferMode = getTransferMode(); |
| 674 | bool transfer = transferMode == TM_ALWAYS; |
| 675 | transfer |= transferMode == TM_WHEN_PLAYING && (posInfo.getIsPlaying() || posInfo.getIsRecording()); |
| 676 | |
| 677 | #if JucePlugin_IsSynth || JucePlugin_IsMidiEffect |
| 678 | buffer.clear(); |
nothing calls this directly
no test coverage detected