Mercurial > audlegacy
annotate src/audacious/output.c @ 4240:29c8603a877a
added FMT_FIXED32, an equivalent of mad_fixed_t, already supported by libSAD; some endianness-related changes
author | Eugene Zagidullin <e.asphyx@gmail.com> |
---|---|
date | Mon, 04 Feb 2008 01:30:53 +0300 |
parents | 51291ce4eb54 |
children | 21008f43bb93 |
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 | |
4234 | 26 #define AUD_DEBUG |
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 |
2811
1c7ee5ed3a10
[svn] Move effect plugin handling into the main thread
ertzing
parents:
2717
diff
changeset
|
43 #include "effect.h" |
3546
fd4cd1945b91
Connect volumecontrol flow to the work pipeline.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
44 #include "volumecontrol.h" |
3559 | 45 #include "visualization.h" |
2811
1c7ee5ed3a10
[svn] Move effect plugin handling into the main thread
ertzing
parents:
2717
diff
changeset
|
46 |
4234 | 47 #include "libSAD.h" |
48 | |
2542 | 49 #include <math.h> |
50 | |
2538
719e0898ff3c
[svn] - Patch to use libsamplerate for high-quality interpolated upsampling,
nenolod
parents:
2373
diff
changeset
|
51 #ifdef USE_SRC |
719e0898ff3c
[svn] - Patch to use libsamplerate for high-quality interpolated upsampling,
nenolod
parents:
2373
diff
changeset
|
52 #include <samplerate.h> |
719e0898ff3c
[svn] - Patch to use libsamplerate for high-quality interpolated upsampling,
nenolod
parents:
2373
diff
changeset
|
53 #endif |
2313 | 54 |
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
|
55 #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
|
56 |
2313 | 57 OutputPluginData op_data = { |
58 NULL, | |
59 NULL | |
60 }; | |
61 | |
62 OutputPluginState op_state = { | |
63 0, | |
64 0, | |
65 0 | |
66 }; | |
67 | |
68 OutputPlugin psuedo_output_plugin = { | |
3549 | 69 .description = "XMMS reverse compatibility output plugin", |
70 .get_volume = output_get_volume, | |
71 .set_volume = output_set_volume, | |
72 | |
73 .open_audio = output_open_audio, | |
74 .write_audio = output_write_audio, | |
75 .close_audio = output_close_audio, | |
2313 | 76 |
3549 | 77 .flush = output_flush, |
78 .pause = output_pause, | |
79 | |
80 .buffer_free = output_buffer_free, | |
81 .buffer_playing = output_buffer_playing, | |
82 .output_time = get_output_time, | |
83 .written_time = get_written_time, | |
2313 | 84 }; |
85 | |
4234 | 86 static const struct { |
87 AFormat afmt; | |
88 SAD_sample_format sadfmt; | |
89 } format_table[] = { | |
90 {FMT_U8, SAD_SAMPLE_U8}, | |
91 {FMT_S8, SAD_SAMPLE_S8}, | |
92 | |
93 {FMT_S16_LE, SAD_SAMPLE_S16_LE}, | |
94 {FMT_S16_BE, SAD_SAMPLE_S16_BE}, | |
95 {FMT_S16_NE, SAD_SAMPLE_S16}, | |
96 | |
97 {FMT_U16_LE, SAD_SAMPLE_U16_LE}, | |
98 {FMT_U16_BE, SAD_SAMPLE_U16_BE}, | |
99 {FMT_U16_NE, SAD_SAMPLE_U16}, | |
100 | |
101 {FMT_S24_LE, SAD_SAMPLE_S24_LE}, | |
102 {FMT_S24_BE, SAD_SAMPLE_S24_BE}, | |
103 {FMT_S24_NE, SAD_SAMPLE_S24}, | |
104 | |
105 {FMT_U24_LE, SAD_SAMPLE_U24_LE}, | |
106 {FMT_U24_BE, SAD_SAMPLE_U24_BE}, | |
107 {FMT_U24_NE, SAD_SAMPLE_U24}, | |
108 | |
109 {FMT_S32_LE, SAD_SAMPLE_S32_LE}, | |
110 {FMT_S32_BE, SAD_SAMPLE_S32_BE}, | |
111 {FMT_S32_NE, SAD_SAMPLE_S32}, | |
112 | |
113 {FMT_U32_LE, SAD_SAMPLE_U32_LE}, | |
114 {FMT_U32_BE, SAD_SAMPLE_U32_BE}, | |
115 {FMT_U32_NE, SAD_SAMPLE_U32}, | |
116 | |
117 {FMT_FLOAT, SAD_SAMPLE_FLOAT}, | |
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
|
118 {FMT_FIXED32, SAD_SAMPLE_FIXED32}, |
4234 | 119 }; |
120 | |
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
|
121 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
|
122 |
4234 | 123 static inline unsigned sample_size(AFormat fmt) { |
124 switch(fmt) { | |
125 case FMT_S8: | |
126 case FMT_U8: return sizeof(gint8); | |
127 case FMT_S16_NE: | |
128 case FMT_S16_LE: | |
129 case FMT_S16_BE: | |
130 case FMT_U16_NE: | |
131 case FMT_U16_LE: | |
132 case FMT_U16_BE: return sizeof(gint16); | |
133 case FMT_S24_NE: | |
134 case FMT_S24_LE: | |
135 case FMT_S24_BE: | |
136 case FMT_U24_NE: | |
137 case FMT_U24_LE: | |
138 case FMT_U24_BE: | |
139 case FMT_S32_NE: | |
140 case FMT_S32_LE: | |
141 case FMT_S32_BE: | |
142 case FMT_U32_NE: | |
143 case FMT_U32_LE: | |
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
|
144 case FMT_U32_BE: |
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
|
145 case FMT_FIXED32: return sizeof(gint32); |
4234 | 146 case FMT_FLOAT: return sizeof(float); |
147 default: return 0; | |
148 } | |
149 } | |
150 | |
151 static SAD_sample_format | |
152 sadfmt_from_afmt(AFormat fmt) | |
153 { | |
154 int i; | |
155 for (i = 0; i < sizeof(format_table) / sizeof(format_table[0]); i++) { | |
156 if (format_table[i].afmt == fmt) return format_table[i].sadfmt; | |
157 } | |
158 | |
159 return -1; | |
160 } | |
161 | |
2313 | 162 OutputPlugin * |
163 get_current_output_plugin(void) | |
164 { | |
165 return op_data.current_output_plugin; | |
166 } | |
167 | |
168 void | |
169 set_current_output_plugin(gint i) | |
170 { | |
171 gboolean playing; | |
172 OutputPlugin *op = get_current_output_plugin(); | |
173 | |
174 GList *node = g_list_nth(op_data.output_list, i); | |
175 if (!node) { | |
176 op_data.current_output_plugin = NULL; | |
177 return; | |
178 } | |
179 | |
180 op_data.current_output_plugin = node->data; | |
181 | |
182 playing = playback_get_playing(); | |
183 | |
184 if (playing == TRUE) | |
185 { | |
186 guint time, pos; | |
2373
ad1d7687814c
[svn] made strings.h for existing strings.c, cleanups
mf0102
parents:
2328
diff
changeset
|
187 PlaylistEntry *entry; |
2313 | 188 |
2373
ad1d7687814c
[svn] made strings.h for existing strings.c, cleanups
mf0102
parents:
2328
diff
changeset
|
189 /* don't stop yet, get the seek time and playlist position first */ |
2313 | 190 pos = playlist_get_position(playlist_get_active()); |
191 time = op->output_time(); | |
192 | |
2373
ad1d7687814c
[svn] made strings.h for existing strings.c, cleanups
mf0102
parents:
2328
diff
changeset
|
193 /* reset the audio system */ |
2313 | 194 mainwin_stop_pushed(); |
195 op->close_audio(); | |
196 | |
2373
ad1d7687814c
[svn] made strings.h for existing strings.c, cleanups
mf0102
parents:
2328
diff
changeset
|
197 g_usleep(300000); |
2313 | 198 |
2373
ad1d7687814c
[svn] made strings.h for existing strings.c, cleanups
mf0102
parents:
2328
diff
changeset
|
199 /* wait for the playback thread to come online */ |
2313 | 200 while (playback_get_playing()) |
201 g_message("waiting for audio system shutdown..."); | |
202 | |
2373
ad1d7687814c
[svn] made strings.h for existing strings.c, cleanups
mf0102
parents:
2328
diff
changeset
|
203 /* wait for the playback thread to come online */ |
2313 | 204 playlist_set_position(playlist_get_active(), pos); |
2373
ad1d7687814c
[svn] made strings.h for existing strings.c, cleanups
mf0102
parents:
2328
diff
changeset
|
205 entry = playlist_get_entry_to_play(playlist_get_active()); |
2313 | 206 playback_play_file(entry); |
207 | |
2373
ad1d7687814c
[svn] made strings.h for existing strings.c, cleanups
mf0102
parents:
2328
diff
changeset
|
208 while (!playback_get_playing()) |
ad1d7687814c
[svn] made strings.h for existing strings.c, cleanups
mf0102
parents:
2328
diff
changeset
|
209 { |
ad1d7687814c
[svn] made strings.h for existing strings.c, cleanups
mf0102
parents:
2328
diff
changeset
|
210 gtk_main_iteration(); |
ad1d7687814c
[svn] made strings.h for existing strings.c, cleanups
mf0102
parents:
2328
diff
changeset
|
211 g_message("waiting for audio system startup..."); |
ad1d7687814c
[svn] made strings.h for existing strings.c, cleanups
mf0102
parents:
2328
diff
changeset
|
212 } |
2313 | 213 |
2373
ad1d7687814c
[svn] made strings.h for existing strings.c, cleanups
mf0102
parents:
2328
diff
changeset
|
214 /* and signal a reseek */ |
2313 | 215 if (playlist_get_current_length(playlist_get_active()) > -1 && |
216 time <= (playlist_get_current_length(playlist_get_active()))) | |
217 playback_seek(time / 1000); | |
218 } | |
219 } | |
220 | |
221 GList * | |
222 get_output_list(void) | |
223 { | |
224 return op_data.output_list; | |
225 } | |
226 | |
227 void | |
228 output_about(gint i) | |
229 { | |
230 OutputPlugin *out = g_list_nth(op_data.output_list, i)->data; | |
231 if (out && out->about) | |
232 out->about(); | |
233 } | |
234 | |
235 void | |
236 output_configure(gint i) | |
237 { | |
238 OutputPlugin *out = g_list_nth(op_data.output_list, i)->data; | |
239 if (out && out->configure) | |
240 out->configure(); | |
241 } | |
242 | |
243 void | |
244 output_get_volume(gint * l, gint * r) | |
245 { | |
246 *l = *r = -1; | |
247 | |
248 if (!op_data.current_output_plugin) | |
249 return; | |
250 | |
251 if (!op_data.current_output_plugin->get_volume) | |
252 return; | |
253 | |
3546
fd4cd1945b91
Connect volumecontrol flow to the work pipeline.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
254 if (cfg.software_volume_control) |
fd4cd1945b91
Connect volumecontrol flow to the work pipeline.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
255 volumecontrol_get_volume_state(l, r); |
fd4cd1945b91
Connect volumecontrol flow to the work pipeline.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
256 else |
fd4cd1945b91
Connect volumecontrol flow to the work pipeline.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
257 op_data.current_output_plugin->get_volume(l, r); |
2313 | 258 } |
259 | |
260 void | |
261 output_set_volume(gint l, gint r) | |
262 { | |
263 if (!op_data.current_output_plugin) | |
264 return; | |
265 | |
266 if (!op_data.current_output_plugin->set_volume) | |
267 return; | |
268 | |
3546
fd4cd1945b91
Connect volumecontrol flow to the work pipeline.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
269 if (cfg.software_volume_control) |
fd4cd1945b91
Connect volumecontrol flow to the work pipeline.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
270 volumecontrol_set_volume_state(l, r); |
fd4cd1945b91
Connect volumecontrol flow to the work pipeline.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
271 else |
fd4cd1945b91
Connect volumecontrol flow to the work pipeline.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
272 op_data.current_output_plugin->set_volume(l, r); |
2313 | 273 } |
274 | |
275 void | |
276 output_set_eq(gboolean active, gfloat pre, gfloat * bands) | |
277 { | |
278 int i; | |
279 preamp[0] = 1.0 + 0.0932471 * pre + 0.00279033 * pre * pre; | |
280 preamp[1] = 1.0 + 0.0932471 * pre + 0.00279033 * pre * pre; | |
281 | |
282 for (i = 0; i < 10; ++i) | |
283 { | |
2813
49f3d1b43518
[svn] - code cleanups involving SRC patch and indentation
nenolod
parents:
2811
diff
changeset
|
284 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
|
285 set_gain(i, 1, 0.03 * bands[i] + 0.000999999 * bands[i] * bands[i]); |
2313 | 286 } |
287 } | |
288 | |
289 /* called by input plugin to peek at the output plugin's write progress */ | |
290 gint | |
291 get_written_time(void) | |
292 { | |
293 OutputPlugin *op = get_current_output_plugin(); | |
294 | |
295 return op->written_time(); | |
296 } | |
297 | |
298 /* called by input plugin to peek at the output plugin's output progress */ | |
299 gint | |
300 get_output_time(void) | |
301 { | |
302 OutputPlugin *op = get_current_output_plugin(); | |
303 | |
304 return op->output_time(); | |
305 } | |
306 | |
2538
719e0898ff3c
[svn] - Patch to use libsamplerate for high-quality interpolated upsampling,
nenolod
parents:
2373
diff
changeset
|
307 #ifdef USE_SRC |
2813
49f3d1b43518
[svn] - code cleanups involving SRC patch and indentation
nenolod
parents:
2811
diff
changeset
|
308 |
2538
719e0898ff3c
[svn] - Patch to use libsamplerate for high-quality interpolated upsampling,
nenolod
parents:
2373
diff
changeset
|
309 static SRC_STATE *src_state; |
719e0898ff3c
[svn] - Patch to use libsamplerate for high-quality interpolated upsampling,
nenolod
parents:
2373
diff
changeset
|
310 static SRC_DATA src_data; |
719e0898ff3c
[svn] - Patch to use libsamplerate for high-quality interpolated upsampling,
nenolod
parents:
2373
diff
changeset
|
311 static int overSamplingFs = 96000; |
719e0898ff3c
[svn] - Patch to use libsamplerate for high-quality interpolated upsampling,
nenolod
parents:
2373
diff
changeset
|
312 static int converter_type = SRC_SINC_BEST_QUALITY; |
719e0898ff3c
[svn] - Patch to use libsamplerate for high-quality interpolated upsampling,
nenolod
parents:
2373
diff
changeset
|
313 static int srcError = 0; |
2648
51495131e4ae
[svn] - synchronize SRC conversion patch with upstream
nenolod
parents:
2542
diff
changeset
|
314 |
51495131e4ae
[svn] - synchronize SRC conversion patch with upstream
nenolod
parents:
2542
diff
changeset
|
315 static float *srcIn = NULL, *srcOut = NULL; |
51495131e4ae
[svn] - synchronize SRC conversion patch with upstream
nenolod
parents:
2542
diff
changeset
|
316 static short int *wOut = NULL; |
51495131e4ae
[svn] - synchronize SRC conversion patch with upstream
nenolod
parents:
2542
diff
changeset
|
317 static int lengthOfSrcIn = 0; |
51495131e4ae
[svn] - synchronize SRC conversion patch with upstream
nenolod
parents:
2542
diff
changeset
|
318 static int lengthOfSrcOut = 0; |
51495131e4ae
[svn] - synchronize SRC conversion patch with upstream
nenolod
parents:
2542
diff
changeset
|
319 |
2538
719e0898ff3c
[svn] - Patch to use libsamplerate for high-quality interpolated upsampling,
nenolod
parents:
2373
diff
changeset
|
320 static void freeSRC() |
719e0898ff3c
[svn] - Patch to use libsamplerate for high-quality interpolated upsampling,
nenolod
parents:
2373
diff
changeset
|
321 { |
719e0898ff3c
[svn] - Patch to use libsamplerate for high-quality interpolated upsampling,
nenolod
parents:
2373
diff
changeset
|
322 if(src_state != NULL) |
719e0898ff3c
[svn] - Patch to use libsamplerate for high-quality interpolated upsampling,
nenolod
parents:
2373
diff
changeset
|
323 src_state = src_delete(src_state); |
2648
51495131e4ae
[svn] - synchronize SRC conversion patch with upstream
nenolod
parents:
2542
diff
changeset
|
324 free(srcIn); |
51495131e4ae
[svn] - synchronize SRC conversion patch with upstream
nenolod
parents:
2542
diff
changeset
|
325 free(srcOut); |
51495131e4ae
[svn] - synchronize SRC conversion patch with upstream
nenolod
parents:
2542
diff
changeset
|
326 free(wOut); |
51495131e4ae
[svn] - synchronize SRC conversion patch with upstream
nenolod
parents:
2542
diff
changeset
|
327 srcIn = NULL; |
51495131e4ae
[svn] - synchronize SRC conversion patch with upstream
nenolod
parents:
2542
diff
changeset
|
328 srcOut = NULL; |
51495131e4ae
[svn] - synchronize SRC conversion patch with upstream
nenolod
parents:
2542
diff
changeset
|
329 wOut = NULL; |
51495131e4ae
[svn] - synchronize SRC conversion patch with upstream
nenolod
parents:
2542
diff
changeset
|
330 lengthOfSrcIn = 0; |
51495131e4ae
[svn] - synchronize SRC conversion patch with upstream
nenolod
parents:
2542
diff
changeset
|
331 lengthOfSrcOut = 0; |
2538
719e0898ff3c
[svn] - Patch to use libsamplerate for high-quality interpolated upsampling,
nenolod
parents:
2373
diff
changeset
|
332 } |
2813
49f3d1b43518
[svn] - code cleanups involving SRC patch and indentation
nenolod
parents:
2811
diff
changeset
|
333 |
2538
719e0898ff3c
[svn] - Patch to use libsamplerate for high-quality interpolated upsampling,
nenolod
parents:
2373
diff
changeset
|
334 #endif |
719e0898ff3c
[svn] - Patch to use libsamplerate for high-quality interpolated upsampling,
nenolod
parents:
2373
diff
changeset
|
335 |
4234 | 336 static SAD_dither_t *sad_state = NULL; |
337 static SAD_dither_t *sad_state_to_float = NULL; | |
338 static SAD_dither_t *sad_state_from_float = NULL; | |
339 static void *sad_out_buf = NULL; | |
340 static int sad_out_buf_length = 0; | |
4237
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
341 static ReplayGainInfo replay_gain_info = { |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
342 .track_gain = 0.0, |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
343 .track_peak = 0.0, |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
344 .album_gain = 0.0, |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
345 .album_peak = 0.0, |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
346 }; |
4234 | 347 |
348 static void | |
349 freeSAD() | |
350 { | |
351 if (sad_state != NULL) {SAD_dither_free(sad_state); sad_state = NULL;} | |
352 if (sad_state_from_float != NULL) {SAD_dither_free(sad_state_from_float); sad_state_from_float = NULL;} | |
353 if (sad_state_to_float != NULL) {SAD_dither_free(sad_state_to_float); sad_state_to_float = NULL;} | |
354 if (sad_out_buf != NULL) {free(sad_out_buf); sad_out_buf = NULL; sad_out_buf_length = 0;} | |
355 } | |
356 | |
2313 | 357 gint |
358 output_open_audio(AFormat fmt, gint rate, gint nch) | |
359 { | |
360 gint ret; | |
361 OutputPlugin *op; | |
4234 | 362 AUDDBG("\n"); |
363 | |
364 AFormat output_fmt; | |
365 int bit_depth; | |
366 SAD_buffer_format input_sad_fmt; | |
367 SAD_buffer_format output_sad_fmt; | |
368 | |
2538
719e0898ff3c
[svn] - Patch to use libsamplerate for high-quality interpolated upsampling,
nenolod
parents:
2373
diff
changeset
|
369 #ifdef USE_SRC |
719e0898ff3c
[svn] - Patch to use libsamplerate for high-quality interpolated upsampling,
nenolod
parents:
2373
diff
changeset
|
370 gboolean src_enabled; |
719e0898ff3c
[svn] - Patch to use libsamplerate for high-quality interpolated upsampling,
nenolod
parents:
2373
diff
changeset
|
371 gint src_rate, src_type; |
4237
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
372 ConfigDb *db; |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
373 |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
374 db = cfg_db_open(); |
2538
719e0898ff3c
[svn] - Patch to use libsamplerate for high-quality interpolated upsampling,
nenolod
parents:
2373
diff
changeset
|
375 |
3686
259b7d3e0976
sed s/bmp_cfg_db/cfg_db/.
William Pitcock <nenolod@atheme.org>
parents:
3681
diff
changeset
|
376 if (cfg_db_get_bool(db, NULL, "enable_src", &src_enabled) == FALSE) |
2538
719e0898ff3c
[svn] - Patch to use libsamplerate for high-quality interpolated upsampling,
nenolod
parents:
2373
diff
changeset
|
377 src_enabled = FALSE; |
719e0898ff3c
[svn] - Patch to use libsamplerate for high-quality interpolated upsampling,
nenolod
parents:
2373
diff
changeset
|
378 |
3686
259b7d3e0976
sed s/bmp_cfg_db/cfg_db/.
William Pitcock <nenolod@atheme.org>
parents:
3681
diff
changeset
|
379 if (cfg_db_get_int(db, NULL, "src_rate", &src_rate) == FALSE) |
2538
719e0898ff3c
[svn] - Patch to use libsamplerate for high-quality interpolated upsampling,
nenolod
parents:
2373
diff
changeset
|
380 overSamplingFs = 48000; |
719e0898ff3c
[svn] - Patch to use libsamplerate for high-quality interpolated upsampling,
nenolod
parents:
2373
diff
changeset
|
381 else |
719e0898ff3c
[svn] - Patch to use libsamplerate for high-quality interpolated upsampling,
nenolod
parents:
2373
diff
changeset
|
382 overSamplingFs = src_rate; |
719e0898ff3c
[svn] - Patch to use libsamplerate for high-quality interpolated upsampling,
nenolod
parents:
2373
diff
changeset
|
383 |
2649
153dc928115a
[svn] - don't resample if source rate matches the internal clock rate. closes #881.
nenolod
parents:
2648
diff
changeset
|
384 /* don't resample if sampling rates are the same --nenolod */ |
153dc928115a
[svn] - don't resample if source rate matches the internal clock rate. closes #881.
nenolod
parents:
2648
diff
changeset
|
385 if (rate == overSamplingFs) |
153dc928115a
[svn] - don't resample if source rate matches the internal clock rate. closes #881.
nenolod
parents:
2648
diff
changeset
|
386 src_enabled = FALSE; |
153dc928115a
[svn] - don't resample if source rate matches the internal clock rate. closes #881.
nenolod
parents:
2648
diff
changeset
|
387 |
3686
259b7d3e0976
sed s/bmp_cfg_db/cfg_db/.
William Pitcock <nenolod@atheme.org>
parents:
3681
diff
changeset
|
388 if (cfg_db_get_int(db, NULL, "src_type", &src_type) == FALSE) |
2538
719e0898ff3c
[svn] - Patch to use libsamplerate for high-quality interpolated upsampling,
nenolod
parents:
2373
diff
changeset
|
389 converter_type = SRC_SINC_BEST_QUALITY; |
719e0898ff3c
[svn] - Patch to use libsamplerate for high-quality interpolated upsampling,
nenolod
parents:
2373
diff
changeset
|
390 else |
719e0898ff3c
[svn] - Patch to use libsamplerate for high-quality interpolated upsampling,
nenolod
parents:
2373
diff
changeset
|
391 converter_type = src_type; |
719e0898ff3c
[svn] - Patch to use libsamplerate for high-quality interpolated upsampling,
nenolod
parents:
2373
diff
changeset
|
392 |
719e0898ff3c
[svn] - Patch to use libsamplerate for high-quality interpolated upsampling,
nenolod
parents:
2373
diff
changeset
|
393 freeSRC(); |
719e0898ff3c
[svn] - Patch to use libsamplerate for high-quality interpolated upsampling,
nenolod
parents:
2373
diff
changeset
|
394 |
4234 | 395 if(src_enabled) |
2538
719e0898ff3c
[svn] - Patch to use libsamplerate for high-quality interpolated upsampling,
nenolod
parents:
2373
diff
changeset
|
396 { |
719e0898ff3c
[svn] - Patch to use libsamplerate for high-quality interpolated upsampling,
nenolod
parents:
2373
diff
changeset
|
397 src_state = src_new(converter_type, nch, &srcError); |
719e0898ff3c
[svn] - Patch to use libsamplerate for high-quality interpolated upsampling,
nenolod
parents:
2373
diff
changeset
|
398 if (src_state != NULL) |
719e0898ff3c
[svn] - Patch to use libsamplerate for high-quality interpolated upsampling,
nenolod
parents:
2373
diff
changeset
|
399 { |
719e0898ff3c
[svn] - Patch to use libsamplerate for high-quality interpolated upsampling,
nenolod
parents:
2373
diff
changeset
|
400 src_data.src_ratio = (float)overSamplingFs/(float)rate; |
719e0898ff3c
[svn] - Patch to use libsamplerate for high-quality interpolated upsampling,
nenolod
parents:
2373
diff
changeset
|
401 rate = overSamplingFs; |
719e0898ff3c
[svn] - Patch to use libsamplerate for high-quality interpolated upsampling,
nenolod
parents:
2373
diff
changeset
|
402 } |
719e0898ff3c
[svn] - Patch to use libsamplerate for high-quality interpolated upsampling,
nenolod
parents:
2373
diff
changeset
|
403 else |
4234 | 404 { |
2538
719e0898ff3c
[svn] - Patch to use libsamplerate for high-quality interpolated upsampling,
nenolod
parents:
2373
diff
changeset
|
405 fprintf(stderr, "src_new(): %s\n\n", src_strerror(srcError)); |
4234 | 406 src_enabled = FALSE; |
407 } | |
2538
719e0898ff3c
[svn] - Patch to use libsamplerate for high-quality interpolated upsampling,
nenolod
parents:
2373
diff
changeset
|
408 } |
4237
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
409 |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
410 cfg_db_close(db); |
2538
719e0898ff3c
[svn] - Patch to use libsamplerate for high-quality interpolated upsampling,
nenolod
parents:
2373
diff
changeset
|
411 #endif |
719e0898ff3c
[svn] - Patch to use libsamplerate for high-quality interpolated upsampling,
nenolod
parents:
2373
diff
changeset
|
412 |
4237
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
413 /*if (cfg_db_get_int(db, NULL, "output_bit_depth", &bit_depth) == FALSE) bit_depth = 16;*/ |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
414 bit_depth = cfg.output_bit_depth; |
4234 | 415 |
416 AUDDBG("bit depth: %d\n", bit_depth); | |
4238
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4237
diff
changeset
|
417 output_fmt = (bit_depth == 24) ? FMT_S24_NE : FMT_S16_NE; |
75ea2083e744
some endianness-related changes
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4237
diff
changeset
|
418 /*output_fmt = (bit_depth == 24) ? FMT_S24_LE : FMT_S16_LE;*/ /* no reason to support other output formats --asphyx */ |
4234 | 419 |
420 freeSAD(); | |
421 | |
422 #ifdef USE_SRC | |
423 if (src_enabled) { | |
424 AUDDBG("initializing dithering engine for 2 stage conversion\n"); | |
425 input_sad_fmt.sample_format = sadfmt_from_afmt(fmt); | |
4239
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
426 if (input_sad_fmt.sample_format < 0) return FALSE; |
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
|
427 input_sad_fmt.fracbits = FMT_FRACBITS(fmt); |
4234 | 428 input_sad_fmt.channels = nch; |
429 input_sad_fmt.channels_order = SAD_CHORDER_INTERLEAVED; | |
430 input_sad_fmt.samplerate = 0; | |
431 | |
432 output_sad_fmt.sample_format = SAD_SAMPLE_FLOAT; | |
433 output_sad_fmt.fracbits = 0; | |
434 output_sad_fmt.channels = nch; | |
435 output_sad_fmt.channels_order = SAD_CHORDER_INTERLEAVED; | |
436 output_sad_fmt.samplerate = 0; | |
437 | |
438 sad_state_to_float = SAD_dither_init(&input_sad_fmt, &output_sad_fmt, &ret); | |
439 if (sad_state_to_float == NULL) { | |
440 AUDDBG("ditherer init failed (decoder's native --> float)\n"); | |
4239
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
441 return FALSE; |
4234 | 442 } |
443 SAD_dither_set_dither (sad_state_to_float, FALSE); | |
444 | |
445 input_sad_fmt.sample_format = SAD_SAMPLE_FLOAT; | |
446 input_sad_fmt.fracbits = 0; | |
447 input_sad_fmt.channels = nch; | |
448 input_sad_fmt.channels_order = SAD_CHORDER_INTERLEAVED; | |
449 input_sad_fmt.samplerate = 0; | |
450 | |
451 output_sad_fmt.sample_format = sadfmt_from_afmt(output_fmt); | |
4239
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
452 if (output_sad_fmt.sample_format < 0) return FALSE; |
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
|
453 output_sad_fmt.fracbits = FMT_FRACBITS(output_fmt); |
4234 | 454 output_sad_fmt.channels = nch; |
455 output_sad_fmt.channels_order = SAD_CHORDER_INTERLEAVED; | |
456 output_sad_fmt.samplerate = 0; | |
457 | |
458 sad_state_from_float = SAD_dither_init(&input_sad_fmt, &output_sad_fmt, &ret); | |
459 if (sad_state_from_float == NULL) { | |
460 SAD_dither_free(sad_state_to_float); | |
461 AUDDBG("ditherer init failed (float --> output)\n"); | |
4239
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
462 return FALSE; |
4234 | 463 } |
464 SAD_dither_set_dither (sad_state_from_float, TRUE); | |
465 | |
466 fmt = output_fmt; | |
467 } else | |
468 #endif /* USE_SRC */ | |
4237
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
469 { /* needed for RG processing !*/ |
4234 | 470 AUDDBG("initializing dithering engine for direct conversion\n"); |
471 | |
472 input_sad_fmt.sample_format = sadfmt_from_afmt(fmt); | |
4239
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
473 if (input_sad_fmt.sample_format < 0) return FALSE; |
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
|
474 input_sad_fmt.fracbits = FMT_FRACBITS(fmt); |
4234 | 475 input_sad_fmt.channels = nch; |
476 input_sad_fmt.channels_order = SAD_CHORDER_INTERLEAVED; | |
477 input_sad_fmt.samplerate = 0; /* resampling not implemented yet in libSAD */ | |
478 | |
479 output_sad_fmt.sample_format = sadfmt_from_afmt(output_fmt); | |
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
|
480 output_sad_fmt.fracbits = FMT_FRACBITS(output_fmt); |
4234 | 481 output_sad_fmt.channels = nch; |
482 output_sad_fmt.channels_order = SAD_CHORDER_INTERLEAVED; | |
483 output_sad_fmt.samplerate = 0; | |
484 | |
485 sad_state = SAD_dither_init(&input_sad_fmt, &output_sad_fmt, &ret); | |
486 if (sad_state == NULL) { | |
487 AUDDBG("ditherer init failed\n"); | |
4239
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
488 return FALSE; |
4234 | 489 } |
490 SAD_dither_set_dither (sad_state, TRUE); | |
491 | |
492 fmt = output_fmt; | |
493 } | |
4237
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
494 |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
495 if(replay_gain_info.album_peak != 0.0 || replay_gain_info.track_peak != 0.0) |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
496 apply_replaygain_info(&replay_gain_info); |
4234 | 497 |
2313 | 498 op = get_current_output_plugin(); |
499 | |
500 if (op == NULL) | |
4239
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
501 return FALSE; |
2313 | 502 |
503 /* Is our output port already open? */ | |
504 if ((op_state.rate != 0 && op_state.nch != 0) && | |
2813
49f3d1b43518
[svn] - code cleanups involving SRC patch and indentation
nenolod
parents:
2811
diff
changeset
|
505 (op_state.rate == rate && op_state.nch == nch && op_state.fmt == fmt)) |
2313 | 506 { |
2813
49f3d1b43518
[svn] - code cleanups involving SRC patch and indentation
nenolod
parents:
2811
diff
changeset
|
507 /* Yes, and it's the correct sampling rate. Reset the counter and go. */ |
4235
2d4b4f13d10d
set_replaygain_info added to PAPI
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
508 AUDDBG("flushing output instead of reopening\n"); |
2813
49f3d1b43518
[svn] - code cleanups involving SRC patch and indentation
nenolod
parents:
2811
diff
changeset
|
509 op->flush(0); |
4239
51291ce4eb54
some endianness-related changes, corrected error handling
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4238
diff
changeset
|
510 return TRUE; |
2313 | 511 } |
512 else if (op_state.rate != 0 && op_state.nch != 0) | |
2813
49f3d1b43518
[svn] - code cleanups involving SRC patch and indentation
nenolod
parents:
2811
diff
changeset
|
513 op->close_audio(); |
2313 | 514 |
515 ret = op->open_audio(fmt, rate, nch); | |
516 | |
2373
ad1d7687814c
[svn] made strings.h for existing strings.c, cleanups
mf0102
parents:
2328
diff
changeset
|
517 if (ret == 1) /* Success? */ |
2313 | 518 { |
4234 | 519 AUDDBG("opened audio: fmt=%d, rate=%d, nch=%d\n", fmt, rate, nch); |
2313 | 520 op_state.fmt = fmt; |
521 op_state.rate = rate; | |
522 op_state.nch = nch; | |
523 } | |
524 | |
525 return ret; | |
526 } | |
527 | |
528 void | |
529 output_write_audio(gpointer ptr, gint length) | |
530 { | |
531 OutputPlugin *op = get_current_output_plugin(); | |
532 | |
533 /* Sanity check. */ | |
534 if (op == NULL) | |
535 return; | |
536 | |
537 op->write_audio(ptr, length); | |
538 } | |
539 | |
540 void | |
541 output_close_audio(void) | |
542 { | |
543 OutputPlugin *op = get_current_output_plugin(); | |
544 | |
4234 | 545 AUDDBG("\n"); |
546 | |
2538
719e0898ff3c
[svn] - Patch to use libsamplerate for high-quality interpolated upsampling,
nenolod
parents:
2373
diff
changeset
|
547 #ifdef USE_SRC |
719e0898ff3c
[svn] - Patch to use libsamplerate for high-quality interpolated upsampling,
nenolod
parents:
2373
diff
changeset
|
548 freeSRC(); |
719e0898ff3c
[svn] - Patch to use libsamplerate for high-quality interpolated upsampling,
nenolod
parents:
2373
diff
changeset
|
549 #endif |
4234 | 550 freeSAD(); |
4237
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
551 |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
552 AUDDBG("clearing RG settings\n"); |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
553 replay_gain_info.track_gain = 0.0; |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
554 replay_gain_info.track_peak = 0.0; |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
555 replay_gain_info.album_gain = 0.0; |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
556 replay_gain_info.album_peak = 0.0; |
2538
719e0898ff3c
[svn] - Patch to use libsamplerate for high-quality interpolated upsampling,
nenolod
parents:
2373
diff
changeset
|
557 |
2313 | 558 /* Do not close if there are still songs to play and the user has |
559 * not requested a stop. --nenolod | |
560 */ | |
561 if (ip_data.stop == FALSE && | |
2673 | 562 (playlist_get_position_nolock(playlist_get_active()) < |
563 playlist_get_length(playlist_get_active()) - 1)) | |
2313 | 564 return; |
565 | |
566 /* Sanity check. */ | |
567 if (op == NULL) | |
568 return; | |
569 | |
570 op->close_audio(); | |
571 | |
572 /* Reset the op_state. */ | |
573 op_state.fmt = op_state.rate = op_state.nch = 0; | |
574 } | |
575 | |
576 void | |
577 output_flush(gint time) | |
578 { | |
579 OutputPlugin *op = get_current_output_plugin(); | |
580 | |
581 if (op == NULL) | |
582 return; | |
583 | |
584 op->flush(time); | |
585 } | |
586 | |
587 void | |
588 output_pause(gshort paused) | |
589 { | |
590 OutputPlugin *op = get_current_output_plugin(); | |
591 | |
592 if (op == NULL) | |
593 return; | |
594 | |
595 op->pause(paused); | |
596 } | |
597 | |
598 gint | |
599 output_buffer_free(void) | |
600 { | |
601 OutputPlugin *op = get_current_output_plugin(); | |
602 | |
603 if (op == NULL) | |
604 return 0; | |
605 | |
606 return op->buffer_free(); | |
607 } | |
608 | |
609 gint | |
610 output_buffer_playing(void) | |
611 { | |
612 OutputPlugin *op = get_current_output_plugin(); | |
613 | |
614 if (op == NULL) | |
615 return 0; | |
616 | |
617 return op->buffer_playing(); | |
618 } | |
619 | |
620 /* called by input plugin when data is ready */ | |
621 void | |
3709
a89a12aa4f2c
Add InputPlayback::pass_audio() which replaces produce_audio().
William Pitcock <nenolod@atheme.org>
parents:
3708
diff
changeset
|
622 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
|
623 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
|
624 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
|
625 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
|
626 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
|
627 int *going /* 0 when time to stop */ |
2313 | 628 ) |
629 { | |
3553
a140fadd741d
software volumecontrol->flow manager API
William Pitcock <nenolod@atheme.org>
parents:
3549
diff
changeset
|
630 static Flow *postproc_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
|
631 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
|
632 gint writeoffs; |
4234 | 633 |
634 if (length <= 0) return; | |
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
|
635 gint time = playback->output->written_time(); |
2313 | 636 |
3553
a140fadd741d
software volumecontrol->flow manager API
William Pitcock <nenolod@atheme.org>
parents:
3549
diff
changeset
|
637 if (postproc_flow == NULL) |
a140fadd741d
software volumecontrol->flow manager API
William Pitcock <nenolod@atheme.org>
parents:
3549
diff
changeset
|
638 { |
a140fadd741d
software volumecontrol->flow manager API
William Pitcock <nenolod@atheme.org>
parents:
3549
diff
changeset
|
639 postproc_flow = flow_new(); |
3560
154f21dcd61e
equalizer -> flow API
William Pitcock <nenolod@atheme.org>
parents:
3559
diff
changeset
|
640 flow_link_element(postproc_flow, iir_flow); |
3555
a73951b8cd9f
effect processing -> flow manager API / attached to postproc_flow.
William Pitcock <nenolod@atheme.org>
parents:
3553
diff
changeset
|
641 flow_link_element(postproc_flow, effect_flow); |
3559 | 642 flow_link_element(postproc_flow, vis_flow); |
3553
a140fadd741d
software volumecontrol->flow manager API
William Pitcock <nenolod@atheme.org>
parents:
3549
diff
changeset
|
643 flow_link_element(postproc_flow, volumecontrol_flow); |
a140fadd741d
software volumecontrol->flow manager API
William Pitcock <nenolod@atheme.org>
parents:
3549
diff
changeset
|
644 } |
a140fadd741d
software volumecontrol->flow manager API
William Pitcock <nenolod@atheme.org>
parents:
3549
diff
changeset
|
645 |
2538
719e0898ff3c
[svn] - Patch to use libsamplerate for high-quality interpolated upsampling,
nenolod
parents:
2373
diff
changeset
|
646 #ifdef USE_SRC |
4234 | 647 if(src_state != NULL) |
2538
719e0898ff3c
[svn] - Patch to use libsamplerate for high-quality interpolated upsampling,
nenolod
parents:
2373
diff
changeset
|
648 { |
4234 | 649 /*int lrLength = length / nch;*/ |
650 int lrLength = length / sample_size(fmt); | |
2538
719e0898ff3c
[svn] - Patch to use libsamplerate for high-quality interpolated upsampling,
nenolod
parents:
2373
diff
changeset
|
651 int overLrLength = (int)floor(lrLength*(src_data.src_ratio+1)); |
2648
51495131e4ae
[svn] - synchronize SRC conversion patch with upstream
nenolod
parents:
2542
diff
changeset
|
652 if(lengthOfSrcIn < lrLength) |
51495131e4ae
[svn] - synchronize SRC conversion patch with upstream
nenolod
parents:
2542
diff
changeset
|
653 { |
51495131e4ae
[svn] - synchronize SRC conversion patch with upstream
nenolod
parents:
2542
diff
changeset
|
654 lengthOfSrcIn = lrLength; |
51495131e4ae
[svn] - synchronize SRC conversion patch with upstream
nenolod
parents:
2542
diff
changeset
|
655 free(srcIn); |
51495131e4ae
[svn] - synchronize SRC conversion patch with upstream
nenolod
parents:
2542
diff
changeset
|
656 srcIn = (float*)malloc(sizeof(float)*lrLength); |
51495131e4ae
[svn] - synchronize SRC conversion patch with upstream
nenolod
parents:
2542
diff
changeset
|
657 } |
51495131e4ae
[svn] - synchronize SRC conversion patch with upstream
nenolod
parents:
2542
diff
changeset
|
658 if(lengthOfSrcOut < overLrLength) |
51495131e4ae
[svn] - synchronize SRC conversion patch with upstream
nenolod
parents:
2542
diff
changeset
|
659 { |
51495131e4ae
[svn] - synchronize SRC conversion patch with upstream
nenolod
parents:
2542
diff
changeset
|
660 lengthOfSrcOut = overLrLength; |
51495131e4ae
[svn] - synchronize SRC conversion patch with upstream
nenolod
parents:
2542
diff
changeset
|
661 free(srcOut); |
51495131e4ae
[svn] - synchronize SRC conversion patch with upstream
nenolod
parents:
2542
diff
changeset
|
662 free(wOut); |
51495131e4ae
[svn] - synchronize SRC conversion patch with upstream
nenolod
parents:
2542
diff
changeset
|
663 srcOut = (float*)malloc(sizeof(float)*overLrLength); |
4234 | 664 wOut = (short int*)malloc(sample_size(op_state.fmt) * overLrLength); |
2648
51495131e4ae
[svn] - synchronize SRC conversion patch with upstream
nenolod
parents:
2542
diff
changeset
|
665 } |
4234 | 666 /*src_short_to_float_array((short int*)ptr, srcIn, lrLength);*/ |
667 SAD_dither_process_buffer(sad_state_to_float, ptr, srcIn, lrLength / nch); | |
2538
719e0898ff3c
[svn] - Patch to use libsamplerate for high-quality interpolated upsampling,
nenolod
parents:
2373
diff
changeset
|
668 src_data.data_in = srcIn; |
719e0898ff3c
[svn] - Patch to use libsamplerate for high-quality interpolated upsampling,
nenolod
parents:
2373
diff
changeset
|
669 src_data.data_out = srcOut; |
719e0898ff3c
[svn] - Patch to use libsamplerate for high-quality interpolated upsampling,
nenolod
parents:
2373
diff
changeset
|
670 src_data.end_of_input = 0; |
4186
833e5faa5847
Make sample rate conversion work with mono files. (Bugzilla #88)
William Pitcock <nenolod@atheme.org>
parents:
3984
diff
changeset
|
671 src_data.input_frames = lrLength / nch; |
833e5faa5847
Make sample rate conversion work with mono files. (Bugzilla #88)
William Pitcock <nenolod@atheme.org>
parents:
3984
diff
changeset
|
672 src_data.output_frames = overLrLength / nch; |
2542 | 673 if ((srcError = src_process(src_state, &src_data)) > 0) |
2538
719e0898ff3c
[svn] - Patch to use libsamplerate for high-quality interpolated upsampling,
nenolod
parents:
2373
diff
changeset
|
674 { |
719e0898ff3c
[svn] - Patch to use libsamplerate for high-quality interpolated upsampling,
nenolod
parents:
2373
diff
changeset
|
675 fprintf(stderr, "src_process(): %s\n", src_strerror(srcError)); |
719e0898ff3c
[svn] - Patch to use libsamplerate for high-quality interpolated upsampling,
nenolod
parents:
2373
diff
changeset
|
676 } |
719e0898ff3c
[svn] - Patch to use libsamplerate for high-quality interpolated upsampling,
nenolod
parents:
2373
diff
changeset
|
677 else |
719e0898ff3c
[svn] - Patch to use libsamplerate for high-quality interpolated upsampling,
nenolod
parents:
2373
diff
changeset
|
678 { |
4234 | 679 /*src_float_to_short_array(srcOut, wOut, src_data.output_frames_gen*2);*/ |
680 SAD_dither_process_buffer(sad_state_from_float, srcOut, wOut, src_data.output_frames_gen); | |
2538
719e0898ff3c
[svn] - Patch to use libsamplerate for high-quality interpolated upsampling,
nenolod
parents:
2373
diff
changeset
|
681 ptr = wOut; |
4234 | 682 length = src_data.output_frames_gen * op_state.nch * sample_size(op_state.fmt); |
2538
719e0898ff3c
[svn] - Patch to use libsamplerate for high-quality interpolated upsampling,
nenolod
parents:
2373
diff
changeset
|
683 } |
4234 | 684 } else |
2538
719e0898ff3c
[svn] - Patch to use libsamplerate for high-quality interpolated upsampling,
nenolod
parents:
2373
diff
changeset
|
685 #endif |
4234 | 686 if(sad_state != NULL) { |
687 int frames = length / nch / sample_size(fmt); | |
688 int len = frames * op_state.nch * sample_size(op_state.fmt); | |
689 if(sad_out_buf == NULL || sad_out_buf_length < len ) { | |
690 if(sad_out_buf != NULL) free (sad_out_buf); | |
691 sad_out_buf = malloc(len); | |
692 sad_out_buf_length = len; | |
693 } | |
694 SAD_dither_process_buffer(sad_state, ptr, sad_out_buf, frames); | |
695 ptr = sad_out_buf; | |
4235
2d4b4f13d10d
set_replaygain_info added to PAPI
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
696 length = len; |
4234 | 697 } |
698 | |
699 if (op_state.fmt == FMT_S16_NE || (op_state.fmt == FMT_S16_LE && G_BYTE_ORDER == G_LITTLE_ENDIAN) || | |
700 (op_state.fmt == FMT_S16_BE && G_BYTE_ORDER == G_BIG_ENDIAN)) { | |
701 length = flow_execute(postproc_flow, time, &ptr, length, op_state.fmt, op_state.rate, op_state.nch); | |
702 } else { | |
703 AUDDBG("postproc_flow can deal only with S16_NE streams\n"); /*FIXME*/ | |
704 } | |
3546
fd4cd1945b91
Connect volumecontrol flow to the work pipeline.
William Pitcock <nenolod@atheme.org>
parents:
3486
diff
changeset
|
705 |
2313 | 706 writeoffs = 0; |
2373
ad1d7687814c
[svn] made strings.h for existing strings.c, cleanups
mf0102
parents:
2328
diff
changeset
|
707 while (writeoffs < length) |
ad1d7687814c
[svn] made strings.h for existing strings.c, cleanups
mf0102
parents:
2328
diff
changeset
|
708 { |
ad1d7687814c
[svn] made strings.h for existing strings.c, cleanups
mf0102
parents:
2328
diff
changeset
|
709 int writable = length - writeoffs; |
2313 | 710 |
2373
ad1d7687814c
[svn] made strings.h for existing strings.c, cleanups
mf0102
parents:
2328
diff
changeset
|
711 if (writable > 2048) |
ad1d7687814c
[svn] made strings.h for existing strings.c, cleanups
mf0102
parents:
2328
diff
changeset
|
712 writable = 2048; |
2313 | 713 |
2813
49f3d1b43518
[svn] - code cleanups involving SRC patch and indentation
nenolod
parents:
2811
diff
changeset
|
714 if (writable == 0) |
2373
ad1d7687814c
[svn] made strings.h for existing strings.c, cleanups
mf0102
parents:
2328
diff
changeset
|
715 return; |
2313 | 716 |
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
|
717 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
|
718 { |
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
|
719 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
|
720 |
418ac922ce87
Use a mutex/condvar/timed wait to allow tickless operation in the output loop.
William Pitcock <nenolod@atheme.org>
parents:
3686
diff
changeset
|
721 g_get_current_time(&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
|
722 g_time_val_add(&pb_abs_time, (cfg.output_buffer_size / 2) * 1000); |
418ac922ce87
Use a mutex/condvar/timed wait to allow tickless operation in the output loop.
William Pitcock <nenolod@atheme.org>
parents:
3686
diff
changeset
|
723 |
2373
ad1d7687814c
[svn] made strings.h for existing strings.c, cleanups
mf0102
parents:
2328
diff
changeset
|
724 if (going && !*going) /* thread stopped? */ |
ad1d7687814c
[svn] made strings.h for existing strings.c, cleanups
mf0102
parents:
2328
diff
changeset
|
725 return; /* so finish */ |
2313 | 726 |
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
|
727 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
|
728 return; /* yes, so finish */ |
2313 | 729 |
3680
6615978ca88c
Instead of waiting 10ms, wait half the time of the period buffer.
William Pitcock <nenolod@atheme.org>
parents:
3560
diff
changeset
|
730 /* else sleep for retry */ |
3787
bce5ac1f368b
don't use semaphore/condvar messaging on Darwin because mach threads are high latency
William Pitcock <nenolod@atheme.org>
parents:
3709
diff
changeset
|
731 #ifndef GDK_WINDOWING_QUARTZ |
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
|
732 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
|
733 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
|
734 g_mutex_unlock(playback->pb_change_mutex); |
3787
bce5ac1f368b
don't use semaphore/condvar messaging on Darwin because mach threads are high latency
William Pitcock <nenolod@atheme.org>
parents:
3709
diff
changeset
|
735 #else |
bce5ac1f368b
don't use semaphore/condvar messaging on Darwin because mach threads are high latency
William Pitcock <nenolod@atheme.org>
parents:
3709
diff
changeset
|
736 /* Darwin threading sucks. */ |
bce5ac1f368b
don't use semaphore/condvar messaging on Darwin because mach threads are high latency
William Pitcock <nenolod@atheme.org>
parents:
3709
diff
changeset
|
737 g_usleep(10000); |
bce5ac1f368b
don't use semaphore/condvar messaging on Darwin because mach threads are high latency
William Pitcock <nenolod@atheme.org>
parents:
3709
diff
changeset
|
738 #endif |
2373
ad1d7687814c
[svn] made strings.h for existing strings.c, cleanups
mf0102
parents:
2328
diff
changeset
|
739 } |
2313 | 740 |
2373
ad1d7687814c
[svn] made strings.h for existing strings.c, cleanups
mf0102
parents:
2328
diff
changeset
|
741 if (ip_data.stop) |
ad1d7687814c
[svn] made strings.h for existing strings.c, cleanups
mf0102
parents:
2328
diff
changeset
|
742 return; |
2313 | 743 |
2373
ad1d7687814c
[svn] made strings.h for existing strings.c, cleanups
mf0102
parents:
2328
diff
changeset
|
744 if (going && !*going) /* thread stopped? */ |
ad1d7687814c
[svn] made strings.h for existing strings.c, cleanups
mf0102
parents:
2328
diff
changeset
|
745 return; /* so finish */ |
2313 | 746 |
2373
ad1d7687814c
[svn] made strings.h for existing strings.c, cleanups
mf0102
parents:
2328
diff
changeset
|
747 /* do output */ |
ad1d7687814c
[svn] made strings.h for existing strings.c, cleanups
mf0102
parents:
2328
diff
changeset
|
748 op->write_audio(((guint8 *) ptr) + writeoffs, writable); |
2313 | 749 |
2373
ad1d7687814c
[svn] made strings.h for existing strings.c, cleanups
mf0102
parents:
2328
diff
changeset
|
750 writeoffs += writable; |
2313 | 751 } |
752 } | |
4235
2d4b4f13d10d
set_replaygain_info added to PAPI
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
753 |
4237
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
754 /* 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
|
755 void |
2d4b4f13d10d
set_replaygain_info added to PAPI
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
756 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
|
757 { |
4237
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
758 replay_gain_info = *rg_info; |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
759 apply_replaygain_info(rg_info); |
4235
2d4b4f13d10d
set_replaygain_info added to PAPI
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4234
diff
changeset
|
760 } |
4237
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
761 |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
762 static void |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
763 apply_replaygain_info (ReplayGainInfo *rg_info) |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
764 { |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
765 SAD_replaygain_mode mode; |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
766 SAD_replaygain_info info; |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
767 /*ConfigDb *db;*/ |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
768 gboolean rg_enabled; |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
769 gboolean album_mode; |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
770 SAD_dither_t *active_state; |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
771 |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
772 |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
773 if(sad_state == NULL && sad_state_from_float == NULL) { |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
774 AUDDBG("SAD not initialized!\n"); |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
775 return; |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
776 } |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
777 |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
778 rg_enabled = cfg.enable_replay_gain; |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
779 album_mode = cfg.replay_gain_album; |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
780 mode.clipping_prevention = cfg.enable_clipping_prevention; |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
781 mode.hard_limit = cfg.enable_hard_limiter; |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
782 |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
783 if(!rg_enabled) return; |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
784 |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
785 mode.mode = album_mode ? SAD_RG_ALBUM : SAD_RG_TRACK; |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
786 mode.preamp = 0.0; /*FIXME*/ |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
787 |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
788 info.present = TRUE; |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
789 info.track_gain = rg_info->track_gain; |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
790 info.track_peak = rg_info->track_peak; |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
791 info.album_gain = rg_info->album_gain; |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
792 info.album_peak = rg_info->album_peak; |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
793 |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
794 AUDDBG("Applying Replay Gain settings:\n"); |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
795 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
|
796 AUDDBG("* clipping prevention: %s\n", mode.clipping_prevention ? "yes" : "no"); |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
797 AUDDBG("* hard limit: %s\n", mode.hard_limit ? "yes" : "no"); |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
798 AUDDBG("* preamp: %+f dB\n", mode.preamp); |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
799 AUDDBG("Replay Gain info for current track:\n"); |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
800 AUDDBG("* track gain: %+f dB\n", info.track_gain); |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
801 AUDDBG("* track peak: %f\n", info.track_peak); |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
802 AUDDBG("* album gain: %+f dB\n", info.album_gain); |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
803 AUDDBG("* album peak: %f\n", info.album_peak); |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
804 |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
805 active_state = sad_state != NULL ? sad_state : sad_state_from_float; |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
806 SAD_dither_apply_replaygain(active_state, &info, &mode); |
8f6956130372
initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4235
diff
changeset
|
807 } |