/*
* This file is part of DisOrder.
- * Copyright (C) 2009 Richard Kettlewell
+ * Copyright (C) 2009, 2013 Richard Kettlewell
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
#include "uaudio.h"
#include "hash.h"
#include "mem.h"
+#include "log.h"
/** @brief Options for chosen uaudio API */
static hash *uaudio_options;
/** @brief Whether samples are signed or unsigned */
int uaudio_signed;
+/** @brief Frames of buffer to tolerate inside chosen API */
+int uaudio_buffer;
+
/** @brief Sample size in bytes
*
* NB one sample is a single point sample; up to @c uaudio_channels samples may
/** @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);
/** @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