Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AudioNodeOutput->bus(r) returns m_inPlacebus instead of m_internalBus #186

Open
dug9 opened this issue Feb 15, 2023 · 1 comment
Open

AudioNodeOutput->bus(r) returns m_inPlacebus instead of m_internalBus #186

dug9 opened this issue Feb 15, 2023 · 1 comment
Assignees
Labels

Comments

@dug9
Copy link
Contributor

dug9 commented Feb 15, 2023

When working with 6 channel source audioBus, SampledAudioNode goes through a bit of code to prepare itself to receive all the channels of the input:
bool mess = false; if (dstChannelCount != srcChannelCount) { mess = true; output(0)->setNumberOfChannels(r, srcChannelCount); dstChannelCount = srcChannelCount; dstBus = output(0)->bus(r); } if (mess) printf("1 dstBus nchan %d\n", dstBus->numberOfChannels());
AudioNodeOutput->setNumberOfChannels works great, resetting m_internalBus to a fresh bus with 6 channels in my case.
Then the problem: output(0)->bus(r) returns something with 2 channels, and code below -confused- bombs.
AudioBus * AudioNodeOutput::bus(ContextRenderLock & r) const { // only legal during rendering because an in-place bus might have been supplied to pull ASSERT(r.context()); //return m_inPlaceBus ? m_inPlaceBus : m_internalBus.get(); // HAS BEEN RETURNING INPLACEBUS WITH M_CHAN 2 return m_internalBus.get(); }
When I modify the function to return m_internalBus and ignor m_inPlaceBus, then my scene runs normally, sound out, and with channelSplitter, channelMerger I'm able to have fun swapping channels around.
Q1. do I need m_internalBus or can I keep it commented out and live happily ever after?
Q2. if I need it, is there something I can do from my application code to clear it before associating AudioBus with SampledAudioNode?
Thanks.

@meshula
Copy link
Member

meshula commented Feb 17, 2023

Thanks for the notes.

In the case of a SampledAudioNode, the internalBus will always be what you want. The inPlace is an optimization for pass through nodes (ie. a gain node set to 1.0 could in theory just pass on a pointer to an upstream bus and thus save copying a buffer).

Your patch should work for now, but I will review the logic around the in place bus. It is a remnant from the original WebKit implementation, and might be best removed at this point.

@meshula meshula added the bug label Sep 18, 2023
@meshula meshula self-assigned this Sep 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants