invalidname

coreaudio-api: AudioObject replaces AudioHardware on Mac

Jul 13th, 2017
290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. 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:
  2.  
  3. // AudioHardwareGetProperty() is deprecated
  4. // CheckError (AudioHardwareGetProperty(kAudioHardwarePropertyDefaultInputDevice,
  5. // &propertySize,
  6. // &defaultDevice),
  7. // "Couldn't get default input device");
  8.  
  9. // AudioObjectProperty stuff new in 10.6, replaces AudioHardwareGetProperty() call
  10. // TODO: need to update ch08 to explain, use this call. need CoreAudio.framework
  11. AudioObjectPropertyAddress defaultDeviceProperty;
  12. defaultDeviceProperty.mSelector = kAudioHardwarePropertyDefaultInputDevice;
  13. defaultDeviceProperty.mScope = kAudioObjectPropertyScopeGlobal;
  14. defaultDeviceProperty.mElement = kAudioObjectPropertyElementMaster;
  15.  
  16. CheckError (AudioObjectGetPropertyData(kAudioObjectSystemObject,
  17. &defaultDeviceProperty,
  18. 0,
  19. NULL,
  20. &propertySize,
  21. &defaultDevice),
  22. "Couldn't get default input device");
  23.  
  24.  
  25. 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.
  26.  
  27. Hopefully that’ll at least get you pointed in the right direction. Sorry the docs aren’t better.
  28.  
  29. —Chris
  30.  
  31. On Jul 13, 2017, at 8:13 PM, Rick Mann <email-hidden> wrote:
  32. >
  33. > 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:
  34. >
  35. > https://developer.apple.com/documentation/coreaudio/1580716-audiohardwaregetpropertyinfo
  36. >
  37. > What's the replacement set of APIs for switching the current audio input on macOS?
  38. >
  39. > Thanks,
Advertisement
Add Comment
Please, Sign In to add comment