Core Audio input: Fix channel config, and a leak

Channel config should not contain duplicate channels, or unsupported
channels. Also fix a memory leak from not freeing the AudioChannelLayout
structure allocated previously.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
CQTexperiment
Christopher Snowhill 2022-02-07 02:47:32 -08:00
parent 22d8b8c132
commit b2177fccbc
1 changed files with 13 additions and 1 deletions

View File

@ -220,12 +220,24 @@ static SInt64 getSizeProc(void *clientData) {
uint32_t config = 0;
for(uint32_t i = 0; i < acl->mNumberChannelDescriptions; ++i) {
int channelNumber = ffat_get_channel_id(acl->mChannelDescriptions[i].mChannelLabel);
if(channelNumber >= 0)
if(channelNumber >= 0) {
if(config & (1 << channelNumber)) {
free(acl);
err = ExtAudioFileDispose(_in);
return NO;
}
config |= 1 << channelNumber;
} else {
free(acl);
err = ExtAudioFileDispose(_in);
return NO;
}
}
channelConfig = config;
free(acl);
bitrate = (_bitrate + 500) / 1000;
CFStringRef formatName;