chiark / gitweb /
uaudio OSS support now compiles
[disorder] / lib / uaudio.h
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.h
20 * @brief Uniform audio interface
21 */
22
23#ifndef UAUDIO_H
24#define UAUDIO_H
25
26/** @brief Callback to get audio data
27 * @param buffer Where to put audio data
28 * @param max_samples How many samples to supply
29 * @param userdata As passed to uaudio_open()
30 * @return Number of samples filled
31 *
32 * One sample is a single 16-bit signed value.
33 */
34typedef size_t uaudio_callback(int16_t *buffer,
35 size_t max_samples,
36 void *userdata);
37
38/** @brief Audio API definition */
39struct uaudio {
40 /** @brief Name of this API */
41 const char *name;
42
43 /** @brief List of options, terminated by NULL */
44 const char *const *options;
45
46 /** @brief Do slow setup
47 * @param ua Handle returned by uaudio_open()
48 * @param callback Called for audio data
49 * @param userdata Passed to @p callback
50 *
51 * This does resource-intensive setup for the output device.
52 *
53 * For instance it might open mixable audio devices or network sockets. It
54 * will create any background thread required. However, it must not exclude
55 * other processes from outputting sound.
56 */
57 void (*start)(uaudio_callback *callback,
58 void *userdata);
59
60 /** @brief Tear down
61 * @param ua Handle returned by uaudio_open()
62 *
63 * This undoes the effect of @c start.
64 */
65 void (*stop)(void);
66
67 /** @brief Enable output
68 *
69 * A background thread will start calling @c callback as set by @c
70 * start and playing the audio data received from it.
71 */
72 void (*activate)(void);
73
74 /** @brief Disable output
75 *
76 * The background thread will stop calling @c callback.
77 */
78 void (*deactivate)(void);
79
80};
81
82void uaudio_set(const char *name, const char *value);
83const char *uaudio_get(const char *name);
84
85#if HAVE_COREAUDIO_AUDIOHARDWARE_H
86extern const struct uaudio uaudio_coreaudio;
87#endif
88
89#if HAVE_ALSA_ASOUNDLIB_H
90extern const struct uaudio uaudio_alsa;
91#endif
92
93#if HAVE_SYS_SOUNDCARD_H || EMPEG_HOST
94extern const struct uaudio uaudio_oss;
95#endif
96
97extern const struct uaudio uaudio_rtp;
98
99extern const struct uaudio *uaudio_apis[];
100
101#endif /* UAUDIO_H */
102
103/*
104Local Variables:
105c-basic-offset:2
106comment-column:40
107fill-column:79
108indent-tabs-mode:nil
109End:
110*/