X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/disorder/blobdiff_plain/b50cfb8a0d4fc71877ae0bfcd7b28879886a2ac1..cc3456940b6b30a0fc4f83226c34e4e873336cd0:/lib/uaudio.c diff --git a/lib/uaudio.c b/lib/uaudio.c index 2f6b67c..e793045 100644 --- a/lib/uaudio.c +++ b/lib/uaudio.c @@ -24,6 +24,7 @@ #include "uaudio.h" #include "hash.h" #include "mem.h" +#include "log.h" /** @brief Options for chosen uaudio API */ static hash *uaudio_options; @@ -50,6 +51,11 @@ size_t uaudio_sample_size; /** @brief Set a uaudio option */ void uaudio_set(const char *name, const char *value) { + if(!value) { + if(uaudio_options) + hash_remove(uaudio_options, name); + return; + } if(!uaudio_options) uaudio_options = hash_new(sizeof(char *)); value = xstrdup(value); @@ -58,10 +64,12 @@ void uaudio_set(const char *name, const char *value) { /** @brief Get a uaudio option */ char *uaudio_get(const char *name, const char *default_value) { - const char *value = (uaudio_options ? - *(char **)hash_find(uaudio_options, name) - : default_value); - return value ? xstrdup(value) : NULL; + if(!uaudio_options) + return default_value ? xstrdup(default_value) : 0; + char **valuep = hash_find(uaudio_options, name); + if(!valuep) + return default_value ? xstrdup(default_value) : 0; + return xstrdup(*valuep); } /** @brief Set sample format