0
0
mirror of https://github.com/obsproject/obs-studio.git synced 2024-09-20 21:13:04 +02:00

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.
This commit is contained in:
jp9000 2015-03-18 19:22:37 -07:00
parent d44d3b1f0a
commit f3104d92d5

View File

@ -203,6 +203,16 @@ static bool coreaudio_init_format(struct coreaudio_data *ca)
if (!ca_success(stat, ca, "coreaudio_init_format", "get input format")) if (!ca_success(stat, ca, "coreaudio_init_format", "get input format"))
return false; 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, stat = set_property(ca->unit, kAudioUnitProperty_StreamFormat,
SCOPE_OUTPUT, BUS_INPUT, &desc, size); SCOPE_OUTPUT, BUS_INPUT, &desc, size);
if (!ca_success(stat, ca, "coreaudio_init_format", "set output format")) if (!ca_success(stat, ca, "coreaudio_init_format", "set output format"))