Skip to content

Instantly share code, notes, and snippets.

View glaurent's full-sized avatar

Guillaume Laurent glaurent

View GitHub Profile
@glaurent
glaurent / ListCoreAudioDevices.swift
Last active July 11, 2023 07:50 — forked from robotconscience/SelectAudioOutput.mm
List CoreAudio devices in Swift
import Foundation
import CoreAudio
var propertyAddress = AudioObjectPropertyAddress(mSelector: kAudioHardwarePropertyDevices, mScope: kAudioObjectPropertyScopeGlobal, mElement: kAudioObjectPropertyElementMaster)
var propertySize:UInt32 = 0
if AudioObjectGetPropertyDataSize(AudioObjectID(kAudioObjectSystemObject), &propertyAddress, 0, nil, &propertySize) == noErr {
let numDevices = Int(propertySize) / MemoryLayout<AudioDeviceID>.size