diff options
author | Stefano Pigozzi <stefano.pigozzi@gmail.com> | 2013-07-13 13:01:50 +0200 |
---|---|---|
committer | Stefano Pigozzi <stefano.pigozzi@gmail.com> | 2013-07-22 21:53:18 +0200 |
commit | 18777ecfe894ec9c7995a69e0786e56f45bc73f8 (patch) | |
tree | 70af9d9a5ffe4960a8b1241953dcd5b08513e614 /audio/out/ao_coreaudio_properties.h | |
parent | 1ed117563613b0ddaa2a9c598acc632a707b9cc2 (diff) | |
download | mpv-18777ecfe894ec9c7995a69e0786e56f45bc73f8.tar.bz2 mpv-18777ecfe894ec9c7995a69e0786e56f45bc73f8.tar.xz |
ao_coreaudio: refactor properties code
Introduce some macros to deal with properties. These allow to work around the
limitation of CoreAudio's API being `void **` based. The macros allow to keep
their client's code DRY, by not asking size and other details which can be
derived by the macro itself. I have no idea why Apple didn't design their API
like this in the first place.
Diffstat (limited to 'audio/out/ao_coreaudio_properties.h')
-rw-r--r-- | audio/out/ao_coreaudio_properties.h | 43 |
1 files changed, 26 insertions, 17 deletions
diff --git a/audio/out/ao_coreaudio_properties.h b/audio/out/ao_coreaudio_properties.h index 8f7cc2907b..88ba889c29 100644 --- a/audio/out/ao_coreaudio_properties.h +++ b/audio/out/ao_coreaudio_properties.h @@ -21,29 +21,38 @@ #include <AudioToolbox/AudioToolbox.h> -OSStatus ca_get(AudioObjectID id, AudioObjectPropertySelector selector, +// CoreAudio names are way too verbose +#define ca_sel AudioObjectPropertySelector +#define ca_scope AudioObjectPropertyScope +#define CA_GLOBAL kAudioObjectPropertyScopeGlobal +#define CA_OUTPUT kAudioObjectPropertyScopeOutput + +OSStatus ca_get(AudioObjectID id, ca_scope scope, ca_sel selector, + uint32_t size, void *data); + +OSStatus ca_set(AudioObjectID id, ca_scope scope, ca_sel selector, uint32_t size, void *data); -#define CA_GET(id, selector, data) ca_get(id, selector, sizeof(*(data)), data) +#define CA_GET(id, sel, data) ca_get(id, CA_GLOBAL, sel, sizeof(*(data)), data) +#define CA_SET(id, sel, data) ca_set(id, CA_GLOBAL, sel, sizeof(*(data)), data) + +OSStatus ca_get_ary(AudioObjectID id, ca_scope scope, ca_sel selector, + uint32_t element_size, void **data, size_t *elements); + +#define CA_GET_ARY(id, sel, data, elements) \ + ca_get_ary(id, CA_GLOBAL, sel, sizeof(**(data)), (void **)data, elements) -uint32_t GetAudioPropertyArray(AudioObjectID id, - AudioObjectPropertySelector selector, - AudioObjectPropertyScope scope, void **data); +#define CA_GET_ARY_O(id, sel, data, elements) \ + ca_get_ary(id, CA_OUTPUT, sel, sizeof(**(data)), (void **)data, elements) -uint32_t GetGlobalAudioPropertyArray(AudioObjectID id, - AudioObjectPropertySelector selector, - void **data); +OSStatus ca_get_str(AudioObjectID id, ca_scope scope,ca_sel selector, + char **data); -OSStatus GetAudioPropertyString(AudioObjectID id, - AudioObjectPropertySelector selector, - char **data); +#define CA_GET_STR(id, sel, data) ca_get_str(id, CA_GLOBAL, sel, data) -OSStatus SetAudioProperty(AudioObjectID id, - AudioObjectPropertySelector selector, - uint32_t size, void *data); +Boolean ca_settable(AudioObjectID id, ca_scope scope, ca_sel selector, + Boolean *data); -Boolean IsAudioPropertySettable(AudioObjectID id, - AudioObjectPropertySelector selector, - Boolean *outData); +#define CA_SETTABLE(id, sel, data) ca_settable(id, CA_GLOBAL, sel, data) #endif /* MPV_COREAUDIO_PROPERTIES_H */ |