Changes to AudioQueueServices backend to capture 7.1 surround with SoundFlower

This commit is contained in:
Jack Andersen 2017-09-19 23:25:02 -10:00
parent bf4b3f7382
commit 71b8893dde
1 changed files with 90 additions and 54 deletions

View File

@ -130,6 +130,9 @@ struct AQSAudioVoiceEngine : BaseAudioVoiceEngine
default: break; default: break;
} }
if (hwChannels > 8)
return AudioChannelSet::Surround71;
return AudioChannelSet::Unknown; return AudioChannelSet::Unknown;
} }
@ -632,15 +635,47 @@ struct AQSAudioVoiceEngine : BaseAudioVoiceEngine
UInt32 layoutSz = sizeof(layout); UInt32 layoutSz = sizeof(layout);
if (AudioQueueGetProperty(m_queue, kAudioQueueProperty_ChannelLayout, &layout, &layoutSz)) if (AudioQueueGetProperty(m_queue, kAudioQueueProperty_ChannelLayout, &layout, &layoutSz))
{ {
Log.report(logvisor::Fatal, "unable to get channel layout from audio queue"); Log.report(logvisor::Warning, "unable to get channel layout from audio queue; using count's default");
return; switch (m_mixInfo.m_channels)
{
case AudioChannelSet::Stereo:
default:
chMapOut.m_channels[chMapOut.m_channelCount++] = AudioChannel::FrontLeft;
chMapOut.m_channels[chMapOut.m_channelCount++] = AudioChannel::FrontRight;
break;
case AudioChannelSet::Quad:
chMapOut.m_channels[chMapOut.m_channelCount++] = AudioChannel::FrontLeft;
chMapOut.m_channels[chMapOut.m_channelCount++] = AudioChannel::FrontRight;
chMapOut.m_channels[chMapOut.m_channelCount++] = AudioChannel::RearLeft;
chMapOut.m_channels[chMapOut.m_channelCount++] = AudioChannel::RearRight;
break;
case AudioChannelSet::Surround51:
chMapOut.m_channels[chMapOut.m_channelCount++] = AudioChannel::FrontLeft;
chMapOut.m_channels[chMapOut.m_channelCount++] = AudioChannel::FrontRight;
chMapOut.m_channels[chMapOut.m_channelCount++] = AudioChannel::FrontCenter;
chMapOut.m_channels[chMapOut.m_channelCount++] = AudioChannel::LFE;
chMapOut.m_channels[chMapOut.m_channelCount++] = AudioChannel::RearLeft;
chMapOut.m_channels[chMapOut.m_channelCount++] = AudioChannel::RearRight;
break;
case AudioChannelSet::Surround71:
chMapOut.m_channels[chMapOut.m_channelCount++] = AudioChannel::FrontLeft;
chMapOut.m_channels[chMapOut.m_channelCount++] = AudioChannel::FrontRight;
chMapOut.m_channels[chMapOut.m_channelCount++] = AudioChannel::FrontCenter;
chMapOut.m_channels[chMapOut.m_channelCount++] = AudioChannel::LFE;
chMapOut.m_channels[chMapOut.m_channelCount++] = AudioChannel::SideLeft;
chMapOut.m_channels[chMapOut.m_channelCount++] = AudioChannel::SideRight;
chMapOut.m_channels[chMapOut.m_channelCount++] = AudioChannel::RearLeft;
chMapOut.m_channels[chMapOut.m_channelCount++] = AudioChannel::RearRight;
break;
} }
}
else
{
switch (layout.mChannelLayoutTag) switch (layout.mChannelLayoutTag)
{ {
case kAudioChannelLayoutTag_UseChannelDescriptions: case kAudioChannelLayoutTag_UseChannelDescriptions:
chMapOut.m_channelCount = layout.mNumberChannelDescriptions; chMapOut.m_channelCount = layout.mNumberChannelDescriptions;
for (int i=0 ; i<layout.mNumberChannelDescriptions ; ++i) for (int i = 0; i < layout.mNumberChannelDescriptions; ++i)
{ {
AudioChannel ch = AQSChannelToBooChannel(layout.mChannelDescriptions[i].mChannelLabel); AudioChannel ch = AQSChannelToBooChannel(layout.mChannelDescriptions[i].mChannelLabel);
chMapOut.m_channels[i] = ch; chMapOut.m_channels[i] = ch;
@ -686,7 +721,7 @@ struct AQSAudioVoiceEngine : BaseAudioVoiceEngine
chMapOut.m_channels[4] = AudioChannel::FrontCenter; chMapOut.m_channels[4] = AudioChannel::FrontCenter;
break; break;
default: default:
Log.report(logvisor::Fatal, Log.report(logvisor::Warning,
"unknown channel layout %u; using stereo", "unknown channel layout %u; using stereo",
layout.mChannelLayoutTag); layout.mChannelLayoutTag);
chMapOut.m_channelCount = 2; chMapOut.m_channelCount = 2;
@ -695,6 +730,7 @@ struct AQSAudioVoiceEngine : BaseAudioVoiceEngine
break; break;
} }
} }
}
else else
{ {
chMapOut.m_channels[chMapOut.m_channelCount++] = AudioChannel::FrontLeft; chMapOut.m_channels[chMapOut.m_channelCount++] = AudioChannel::FrontLeft;