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

Use different scopes on the output bus depending on AudioUnit type #233

Merged
merged 2 commits into from
Aug 13, 2024

Conversation

Pehrsons
Copy link
Contributor

@Pehrsons Pehrsons commented Aug 7, 2024

As the inline comment says it seems a HAL unit for a device with >2 output channels reports only 2 channels on the input scope of the output bus. Not sure what these 2 reflect but let's differentiate VPIO (where input scope reports 1 which we want, and output scope reflects hw) and HAL units when selecting scope as they're the only types we use.

Copy link
Member

@ChunMinChang ChunMinChang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the change!

Are there other coming commits? Landing this individually may cause a noise issue.

With this patch, the mNumberChannels of the given AudioBuffer provided by audiounit_output_callback will be matched to the channel count of the device, since now the output_dev_desc.mChannelsPerFrame matches output_hw_desc.mChannelsPerFrame's value.

However, if the channel count mismatches the output_stream_params.channels() channel, no mixer will be set up, and there will not be enough or too much data for the output buffer in the callback since the buffer (prepared by resampler) is for the output_stream_params.channels() channel.

I tested this with my Cubilux Surround Sound Card (CA7) with test_tone. Noise appears in all the channels.

@Pehrsons
Copy link
Contributor Author

Pehrsons commented Aug 8, 2024

The new commit updates output_dev_desc so we configure the device correctly for 2 channels when deciding to skip the mixer. With my Studio Display that has 8 channels I get an error with the stereo variant of test_tone though:
AudioConverter.cpp:748 Failed to created a new in process converter -> from 2 ch, 48000 Hz, lpcm (0x00000009) 32-bit little-endian float, packed in 16 bytes low-aligned to 8 ch, 48000 Hz, Float32, interleaved, with status 1718449215
Note 1718449215 is the fourcc for fmt?, i.e. kAudioConverterErr_FormatNotSupported.

@Pehrsons Pehrsons force-pushed the audiounit-output-bus-scope-selection branch from 6013d98 to 8a43771 Compare August 8, 2024 13:28
@Pehrsons
Copy link
Contributor Author

Pehrsons commented Aug 8, 2024

Ah my bug, fixed now. With this stack playing something >2ch should work on a device with >2ch.

Copy link
Member

@ChunMinChang ChunMinChang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! thanks!

@ChunMinChang ChunMinChang merged commit f7e50c2 into trailblazer Aug 13, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants