X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/disorder/blobdiff_plain/b25aac593c0321473525a3e5b12f406bd3961aec..fcb632a28d698e5e3c4463b2db184025555015a2:/lib/mixer.c diff --git a/lib/mixer.c b/lib/mixer.c index 58d9e60..36acd73 100644 --- a/lib/mixer.c +++ b/lib/mixer.c @@ -21,8 +21,7 @@ * @brief Mixer support */ -#include -#include "types.h" +#include "common.h" #include "configuration.h" #include "mixer.h" @@ -69,13 +68,25 @@ static const struct mixer *mixers[] = { static const struct mixer *find_mixer(int api) { size_t n; + if(api == -1) + api = config->api; for(n = 0; n < NMIXERS; ++n) if(mixers[n]->api == api) return mixers[n]; return &mixer_none; } +/** @brief Return true if we know how to drive the mixer + * @param api Sound api or -1 for default + * @return true if suppored, false otherwise + */ +int mixer_supported(int api) { + const struct mixer *const m = find_mixer(api); + return m != &mixer_none; +} + /** @brief Get/set volume + * @param api Sound api or -1 for default * @param left Left channel level, 0-100 * @param right Right channel level, 0-100 * @param set Set volume if non-0 @@ -86,8 +97,8 @@ static const struct mixer *find_mixer(int api) { * If setting the volume then the target levels are read from @p left and * @p right, and the actual level set is stored in them. */ -int mixer_control(int *left, int *right, int set) { - const struct mixer *const m = find_mixer(config->api); +int mixer_control(int api, int *left, int *right, int set) { + const struct mixer *const m = find_mixer(api); /* We impose defaults bizarrely late, but this has the advantage of * not making everything depend on sound libraries */