2 * This file is part of DisOrder.
3 * Copyright (C) 2009 Richard Kettlewell
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.
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.
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/>.
19 /** @file lib/uaudio.h
20 * @brief Uniform audio interface
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
32 * One sample is a single 16-bit signed value.
34 typedef size_t uaudio_callback(int16_t *buffer,
38 /** @brief Audio API definition */
40 /** @brief Name of this API */
43 /** @brief List of options, terminated by NULL */
44 const char *const *options;
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
51 * This does resource-intensive setup for the output device.
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.
57 void (*start)(uaudio_callback *callback,
61 * @param ua Handle returned by uaudio_open()
63 * This undoes the effect of @c start.
67 /** @brief Enable output
69 * A background thread will start calling @c callback as set by @c
70 * start and playing the audio data received from it.
72 void (*activate)(void);
74 /** @brief Disable output
76 * The background thread will stop calling @c callback.
78 void (*deactivate)(void);
82 void uaudio_set(const char *name, const char *value);
83 const char *uaudio_get(const char *name);
85 #if HAVE_COREAUDIO_AUDIOHARDWARE_H
86 extern const struct uaudio uaudio_coreaudio;
89 #if HAVE_ALSA_ASOUNDLIB_H
90 extern const struct uaudio uaudio_alsa;
93 #if HAVE_SYS_SOUNDCARD_H || EMPEG_HOST
94 extern const struct uaudio uaudio_oss;
97 extern const struct uaudio uaudio_rtp;
99 extern const struct uaudio *uaudio_apis[];
101 #endif /* UAUDIO_H */