Skip to content

Commit

Permalink
audiounit: fix surround input on stereo output
Browse files Browse the repository at this point in the history
setPreferredOutputNumberOfChannels can fail, don't configure more
channels than accepted. The OS will drop the extra channels instead of
downmixing it.

When I first tested it, the apple TV was configured to always accept
surround even with a stereo output (Change Format = Off) but this is not
necessarily the case.
  • Loading branch information
tguillem authored and robUx4 committed Jan 6, 2023
1 parent a4b715b commit 6c08c24
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions modules/audio_output/audiounit_ios.m
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,14 @@ static int role2policy_cmp(const void *key, const void *val)
(long) [p_sys->avInstance outputNumberOfChannels],
p_sys->b_spatial_audio_supported);

if (!p_sys->b_preferred_channels_set && fmt->i_channels > 2)
{
/* Ask the core to downmix to stereo if the preferred number of
* channels can't be set. */
fmt->i_physical_channels = AOUT_CHANS_STEREO;
aout_FormatPrepare(fmt);
}

p_aout->current_sink_info.headphones = port_type == PORT_TYPE_HEADPHONES;

p_sys->au_unit = au_NewOutputInstance(p_aout, kAudioUnitSubType_RemoteIO);
Expand Down

0 comments on commit 6c08c24

Please sign in to comment.