From a63e27f95cf39add68853752396f3d30281d33ab Mon Sep 17 00:00:00 2001 From: Chris Moeller Date: Wed, 9 Oct 2013 13:52:39 -0700 Subject: [PATCH] Fixed preferences page to only list output devices --- Preferences/General/OutputsArrayController.m | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/Preferences/General/OutputsArrayController.m b/Preferences/General/OutputsArrayController.m index 0007e0a9a..a8be2516d 100644 --- a/Preferences/General/OutputsArrayController.m +++ b/Preferences/General/OutputsArrayController.m @@ -35,14 +35,18 @@ theAddress.mSelector = kAudioDevicePropertyDeviceNameCFString; verify_noerr(AudioObjectGetPropertyData(devids[i], &theAddress, 0, NULL, &propsize, &name)); - // Ignore devices that have no output channels: - // This tells us the size of the buffer required to hold the information about the channels + propsize = 0; theAddress.mSelector = kAudioDevicePropertyStreamConfiguration; verify_noerr(AudioObjectGetPropertyDataSize(devids[i], &theAddress, 0, NULL, &propsize)); - // Knowing the size of the required buffer, we can determine how many channels there are - // without actually allocating a buffer and requesting the information. - // (we don't care about the exact number of channels, only if there are more than zero or not) - if (propsize <= sizeof(UInt32)) continue; + + if (propsize < sizeof(UInt32)) continue; + + AudioBufferList * bufferList = (AudioBufferList *) malloc(propsize); + verify_noerr(AudioObjectGetPropertyData(devids[i], &theAddress, 0, NULL, &propsize, bufferList)); + UInt32 bufferCount = bufferList->mNumberBuffers; + free(bufferList); + + if (!bufferCount) continue; NSDictionary *deviceInfo = [NSDictionary dictionaryWithObjectsAndKeys: [NSString stringWithString:(NSString*)name], @"name",