فهرست منبع

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.
jp9000 11 سال پیش
والد
کامیت
f3104d92d5
1فایلهای تغییر یافته به همراه10 افزوده شده و 0 حذف شده
  1. 10 0
      plugins/mac-capture/mac-audio.c

+ 10 - 0
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"))
 	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"))