Mercurial > audlegacy
annotate audacious/output.c @ 1860:5edb4f242bf6 trunk
[svn] - cleanup some skin textures
author | nenolod |
---|---|
date | Wed, 11 Oct 2006 19:44:00 -0700 |
parents | def887eae029 |
children | a99862e5bd65 |
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 | |
1459 | 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
0 | 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 /* FIXME: we do all on our own here */ | |
96 | |
97 guint min = 0, sec = 0, params, time, pos; | |
98 gchar timestr[10]; | |
99 | |
100 bmp_playback_pause(); | |
101 pos = get_playlist_position(); | |
102 time = bmp_playback_get_time() / 1000; | |
103 g_snprintf(timestr, sizeof(timestr), "%u:%2.2u", | |
104 time / 60, time % 60); | |
105 | |
106 params = sscanf(timestr, "%u:%u", &min, &sec); | |
107 if (params == 2) | |
108 time = (min * 60) + sec; | |
109 else if (params == 1) | |
110 time = min; | |
111 else | |
112 return; | |
113 | |
114 bmp_playback_stop(); | |
115 playlist_set_position(pos); | |
116 bmp_playback_play_file(playlist_get_filename(pos)); | |
117 | |
118 while (!bmp_playback_get_playing()) | |
119 g_message("waiting..."); | |
120 | |
121 if (playlist_get_current_length() > -1 && | |
122 time <= (playlist_get_current_length() / 1000)) { | |
123 /* Some time for things to cool down and heat up */ | |
124 g_usleep(1000000); | |
125 bmp_playback_seek(time); | |
126 } | |
127 } | |
128 #endif | |
129 } | |
130 | |
131 GList * | |
132 get_output_list(void) | |
133 { | |
134 return op_data.output_list; | |
135 } | |
136 | |
137 void | |
138 output_about(gint i) | |
139 { | |
140 OutputPlugin *out = g_list_nth(op_data.output_list, i)->data; | |
141 if (out && out->about) | |
142 out->about(); | |
143 } | |
144 | |
145 void | |
146 output_configure(gint i) | |
147 { | |
148 OutputPlugin *out = g_list_nth(op_data.output_list, i)->data; | |
149 if (out && out->configure) | |
150 out->configure(); | |
151 } | |
152 | |
153 void | |
154 output_get_volume(gint * l, gint * r) | |
155 { | |
156 *l = *r = -1; | |
157 | |
158 if (!op_data.current_output_plugin) | |
159 return; | |
160 | |
161 if (!op_data.current_output_plugin->get_volume) | |
162 return; | |
163 | |
164 op_data.current_output_plugin->get_volume(l, r); | |
165 } | |
166 | |
167 void | |
168 output_set_volume(gint l, gint r) | |
169 { | |
170 if (!op_data.current_output_plugin) | |
171 return; | |
172 | |
173 if (!op_data.current_output_plugin->set_volume) | |
174 return; | |
175 | |
176 op_data.current_output_plugin->set_volume(l, r); | |
177 } | |
178 | |
179 void | |
180 output_set_eq(gboolean active, gfloat pre, gfloat * bands) | |
181 { | |
182 int i; | |
430
67cd014f35a2
[svn] This commit rips out the old equalization engine with a dynamic engine
nenolod
parents:
0
diff
changeset
|
183 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
|
184 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
|
185 |
0 | 186 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
|
187 { |
67cd014f35a2
[svn] This commit rips out the old equalization engine with a dynamic engine
nenolod
parents:
0
diff
changeset
|
188 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
|
189 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
|
190 } |
0 | 191 } |
192 | |
193 /* this should be in BYTES, NOT gint16s */ | |
194 static void | |
195 byteswap(size_t size, | |
196 gint16 * buf) | |
197 { | |
198 gint16 *it; | |
199 size &= ~1; /* must be multiple of 2 */ | |
200 for (it = buf; it < buf + size / 2; ++it) | |
201 *(guint16 *) it = GUINT16_SWAP_LE_BE(*(guint16 *) it); | |
202 } | |
203 | |
806 | 204 /* called by input plugin to peek at the output plugin's write progress */ |
205 gint | |
206 get_written_time(void) | |
207 { | |
208 OutputPlugin *op = get_current_output_plugin(); | |
209 | |
210 return op->written_time(); | |
211 } | |
212 | |
213 /* called by input plugin to peek at the output plugin's output progress */ | |
214 gint | |
215 get_output_time(void) | |
216 { | |
217 OutputPlugin *op = get_current_output_plugin(); | |
218 | |
219 return op->output_time(); | |
220 } | |
221 | |
890
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
222 gint |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
223 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
|
224 { |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
225 gint ret; |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
226 OutputPlugin *op; |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
227 |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
228 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
|
229 |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
230 if (op == NULL) |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
231 return -1; |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
232 |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
233 /* 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
|
234 if ((op_state.rate != 0 && op_state.nch != 0) && |
1768 | 235 (op_state.rate == rate && op_state.nch == nch && op_state.fmt == fmt)) |
890
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
236 { |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
237 /* 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
|
238 op->flush(0); |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
239 return 1; |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
240 } |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
241 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
|
242 op->close_audio(); |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
243 |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
244 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
|
245 |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
246 if (ret == 1) /* Success? */ |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
247 { |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
248 op_state.fmt = fmt; |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
249 op_state.rate = rate; |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
250 op_state.nch = nch; |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
251 } |
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 return ret; |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
254 } |
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 void |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
257 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
|
258 { |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
259 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
|
260 |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
261 /* Sanity check. */ |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
262 if (op == NULL) |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
263 return; |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
264 |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
265 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
|
266 } |
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 void |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
269 output_close_audio(void) |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
270 { |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
271 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
|
272 |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
273 /* 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
|
274 * 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
|
275 */ |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
276 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
|
277 (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
|
278 return; |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
279 |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
280 /* Sanity check. */ |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
281 if (op == NULL) |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
282 return; |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
283 |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
284 op->close_audio(); |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
285 |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
286 /* Reset the op_state. */ |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
287 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
|
288 } |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
289 |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
290 void |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
291 output_flush(gint time) |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
292 { |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
293 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
|
294 |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
295 if (op == NULL) |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
296 return; |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
297 |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
298 op->flush(time); |
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 |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
301 void |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
302 output_pause(gshort paused) |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
303 { |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
304 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
|
305 |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
306 if (op == NULL) |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
307 return; |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
308 |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
309 op->pause(paused); |
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 |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
312 gint |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
313 output_buffer_free(void) |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
314 { |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
315 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
|
316 |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
317 if (op == NULL) |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
318 return 0; |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
319 |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
320 return op->buffer_free(); |
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 |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
323 gint |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
324 output_buffer_playing(void) |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
325 { |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
326 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
|
327 |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
328 if (op == NULL) |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
329 return 0; |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
330 |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
331 return op->buffer_playing(); |
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 |
0 | 334 /* called by input plugin when data is ready */ |
335 void | |
336 produce_audio(gint time, /* position */ | |
337 AFormat fmt, /* output format */ | |
338 gint nch, /* channels */ | |
339 gint length, /* length of sample */ | |
340 gpointer ptr, /* data */ | |
341 int *going /* 0 when time to stop */ | |
342 ) | |
343 { | |
344 static int init = 0; | |
345 int swapped = 0; | |
625
0a73d1faeb4e
[svn] GCC 4.1 warning fixes by Diego 'Flameeyes' Petteno from Gentoo.
chainsaw
parents:
519
diff
changeset
|
346 guint myorder = G_BYTE_ORDER == G_LITTLE_ENDIAN ? FMT_S16_LE : FMT_S16_BE; |
0 | 347 int caneq = (fmt == FMT_S16_NE || fmt == myorder); |
518 | 348 OutputPlugin *op = get_current_output_plugin(); |
929
54b23650fac1
[svn] - experimental produce-audio changes via shd of the UADE team
nenolod
parents:
890
diff
changeset
|
349 int writeoffs; |
0 | 350 |
351 if (!caneq && cfg.equalizer_active) { /* wrong byte order */ | |
352 byteswap(length, ptr); /* so convert */ | |
353 ++swapped; | |
354 ++caneq; | |
355 } /* can eq now, mark swapd */ | |
356 else if (caneq && !cfg.equalizer_active) /* right order but no eq */ | |
357 caneq = 0; /* so don't eq */ | |
358 | |
359 if (caneq) { /* if eq enab */ | |
360 if (!init) { /* if first run */ | |
361 init_iir(); /* then init eq */ | |
362 ++init; | |
363 } | |
364 | |
430
67cd014f35a2
[svn] This commit rips out the old equalization engine with a dynamic engine
nenolod
parents:
0
diff
changeset
|
365 iir(&ptr, length, nch); |
0 | 366 |
367 if (swapped) /* if was swapped */ | |
368 byteswap(length, ptr); /* swap back for output */ | |
369 } | |
370 | |
518 | 371 /* do vis plugin(s) */ |
519
88e9a6a8336f
[svn] whoever wrote output_to_audio() was a crackhead.
nenolod
parents:
518
diff
changeset
|
372 input_add_vis_pcm(time, fmt, nch, length, ptr); |
0 | 373 |
929
54b23650fac1
[svn] - experimental produce-audio changes via shd of the UADE team
nenolod
parents:
890
diff
changeset
|
374 writeoffs = 0; |
54b23650fac1
[svn] - experimental produce-audio changes via shd of the UADE team
nenolod
parents:
890
diff
changeset
|
375 while (writeoffs < length) { |
54b23650fac1
[svn] - experimental produce-audio changes via shd of the UADE team
nenolod
parents:
890
diff
changeset
|
376 int writable = length - writeoffs; |
54b23650fac1
[svn] - experimental produce-audio changes via shd of the UADE team
nenolod
parents:
890
diff
changeset
|
377 |
54b23650fac1
[svn] - experimental produce-audio changes via shd of the UADE team
nenolod
parents:
890
diff
changeset
|
378 if (writable > 2048) |
54b23650fac1
[svn] - experimental produce-audio changes via shd of the UADE team
nenolod
parents:
890
diff
changeset
|
379 writable = 2048; |
518 | 380 |
1051
6e95edd16b43
[svn] - if writable == 0 then bail out of produce_audio() instead of segfault
nenolod
parents:
1036
diff
changeset
|
381 if (writable == 0) |
6e95edd16b43
[svn] - if writable == 0 then bail out of produce_audio() instead of segfault
nenolod
parents:
1036
diff
changeset
|
382 return; |
6e95edd16b43
[svn] - if writable == 0 then bail out of produce_audio() instead of segfault
nenolod
parents:
1036
diff
changeset
|
383 |
1036
976a54334538
[svn] - abort out of produce_audio if a stop has been requested
nenolod
parents:
929
diff
changeset
|
384 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
|
385 if (going && !*going) /* thread stopped? */ |
976a54334538
[svn] - abort out of produce_audio if a stop has been requested
nenolod
parents:
929
diff
changeset
|
386 return; /* so finish */ |
929
54b23650fac1
[svn] - experimental produce-audio changes via shd of the UADE team
nenolod
parents:
890
diff
changeset
|
387 |
1036
976a54334538
[svn] - abort out of produce_audio if a stop has been requested
nenolod
parents:
929
diff
changeset
|
388 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
|
389 return; /* yes, so finish */ |
976a54334538
[svn] - abort out of produce_audio if a stop has been requested
nenolod
parents:
929
diff
changeset
|
390 |
976a54334538
[svn] - abort out of produce_audio if a stop has been requested
nenolod
parents:
929
diff
changeset
|
391 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
|
392 } |
518 | 393 |
1053 | 394 if (ip_data.stop) |
395 return; | |
396 | |
929
54b23650fac1
[svn] - experimental produce-audio changes via shd of the UADE team
nenolod
parents:
890
diff
changeset
|
397 /* do output */ |
54b23650fac1
[svn] - experimental produce-audio changes via shd of the UADE team
nenolod
parents:
890
diff
changeset
|
398 op->write_audio(((guint8 *) ptr) + writeoffs, writable); |
54b23650fac1
[svn] - experimental produce-audio changes via shd of the UADE team
nenolod
parents:
890
diff
changeset
|
399 |
54b23650fac1
[svn] - experimental produce-audio changes via shd of the UADE team
nenolod
parents:
890
diff
changeset
|
400 writeoffs += writable; |
54b23650fac1
[svn] - experimental produce-audio changes via shd of the UADE team
nenolod
parents:
890
diff
changeset
|
401 } |
0 | 402 } |