Mercurial > audlegacy
annotate src/audacious/output.c @ 4299:a16edefb8836
- 1st attempt to integrate MPlayer's equalizer (will work in 24bit mode too).
Please, check sound quality! Let me know, if you will find it not
appropriate.
- EQ pregain doesn't work yet.
author | Eugene Zagidullin <e.asphyx@gmail.com> |
---|---|
date | Sat, 23 Feb 2008 16:34:10 +0300 |
parents | 5b277773870e |
children | fec498c745f6 |
rev | line source |
---|---|
2313 | 1 /* Audacious - Cross-platform multimedia player |
4234 | 2 * Copyright (C) 2005-2008 Audacious team |
2313 | 3 * |
4 * Based on BMP: | |
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 | |
3121
3b6d316f8b09
GPL3 relicensing.
William Pitcock <nenolod@atheme-project.org>
parents:
2813
diff
changeset
|
12 * the Free Software Foundation; under version 3 of the License. |
2313 | 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 | |
3121
3b6d316f8b09
GPL3 relicensing.
William Pitcock <nenolod@atheme-project.org>
parents:
2813
diff
changeset
|
20 * along with this program. If not, see <http://www.gnu.org/licenses>. |
3123
f1c756f39e6c
Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents:
3121
diff
changeset
|
21 * |
f1c756f39e6c
Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents:
3121
diff
changeset
|
22 * The Audacious team does not consider modular code linking to |
f1c756f39e6c
Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents:
3121
diff
changeset
|
23 * Audacious or using our public API to be a derived work. |
2313 | 24 */ |
25 | |
4299
a16edefb8836
- 1st attempt to integrate MPlayer's equalizer (will work in 24bit mode too).
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4290
diff
changeset
|
26 #define AUD_DEBUG |
4234 | 27 |
2313 | 28 #ifdef HAVE_CONFIG_H |
29 # include "config.h" | |
30 #endif | |
31 | |
32 #include "output.h" | |
33 #include "iir.h" | |
34 #include "main.h" | |
35 #include "input.h" | |
2328 | 36 #include "playback.h" |
2313 | 37 |
38 #include "playlist.h" | |
2717 | 39 #include "configdb.h" |
2542 | 40 |
3553
a140fadd741d
software volumecontrol->flow manager API
William Pitcock <nenolod@atheme.org>
parents:
3549
diff
changeset
|
41 #include "flow.h" |
a140fadd741d
software volumecontrol->flow manager API
William Pitcock <nenolod@atheme.org>
parents:
3549
diff
changeset
|
42 |
4266
2b7a74fce100
Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents:
4259
diff
changeset
|
43 #include "pluginenum.h" |
2b7a74fce100
Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents:
4259
diff
changeset
|
44 |
2811
1c7ee5ed3a10
[svn] Move effect plugin handling into the main thread
ertzing
parents:
2717
diff
changeset
|
45 #include "effect.h" |
3546
fd4cd1945b91
Connect volumecontrol flow to the work pipeline.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
46 #include "volumecontrol.h" |
3559 | 47 #include "visualization.h" |
2811
1c7ee5ed3a10
[svn] Move effect plugin handling into the main thread
ertzing
parents:
2717
diff
changeset
|
48 |
4234 | 49 #include "libSAD.h" |
4259
92642f860860
- added template for src_flow
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4258
diff
changeset
|
50 #include "util.h" |
4299
a16edefb8836
- 1st attempt to integrate MPlayer's equalizer (will work in 24bit mode too).
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4290
diff
changeset
|
51 #include "equalizer_flow.h" |
4234 | 52 |
2542 | 53 #include <math.h> |
54 | |
2538
719e0898ff3c
[svn] - Patch to use libsamplerate for high-quality interpolated upsampling,
nenolod
parents:
2373
diff
changeset
|
55 #ifdef USE_SRC |
4267
a41fb6bc632a
- src stuff traveled to src_flow.c
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4259
diff
changeset
|
56 # include "src_flow.h" |
2538
719e0898ff3c
[svn] - Patch to use libsamplerate for high-quality interpolated upsampling,
nenolod
parents:
2373
diff
changeset
|
57 #endif |
2313 | 58 |
4240
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
59 #define FMT_FRACBITS(a) ( (a) == FMT_FIXED32 ? __AUDACIOUS_ASSUMED_MAD_F_FRACBITS__ : 0 ) |
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
60 |
2313 | 61 OutputPluginData op_data = { |
62 NULL, | |
63 NULL | |
64 }; | |
65 | |
66 OutputPluginState op_state = { | |
67 0, | |
68 0, | |
69 0 | |
70 }; | |
71 | |
4267
a41fb6bc632a
- src stuff traveled to src_flow.c
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4259
diff
changeset
|
72 static gint decoder_srate = 0; |
4286
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
73 static gboolean bypass_dsp = FALSE; |
4267
a41fb6bc632a
- src stuff traveled to src_flow.c
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4259
diff
changeset
|
74 |
2313 | 75 OutputPlugin psuedo_output_plugin = { |
3549 | 76 .description = "XMMS reverse compatibility output plugin", |
77 .get_volume = output_get_volume, | |
78 .set_volume = output_set_volume, | |
79 | |
80 .open_audio = output_open_audio, | |
81 .write_audio = output_write_audio, | |
82 .close_audio = output_close_audio, | |
2313 | 83 |
3549 | 84 .flush = output_flush, |
85 .pause = output_pause, | |
86 | |
87 .buffer_free = output_buffer_free, | |
88 .buffer_playing = output_buffer_playing, | |
89 .output_time = get_output_time, | |
90 .written_time = get_written_time, | |
2313 | 91 }; |
92 | |
4240
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
93 static void apply_replaygain_info (ReplayGainInfo *rg_info); |
29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4239
diff
changeset
|
94 |
2313 | 95 OutputPlugin * |
96 get_current_output_plugin(void) | |
97 { | |
98 return op_data.current_output_plugin; | |
99 } | |
100 | |
101 void | |
102 set_current_output_plugin(gint i) | |
103 { | |
104 gboolean playing; | |
105 OutputPlugin *op = get_current_output_plugin(); | |
106 | |
107 GList *node = g_list_nth(op_data.output_list, i); | |
108 if (!node) { | |
109 op_data.current_output_plugin = NULL; | |
110 return; | |
111 } | |
112 | |
113 op_data.current_output_plugin = node->data; | |
114 | |
115 playing = playback_get_playing(); | |
116 | |
117 if (playing == TRUE) | |
118 { | |
119 guint time, pos; | |
2373
ad1d7687814c
[svn] made strings.h for existing strings.c, cleanups
mf0102
parents:
2328
diff
changeset
|
120 PlaylistEntry *entry; |
4266
2b7a74fce100
Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents:
4259
diff
changeset
|
121 |
2b7a74fce100
Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents:
4259
diff
changeset
|
122 plugin_set_current((Plugin *)op); |
2313 | 123 |
2373
ad1d7687814c
[svn] made strings.h for existing strings.c, cleanups
mf0102
parents:
2328
diff
changeset
|
124 /* don't stop yet, get the seek time and playlist position first */ |
2313 | 125 pos = playlist_get_position(playlist_get_active()); |
126 time = op->output_time(); | |
127 | |
2373
ad1d7687814c
[svn] made strings.h for existing strings.c, cleanups
mf0102
parents:
2328
diff
changeset
|
128 /* reset the audio system */ |
2313 | 129 mainwin_stop_pushed(); |
130 op->close_audio(); | |
131 | |
2373
ad1d7687814c
[svn] made strings.h for existing strings.c, cleanups
mf0102
parents:
2328
diff
changeset
|
132 g_usleep(300000); |
2313 | 133 |
2373
ad1d7687814c
[svn] made strings.h for existing strings.c, cleanups
mf0102
parents:
2328
diff
changeset
|
134 /* wait for the playback thread to come online */ |
2313 | 135 while (playback_get_playing()) |
136 g_message("waiting for audio system shutdown..."); | |
137 | |
2373
ad1d7687814c
[svn] made strings.h for existing strings.c, cleanups
mf0102
parents:
2328
diff
changeset
|
138 /* wait for the playback thread to come online */ |
2313 | 139 playlist_set_position(playlist_get_active(), pos); |
2373
ad1d7687814c
[svn] made strings.h for existing strings.c, cleanups
mf0102
parents:
2328
diff
changeset
|
140 entry = playlist_get_entry_to_play(playlist_get_active()); |
2313 | 141 playback_play_file(entry); |
142 | |
2373
ad1d7687814c
[svn] made strings.h for existing strings.c, cleanups
mf0102
parents:
2328
diff
changeset
|
143 while (!playback_get_playing()) |
ad1d7687814c
[svn] made strings.h for existing strings.c, cleanups
mf0102
parents:
2328
diff
changeset
|
144 { |
ad1d7687814c
[svn] made strings.h for existing strings.c, cleanups
mf0102
parents:
2328
diff
changeset
|
145 gtk_main_iteration(); |
ad1d7687814c
[svn] made strings.h for existing strings.c, cleanups
mf0102
parents:
2328
diff
changeset
|
146 g_message("waiting for audio system startup..."); |
ad1d7687814c
[svn] made strings.h for existing strings.c, cleanups
mf0102
parents:
2328
diff
changeset
|
147 } |
2313 | 148 |
2373
ad1d7687814c
[svn] made strings.h for existing strings.c, cleanups
mf0102
parents:
2328
diff
changeset
|
149 /* and signal a reseek */ |
2313 | 150 if (playlist_get_current_length(playlist_get_active()) > -1 && |
151 time <= (playlist_get_current_length(playlist_get_active()))) | |
152 playback_seek(time / 1000); | |
153 } | |
154 } | |
155 | |
156 GList * | |
157 get_output_list(void) | |
158 { | |
159 return op_data.output_list; | |
160 } | |
161 | |
162 void | |
163 output_about(gint i) | |
164 { | |
165 OutputPlugin *out = g_list_nth(op_data.output_list, i)->data; | |
166 if (out && out->about) | |
4266
2b7a74fce100
Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents:
4259
diff
changeset
|
167 { |
2b7a74fce100
Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents:
4259
diff
changeset
|
168 plugin_set_current((Plugin *)out); |
2313 | 169 out->about(); |
4266
2b7a74fce100
Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents:
4259
diff
changeset
|
170 } |
2313 | 171 } |
172 | |
173 void | |
174 output_configure(gint i) | |
175 { | |
176 OutputPlugin *out = g_list_nth(op_data.output_list, i)->data; | |
177 if (out && out->configure) | |
4266
2b7a74fce100
Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents:
4259
diff
changeset
|
178 { |
2b7a74fce100
Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents:
4259
diff
changeset
|
179 plugin_set_current((Plugin *)out); |
2313 | 180 out->configure(); |
4266
2b7a74fce100
Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents:
4259
diff
changeset
|
181 } |
2313 | 182 } |
183 | |
184 void | |
185 output_get_volume(gint * l, gint * r) | |
186 { | |
187 *l = *r = -1; | |
188 | |
189 if (!op_data.current_output_plugin) | |
190 return; | |
191 | |
192 if (!op_data.current_output_plugin->get_volume) | |
193 return; | |
194 | |
3546
fd4cd1945b91
Connect volumecontrol flow to the work pipeline.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
195 if (cfg.software_volume_control) |
fd4cd1945b91
Connect volumecontrol flow to the work pipeline.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
196 volumecontrol_get_volume_state(l, r); |
fd4cd1945b91
Connect volumecontrol flow to the work pipeline.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
197 else |
4266
2b7a74fce100
Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents:
4259
diff
changeset
|
198 { |
2b7a74fce100
Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents:
4259
diff
changeset
|
199 plugin_set_current((Plugin *)op_data.current_output_plugin); |
3546
fd4cd1945b91
Connect volumecontrol flow to the work pipeline.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
200 op_data.current_output_plugin->get_volume(l, r); |
4266
2b7a74fce100
Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents:
4259
diff
changeset
|
201 } |
2313 | 202 } |
203 | |
204 void | |
205 output_set_volume(gint l, gint r) | |
206 { | |
207 if (!op_data.current_output_plugin) | |
208 return; | |
209 | |
210 if (!op_data.current_output_plugin->set_volume) | |
211 return; | |
212 | |
3546
fd4cd1945b91
Connect volumecontrol flow to the work pipeline.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
213 if (cfg.software_volume_control) |
fd4cd1945b91
Connect volumecontrol flow to the work pipeline.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
214 volumecontrol_set_volume_state(l, r); |
fd4cd1945b91
Connect volumecontrol flow to the work pipeline.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
215 else |
4266
2b7a74fce100
Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents:
4259
diff
changeset
|
216 { |
2b7a74fce100
Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents:
4259
diff
changeset
|
217 plugin_set_current((Plugin *)op_data.current_output_plugin); |
3546
fd4cd1945b91
Connect volumecontrol flow to the work pipeline.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
218 op_data.current_output_plugin->set_volume(l, r); |
4266
2b7a74fce100
Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents:
4259
diff
changeset
|
219 } |
2313 | 220 } |
221 | |
222 void | |
223 output_set_eq(gboolean active, gfloat pre, gfloat * bands) | |
224 { | |
225 int i; | |
4299
a16edefb8836
- 1st attempt to integrate MPlayer's equalizer (will work in 24bit mode too).
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4290
diff
changeset
|
226 /* |
2313 | 227 preamp[0] = 1.0 + 0.0932471 * pre + 0.00279033 * pre * pre; |
228 preamp[1] = 1.0 + 0.0932471 * pre + 0.00279033 * pre * pre; | |
4299
a16edefb8836
- 1st attempt to integrate MPlayer's equalizer (will work in 24bit mode too).
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4290
diff
changeset
|
229 AUDDBG("preamp: %f, bands: %f:%f:%f:%f:%f:%f:%f:%f:%f:%f\n", pre, bands[0], bands[1], bands[2], bands[3], bands[4], |
a16edefb8836
- 1st attempt to integrate MPlayer's equalizer (will work in 24bit mode too).
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4290
diff
changeset
|
230 bands[5], bands[6], bands[7], bands[8], bands[9]); |
2313 | 231 |
232 for (i = 0; i < 10; ++i) | |
233 { | |
2813
49f3d1b43518
[svn] - code cleanups involving SRC patch and indentation
nenolod
parents:
2811
diff
changeset
|
234 set_gain(i, 0, 0.03 * bands[i] + 0.000999999 * bands[i] * bands[i]); |
49f3d1b43518
[svn] - code cleanups involving SRC patch and indentation
nenolod
parents:
2811
diff
changeset
|
235 set_gain(i, 1, 0.03 * bands[i] + 0.000999999 * bands[i] * bands[i]); |
2313 | 236 } |
4299
a16edefb8836
- 1st attempt to integrate MPlayer's equalizer (will work in 24bit mode too).
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4290
diff
changeset
|
237 */ |
a16edefb8836
- 1st attempt to integrate MPlayer's equalizer (will work in 24bit mode too).
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4290
diff
changeset
|
238 |
a16edefb8836
- 1st attempt to integrate MPlayer's equalizer (will work in 24bit mode too).
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4290
diff
changeset
|
239 gfloat b[10]; |
a16edefb8836
- 1st attempt to integrate MPlayer's equalizer (will work in 24bit mode too).
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4290
diff
changeset
|
240 for (i = 0; i < 10; i++) { |
a16edefb8836
- 1st attempt to integrate MPlayer's equalizer (will work in 24bit mode too).
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4290
diff
changeset
|
241 b[i] = bands[i] * 12.0 / 20.0; /* FIXME: change equalizer sliders range from -20..20 to -12..12 dB --asphyx */ |
a16edefb8836
- 1st attempt to integrate MPlayer's equalizer (will work in 24bit mode too).
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4290
diff
changeset
|
242 } |
a16edefb8836
- 1st attempt to integrate MPlayer's equalizer (will work in 24bit mode too).
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4290
diff
changeset
|
243 equalizer_flow_set_bands(pre, b); |
2313 | 244 } |
245 | |
246 /* called by input plugin to peek at the output plugin's write progress */ | |
247 gint | |
248 get_written_time(void) | |
249 { | |
250 OutputPlugin *op = get_current_output_plugin(); | |
251 | |
4266
2b7a74fce100
Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents:
4259
diff
changeset
|
252 plugin_set_current((Plugin *)op); |
2313 | 253 return op->written_time(); |
254 } | |
255 | |
256 /* called by input plugin to peek at the output plugin's output progress */ | |
257 gint | |
258 get_output_time(void) | |
259 { | |
260 OutputPlugin *op = get_current_output_plugin(); | |
261 | |
4266
2b7a74fce100
Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents:
4259
diff
changeset
|
262 plugin_set_current((Plugin *)op); |
2313 | 263 return op->output_time(); |
264 } | |
265 | |
4234 | 266 static SAD_dither_t *sad_state_to_float = NULL; |
267 static SAD_dither_t *sad_state_from_float = NULL; | |
4267
a41fb6bc632a
- src stuff traveled to src_flow.c
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4259
diff
changeset
|
268 static float *sad_float_buf = NULL; |
4234 | 269 static void *sad_out_buf = NULL; |
4278 | 270 static gsize sad_float_buf_length = 0; |
271 static gsize sad_out_buf_length = 0; | |
4237
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
272 static ReplayGainInfo replay_gain_info = { |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
273 .track_gain = 0.0, |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
274 .track_peak = 0.0, |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
275 .album_gain = 0.0, |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
276 .album_peak = 0.0, |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
277 }; |
4234 | 278 |
279 static void | |
280 freeSAD() | |
281 { | |
282 if (sad_state_from_float != NULL) {SAD_dither_free(sad_state_from_float); sad_state_from_float = NULL;} | |
283 if (sad_state_to_float != NULL) {SAD_dither_free(sad_state_to_float); sad_state_to_float = NULL;} | |
284 } | |
285 | |
4286
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
286 static gboolean |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
287 reopen_audio(AFormat fmt, gint rate, gint nch) |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
288 { |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
289 OutputPlugin *op = get_current_output_plugin(); |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
290 |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
291 if (op == NULL) |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
292 return FALSE; |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
293 |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
294 /* Is our output port already open? */ |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
295 if ((op_state.rate != 0 && op_state.nch != 0) && |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
296 (op_state.rate == rate && op_state.nch == nch && op_state.fmt == fmt)) |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
297 { |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
298 /* Yes, and it's the correct sampling rate. Reset the counter and go. */ |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
299 AUDDBG("flushing output instead of reopening\n"); |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
300 plugin_set_current((Plugin *)op); |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
301 op->flush(0); |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
302 return TRUE; |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
303 } |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
304 else if (op_state.rate != 0 && op_state.nch != 0) |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
305 { |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
306 plugin_set_current((Plugin *)op); |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
307 op->close_audio(); |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
308 } |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
309 |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
310 plugin_set_current((Plugin *)op); |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
311 gint ret = op->open_audio(fmt, rate, nch); |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
312 |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
313 if (ret == 1) /* Success? */ |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
314 { |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
315 AUDDBG("opened audio: fmt=%d, rate=%d, nch=%d\n", fmt, rate, nch); |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
316 op_state.fmt = fmt; |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
317 op_state.rate = rate; |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
318 op_state.nch = nch; |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
319 |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
320 return TRUE; |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
321 } else { |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
322 return FALSE; |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
323 } |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
324 } |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
325 |
2313 | 326 gint |
327 output_open_audio(AFormat fmt, gint rate, gint nch) | |
328 { | |
329 gint ret; | |
4267
a41fb6bc632a
- src stuff traveled to src_flow.c
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4259
diff
changeset
|
330 AUDDBG("requested: fmt=%d, rate=%d, nch=%d\n", fmt, rate, nch); |
4234 | 331 |
332 AFormat output_fmt; | |
333 int bit_depth; | |
334 SAD_buffer_format input_sad_fmt; | |
335 SAD_buffer_format output_sad_fmt; | |
336 | |
4267
a41fb6bc632a
- src stuff traveled to src_flow.c
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4259
diff
changeset
|
337 decoder_srate = rate; |
4286
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
338 bypass_dsp = cfg.bypass_dsp; |
2649
153dc928115a
[svn] - don't resample if source rate matches the internal clock rate. closes #881.
nenolod
parents:
2648
diff
changeset
|
339 |
4286
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
340 if (bypass_dsp) { |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
341 AUDDBG("trying to open audio in native format\n"); |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
342 bypass_dsp = reopen_audio(fmt, rate, nch); |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
343 AUDDBG("opening in native fmt %s\n", bypass_dsp ? "succeeded" : "failed"); |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
344 } |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
345 |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
346 if (bypass_dsp) { |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
347 return TRUE; |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
348 } else { |
4267
a41fb6bc632a
- src stuff traveled to src_flow.c
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4259
diff
changeset
|
349 #ifdef USE_SRC |
4290
5b277773870e
don't change src settings in play time
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4287
diff
changeset
|
350 rate = src_flow_init(rate, nch); /* returns sample rate unchanged if resampling switched off */ |
2538
719e0898ff3c
[svn] - Patch to use libsamplerate for high-quality interpolated upsampling,
nenolod
parents:
2373
diff
changeset
|
351 #endif |
719e0898ff3c
[svn] - Patch to use libsamplerate for high-quality interpolated upsampling,
nenolod
parents:
2373
diff
changeset
|
352 |
4286
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
353 bit_depth = cfg.output_bit_depth; |
4234 | 354 |
4286
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
355 AUDDBG("bit depth: %d\n", bit_depth); |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
356 output_fmt = (bit_depth == 24) ? FMT_S24_NE : FMT_S16_NE; |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
357 |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
358 freeSAD(); |
4267
a41fb6bc632a
- src stuff traveled to src_flow.c
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4259
diff
changeset
|
359 |
4286
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
360 AUDDBG("initializing dithering engine for 2 stage conversion: fmt%d --> float -->fmt%d\n", fmt, output_fmt); |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
361 input_sad_fmt.sample_format = sadfmt_from_afmt(fmt); |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
362 if (input_sad_fmt.sample_format < 0) return FALSE; |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
363 input_sad_fmt.fracbits = FMT_FRACBITS(fmt); |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
364 input_sad_fmt.channels = nch; |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
365 input_sad_fmt.channels_order = SAD_CHORDER_INTERLEAVED; |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
366 input_sad_fmt.samplerate = 0; |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
367 |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
368 output_sad_fmt.sample_format = SAD_SAMPLE_FLOAT; |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
369 output_sad_fmt.fracbits = 0; |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
370 output_sad_fmt.channels = nch; |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
371 output_sad_fmt.channels_order = SAD_CHORDER_INTERLEAVED; |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
372 output_sad_fmt.samplerate = 0; |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
373 |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
374 sad_state_to_float = SAD_dither_init(&input_sad_fmt, &output_sad_fmt, &ret); |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
375 if (sad_state_to_float == NULL) { |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
376 AUDDBG("ditherer init failed (decoder's native --> float)\n"); |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
377 return FALSE; |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
378 } |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
379 SAD_dither_set_dither (sad_state_to_float, FALSE); |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
380 |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
381 input_sad_fmt.sample_format = SAD_SAMPLE_FLOAT; |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
382 input_sad_fmt.fracbits = 0; |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
383 input_sad_fmt.channels = nch; |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
384 input_sad_fmt.channels_order = SAD_CHORDER_INTERLEAVED; |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
385 input_sad_fmt.samplerate = 0; |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
386 |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
387 output_sad_fmt.sample_format = sadfmt_from_afmt(output_fmt); |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
388 if (output_sad_fmt.sample_format < 0) return FALSE; |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
389 output_sad_fmt.fracbits = FMT_FRACBITS(output_fmt); |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
390 output_sad_fmt.channels = nch; |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
391 output_sad_fmt.channels_order = SAD_CHORDER_INTERLEAVED; |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
392 output_sad_fmt.samplerate = 0; |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
393 |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
394 sad_state_from_float = SAD_dither_init(&input_sad_fmt, &output_sad_fmt, &ret); |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
395 if (sad_state_from_float == NULL) { |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
396 SAD_dither_free(sad_state_to_float); |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
397 AUDDBG("ditherer init failed (float --> output)\n"); |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
398 return FALSE; |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
399 } |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
400 SAD_dither_set_dither (sad_state_from_float, TRUE); |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
401 |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
402 fmt = output_fmt; |
4267
a41fb6bc632a
- src stuff traveled to src_flow.c
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4259
diff
changeset
|
403 |
4286
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
404 if(replay_gain_info.album_peak == 0.0 && replay_gain_info.track_peak == 0.0) { |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
405 AUDDBG("RG info isn't set yet. Filling replay_gain_info with default values.\n"); |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
406 replay_gain_info.track_gain = cfg.default_gain; |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
407 replay_gain_info.track_peak = 0.01; |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
408 replay_gain_info.album_gain = cfg.default_gain; |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
409 replay_gain_info.album_peak = 0.01; |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
410 } |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
411 apply_replaygain_info(&replay_gain_info); |
4267
a41fb6bc632a
- src stuff traveled to src_flow.c
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4259
diff
changeset
|
412 |
4286
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
413 return reopen_audio(fmt, rate, nch); |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
414 } /* bypass_dsp */ |
2313 | 415 } |
416 | |
417 void | |
418 output_write_audio(gpointer ptr, gint length) | |
419 { | |
420 OutputPlugin *op = get_current_output_plugin(); | |
421 | |
422 /* Sanity check. */ | |
423 if (op == NULL) | |
424 return; | |
425 | |
4266
2b7a74fce100
Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents:
4259
diff
changeset
|
426 plugin_set_current((Plugin *)op); |
2313 | 427 op->write_audio(ptr, length); |
428 } | |
429 | |
430 void | |
431 output_close_audio(void) | |
432 { | |
433 OutputPlugin *op = get_current_output_plugin(); | |
434 | |
4234 | 435 freeSAD(); |
4237
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
436 |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
437 AUDDBG("clearing RG settings\n"); |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
438 replay_gain_info.track_gain = 0.0; |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
439 replay_gain_info.track_peak = 0.0; |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
440 replay_gain_info.album_gain = 0.0; |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
441 replay_gain_info.album_peak = 0.0; |
2538
719e0898ff3c
[svn] - Patch to use libsamplerate for high-quality interpolated upsampling,
nenolod
parents:
2373
diff
changeset
|
442 |
4290
5b277773870e
don't change src settings in play time
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4287
diff
changeset
|
443 #ifdef USE_SRC |
5b277773870e
don't change src settings in play time
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4287
diff
changeset
|
444 src_flow_free(); |
5b277773870e
don't change src settings in play time
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4287
diff
changeset
|
445 #endif |
2313 | 446 /* Do not close if there are still songs to play and the user has |
447 * not requested a stop. --nenolod | |
448 */ | |
4267
a41fb6bc632a
- src stuff traveled to src_flow.c
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4259
diff
changeset
|
449 Playlist *pl = playlist_get_active(); |
a41fb6bc632a
- src stuff traveled to src_flow.c
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4259
diff
changeset
|
450 if (ip_data.stop == FALSE && |
a41fb6bc632a
- src stuff traveled to src_flow.c
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4259
diff
changeset
|
451 (playlist_get_position_nolock(pl) < playlist_get_length(pl) - 1)) { |
a41fb6bc632a
- src stuff traveled to src_flow.c
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4259
diff
changeset
|
452 AUDDBG("leaving audio opened\n"); |
a41fb6bc632a
- src stuff traveled to src_flow.c
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4259
diff
changeset
|
453 return; |
a41fb6bc632a
- src stuff traveled to src_flow.c
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4259
diff
changeset
|
454 } |
2313 | 455 |
456 /* Sanity check. */ | |
457 if (op == NULL) | |
458 return; | |
459 | |
4266
2b7a74fce100
Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents:
4259
diff
changeset
|
460 plugin_set_current((Plugin *)op); |
2313 | 461 op->close_audio(); |
4267
a41fb6bc632a
- src stuff traveled to src_flow.c
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4259
diff
changeset
|
462 AUDDBG("done\n"); |
2313 | 463 |
464 /* Reset the op_state. */ | |
465 op_state.fmt = op_state.rate = op_state.nch = 0; | |
4299
a16edefb8836
- 1st attempt to integrate MPlayer's equalizer (will work in 24bit mode too).
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4290
diff
changeset
|
466 equalizer_flow_free(); |
2313 | 467 } |
468 | |
469 void | |
470 output_flush(gint time) | |
471 { | |
472 OutputPlugin *op = get_current_output_plugin(); | |
473 | |
474 if (op == NULL) | |
475 return; | |
476 | |
4266
2b7a74fce100
Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents:
4259
diff
changeset
|
477 plugin_set_current((Plugin *)op); |
2313 | 478 op->flush(time); |
479 } | |
480 | |
481 void | |
482 output_pause(gshort paused) | |
483 { | |
484 OutputPlugin *op = get_current_output_plugin(); | |
485 | |
486 if (op == NULL) | |
487 return; | |
488 | |
4266
2b7a74fce100
Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents:
4259
diff
changeset
|
489 plugin_set_current((Plugin *)op); |
2313 | 490 op->pause(paused); |
491 } | |
492 | |
493 gint | |
494 output_buffer_free(void) | |
495 { | |
496 OutputPlugin *op = get_current_output_plugin(); | |
497 | |
498 if (op == NULL) | |
499 return 0; | |
500 | |
4266
2b7a74fce100
Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents:
4259
diff
changeset
|
501 plugin_set_current((Plugin *)op); |
2313 | 502 return op->buffer_free(); |
503 } | |
504 | |
505 gint | |
506 output_buffer_playing(void) | |
507 { | |
508 OutputPlugin *op = get_current_output_plugin(); | |
509 | |
510 if (op == NULL) | |
511 return 0; | |
512 | |
4266
2b7a74fce100
Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents:
4259
diff
changeset
|
513 plugin_set_current((Plugin *)op); |
2313 | 514 return op->buffer_playing(); |
515 } | |
516 | |
517 /* called by input plugin when data is ready */ | |
518 void | |
3709
a89a12aa4f2c
Add InputPlayback::pass_audio() which replaces produce_audio().
William Pitcock <nenolod@atheme.org>
parents:
3708
diff
changeset
|
519 output_pass_audio(InputPlayback *playback, |
3696
418ac922ce87
Use a mutex/condvar/timed wait to allow tickless operation in the output loop.
William Pitcock <nenolod@atheme.org>
parents:
3686
diff
changeset
|
520 AFormat fmt, /* output format */ |
418ac922ce87
Use a mutex/condvar/timed wait to allow tickless operation in the output loop.
William Pitcock <nenolod@atheme.org>
parents:
3686
diff
changeset
|
521 gint nch, /* channels */ |
418ac922ce87
Use a mutex/condvar/timed wait to allow tickless operation in the output loop.
William Pitcock <nenolod@atheme.org>
parents:
3686
diff
changeset
|
522 gint length, /* length of sample */ |
418ac922ce87
Use a mutex/condvar/timed wait to allow tickless operation in the output loop.
William Pitcock <nenolod@atheme.org>
parents:
3686
diff
changeset
|
523 gpointer ptr, /* data */ |
418ac922ce87
Use a mutex/condvar/timed wait to allow tickless operation in the output loop.
William Pitcock <nenolod@atheme.org>
parents:
3686
diff
changeset
|
524 int *going /* 0 when time to stop */ |
2313 | 525 ) |
526 { | |
3553
a140fadd741d
software volumecontrol->flow manager API
William Pitcock <nenolod@atheme.org>
parents:
3549
diff
changeset
|
527 static Flow *postproc_flow = NULL; |
4259
92642f860860
- added template for src_flow
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4258
diff
changeset
|
528 static Flow *legacy_flow = NULL; |
3696
418ac922ce87
Use a mutex/condvar/timed wait to allow tickless operation in the output loop.
William Pitcock <nenolod@atheme.org>
parents:
3686
diff
changeset
|
529 OutputPlugin *op = playback->output; |
418ac922ce87
Use a mutex/condvar/timed wait to allow tickless operation in the output loop.
William Pitcock <nenolod@atheme.org>
parents:
3686
diff
changeset
|
530 gint writeoffs; |
4267
a41fb6bc632a
- src stuff traveled to src_flow.c
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4259
diff
changeset
|
531 gpointer float_ptr; |
4271 | 532 |
4286
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
533 if (!bypass_dsp) { |
2313 | 534 |
4286
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
535 if(length <= 0 || sad_state_from_float == NULL || sad_state_to_float == NULL) return; |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
536 |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
537 plugin_set_current((Plugin *)(playback->output)); |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
538 gint time = playback->output->written_time(); |
3553
a140fadd741d
software volumecontrol->flow manager API
William Pitcock <nenolod@atheme.org>
parents:
3549
diff
changeset
|
539 |
4286
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
540 if (legacy_flow == NULL) |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
541 { |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
542 legacy_flow = flow_new(); |
4299
a16edefb8836
- 1st attempt to integrate MPlayer's equalizer (will work in 24bit mode too).
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4290
diff
changeset
|
543 /*flow_link_element(legacy_flow, iir_flow);*/ |
4286
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
544 flow_link_element(legacy_flow, effect_flow); |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
545 } |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
546 |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
547 if (postproc_flow == NULL) |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
548 { |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
549 postproc_flow = flow_new(); |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
550 flow_link_element(postproc_flow, vis_flow); |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
551 #ifdef USE_SRC |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
552 flow_link_element(postproc_flow, src_flow); |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
553 #endif |
4299
a16edefb8836
- 1st attempt to integrate MPlayer's equalizer (will work in 24bit mode too).
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4290
diff
changeset
|
554 flow_link_element(postproc_flow, equalizer_flow); |
4286
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
555 flow_link_element(postproc_flow, volumecontrol_flow); |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
556 } |
4267
a41fb6bc632a
- src stuff traveled to src_flow.c
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4259
diff
changeset
|
557 |
4286
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
558 int frames = length / nch / FMT_SIZEOF(fmt); |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
559 int len = frames * nch * sizeof(float); |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
560 if(sad_float_buf == NULL || sad_float_buf_length < len) { |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
561 sad_float_buf_length = len; |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
562 sad_float_buf = smart_realloc(sad_float_buf, &sad_float_buf_length); |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
563 } |
4267
a41fb6bc632a
- src stuff traveled to src_flow.c
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4259
diff
changeset
|
564 |
4286
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
565 SAD_dither_process_buffer(sad_state_to_float, ptr, sad_float_buf, frames); |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
566 float_ptr = sad_float_buf; |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
567 |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
568 length = flow_execute(postproc_flow, |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
569 time, |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
570 &float_ptr, |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
571 len, |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
572 FMT_FLOAT, |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
573 decoder_srate, |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
574 nch); |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
575 |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
576 frames = length / nch / sizeof(float); |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
577 len = frames * nch * FMT_SIZEOF(op_state.fmt); |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
578 if(sad_out_buf == NULL || sad_out_buf_length < len) { |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
579 sad_out_buf_length = len; |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
580 sad_out_buf = smart_realloc(sad_out_buf, &sad_out_buf_length); |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
581 } |
4234 | 582 |
4286
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
583 SAD_dither_process_buffer(sad_state_from_float, float_ptr, sad_out_buf, frames); |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
584 |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
585 length = len; |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
586 ptr = sad_out_buf; |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
587 |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
588 if (op_state.fmt == FMT_S16_NE || (op_state.fmt == FMT_S16_LE && G_BYTE_ORDER == G_LITTLE_ENDIAN) || |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
589 (op_state.fmt == FMT_S16_BE && G_BYTE_ORDER == G_BIG_ENDIAN)) { |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
590 length = flow_execute(legacy_flow, time, &ptr, length, op_state.fmt, op_state.rate, op_state.nch); |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
591 } else { |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
592 AUDDBG("legacy_flow can deal only with S16_NE streams\n"); /*FIXME*/ |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
593 } |
af324ff0a983
added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4278
diff
changeset
|
594 } /* !bypass_dsp */ |
3546
fd4cd1945b91
Connect volumecontrol flow to the work pipeline.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
595 |
4267
a41fb6bc632a
- src stuff traveled to src_flow.c
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4259
diff
changeset
|
596 /**** write it out ****/ |
a41fb6bc632a
- src stuff traveled to src_flow.c
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4259
diff
changeset
|
597 |
2313 | 598 writeoffs = 0; |
2373
ad1d7687814c
[svn] made strings.h for existing strings.c, cleanups
mf0102
parents:
2328
diff
changeset
|
599 while (writeoffs < length) |
ad1d7687814c
[svn] made strings.h for existing strings.c, cleanups
mf0102
parents:
2328
diff
changeset
|
600 { |
ad1d7687814c
[svn] made strings.h for existing strings.c, cleanups
mf0102
parents:
2328
diff
changeset
|
601 int writable = length - writeoffs; |
2313 | 602 |
2373
ad1d7687814c
[svn] made strings.h for existing strings.c, cleanups
mf0102
parents:
2328
diff
changeset
|
603 if (writable > 2048) |
ad1d7687814c
[svn] made strings.h for existing strings.c, cleanups
mf0102
parents:
2328
diff
changeset
|
604 writable = 2048; |
2313 | 605 |
2813
49f3d1b43518
[svn] - code cleanups involving SRC patch and indentation
nenolod
parents:
2811
diff
changeset
|
606 if (writable == 0) |
2373
ad1d7687814c
[svn] made strings.h for existing strings.c, cleanups
mf0102
parents:
2328
diff
changeset
|
607 return; |
2313 | 608 |
3486
96baf555b449
Get rid of "XMMS Multiple Effect Plugin support" hack. Effects processing is handled in produce_audio() now days.
William Pitcock <nenolod@atheme.org>
parents:
3437
diff
changeset
|
609 while (op->buffer_free() < writable) /* wait output buf */ |
96baf555b449
Get rid of "XMMS Multiple Effect Plugin support" hack. Effects processing is handled in produce_audio() now days.
William Pitcock <nenolod@atheme.org>
parents:
3437
diff
changeset
|
610 { |
3696
418ac922ce87
Use a mutex/condvar/timed wait to allow tickless operation in the output loop.
William Pitcock <nenolod@atheme.org>
parents:
3686
diff
changeset
|
611 GTimeVal pb_abs_time; |
418ac922ce87
Use a mutex/condvar/timed wait to allow tickless operation in the output loop.
William Pitcock <nenolod@atheme.org>
parents:
3686
diff
changeset
|
612 |
418ac922ce87
Use a mutex/condvar/timed wait to allow tickless operation in the output loop.
William Pitcock <nenolod@atheme.org>
parents:
3686
diff
changeset
|
613 g_get_current_time(&pb_abs_time); |
4230
b3e82a1eb129
Experimental patch to fix pulseaudio deficencies by sleeping 10000us.
William Pitcock <nenolod@atheme.org>
parents:
4186
diff
changeset
|
614 g_time_val_add(&pb_abs_time, 10000); |
3696
418ac922ce87
Use a mutex/condvar/timed wait to allow tickless operation in the output loop.
William Pitcock <nenolod@atheme.org>
parents:
3686
diff
changeset
|
615 |
2373
ad1d7687814c
[svn] made strings.h for existing strings.c, cleanups
mf0102
parents:
2328
diff
changeset
|
616 if (going && !*going) /* thread stopped? */ |
ad1d7687814c
[svn] made strings.h for existing strings.c, cleanups
mf0102
parents:
2328
diff
changeset
|
617 return; /* so finish */ |
2313 | 618 |
3486
96baf555b449
Get rid of "XMMS Multiple Effect Plugin support" hack. Effects processing is handled in produce_audio() now days.
William Pitcock <nenolod@atheme.org>
parents:
3437
diff
changeset
|
619 if (ip_data.stop) /* has a stop been requested? */ |
2373
ad1d7687814c
[svn] made strings.h for existing strings.c, cleanups
mf0102
parents:
2328
diff
changeset
|
620 return; /* yes, so finish */ |
2313 | 621 |
3680
6615978ca88c
Instead of waiting 10ms, wait half the time of the period buffer.
William Pitcock <nenolod@atheme.org>
parents:
3560
diff
changeset
|
622 /* else sleep for retry */ |
3696
418ac922ce87
Use a mutex/condvar/timed wait to allow tickless operation in the output loop.
William Pitcock <nenolod@atheme.org>
parents:
3686
diff
changeset
|
623 g_mutex_lock(playback->pb_change_mutex); |
418ac922ce87
Use a mutex/condvar/timed wait to allow tickless operation in the output loop.
William Pitcock <nenolod@atheme.org>
parents:
3686
diff
changeset
|
624 g_cond_timed_wait(playback->pb_change_cond, playback->pb_change_mutex, &pb_abs_time); |
418ac922ce87
Use a mutex/condvar/timed wait to allow tickless operation in the output loop.
William Pitcock <nenolod@atheme.org>
parents:
3686
diff
changeset
|
625 g_mutex_unlock(playback->pb_change_mutex); |
2373
ad1d7687814c
[svn] made strings.h for existing strings.c, cleanups
mf0102
parents:
2328
diff
changeset
|
626 } |
2313 | 627 |
2373
ad1d7687814c
[svn] made strings.h for existing strings.c, cleanups
mf0102
parents:
2328
diff
changeset
|
628 if (ip_data.stop) |
ad1d7687814c
[svn] made strings.h for existing strings.c, cleanups
mf0102
parents:
2328
diff
changeset
|
629 return; |
2313 | 630 |
2373
ad1d7687814c
[svn] made strings.h for existing strings.c, cleanups
mf0102
parents:
2328
diff
changeset
|
631 if (going && !*going) /* thread stopped? */ |
ad1d7687814c
[svn] made strings.h for existing strings.c, cleanups
mf0102
parents:
2328
diff
changeset
|
632 return; /* so finish */ |
2313 | 633 |
2373
ad1d7687814c
[svn] made strings.h for existing strings.c, cleanups
mf0102
parents:
2328
diff
changeset
|
634 /* do output */ |
4266
2b7a74fce100
Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents:
4259
diff
changeset
|
635 plugin_set_current((Plugin *)op); |
2373
ad1d7687814c
[svn] made strings.h for existing strings.c, cleanups
mf0102
parents:
2328
diff
changeset
|
636 op->write_audio(((guint8 *) ptr) + writeoffs, writable); |
2313 | 637 |
2373
ad1d7687814c
[svn] made strings.h for existing strings.c, cleanups
mf0102
parents:
2328
diff
changeset
|
638 writeoffs += writable; |
2313 | 639 } |
640 } | |
4235
2d4b4f13d10d
set_replaygain_info added to PAPI
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
641 |
4237
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
642 /* called by input plugin when RG info available --asphyx */ |
4235
2d4b4f13d10d
set_replaygain_info added to PAPI
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
643 void |
2d4b4f13d10d
set_replaygain_info added to PAPI
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
644 output_set_replaygain_info (InputPlayback *pb, ReplayGainInfo *rg_info) |
2d4b4f13d10d
set_replaygain_info added to PAPI
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
645 { |
4237
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
646 replay_gain_info = *rg_info; |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
647 apply_replaygain_info(rg_info); |
4235
2d4b4f13d10d
set_replaygain_info added to PAPI
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
648 } |
4237
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
649 |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
650 static void |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
651 apply_replaygain_info (ReplayGainInfo *rg_info) |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
652 { |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
653 SAD_replaygain_mode mode; |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
654 SAD_replaygain_info info; |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
655 gboolean rg_enabled; |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
656 gboolean album_mode; |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
657 |
4267
a41fb6bc632a
- src stuff traveled to src_flow.c
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4259
diff
changeset
|
658 if(sad_state_from_float == NULL) { |
4237
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
659 AUDDBG("SAD not initialized!\n"); |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
660 return; |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
661 } |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
662 |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
663 rg_enabled = cfg.enable_replay_gain; |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
664 album_mode = cfg.replay_gain_album; |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
665 mode.clipping_prevention = cfg.enable_clipping_prevention; |
4256
b0ca963fd965
adaptive scaler added, disabled hard limiter
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4247
diff
changeset
|
666 mode.hard_limit = FALSE; |
b0ca963fd965
adaptive scaler added, disabled hard limiter
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4247
diff
changeset
|
667 mode.adaptive_scaler = cfg.enable_adaptive_scaler; |
4237
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
668 |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
669 if(!rg_enabled) return; |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
670 |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
671 mode.mode = album_mode ? SAD_RG_ALBUM : SAD_RG_TRACK; |
4242
21008f43bb93
RG improved. It f... works.
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4240
diff
changeset
|
672 mode.preamp = cfg.replay_gain_preamp; |
4237
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
673 |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
674 info.present = TRUE; |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
675 info.track_gain = rg_info->track_gain; |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
676 info.track_peak = rg_info->track_peak; |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
677 info.album_gain = rg_info->album_gain; |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
678 info.album_peak = rg_info->album_peak; |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
679 |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
680 AUDDBG("Applying Replay Gain settings:\n"); |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
681 AUDDBG("* mode: %s\n", mode.mode == SAD_RG_ALBUM ? "album" : "track"); |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
682 AUDDBG("* clipping prevention: %s\n", mode.clipping_prevention ? "yes" : "no"); |
4256
b0ca963fd965
adaptive scaler added, disabled hard limiter
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4247
diff
changeset
|
683 AUDDBG("* adaptive scaler %s\n", mode.adaptive_scaler ? "yes" : "no"); |
4237
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
684 AUDDBG("* preamp: %+f dB\n", mode.preamp); |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
685 AUDDBG("Replay Gain info for current track:\n"); |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
686 AUDDBG("* track gain: %+f dB\n", info.track_gain); |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
687 AUDDBG("* track peak: %f\n", info.track_peak); |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
688 AUDDBG("* album gain: %+f dB\n", info.album_gain); |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
689 AUDDBG("* album peak: %f\n", info.album_peak); |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
690 |
4267
a41fb6bc632a
- src stuff traveled to src_flow.c
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4259
diff
changeset
|
691 SAD_dither_apply_replaygain(sad_state_from_float, &info, &mode); |
4237
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
692 } |