Mercurial > audlegacy
annotate audacious/output.c @ 2097:75100f6b216a trunk
[svn] - make sure &default_playlist (temporary construct) has full padding.
probably won't help this, but it seems like it wont hurt, either.
author | nenolod |
---|---|
date | Mon, 11 Dec 2006 05:47:05 -0800 |
parents | ef095eb43578 |
children | f18a5b617c34 |
rev | line source |
---|---|
2067
0b0a12ea9dd9
[svn] - allow the output plugin to be changed while playing.
nenolod
parents:
2017
diff
changeset
|
1 /* Audacious |
0b0a12ea9dd9
[svn] - allow the output plugin to be changed while playing.
nenolod
parents:
2017
diff
changeset
|
2 * Copyright (C) 2005-2007 Audacious team |
0b0a12ea9dd9
[svn] - allow the output plugin to be changed while playing.
nenolod
parents:
2017
diff
changeset
|
3 * |
0b0a12ea9dd9
[svn] - allow the output plugin to be changed while playing.
nenolod
parents:
2017
diff
changeset
|
4 * BMP - Cross-platform multimedia player |
0 | 5 * Copyright (C) 2003-2004 BMP development team. |
6 * | |
7 * Based on XMMS: | |
8 * Copyright (C) 1998-2003 XMMS development team. | |
9 * | |
10 * This program is free software; you can redistribute it and/or modify | |
11 * it under the terms of the GNU General Public License as published by | |
12 * the Free Software Foundation; either version 2 of the License, or | |
13 * (at your option) any later version. | |
14 * | |
15 * This program is distributed in the hope that it will be useful, | |
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 * GNU General Public License for more details. | |
19 * | |
20 * You should have received a copy of the GNU General Public License | |
21 * along with this program; if not, write to the Free Software | |
1459 | 22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
0 | 23 */ |
24 | |
25 #ifdef HAVE_CONFIG_H | |
26 # include "config.h" | |
27 #endif | |
28 | |
29 #include "output.h" | |
30 #include "iir.h" | |
31 #include "main.h" | |
32 #include "input.h" | |
33 | |
34 #include "playlist.h" | |
35 #include "libaudacious/util.h" | |
36 | |
37 OutputPluginData op_data = { | |
38 NULL, | |
39 NULL | |
40 }; | |
41 | |
890
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
42 OutputPluginState op_state = { |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
43 0, |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
44 0, |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
45 0 |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
46 }; |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
47 |
809 | 48 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
|
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 "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
|
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 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
|
54 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
|
55 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
|
56 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
|
57 output_set_volume, |
890
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
58 output_open_audio, |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
59 output_write_audio, |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
60 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
|
61 |
890
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
62 output_flush, |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
63 output_pause, |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
64 output_buffer_free, |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
65 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
|
66 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
|
67 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
|
68 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
|
69 }; |
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
|
70 |
0 | 71 OutputPlugin * |
72 get_current_output_plugin(void) | |
73 { | |
74 return op_data.current_output_plugin; | |
75 } | |
76 | |
77 void | |
78 set_current_output_plugin(gint i) | |
79 { | |
80 gint time; | |
81 gint pos; | |
82 gboolean playing; | |
2067
0b0a12ea9dd9
[svn] - allow the output plugin to be changed while playing.
nenolod
parents:
2017
diff
changeset
|
83 OutputPlugin *op = get_current_output_plugin(); |
0 | 84 |
85 GList *node = g_list_nth(op_data.output_list, i); | |
86 if (!node) { | |
87 op_data.current_output_plugin = NULL; | |
88 return; | |
89 } | |
90 | |
91 op_data.current_output_plugin = node->data; | |
92 | |
2067
0b0a12ea9dd9
[svn] - allow the output plugin to be changed while playing.
nenolod
parents:
2017
diff
changeset
|
93 playing = bmp_playback_get_playing(); |
0 | 94 |
2067
0b0a12ea9dd9
[svn] - allow the output plugin to be changed while playing.
nenolod
parents:
2017
diff
changeset
|
95 if (playing == TRUE) |
0b0a12ea9dd9
[svn] - allow the output plugin to be changed while playing.
nenolod
parents:
2017
diff
changeset
|
96 { |
0b0a12ea9dd9
[svn] - allow the output plugin to be changed while playing.
nenolod
parents:
2017
diff
changeset
|
97 gint i = 99; |
0b0a12ea9dd9
[svn] - allow the output plugin to be changed while playing.
nenolod
parents:
2017
diff
changeset
|
98 guint time, pos; |
0b0a12ea9dd9
[svn] - allow the output plugin to be changed while playing.
nenolod
parents:
2017
diff
changeset
|
99 PlaylistEntry *entry; |
0b0a12ea9dd9
[svn] - allow the output plugin to be changed while playing.
nenolod
parents:
2017
diff
changeset
|
100 |
0b0a12ea9dd9
[svn] - allow the output plugin to be changed while playing.
nenolod
parents:
2017
diff
changeset
|
101 /* don't stop yet, get the seek time and playlist position first */ |
2089 | 102 pos = playlist_get_position(playlist_get_active()); |
2067
0b0a12ea9dd9
[svn] - allow the output plugin to be changed while playing.
nenolod
parents:
2017
diff
changeset
|
103 time = op->output_time(); |
0b0a12ea9dd9
[svn] - allow the output plugin to be changed while playing.
nenolod
parents:
2017
diff
changeset
|
104 |
0b0a12ea9dd9
[svn] - allow the output plugin to be changed while playing.
nenolod
parents:
2017
diff
changeset
|
105 /* reset the audio system */ |
0b0a12ea9dd9
[svn] - allow the output plugin to be changed while playing.
nenolod
parents:
2017
diff
changeset
|
106 mainwin_stop_pushed(); |
0b0a12ea9dd9
[svn] - allow the output plugin to be changed while playing.
nenolod
parents:
2017
diff
changeset
|
107 op->close_audio(); |
0b0a12ea9dd9
[svn] - allow the output plugin to be changed while playing.
nenolod
parents:
2017
diff
changeset
|
108 |
0b0a12ea9dd9
[svn] - allow the output plugin to be changed while playing.
nenolod
parents:
2017
diff
changeset
|
109 g_usleep(300000); |
0b0a12ea9dd9
[svn] - allow the output plugin to be changed while playing.
nenolod
parents:
2017
diff
changeset
|
110 |
0b0a12ea9dd9
[svn] - allow the output plugin to be changed while playing.
nenolod
parents:
2017
diff
changeset
|
111 /* wait for the playback thread to come online */ |
0b0a12ea9dd9
[svn] - allow the output plugin to be changed while playing.
nenolod
parents:
2017
diff
changeset
|
112 while (bmp_playback_get_playing()) |
0b0a12ea9dd9
[svn] - allow the output plugin to be changed while playing.
nenolod
parents:
2017
diff
changeset
|
113 g_message("waiting for audio system shutdown..."); |
0b0a12ea9dd9
[svn] - allow the output plugin to be changed while playing.
nenolod
parents:
2017
diff
changeset
|
114 |
0b0a12ea9dd9
[svn] - allow the output plugin to be changed while playing.
nenolod
parents:
2017
diff
changeset
|
115 /* wait for the playback thread to come online */ |
2089 | 116 playlist_set_position(playlist_get_active(), pos); |
117 entry = playlist_get_entry_to_play(playlist_get_active()); | |
2067
0b0a12ea9dd9
[svn] - allow the output plugin to be changed while playing.
nenolod
parents:
2017
diff
changeset
|
118 bmp_playback_play_file(entry); |
0 | 119 |
2067
0b0a12ea9dd9
[svn] - allow the output plugin to be changed while playing.
nenolod
parents:
2017
diff
changeset
|
120 while (!bmp_playback_get_playing()) |
0b0a12ea9dd9
[svn] - allow the output plugin to be changed while playing.
nenolod
parents:
2017
diff
changeset
|
121 { |
0b0a12ea9dd9
[svn] - allow the output plugin to be changed while playing.
nenolod
parents:
2017
diff
changeset
|
122 gtk_main_iteration(); |
0b0a12ea9dd9
[svn] - allow the output plugin to be changed while playing.
nenolod
parents:
2017
diff
changeset
|
123 g_message("waiting for audio system startup..."); |
0b0a12ea9dd9
[svn] - allow the output plugin to be changed while playing.
nenolod
parents:
2017
diff
changeset
|
124 } |
0b0a12ea9dd9
[svn] - allow the output plugin to be changed while playing.
nenolod
parents:
2017
diff
changeset
|
125 |
0b0a12ea9dd9
[svn] - allow the output plugin to be changed while playing.
nenolod
parents:
2017
diff
changeset
|
126 /* and signal a reseek */ |
2089 | 127 if (playlist_get_current_length(playlist_get_active()) > -1 && |
128 time <= (playlist_get_current_length(playlist_get_active()))) | |
2067
0b0a12ea9dd9
[svn] - allow the output plugin to be changed while playing.
nenolod
parents:
2017
diff
changeset
|
129 { |
0b0a12ea9dd9
[svn] - allow the output plugin to be changed while playing.
nenolod
parents:
2017
diff
changeset
|
130 gint i; |
0b0a12ea9dd9
[svn] - allow the output plugin to be changed while playing.
nenolod
parents:
2017
diff
changeset
|
131 |
0b0a12ea9dd9
[svn] - allow the output plugin to be changed while playing.
nenolod
parents:
2017
diff
changeset
|
132 bmp_playback_seek(time / 1000); |
0 | 133 } |
134 } | |
135 } | |
136 | |
137 GList * | |
138 get_output_list(void) | |
139 { | |
140 return op_data.output_list; | |
141 } | |
142 | |
143 void | |
144 output_about(gint i) | |
145 { | |
146 OutputPlugin *out = g_list_nth(op_data.output_list, i)->data; | |
147 if (out && out->about) | |
148 out->about(); | |
149 } | |
150 | |
151 void | |
152 output_configure(gint i) | |
153 { | |
154 OutputPlugin *out = g_list_nth(op_data.output_list, i)->data; | |
155 if (out && out->configure) | |
156 out->configure(); | |
157 } | |
158 | |
159 void | |
160 output_get_volume(gint * l, gint * r) | |
161 { | |
162 *l = *r = -1; | |
163 | |
164 if (!op_data.current_output_plugin) | |
165 return; | |
166 | |
167 if (!op_data.current_output_plugin->get_volume) | |
168 return; | |
169 | |
170 op_data.current_output_plugin->get_volume(l, r); | |
171 } | |
172 | |
173 void | |
174 output_set_volume(gint l, gint r) | |
175 { | |
176 if (!op_data.current_output_plugin) | |
177 return; | |
178 | |
179 if (!op_data.current_output_plugin->set_volume) | |
180 return; | |
181 | |
182 op_data.current_output_plugin->set_volume(l, r); | |
183 } | |
184 | |
185 void | |
186 output_set_eq(gboolean active, gfloat pre, gfloat * bands) | |
187 { | |
188 int i; | |
430
67cd014f35a2
[svn] This commit rips out the old equalization engine with a dynamic engine
nenolod
parents:
0
diff
changeset
|
189 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
|
190 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
|
191 |
0 | 192 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
|
193 { |
67cd014f35a2
[svn] This commit rips out the old equalization engine with a dynamic engine
nenolod
parents:
0
diff
changeset
|
194 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
|
195 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
|
196 } |
0 | 197 } |
198 | |
199 /* this should be in BYTES, NOT gint16s */ | |
200 static void | |
201 byteswap(size_t size, | |
202 gint16 * buf) | |
203 { | |
204 gint16 *it; | |
205 size &= ~1; /* must be multiple of 2 */ | |
206 for (it = buf; it < buf + size / 2; ++it) | |
207 *(guint16 *) it = GUINT16_SWAP_LE_BE(*(guint16 *) it); | |
208 } | |
209 | |
806 | 210 /* called by input plugin to peek at the output plugin's write progress */ |
211 gint | |
212 get_written_time(void) | |
213 { | |
214 OutputPlugin *op = get_current_output_plugin(); | |
215 | |
216 return op->written_time(); | |
217 } | |
218 | |
219 /* called by input plugin to peek at the output plugin's output progress */ | |
220 gint | |
221 get_output_time(void) | |
222 { | |
223 OutputPlugin *op = get_current_output_plugin(); | |
224 | |
225 return op->output_time(); | |
226 } | |
227 | |
890
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
228 gint |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
229 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
|
230 { |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
231 gint ret; |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
232 OutputPlugin *op; |
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 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
|
235 |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
236 if (op == NULL) |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
237 return -1; |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
238 |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
239 /* 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
|
240 if ((op_state.rate != 0 && op_state.nch != 0) && |
1768 | 241 (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
|
242 { |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
243 /* 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
|
244 op->flush(0); |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
245 return 1; |
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 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
|
248 op->close_audio(); |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
249 |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
250 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
|
251 |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
252 if (ret == 1) /* Success? */ |
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 op_state.fmt = fmt; |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
255 op_state.rate = rate; |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
256 op_state.nch = nch; |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
257 } |
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 return ret; |
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 |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
262 void |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
263 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
|
264 { |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
265 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
|
266 |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
267 /* Sanity check. */ |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
268 if (op == NULL) |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
269 return; |
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 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
|
272 } |
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 void |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
275 output_close_audio(void) |
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 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
|
278 |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
279 /* 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
|
280 * 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
|
281 */ |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
282 if (ip_data.stop == FALSE && |
2089 | 283 (playlist_get_position_nolock(playlist_get_active()) < playlist_get_length_nolock(playlist_get_active()) - 1)) |
890
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
284 return; |
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 /* Sanity check. */ |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
287 if (op == NULL) |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
288 return; |
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 op->close_audio(); |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
291 |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
292 /* Reset the op_state. */ |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
293 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
|
294 } |
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 void |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
297 output_flush(gint time) |
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 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
|
300 |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
301 if (op == NULL) |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
302 return; |
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 op->flush(time); |
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 |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
307 void |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
308 output_pause(gshort paused) |
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 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
|
311 |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
312 if (op == NULL) |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
313 return; |
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 op->pause(paused); |
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 |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
318 gint |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
319 output_buffer_free(void) |
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 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
|
322 |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
323 if (op == NULL) |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
324 return 0; |
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 return op->buffer_free(); |
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 |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
329 gint |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
330 output_buffer_playing(void) |
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 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
|
333 |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
334 if (op == NULL) |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
335 return 0; |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
336 |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
337 return op->buffer_playing(); |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
338 } |
ed26947bbf57
[svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents:
809
diff
changeset
|
339 |
0 | 340 /* called by input plugin when data is ready */ |
341 void | |
342 produce_audio(gint time, /* position */ | |
343 AFormat fmt, /* output format */ | |
344 gint nch, /* channels */ | |
345 gint length, /* length of sample */ | |
346 gpointer ptr, /* data */ | |
347 int *going /* 0 when time to stop */ | |
348 ) | |
349 { | |
350 static int init = 0; | |
351 int swapped = 0; | |
625
0a73d1faeb4e
[svn] GCC 4.1 warning fixes by Diego 'Flameeyes' Petteno from Gentoo.
chainsaw
parents:
519
diff
changeset
|
352 guint myorder = G_BYTE_ORDER == G_LITTLE_ENDIAN ? FMT_S16_LE : FMT_S16_BE; |
0 | 353 int caneq = (fmt == FMT_S16_NE || fmt == myorder); |
518 | 354 OutputPlugin *op = get_current_output_plugin(); |
929
54b23650fac1
[svn] - experimental produce-audio changes via shd of the UADE team
nenolod
parents:
890
diff
changeset
|
355 int writeoffs; |
0 | 356 |
357 if (!caneq && cfg.equalizer_active) { /* wrong byte order */ | |
358 byteswap(length, ptr); /* so convert */ | |
359 ++swapped; | |
360 ++caneq; | |
361 } /* can eq now, mark swapd */ | |
362 else if (caneq && !cfg.equalizer_active) /* right order but no eq */ | |
363 caneq = 0; /* so don't eq */ | |
364 | |
365 if (caneq) { /* if eq enab */ | |
366 if (!init) { /* if first run */ | |
367 init_iir(); /* then init eq */ | |
368 ++init; | |
369 } | |
370 | |
430
67cd014f35a2
[svn] This commit rips out the old equalization engine with a dynamic engine
nenolod
parents:
0
diff
changeset
|
371 iir(&ptr, length, nch); |
0 | 372 |
373 if (swapped) /* if was swapped */ | |
374 byteswap(length, ptr); /* swap back for output */ | |
375 } | |
376 | |
518 | 377 /* do vis plugin(s) */ |
519
88e9a6a8336f
[svn] whoever wrote output_to_audio() was a crackhead.
nenolod
parents:
518
diff
changeset
|
378 input_add_vis_pcm(time, fmt, nch, length, ptr); |
0 | 379 |
929
54b23650fac1
[svn] - experimental produce-audio changes via shd of the UADE team
nenolod
parents:
890
diff
changeset
|
380 writeoffs = 0; |
54b23650fac1
[svn] - experimental produce-audio changes via shd of the UADE team
nenolod
parents:
890
diff
changeset
|
381 while (writeoffs < length) { |
54b23650fac1
[svn] - experimental produce-audio changes via shd of the UADE team
nenolod
parents:
890
diff
changeset
|
382 int writable = length - writeoffs; |
54b23650fac1
[svn] - experimental produce-audio changes via shd of the UADE team
nenolod
parents:
890
diff
changeset
|
383 |
54b23650fac1
[svn] - experimental produce-audio changes via shd of the UADE team
nenolod
parents:
890
diff
changeset
|
384 if (writable > 2048) |
54b23650fac1
[svn] - experimental produce-audio changes via shd of the UADE team
nenolod
parents:
890
diff
changeset
|
385 writable = 2048; |
518 | 386 |
1051
6e95edd16b43
[svn] - if writable == 0 then bail out of produce_audio() instead of segfault
nenolod
parents:
1036
diff
changeset
|
387 if (writable == 0) |
6e95edd16b43
[svn] - if writable == 0 then bail out of produce_audio() instead of segfault
nenolod
parents:
1036
diff
changeset
|
388 return; |
6e95edd16b43
[svn] - if writable == 0 then bail out of produce_audio() instead of segfault
nenolod
parents:
1036
diff
changeset
|
389 |
1036
976a54334538
[svn] - abort out of produce_audio if a stop has been requested
nenolod
parents:
929
diff
changeset
|
390 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
|
391 if (going && !*going) /* thread stopped? */ |
976a54334538
[svn] - abort out of produce_audio if a stop has been requested
nenolod
parents:
929
diff
changeset
|
392 return; /* so finish */ |
929
54b23650fac1
[svn] - experimental produce-audio changes via shd of the UADE team
nenolod
parents:
890
diff
changeset
|
393 |
1036
976a54334538
[svn] - abort out of produce_audio if a stop has been requested
nenolod
parents:
929
diff
changeset
|
394 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
|
395 return; /* yes, so finish */ |
976a54334538
[svn] - abort out of produce_audio if a stop has been requested
nenolod
parents:
929
diff
changeset
|
396 |
976a54334538
[svn] - abort out of produce_audio if a stop has been requested
nenolod
parents:
929
diff
changeset
|
397 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
|
398 } |
518 | 399 |
1053 | 400 if (ip_data.stop) |
401 return; | |
402 | |
2017
a99862e5bd65
[svn] - avoid a race condition in produce_audio() where we have closed output,
nenolod
parents:
1768
diff
changeset
|
403 if (going && !*going) /* thread stopped? */ |
a99862e5bd65
[svn] - avoid a race condition in produce_audio() where we have closed output,
nenolod
parents:
1768
diff
changeset
|
404 return; /* so finish */ |
a99862e5bd65
[svn] - avoid a race condition in produce_audio() where we have closed output,
nenolod
parents:
1768
diff
changeset
|
405 |
929
54b23650fac1
[svn] - experimental produce-audio changes via shd of the UADE team
nenolod
parents:
890
diff
changeset
|
406 /* do output */ |
54b23650fac1
[svn] - experimental produce-audio changes via shd of the UADE team
nenolod
parents:
890
diff
changeset
|
407 op->write_audio(((guint8 *) ptr) + writeoffs, writable); |
54b23650fac1
[svn] - experimental produce-audio changes via shd of the UADE team
nenolod
parents:
890
diff
changeset
|
408 |
54b23650fac1
[svn] - experimental produce-audio changes via shd of the UADE team
nenolod
parents:
890
diff
changeset
|
409 writeoffs += writable; |
54b23650fac1
[svn] - experimental produce-audio changes via shd of the UADE team
nenolod
parents:
890
diff
changeset
|
410 } |
0 | 411 } |