提交 d5140e92 编写于 作者: P pkviet 提交者: jp9000

mac-capture: Update fix for Soundflower

Some audio devices do not have a fixed number of channels.  For example,
Soundflower.  This was previously fixed by defaulting the speaker layout
to stereo.  With surround sound support, the default has been changed to
the output speaker layout as set in Settings > Audio.

Closes jp9000/obs-studio#1110
上级 974e64eb
......@@ -205,6 +205,14 @@ static bool coreaudio_init_format(struct coreaudio_data *ca)
AudioStreamBasicDescription desc;
OSStatus stat;
UInt32 size = sizeof(desc);
struct obs_audio_info aoi;
int channels;
if (!obs_get_audio_info(&aoi)) {
blog(LOG_WARNING, "No active audio");
return false;
}
channels = get_audio_channels(aoi.speakers);
stat = get_property(ca->unit, kAudioUnitProperty_StreamFormat,
SCOPE_INPUT, BUS_INPUT, &desc, &size);
......@@ -213,13 +221,13 @@ static bool coreaudio_init_format(struct coreaudio_data *ca)
/* 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;
}
* so if we encounter this situation just force to what is defined in output */
if (desc.mChannelsPerFrame > 8) {
desc.mChannelsPerFrame = channels;
desc.mBytesPerFrame = channels * desc.mBitsPerChannel / 8;
desc.mBytesPerPacket =
desc.mFramesPerPacket * desc.mBytesPerFrame;
}
stat = set_property(ca->unit, kAudioUnitProperty_StreamFormat,
SCOPE_OUTPUT, BUS_INPUT, &desc, size);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册