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