Skip to content

Commit

Permalink
Cannot switch audio device by UUID, wrong use of AudioObjectGetProper…
Browse files Browse the repository at this point in the history
…tyData output argument (#53)
  • Loading branch information
mayhemer authored Apr 22, 2023
1 parent ee5ba97 commit 6659247
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions audio_switch.c
Original file line number Diff line number Diff line change
Expand Up @@ -321,12 +321,13 @@ AudioDeviceID getRequestedDeviceIDFromUIDSubstring(char * requestedDeviceUID, AS
}

char deviceUID[256];
CFStringRef deviceUIDRef = NULL;
propertyAddress.mSelector = kAudioDevicePropertyDeviceUID;
propertyAddress.mScope = kAudioObjectPropertyScopeGlobal;
propertyAddress.mElement = dev_array[i];
propertySize = sizeof(deviceUID);
AudioObjectGetPropertyData(dev_array[i], &propertyAddress, 0, NULL, &propertySize, &deviceUID);

propertySize = sizeof(deviceUIDRef);
AudioObjectGetPropertyData(dev_array[i], &propertyAddress, 0, NULL, &propertySize, &deviceUIDRef);
CFStringGetCString(deviceUIDRef, deviceUID, sizeof(deviceUID), CFStringGetSystemEncoding());
if (strstr(deviceUID, requestedDeviceUID) != NULL) {
return dev_array[i];
}
Expand Down

0 comments on commit 6659247

Please sign in to comment.