Unfortunately, I did not find what I was looking for but I Googled what I 
thought you needed.
Hopefully, these two resources will help.

https://gist.github.com/mikeash/2e2d482058013c837a43 (AudioUnitSetProperty)

https://github.com/shogo4405/lf.swift/blob/master/Platforms/macOS/AudioUtil.swift
 (AudioObjectSetPropertyData)


W.



From: Coreaudio-api 
[mailto:[email protected]] On Behalf Of 
Waverly Edwards
Sent: Friday, July 14, 2017 12:47 PM
To: Rick Mann <[email protected]>; Chris Adamson <[email protected]>
Cc: Core Audio List <[email protected]>
Subject: RE: Replacements for AudioHardwareGetPropertyInfo() et al.?

I’ll look around for some code I should have on my machine but I believe you’ll 
need to use AudioUnitSetProperty or AudioObjectSetPropertyData

>>… highly unintuitive Swift since it uses lots of inout and free functions and 
>>UnsafeMutableRawPointerWillKillYouInYourSleep and all that.

Oh, I’ve had LOTS of (miserable) experience with 
UnsafeMutableRawPointerWillKillYouInYourSleep.

I really like Swift but Coreaudio + Swift = SometimesIncrediblyPainful


W.


From: Coreaudio-api 
[mailto:[email protected]] On Behalf Of 
Rick Mann
Sent: Thursday, July 13, 2017 9:38 PM
To: Chris Adamson <[email protected]<mailto:[email protected]>>
Cc: Core Audio List 
<[email protected]<mailto:[email protected]>>
Subject: Re: Replacements for AudioHardwareGetPropertyInfo() et al.?

Thanks, I’ll check it out.

Can’t call the deprecated one from Swift because it won’t let me (anything 
deprecated before 10.9).
--
Rick Mann
[email protected]<mailto:[email protected]>

On Jul 13, 2017, at 18:30, Chris Adamson 
<[email protected]<mailto:[email protected]>> wrote:
IIRC, the AudioObject* APIs replaced AudioHardware* some time ago. It’s been a 
while since I’ve done anything that uses them, but I did notice this in the 
last version of the Learning Core Audio sample code that I uploaded as errata:

               // AudioHardwareGetProperty() is deprecated
               //             CheckError 
(AudioHardwareGetProperty(kAudioHardwarePropertyDefaultInputDevice,
               //                                                               
                                                                                
     &propertySize,
               //                                                               
                                                                                
     &defaultDevice),
               //                                                          
"Couldn't get default input device");

               // AudioObjectProperty stuff new in 10.6, replaces 
AudioHardwareGetProperty() call
               // TODO: need to update ch08 to explain, use this call. need 
CoreAudio.framework
               AudioObjectPropertyAddress defaultDeviceProperty;
               defaultDeviceProperty.mSelector = 
kAudioHardwarePropertyDefaultInputDevice;
               defaultDeviceProperty.mScope = kAudioObjectPropertyScopeGlobal;
               defaultDeviceProperty.mElement = 
kAudioObjectPropertyElementMaster;

               CheckError (AudioObjectGetPropertyData(kAudioObjectSystemObject,
                                                                                
                                                                        
&defaultDeviceProperty,
                                                                                
                                                                        0,
                                                                                
                                                                        NULL,
                                                                                
                                                                        
&propertySize,
                                                                                
                                                                        
&defaultDevice),
                                                            "Couldn't get 
default input device");


Also, calling AudioObject from Swift will work just as well/poorly as 
AudioHardware. Any C function in a public API can be called from Swift just 
fine… it’s just highly unintuitive Swift since it uses lots of inout and free 
functions and UnsafeMutableRawPointerWillKillYouInYourSleep and all that.

Hopefully that’ll at least get you pointed in the right direction. Sorry the 
docs aren’t better.

—Chris


On Jul 13, 2017, at 8:13 PM, Rick Mann 
<[email protected]<mailto:[email protected]>> wrote:

Apple's docs are sorely lacking. A whole suite of APIs is deprecated, with no 
indication of what to use in their stead, and no accessibility from Swift:

https://developer.apple.com/documentation/coreaudio/1580716-audiohardwaregetpropertyinfo

What's the replacement set of APIs for switching the current audio input on 
macOS?

Thanks,

--
Rick Mann
[email protected]<mailto:[email protected]>


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list      
([email protected]<mailto:[email protected]>)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/coreaudio-api/invalidname%40gmail.com

This email sent to [email protected]<mailto:[email protected]>

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/coreaudio-api/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to