Clean up several CFStringRef leaks

CQTexperiment
Christopher Snowhill 2021-12-26 18:08:53 -08:00
parent f241d88e16
commit 378aaf23ae
2 changed files with 19 additions and 5 deletions

View File

@ -135,10 +135,12 @@ static void Sound_Renderer(void *userData, AudioQueueRef queue, AudioQueueBuffer
err = AudioQueueStop(audioQueue, true); err = AudioQueueStop(audioQueue, true);
if (err) { if (err) {
DLog(@"Error stopping stream to set device"); DLog(@"Error stopping stream to set device");
CFRelease(theDeviceUID);
return err; return err;
} }
primed = NO; primed = NO;
err = AudioQueueSetProperty(audioQueue, kAudioQueueProperty_CurrentDevice, &theDeviceUID, sizeof(theDeviceUID)); err = AudioQueueSetProperty(audioQueue, kAudioQueueProperty_CurrentDevice, &theDeviceUID, sizeof(theDeviceUID));
CFRelease(theDeviceUID);
if (running) if (running)
[self start]; [self start];
} }
@ -240,14 +242,20 @@ static void Sound_Renderer(void *userData, AudioQueueRef queue, AudioQueueBuffer
theAddress.mSelector = kAudioDevicePropertyStreamConfiguration; theAddress.mSelector = kAudioDevicePropertyStreamConfiguration;
__Verify_noErr(AudioObjectGetPropertyDataSize(devids[i], &theAddress, 0, NULL, &propsize)); __Verify_noErr(AudioObjectGetPropertyDataSize(devids[i], &theAddress, 0, NULL, &propsize));
if (propsize < sizeof(UInt32)) continue; if (propsize < sizeof(UInt32)) {
CFRelease(name);
continue;
}
AudioBufferList * bufferList = (AudioBufferList *) malloc(propsize); AudioBufferList * bufferList = (AudioBufferList *) malloc(propsize);
__Verify_noErr(AudioObjectGetPropertyData(devids[i], &theAddress, 0, NULL, &propsize, bufferList)); __Verify_noErr(AudioObjectGetPropertyData(devids[i], &theAddress, 0, NULL, &propsize, bufferList));
UInt32 bufferCount = bufferList->mNumberBuffers; UInt32 bufferCount = bufferList->mNumberBuffers;
free(bufferList); free(bufferList);
if (!bufferCount) continue; if (!bufferCount) {
CFRelease(name);
continue;
}
BOOL stop = NO; BOOL stop = NO;
block([NSString stringWithString:(__bridge NSString *)name], block([NSString stringWithString:(__bridge NSString *)name],

View File

@ -75,14 +75,20 @@
theAddress.mSelector = kAudioDevicePropertyStreamConfiguration; theAddress.mSelector = kAudioDevicePropertyStreamConfiguration;
__Verify_noErr(AudioObjectGetPropertyDataSize(devids[i], &theAddress, 0, NULL, &propsize)); __Verify_noErr(AudioObjectGetPropertyDataSize(devids[i], &theAddress, 0, NULL, &propsize));
if (propsize < sizeof(UInt32)) continue; if (propsize < sizeof(UInt32)) {
CFRelease(name);
continue;
}
AudioBufferList * bufferList = (AudioBufferList *) malloc(propsize); AudioBufferList * bufferList = (AudioBufferList *) malloc(propsize);
__Verify_noErr(AudioObjectGetPropertyData(devids[i], &theAddress, 0, NULL, &propsize, bufferList)); __Verify_noErr(AudioObjectGetPropertyData(devids[i], &theAddress, 0, NULL, &propsize, bufferList));
UInt32 bufferCount = bufferList->mNumberBuffers; UInt32 bufferCount = bufferList->mNumberBuffers;
free(bufferList); free(bufferList);
if (!bufferCount) continue; if (!bufferCount) {
CFRelease(name);
continue;
}
BOOL stop = NO; BOOL stop = NO;
block([NSString stringWithString:(__bridge NSString *)name], block([NSString stringWithString:(__bridge NSString *)name],