X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/disorder/blobdiff_plain/b25aac593c0321473525a3e5b12f406bd3961aec..401d3485a7923ae9b83b23399bee0ef8d19d0444:/lib/mixer.c diff --git a/lib/mixer.c b/lib/mixer.c index 58d9e60..a24f7eb 100644 --- a/lib/mixer.c +++ b/lib/mixer.c @@ -2,27 +2,24 @@ * This file is part of DisOrder * Copyright (C) 2007 Richard Kettlewell * - * This program is free software; you can redistribute it and/or modify + * 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 - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA + * along with this program. If not, see . */ /** @file lib/mixer.c * @brief Mixer support */ -#include -#include "types.h" +#include "common.h" #include "configuration.h" #include "mixer.h" @@ -69,13 +66,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 +95,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 */