2
* Copyright (C) 2003-2011 The Music Player Daemon Project
3
* http://www.musicpd.org
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 2 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 along
16
* with this program; if not, write to the Free Software Foundation, Inc.,
17
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20
#ifndef MPD_OUTPUT_PLUGIN_H
21
#define MPD_OUTPUT_PLUGIN_H
33
* A plugin which controls an audio output device.
35
struct audio_output_plugin {
42
* Test if this plugin can provide a default output, in case
43
* none has been configured. This method is optional.
45
bool (*test_default_device)(void);
48
* Configure and initialize the device, but do not open it
51
* @param param the configuration section, or NULL if there is
53
* @param error location to store the error occurring, or NULL
55
* @return NULL on error, or an opaque pointer to the plugin's
58
struct audio_output *(*init)(const struct config_param *param,
62
* Free resources allocated by this device.
64
void (*finish)(struct audio_output *data);
67
* Enable the device. This may allocate resources, preparing
68
* for the device to be opened. Enabling a device cannot
69
* fail: if an error occurs during that, it should be reported
70
* by the open() method.
72
* @param error_r location to store the error occurring, or
73
* NULL to ignore errors
74
* @return true on success, false on error
76
bool (*enable)(struct audio_output *data, GError **error_r);
79
* Disables the device. It is closed before this method is
82
void (*disable)(struct audio_output *data);
85
* Really open the device.
87
* @param audio_format the audio format in which data is going
88
* to be delivered; may be modified by the plugin
89
* @param error location to store the error occurring, or NULL
92
bool (*open)(struct audio_output *data, struct audio_format *audio_format,
98
void (*close)(struct audio_output *data);
101
* Returns a positive number if the output thread shall delay
102
* the next call to play() or pause(). This should be
103
* implemented instead of doing a sleep inside the plugin,
104
* because this allows MPD to listen to commands meanwhile.
106
* @return the number of milliseconds to wait
108
unsigned (*delay)(struct audio_output *data);
111
* Display metadata for the next chunk. Optional method,
112
* because not all devices can display metadata.
114
void (*send_tag)(struct audio_output *data, const struct tag *tag);
117
* Play a chunk of audio data.
119
* @param error location to store the error occurring, or NULL
121
* @return the number of bytes played, or 0 on error
123
size_t (*play)(struct audio_output *data,
124
const void *chunk, size_t size,
128
* Wait until the device has finished playing.
130
void (*drain)(struct audio_output *data);
133
* Try to cancel data which may still be in the device's
136
void (*cancel)(struct audio_output *data);
139
* Pause the device. If supported, it may perform a special
140
* action, which keeps the device open, but does not play
141
* anything. Output plugins like "shout" might want to play
142
* silence during pause, so their clients won't be
143
* disconnected. Plugins which do not support pausing will
144
* simply be closed, and have to be reopened when unpaused.
146
* @return false on error (output will be closed then), true
147
* for continue to pause
149
bool (*pause)(struct audio_output *data);
152
* The mixer plugin associated with this output plugin. This
153
* may be NULL if no mixer plugin is implemented. When
154
* created, this mixer plugin gets the same #config_param as
155
* this audio output device.
157
const struct mixer_plugin *mixer_plugin;
161
ao_plugin_test_default_device(const struct audio_output_plugin *plugin)
163
return plugin->test_default_device != NULL
164
? plugin->test_default_device()
169
struct audio_output *
170
ao_plugin_init(const struct audio_output_plugin *plugin,
171
const struct config_param *param,
175
ao_plugin_finish(struct audio_output *ao);
178
ao_plugin_enable(struct audio_output *ao, GError **error_r);
181
ao_plugin_disable(struct audio_output *ao);
184
ao_plugin_open(struct audio_output *ao, struct audio_format *audio_format,
188
ao_plugin_close(struct audio_output *ao);
192
ao_plugin_delay(struct audio_output *ao);
195
ao_plugin_send_tag(struct audio_output *ao, const struct tag *tag);
198
ao_plugin_play(struct audio_output *ao, const void *chunk, size_t size,
202
ao_plugin_drain(struct audio_output *ao);
205
ao_plugin_cancel(struct audio_output *ao);
208
ao_plugin_pause(struct audio_output *ao);