From f3104d92d52a2ff7bc2ac5cb886ac69232dab95e Mon Sep 17 00:00:00 2001 From: jp9000 Date: Wed, 18 Mar 2015 19:22:37 -0700 Subject: [PATCH] mac-capture: If channels above 8, force to stereo Certain devices (particularly certain mixers and soundflower 64ch) would have an arbitrary number of channels, and wouldn't really be mappable to a specific speaker layout supported by libobs. So to fix this issue, if the channel count is above 8, force the data to stereo to ensure playback can still occur, rather than cause it to just fail. --- plugins/mac-capture/mac-audio.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/plugins/mac-capture/mac-audio.c b/plugins/mac-capture/mac-audio.c index 392202f0c..8fb6c0533 100644 --- a/plugins/mac-capture/mac-audio.c +++ b/plugins/mac-capture/mac-audio.c @@ -203,6 +203,16 @@ static bool coreaudio_init_format(struct coreaudio_data *ca) if (!ca_success(stat, ca, "coreaudio_init_format", "get input format")) return false; + /* Certain types of devices have no limit on channel count, and + * there's no way to know the actual number of channels it's using, + * so if we encounter this situation just force to stereo */ + if (desc.mChannelsPerFrame > 8) { + desc.mChannelsPerFrame = 2; + desc.mBytesPerFrame = 2 * desc.mBitsPerChannel / 8; + desc.mBytesPerPacket = + desc.mFramesPerPacket * desc.mBytesPerFrame; + } + stat = set_property(ca->unit, kAudioUnitProperty_StreamFormat, SCOPE_OUTPUT, BUS_INPUT, &desc, size); if (!ca_success(stat, ca, "coreaudio_init_format", "set output format"))