MPD  0.20.18
OutputPlugin.hxx
Go to the documentation of this file.
1 /*
2  * Copyright 2003-2017 The Music Player Daemon Project
3  * http://www.musicpd.org
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 2 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 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.
18  */
19 
20 #ifndef MPD_OUTPUT_PLUGIN_HXX
21 #define MPD_OUTPUT_PLUGIN_HXX
22 
23 #include "Compiler.h"
24 
25 #include <chrono>
26 
27 #include <stddef.h>
28 
29 struct ConfigBlock;
30 struct AudioFormat;
31 struct Tag;
32 struct AudioOutput;
33 struct MixerPlugin;
34 
42  const char *name;
43 
49 
59  AudioOutput *(*init)(const ConfigBlock &block);
60 
64  void (*finish)(AudioOutput *data);
65 
72  void (*enable)(AudioOutput *data);
73 
78  void (*disable)(AudioOutput *data);
79 
88  void (*open)(AudioOutput *data, AudioFormat &audio_format);
89 
93  void (*close)(AudioOutput *data);
94 
104  std::chrono::steady_clock::duration (*delay)(AudioOutput *data) noexcept;
105 
110  void (*send_tag)(AudioOutput *data, const Tag &tag);
111 
119  size_t (*play)(AudioOutput *data,
120  const void *chunk, size_t size);
121 
125  void (*drain)(AudioOutput *data);
126 
131  void (*cancel)(AudioOutput *data);
132 
144  bool (*pause)(AudioOutput *data);
145 
153 };
154 
155 static inline bool
157 {
158  return plugin->test_default_device != nullptr
159  ? plugin->test_default_device()
160  : false;
161 }
162 
164 AudioOutput *
165 ao_plugin_init(const AudioOutputPlugin *plugin,
166  const ConfigBlock &block);
167 
168 void
170 
171 void
173 
174 void
176 
177 void
178 ao_plugin_open(AudioOutput *ao, AudioFormat &audio_format);
179 
180 void
182 
183 gcc_pure
184 std::chrono::steady_clock::duration
185 ao_plugin_delay(AudioOutput *ao) noexcept;
186 
187 void
188 ao_plugin_send_tag(AudioOutput *ao, const Tag &tag);
189 
190 size_t
191 ao_plugin_play(AudioOutput *ao, const void *chunk, size_t size);
192 
193 void
195 
196 void
198 
199 bool
201 
202 #endif
void ao_plugin_disable(AudioOutput *ao)
void(* enable)(AudioOutput *data)
Enable the device.
void(* close)(AudioOutput *data)
Close the device.
This structure describes the format of a raw PCM stream.
Definition: AudioFormat.hxx:37
bool(* test_default_device)()
Test if this plugin can provide a default output, in case none has been configured.
size_t(* play)(AudioOutput *data, const void *chunk, size_t size)
Play a chunk of audio data.
std::chrono::steady_clock::duration(* delay)(AudioOutput *data) noexcept
Returns a positive number if the output thread shall further delay the next call to play() or pause()...
The meta information about a song file.
Definition: Tag.hxx:34
void(* open)(AudioOutput *data, AudioFormat &audio_format)
Really open the device.
#define gcc_malloc
Definition: Compiler.h:112
void ao_plugin_drain(AudioOutput *ao)
const char * name
the plugin&#39;s name
void ao_plugin_send_tag(AudioOutput *ao, const Tag &tag)
void(* finish)(AudioOutput *data)
Free resources allocated by this device.
static bool ao_plugin_test_default_device(const AudioOutputPlugin *plugin)
void ao_plugin_finish(AudioOutput *ao)
void(* cancel)(AudioOutput *data)
Try to cancel data which may still be in the device&#39;s buffers.
void ao_plugin_cancel(AudioOutput *ao)
void ao_plugin_enable(AudioOutput *ao)
gcc_pure std::chrono::steady_clock::duration ao_plugin_delay(AudioOutput *ao) noexcept
bool(* pause)(AudioOutput *data)
Pause the device.
void(* drain)(AudioOutput *data)
Wait until the device has finished playing.
void ao_plugin_close(AudioOutput *ao)
void ao_plugin_open(AudioOutput *ao, AudioFormat &audio_format)
void(* send_tag)(AudioOutput *data, const Tag &tag)
Display metadata for the next chunk.
const MixerPlugin * mixer_plugin
The mixer plugin associated with this output plugin.
size_t ao_plugin_play(AudioOutput *ao, const void *chunk, size_t size)
gcc_malloc AudioOutput * ao_plugin_init(const AudioOutputPlugin *plugin, const ConfigBlock &block)
bool ao_plugin_pause(AudioOutput *ao)
void(* disable)(AudioOutput *data)
Disables the device.
#define gcc_pure
Definition: Compiler.h:116
A plugin which controls an audio output device.