strtok() is recursive by default on win32.
[mpd-mk.git] / src / output_internal.h
blob06df9531bc82a0fd6ce5d6592719faf03347d599
1 /*
2 * Copyright (C) 2003-2010 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_INTERNAL_H
21 #define MPD_OUTPUT_INTERNAL_H
23 #include "audio_format.h"
25 #include <glib.h>
27 #include <time.h>
29 enum audio_output_command {
30 AO_COMMAND_NONE = 0,
31 AO_COMMAND_ENABLE,
32 AO_COMMAND_DISABLE,
33 AO_COMMAND_OPEN,
35 /**
36 * This command is invoked when the input audio format
37 * changes.
39 AO_COMMAND_REOPEN,
41 AO_COMMAND_CLOSE,
42 AO_COMMAND_PAUSE,
44 /**
45 * Drains the internal (hardware) buffers of the device. This
46 * operation may take a while to complete.
48 AO_COMMAND_DRAIN,
50 AO_COMMAND_CANCEL,
51 AO_COMMAND_KILL
54 struct audio_output {
55 /**
56 * The device's configured display name.
58 const char *name;
60 /**
61 * The plugin which implements this output device.
63 const struct audio_output_plugin *plugin;
65 /**
66 * The plugin's internal data. It is passed to every plugin
67 * method.
69 void *data;
71 /**
72 * The #mixer object associated with this audio output device.
73 * May be NULL if none is available, or if software volume is
74 * configured.
76 struct mixer *mixer;
78 /**
79 * Shall this output always play something (i.e. silence),
80 * even when playback is stopped?
82 bool always_on;
84 /**
85 * Has the user enabled this device?
87 bool enabled;
89 /**
90 * Is this device actually enabled, i.e. the "enable" method
91 * has succeeded?
93 bool really_enabled;
95 /**
96 * Is the device (already) open and functional?
98 * This attribute may only be modified by the output thread.
99 * It is protected with #mutex: write accesses inside the
100 * output thread and read accesses outside of it may only be
101 * performed while the lock is held.
103 bool open;
106 * Is the device paused? i.e. the output thread is in the
107 * ao_pause() loop.
109 bool pause;
112 * If not NULL, the device has failed, and this timer is used
113 * to estimate how long it should stay disabled (unless
114 * explicitly reopened with "play").
116 GTimer *fail_timer;
119 * The configured audio format.
121 struct audio_format config_audio_format;
124 * The audio_format in which audio data is received from the
125 * player thread (which in turn receives it from the decoder).
127 struct audio_format in_audio_format;
130 * The audio_format which is really sent to the device. This
131 * is basically config_audio_format (if configured) or
132 * in_audio_format, but may have been modified by
133 * plugin->open().
135 struct audio_format out_audio_format;
138 * The filter object of this audio output. This is an
139 * instance of chain_filter_plugin.
141 struct filter *filter;
144 * The replay_gain_filter_plugin instance of this audio
145 * output.
147 struct filter *replay_gain_filter;
150 * The serial number of the last replay gain info. 0 means no
151 * replay gain info was available.
153 unsigned replay_gain_serial;
156 * The convert_filter_plugin instance of this audio output.
157 * It is the last item in the filter chain, and is responsible
158 * for converting the input data into the appropriate format
159 * for this audio output.
161 struct filter *convert_filter;
164 * The thread handle, or NULL if the output thread isn't
165 * running.
167 GThread *thread;
170 * The next command to be performed by the output thread.
172 enum audio_output_command command;
175 * The music pipe which provides music chunks to be played.
177 const struct music_pipe *pipe;
180 * This mutex protects #open, #chunk and #chunk_finished.
182 GMutex *mutex;
185 * This condition object wakes up the output thread after
186 * #command has been set.
188 GCond *cond;
191 * The #music_chunk which is currently being played. All
192 * chunks before this one may be returned to the
193 * #music_buffer, because they are not going to be used by
194 * this output anymore.
196 const struct music_chunk *chunk;
199 * Has the output finished playing #chunk?
201 bool chunk_finished;
205 * Notify object used by the thread's client, i.e. we will send a
206 * notify signal to this object, expecting the caller to wait on it.
208 extern struct notify audio_output_client_notify;
210 static inline bool
211 audio_output_is_open(const struct audio_output *ao)
213 return ao->open;
216 static inline bool
217 audio_output_command_is_finished(const struct audio_output *ao)
219 return ao->command == AO_COMMAND_NONE;
222 #endif