Mercurial > audlegacy
annotate audacious/output.c @ 1252:ece68ef26b94 trunk
[svn] - we don't really have to unwire track 0 this way, as 0 will be selected by default if no subsong URI is given
author | nenolod |
---|---|
date | Thu, 15 Jun 2006 05:17:49 -0700 |
parents | 86da433104a8 |
children | f12d7e208b43 |
rev | line source |
---|---|
0 | 1 /* BMP - Cross-platform multimedia player |
2 * Copyright (C) 2003-2004 BMP development team. | |
3 * | |
4 * Based on XMMS: | |
5 * Copyright (C) 1998-2003 XMMS development team. | |
6 * | |
7 * This program is free software; you can redistribute it and/or modify | |
8 * it under the terms of the GNU General Public License as published by | |
9 * the Free Software Foundation; either version 2 of the License, or | |
10 * (at your option) any later version. | |
11 * | |
12 * This program is distributed in the hope that it will be useful, | |
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 * GNU General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU General Public License | |
18 * along with this program; if not, write to the Free Software | |
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
20 */ | |
21 | |
22 #ifdef HAVE_CONFIG_H | |
23 # include "config.h" | |
24 #endif | |
25 | |
26 #include "output.h" | |
27 #include "iir.h" | |
28 #include "main.h" | |
29 #include "input.h" | |
30 | |
31 #include "playlist.h" | |
32 #include "libaudacious/util.h" | |
33 | |
34 OutputPluginData op_data = { | |
35 NULL, | |
36 NULL | |
37 }; | |
38 | |
890
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
39 OutputPluginState op_state = { |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
40 0, |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
41 0, |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
42 0 |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
43 }; |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
44 |
809 | 45 OutputPlugin psuedo_output_plugin = { |
807
df3412dc33c4
[svn] - add psuedo_output_plugin, a psuedo output plugin that will be used for reverse compatibility with old plugins.
nenolod
parents:
806
diff
changeset
|
46 NULL, |
df3412dc33c4
[svn] - add psuedo_output_plugin, a psuedo output plugin that will be used for reverse compatibility with old plugins.
nenolod
parents:
806
diff
changeset
|
47 NULL, |
df3412dc33c4
[svn] - add psuedo_output_plugin, a psuedo output plugin that will be used for reverse compatibility with old plugins.
nenolod
parents:
806
diff
changeset
|
48 "XMMS reverse compatibility output plugin", |
df3412dc33c4
[svn] - add psuedo_output_plugin, a psuedo output plugin that will be used for reverse compatibility with old plugins.
nenolod
parents:
806
diff
changeset
|
49 NULL, |
df3412dc33c4
[svn] - add psuedo_output_plugin, a psuedo output plugin that will be used for reverse compatibility with old plugins.
nenolod
parents:
806
diff
changeset
|
50 NULL, |
df3412dc33c4
[svn] - add psuedo_output_plugin, a psuedo output plugin that will be used for reverse compatibility with old plugins.
nenolod
parents:
806
diff
changeset
|
51 NULL, |
df3412dc33c4
[svn] - add psuedo_output_plugin, a psuedo output plugin that will be used for reverse compatibility with old plugins.
nenolod
parents:
806
diff
changeset
|
52 NULL, |
df3412dc33c4
[svn] - add psuedo_output_plugin, a psuedo output plugin that will be used for reverse compatibility with old plugins.
nenolod
parents:
806
diff
changeset
|
53 output_get_volume, |
df3412dc33c4
[svn] - add psuedo_output_plugin, a psuedo output plugin that will be used for reverse compatibility with old plugins.
nenolod
parents:
806
diff
changeset
|
54 output_set_volume, |
890
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
55 output_open_audio, |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
56 output_write_audio, |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
57 output_close_audio, |
807
df3412dc33c4
[svn] - add psuedo_output_plugin, a psuedo output plugin that will be used for reverse compatibility with old plugins.
nenolod
parents:
806
diff
changeset
|
58 |
890
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
59 output_flush, |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
60 output_pause, |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
61 output_buffer_free, |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
62 output_buffer_playing, |
807
df3412dc33c4
[svn] - add psuedo_output_plugin, a psuedo output plugin that will be used for reverse compatibility with old plugins.
nenolod
parents:
806
diff
changeset
|
63 get_output_time, |
df3412dc33c4
[svn] - add psuedo_output_plugin, a psuedo output plugin that will be used for reverse compatibility with old plugins.
nenolod
parents:
806
diff
changeset
|
64 get_written_time, |
df3412dc33c4
[svn] - add psuedo_output_plugin, a psuedo output plugin that will be used for reverse compatibility with old plugins.
nenolod
parents:
806
diff
changeset
|
65 NULL |
df3412dc33c4
[svn] - add psuedo_output_plugin, a psuedo output plugin that will be used for reverse compatibility with old plugins.
nenolod
parents:
806
diff
changeset
|
66 }; |
df3412dc33c4
[svn] - add psuedo_output_plugin, a psuedo output plugin that will be used for reverse compatibility with old plugins.
nenolod
parents:
806
diff
changeset
|
67 |
0 | 68 OutputPlugin * |
69 get_current_output_plugin(void) | |
70 { | |
71 return op_data.current_output_plugin; | |
72 } | |
73 | |
74 void | |
75 set_current_output_plugin(gint i) | |
76 { | |
77 #if 0 | |
78 gint time; | |
79 gint pos; | |
80 gboolean playing; | |
81 #endif | |
82 | |
83 GList *node = g_list_nth(op_data.output_list, i); | |
84 if (!node) { | |
85 op_data.current_output_plugin = NULL; | |
86 return; | |
87 } | |
88 | |
89 op_data.current_output_plugin = node->data; | |
90 | |
91 | |
92 #if 0 | |
93 playing = bmp_playback_get_playing(); | |
94 if (playing) { | |
95 | |
96 /* FIXME: we do all on our own here */ | |
97 | |
98 guint min = 0, sec = 0, params, time, pos; | |
99 gchar timestr[10]; | |
100 | |
101 bmp_playback_pause(); | |
102 pos = get_playlist_position(); | |
103 time = bmp_playback_get_time() / 1000; | |
104 g_snprintf(timestr, sizeof(timestr), "%u:%2.2u", | |
105 time / 60, time % 60); | |
106 | |
107 params = sscanf(timestr, "%u:%u", &min, &sec); | |
108 if (params == 2) | |
109 time = (min * 60) + sec; | |
110 else if (params == 1) | |
111 time = min; | |
112 else | |
113 return; | |
114 | |
115 bmp_playback_stop(); | |
116 playlist_set_position(pos); | |
117 bmp_playback_play_file(playlist_get_filename(pos)); | |
118 | |
119 while (!bmp_playback_get_playing()) | |
120 g_message("waiting..."); | |
121 | |
122 if (playlist_get_current_length() > -1 && | |
123 time <= (playlist_get_current_length() / 1000)) { | |
124 /* Some time for things to cool down and heat up */ | |
125 g_usleep(1000000); | |
126 bmp_playback_seek(time); | |
127 } | |
128 } | |
129 #endif | |
130 } | |
131 | |
132 GList * | |
133 get_output_list(void) | |
134 { | |
135 return op_data.output_list; | |
136 } | |
137 | |
138 void | |
139 output_about(gint i) | |
140 { | |
141 OutputPlugin *out = g_list_nth(op_data.output_list, i)->data; | |
142 if (out && out->about) | |
143 out->about(); | |
144 } | |
145 | |
146 void | |
147 output_configure(gint i) | |
148 { | |
149 OutputPlugin *out = g_list_nth(op_data.output_list, i)->data; | |
150 if (out && out->configure) | |
151 out->configure(); | |
152 } | |
153 | |
154 void | |
155 output_get_volume(gint * l, gint * r) | |
156 { | |
157 *l = *r = -1; | |
158 | |
159 if (!op_data.current_output_plugin) | |
160 return; | |
161 | |
162 if (!op_data.current_output_plugin->get_volume) | |
163 return; | |
164 | |
165 op_data.current_output_plugin->get_volume(l, r); | |
166 } | |
167 | |
168 void | |
169 output_set_volume(gint l, gint r) | |
170 { | |
171 if (!op_data.current_output_plugin) | |
172 return; | |
173 | |
174 if (!op_data.current_output_plugin->set_volume) | |
175 return; | |
176 | |
177 op_data.current_output_plugin->set_volume(l, r); | |
178 } | |
179 | |
180 void | |
181 output_set_eq(gboolean active, gfloat pre, gfloat * bands) | |
182 { | |
183 int i; | |
430
67cd014f35a2
[svn] This commit rips out the old equalization engine with a dynamic engine
nenolod
parents:
0
diff
changeset
|
184 preamp[0] = 1.0 + 0.0932471 * pre + 0.00279033 * pre * pre; |
67cd014f35a2
[svn] This commit rips out the old equalization engine with a dynamic engine
nenolod
parents:
0
diff
changeset
|
185 preamp[1] = 1.0 + 0.0932471 * pre + 0.00279033 * pre * pre; |
67cd014f35a2
[svn] This commit rips out the old equalization engine with a dynamic engine
nenolod
parents:
0
diff
changeset
|
186 |
0 | 187 for (i = 0; i < 10; ++i) |
430
67cd014f35a2
[svn] This commit rips out the old equalization engine with a dynamic engine
nenolod
parents:
0
diff
changeset
|
188 { |
67cd014f35a2
[svn] This commit rips out the old equalization engine with a dynamic engine
nenolod
parents:
0
diff
changeset
|
189 set_gain(i, 0, 0.03 * bands[i] + 0.000999999 * bands[i] * bands[i]); |
67cd014f35a2
[svn] This commit rips out the old equalization engine with a dynamic engine
nenolod
parents:
0
diff
changeset
|
190 set_gain(i, 1, 0.03 * bands[i] + 0.000999999 * bands[i] * bands[i]); |
67cd014f35a2
[svn] This commit rips out the old equalization engine with a dynamic engine
nenolod
parents:
0
diff
changeset
|
191 } |
0 | 192 } |
193 | |
194 /* this should be in BYTES, NOT gint16s */ | |
195 static void | |
196 byteswap(size_t size, | |
197 gint16 * buf) | |
198 { | |
199 gint16 *it; | |
200 size &= ~1; /* must be multiple of 2 */ | |
201 for (it = buf; it < buf + size / 2; ++it) | |
202 *(guint16 *) it = GUINT16_SWAP_LE_BE(*(guint16 *) it); | |
203 } | |
204 | |
806 | 205 /* called by input plugin to peek at the output plugin's write progress */ |
206 gint | |
207 get_written_time(void) | |
208 { | |
209 OutputPlugin *op = get_current_output_plugin(); | |
210 | |
211 return op->written_time(); | |
212 } | |
213 | |
214 /* called by input plugin to peek at the output plugin's output progress */ | |
215 gint | |
216 get_output_time(void) | |
217 { | |
218 OutputPlugin *op = get_current_output_plugin(); | |
219 | |
220 return op->output_time(); | |
221 } | |
222 | |
890
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
223 gint |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
224 output_open_audio(AFormat fmt, gint rate, gint nch) |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
225 { |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
226 gint ret; |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
227 OutputPlugin *op; |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
228 |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
229 op = get_current_output_plugin(); |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
230 |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
231 if (op == NULL) |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
232 return -1; |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
233 |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
234 /* Is our output port already open? */ |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
235 if ((op_state.rate != 0 && op_state.nch != 0) && |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
236 (op_state.rate == rate && op_state.nch == nch)) |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
237 { |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
238 /* Yes, and it's the correct sampling rate. Reset the counter and go. */ |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
239 op->flush(0); |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
240 return 1; |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
241 } |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
242 else if (op_state.rate != 0 && op_state.nch != 0) |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
243 op->close_audio(); |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
244 |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
245 ret = op->open_audio(fmt, rate, nch); |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
246 |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
247 if (ret == 1) /* Success? */ |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
248 { |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
249 op_state.fmt = fmt; |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
250 op_state.rate = rate; |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
251 op_state.nch = nch; |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
252 } |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
253 |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
254 return ret; |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
255 } |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
256 |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
257 void |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
258 output_write_audio(gpointer ptr, gint length) |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
259 { |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
260 OutputPlugin *op = get_current_output_plugin(); |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
261 |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
262 /* Sanity check. */ |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
263 if (op == NULL) |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
264 return; |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
265 |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
266 op->write_audio(ptr, length); |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
267 } |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
268 |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
269 void |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
270 output_close_audio(void) |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
271 { |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
272 OutputPlugin *op = get_current_output_plugin(); |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
273 |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
274 /* Do not close if there are still songs to play and the user has |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
275 * not requested a stop. --nenolod |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
276 */ |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
277 if (ip_data.stop == FALSE && |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
278 (playlist_get_position_nolock() < playlist_get_length_nolock() - 1)) |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
279 return; |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
280 |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
281 /* Sanity check. */ |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
282 if (op == NULL) |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
283 return; |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
284 |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
285 #if 0 |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
286 g_print("Requirements to close audio output have been met:\n" |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
287 "ip_data.stop = %d\n" |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
288 "playlist_get_position_nolock() = %d\n" |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
289 "playlist_get_length_nolock() - 1 = %d\n", |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
290 ip_data.stop, playlist_get_position_nolock(), |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
291 playlist_get_length_nolock() - 1); |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
292 #endif |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
293 |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
294 op->close_audio(); |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
295 |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
296 /* Reset the op_state. */ |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
297 op_state.fmt = op_state.rate = op_state.nch = 0; |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
298 } |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
299 |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
300 void |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
301 output_flush(gint time) |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
302 { |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
303 OutputPlugin *op = get_current_output_plugin(); |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
304 |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
305 if (op == NULL) |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
306 return; |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
307 |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
308 op->flush(time); |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
309 } |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
310 |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
311 void |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
312 output_pause(gshort paused) |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
313 { |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
314 OutputPlugin *op = get_current_output_plugin(); |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
315 |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
316 if (op == NULL) |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
317 return; |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
318 |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
319 op->pause(paused); |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
320 } |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
321 |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
322 gint |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
323 output_buffer_free(void) |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
324 { |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
325 OutputPlugin *op = get_current_output_plugin(); |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
326 |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
327 if (op == NULL) |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
328 return 0; |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
329 |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
330 return op->buffer_free(); |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
331 } |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
332 |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
333 gint |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
334 output_buffer_playing(void) |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
335 { |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
336 OutputPlugin *op = get_current_output_plugin(); |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
337 |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
338 if (op == NULL) |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
339 return 0; |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
340 |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
341 return op->buffer_playing(); |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
342 } |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
343 |
0 | 344 /* called by input plugin when data is ready */ |
345 void | |
346 produce_audio(gint time, /* position */ | |
347 AFormat fmt, /* output format */ | |
348 gint nch, /* channels */ | |
349 gint length, /* length of sample */ | |
350 gpointer ptr, /* data */ | |
351 int *going /* 0 when time to stop */ | |
352 ) | |
353 { | |
354 static int init = 0; | |
355 int swapped = 0; | |
625
0a73d1faeb4e
[svn] GCC 4.1 warning fixes by Diego 'Flameeyes' Petteno from Gentoo.
chainsaw
parents:
519
diff
changeset
|
356 guint myorder = G_BYTE_ORDER == G_LITTLE_ENDIAN ? FMT_S16_LE : FMT_S16_BE; |
0 | 357 int caneq = (fmt == FMT_S16_NE || fmt == myorder); |
518 | 358 OutputPlugin *op = get_current_output_plugin(); |
929
54b23650fac1
[svn] - experimental produce-audio changes via shd of the UADE team
nenolod
parents:
890
diff
changeset
|
359 int writeoffs; |
0 | 360 |
361 if (!caneq && cfg.equalizer_active) { /* wrong byte order */ | |
362 byteswap(length, ptr); /* so convert */ | |
363 ++swapped; | |
364 ++caneq; | |
365 } /* can eq now, mark swapd */ | |
366 else if (caneq && !cfg.equalizer_active) /* right order but no eq */ | |
367 caneq = 0; /* so don't eq */ | |
368 | |
369 if (caneq) { /* if eq enab */ | |
370 if (!init) { /* if first run */ | |
371 init_iir(); /* then init eq */ | |
372 ++init; | |
373 } | |
374 | |
430
67cd014f35a2
[svn] This commit rips out the old equalization engine with a dynamic engine
nenolod
parents:
0
diff
changeset
|
375 iir(&ptr, length, nch); |
0 | 376 |
377 if (swapped) /* if was swapped */ | |
378 byteswap(length, ptr); /* swap back for output */ | |
379 } | |
380 | |
518 | 381 /* do vis plugin(s) */ |
519
88e9a6a8336f
[svn] whoever wrote output_to_audio() was a crackhead.
nenolod
parents:
518
diff
changeset
|
382 input_add_vis_pcm(time, fmt, nch, length, ptr); |
0 | 383 |
929
54b23650fac1
[svn] - experimental produce-audio changes via shd of the UADE team
nenolod
parents:
890
diff
changeset
|
384 writeoffs = 0; |
54b23650fac1
[svn] - experimental produce-audio changes via shd of the UADE team
nenolod
parents:
890
diff
changeset
|
385 while (writeoffs < length) { |
54b23650fac1
[svn] - experimental produce-audio changes via shd of the UADE team
nenolod
parents:
890
diff
changeset
|
386 int writable = length - writeoffs; |
54b23650fac1
[svn] - experimental produce-audio changes via shd of the UADE team
nenolod
parents:
890
diff
changeset
|
387 |
54b23650fac1
[svn] - experimental produce-audio changes via shd of the UADE team
nenolod
parents:
890
diff
changeset
|
388 if (writable > 2048) |
54b23650fac1
[svn] - experimental produce-audio changes via shd of the UADE team
nenolod
parents:
890
diff
changeset
|
389 writable = 2048; |
518 | 390 |
1051
6e95edd16b43
[svn] - if writable == 0 then bail out of produce_audio() instead of segfault
nenolod
parents:
1036
diff
changeset
|
391 if (writable == 0) |
6e95edd16b43
[svn] - if writable == 0 then bail out of produce_audio() instead of segfault
nenolod
parents:
1036
diff
changeset
|
392 return; |
6e95edd16b43
[svn] - if writable == 0 then bail out of produce_audio() instead of segfault
nenolod
parents:
1036
diff
changeset
|
393 |
1036
976a54334538
[svn] - abort out of produce_audio if a stop has been requested
nenolod
parents:
929
diff
changeset
|
394 while (op->buffer_free() < writable) { /* wait output buf */ |
976a54334538
[svn] - abort out of produce_audio if a stop has been requested
nenolod
parents:
929
diff
changeset
|
395 if (going && !*going) /* thread stopped? */ |
976a54334538
[svn] - abort out of produce_audio if a stop has been requested
nenolod
parents:
929
diff
changeset
|
396 return; /* so finish */ |
929
54b23650fac1
[svn] - experimental produce-audio changes via shd of the UADE team
nenolod
parents:
890
diff
changeset
|
397 |
1036
976a54334538
[svn] - abort out of produce_audio if a stop has been requested
nenolod
parents:
929
diff
changeset
|
398 if (ip_data.stop) /* has a stop been requested? */ |
976a54334538
[svn] - abort out of produce_audio if a stop has been requested
nenolod
parents:
929
diff
changeset
|
399 return; /* yes, so finish */ |
976a54334538
[svn] - abort out of produce_audio if a stop has been requested
nenolod
parents:
929
diff
changeset
|
400 |
976a54334538
[svn] - abort out of produce_audio if a stop has been requested
nenolod
parents:
929
diff
changeset
|
401 g_usleep(10000); /* else sleep for retry */ |
929
54b23650fac1
[svn] - experimental produce-audio changes via shd of the UADE team
nenolod
parents:
890
diff
changeset
|
402 } |
518 | 403 |
1053 | 404 if (ip_data.stop) |
405 return; | |
406 | |
929
54b23650fac1
[svn] - experimental produce-audio changes via shd of the UADE team
nenolod
parents:
890
diff
changeset
|
407 /* do output */ |
54b23650fac1
[svn] - experimental produce-audio changes via shd of the UADE team
nenolod
parents:
890
diff
changeset
|
408 op->write_audio(((guint8 *) ptr) + writeoffs, writable); |
54b23650fac1
[svn] - experimental produce-audio changes via shd of the UADE team
nenolod
parents:
890
diff
changeset
|
409 |
54b23650fac1
[svn] - experimental produce-audio changes via shd of the UADE team
nenolod
parents:
890
diff
changeset
|
410 writeoffs += writable; |
54b23650fac1
[svn] - experimental produce-audio changes via shd of the UADE team
nenolod
parents:
890
diff
changeset
|
411 } |
0 | 412 } |