osx - How to ignore changing audio-output from System Preference? (macOS) -


i made app can select audio-output. (like 'system default' or 'user's dac')

but when user choose output system preferences panel - sound, app's output follows output user seleced.

i searched lot , add listener can change immediatly app's output user selected if system output has been changed.

but makes anonying few milliseconds swiching delay.

i guess because switch app's output after it's changed system default.

so wonder if can know before system default output's changing. (like viewwillappear api cocoa)

thank you.

listener used knowing chaninging of system default audio out article below.

how notification if system preferences default sound changed

thanks

more details

i used audiounitsetproperty(audioout, kaudiooutputunitproperty_currentdevice, kaudiounitscope_output, 0, &deviceid, (uint32)sizeof(deviceid)) selecting output device. apple document

and add listener

func addlistenerblock(listenerblock: @escaping audioobjectpropertylistenerblock, onaudioobjectid: audioobjectid, forpropertyaddress: inout audioobjectpropertyaddress) {                 if (kaudiohardwarenoerror != audioobjectaddpropertylistenerblock(onaudioobjectid, &forpropertyaddress, nil, listenerblock)) {                     log("error calling: audioobjectaddpropertylistenerblock") }             }  func add() {          var propertyaddress = audioobjectpropertyaddress(mselector: kaudiohardwarepropertydefaultoutputdevice,                                                          mscope: kaudioobjectpropertyscopeglobal,                                                          melement: kaudioobjectpropertyelementmaster)         self.addlistenerblock(listenerblock: audioobjectpropertylistenerblock,                                           onaudioobjectid: audioobjectid(bitpattern: kaudioobjectsystemobject),                                           forpropertyaddress: &propertyaddress)     } 

kaudiounitsubtype_defaultoutput tracks current output device selected user in sound preferences. play specific device use kaudiounitsubtype_haloutput. comments in aucomponent.h helpful:

@enum           apple input/output audio unit sub types (os x) @constant       kaudiounitsubtype_haloutput                              - desktop                 audio unit interfaces audio device. user specifies                  audio device track. audio unit can input device                  output device. bus 0 used output side, bus 1 used                 audio input device.  @constant       kaudiounitsubtype_defaultoutput                          - desktop                 specialisation of auhal used track user's selection of                  default device set in sound prefs  @constant       kaudiounitsubtype_systemoutput                           - desktop                 specialisation of auhal used track user's selection of                  device use sound effects, alerts                 , other ui sounds. 

you didn't specify how you're setting output (augraph?) way use kaudiounitsubtype_haloutput varies.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -