chiark / gitweb /
uaudio OSS support now compiles
[disorder] / lib / uaudio.c
CommitLineData
7a2c7068
RK
1/*
2 * This file is part of DisOrder.
3 * Copyright (C) 2009 Richard Kettlewell
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19/** @file lib/uaudio.c
20 * @brief Uniform audio interface
21 */
22
23#include "common.h"
24#include "uaudio.h"
25#include "hash.h"
26#include "mem.h"
27
28/** @brief Options for chosen uaudio API */
29static hash *uaudio_options;
30
31/** @brief Set a uaudio option */
32void uaudio_set(const char *name, const char *value) {
33 if(!uaudio_options)
34 uaudio_options = hash_new(sizeof(char *));
35 value = xstrdup(value);
36 hash_add(uaudio_options, name, &value, HASH_INSERT_OR_REPLACE);
37}
38
39/** @brief Set a uaudio option */
40const char *uaudio_get(const char *name) {
41 const char *value = (uaudio_options ?
42 *(char **)hash_find(uaudio_options, name)
43 : NULL);
44 return value ? xstrdup(value) : NULL;
45}
46
47/** @brief List of known APIs
48 *
49 * Terminated by a null pointer.
50 *
51 * The first one will be used as a default, so putting ALSA before OSS
52 * constitutes a policy decision.
53 */
54const struct uaudio *uaudio_apis[] = {
55#if HAVE_COREAUDIO_AUDIOHARDWARE_H
56 &uaudio_coreaudio,
57#endif
58#if HAVE_ALSA_ASOUNDLIB_H
59 &uaudio_alsa,
60#endif
61#if HAVE_SYS_SOUNDCARD_H || EMPEG_HOST
62 &uaudio_oss,
63#endif
64 &uaudio_rtp,
65 NULL,
66};
67
68/*
69Local Variables:
70c-basic-offset:2
71comment-column:40
72fill-column:79
73indent-tabs-mode:nil
74End:
75*/