annotate src/audacious/output.c @ 4752:22b7212eb3f9

move FMT_FRACBITS() to plugin.h
author Andrew O. Shadoura <bugzilla@tut.by>
date Wed, 06 Aug 2008 23:04:34 +0300
parents b3e4f5c31546
children f084f639e962
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1 /* Audacious - Cross-platform multimedia player
4234
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4186
diff changeset
2 * Copyright (C) 2005-2008 Audacious team
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3 *
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
4 * Based on BMP:
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
5 * Copyright (C) 2003-2004 BMP development team.
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
6 *
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
7 * Based on XMMS:
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
8 * Copyright (C) 1998-2003 XMMS development team.
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
9 *
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
10 * This program is free software; you can redistribute it and/or modify
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
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
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
13 *
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
14 * This program is distributed in the hope that it will be useful,
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
17 * GNU General Public License for more details.
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
18 *
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
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
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
24 */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
25
4307
cfaecedace4e importing of winamp EQ presets library
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4306
diff changeset
26 /*#define AUD_DEBUG*/
4234
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4186
diff changeset
27
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
28 #ifdef HAVE_CONFIG_H
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
29 # include "config.h"
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
30 #endif
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
31
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
32 #include "output.h"
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
33 #include "main.h"
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
34 #include "input.h"
2328
d88558b0de0a [svn] - Added script for migration to XDG basedir.
js
parents: 2313
diff changeset
35 #include "playback.h"
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
36
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
37 #include "playlist.h"
2717
6884a2144a01 [svn] - make audacious build again
nenolod
parents: 2673
diff changeset
38 #include "configdb.h"
2542
ef01234ae265 [svn] - ppc64 warning fixes for upsampling patch
nenolod
parents: 2538
diff changeset
39
3553
a140fadd741d software volumecontrol->flow manager API
William Pitcock <nenolod@atheme.org>
parents: 3549
diff changeset
40 #include "flow.h"
a140fadd741d software volumecontrol->flow manager API
William Pitcock <nenolod@atheme.org>
parents: 3549
diff changeset
41
4266
2b7a74fce100 Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents: 4259
diff changeset
42 #include "pluginenum.h"
2b7a74fce100 Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents: 4259
diff changeset
43
2811
1c7ee5ed3a10 [svn] Move effect plugin handling into the main thread
ertzing
parents: 2717
diff changeset
44 #include "effect.h"
3546
fd4cd1945b91 Connect volumecontrol flow to the work pipeline.
William Pitcock <nenolod@atheme.org>
parents: 3486
diff changeset
45 #include "volumecontrol.h"
3559
0898b8139af8 Vis -> Flow API.
William Pitcock <nenolod@atheme.org>
parents: 3558
diff changeset
46 #include "visualization.h"
2811
1c7ee5ed3a10 [svn] Move effect plugin handling into the main thread
ertzing
parents: 2717
diff changeset
47
4234
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4186
diff changeset
48 #include "libSAD.h"
4259
92642f860860 - added template for src_flow
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4258
diff changeset
49 #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
50 #include "equalizer_flow.h"
4234
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4186
diff changeset
51
2542
ef01234ae265 [svn] - ppc64 warning fixes for upsampling patch
nenolod
parents: 2538
diff changeset
52 #include <math.h>
ef01234ae265 [svn] - ppc64 warning fixes for upsampling patch
nenolod
parents: 2538
diff changeset
53
4523
b3e4f5c31546 Conditional USE_SRC was changed to USE_SAMPLERATE earlier.
Matti Hamalainen <ccr@tnsp.org>
parents: 4364
diff changeset
54 #ifdef USE_SAMPLERATE
4267
a41fb6bc632a - src stuff traveled to src_flow.c
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4259
diff changeset
55 # include "src_flow.h"
2538
719e0898ff3c [svn] - Patch to use libsamplerate for high-quality interpolated upsampling,
nenolod
parents: 2373
diff changeset
56 #endif
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
57
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
58 OutputPluginData op_data = {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
59 NULL,
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
60 NULL
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
61 };
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
62
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
63 OutputPluginState op_state = {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
64 0,
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
65 0,
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
66 0
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
67 };
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
68
4267
a41fb6bc632a - src stuff traveled to src_flow.c
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4259
diff changeset
69 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
70 static gboolean bypass_dsp = FALSE;
4267
a41fb6bc632a - src stuff traveled to src_flow.c
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4259
diff changeset
71
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
72 OutputPlugin psuedo_output_plugin = {
3549
a5b1084e7f38 C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 3546
diff changeset
73 .description = "XMMS reverse compatibility output plugin",
a5b1084e7f38 C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 3546
diff changeset
74 .get_volume = output_get_volume,
a5b1084e7f38 C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 3546
diff changeset
75 .set_volume = output_set_volume,
a5b1084e7f38 C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 3546
diff changeset
76
a5b1084e7f38 C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 3546
diff changeset
77 .open_audio = output_open_audio,
a5b1084e7f38 C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 3546
diff changeset
78 .write_audio = output_write_audio,
a5b1084e7f38 C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 3546
diff changeset
79 .close_audio = output_close_audio,
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
80
3549
a5b1084e7f38 C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 3546
diff changeset
81 .flush = output_flush,
a5b1084e7f38 C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 3546
diff changeset
82 .pause = output_pause,
a5b1084e7f38 C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 3546
diff changeset
83
a5b1084e7f38 C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 3546
diff changeset
84 .buffer_free = output_buffer_free,
a5b1084e7f38 C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 3546
diff changeset
85 .buffer_playing = output_buffer_playing,
a5b1084e7f38 C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 3546
diff changeset
86 .output_time = get_output_time,
a5b1084e7f38 C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 3546
diff changeset
87 .written_time = get_written_time,
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
88 };
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
89
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
90 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
91
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
92 OutputPlugin *
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
93 get_current_output_plugin(void)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
94 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
95 return op_data.current_output_plugin;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
96 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
97
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
98 void
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
99 set_current_output_plugin(gint i)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
100 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
101 gboolean playing;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
102 OutputPlugin *op = get_current_output_plugin();
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
103
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
104 GList *node = g_list_nth(op_data.output_list, i);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
105 if (!node) {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
106 op_data.current_output_plugin = NULL;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
107 return;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
108 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
109
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
110 op_data.current_output_plugin = node->data;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
111
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
112 playing = playback_get_playing();
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
113
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
114 if (playing == TRUE)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
115 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
116 guint time, pos;
2373
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
117 PlaylistEntry *entry;
4266
2b7a74fce100 Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents: 4259
diff changeset
118
2b7a74fce100 Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents: 4259
diff changeset
119 plugin_set_current((Plugin *)op);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
120
2373
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
121 /* don't stop yet, get the seek time and playlist position first */
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
122 pos = playlist_get_position(playlist_get_active());
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
123 time = op->output_time();
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
124
2373
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
125 /* reset the audio system */
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
126 mainwin_stop_pushed();
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
127 op->close_audio();
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
128
2373
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
129 g_usleep(300000);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
130
2373
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
131 /* wait for the playback thread to come online */
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
132 while (playback_get_playing())
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
133 g_message("waiting for audio system shutdown...");
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
134
2373
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
135 /* wait for the playback thread to come online */
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
136 playlist_set_position(playlist_get_active(), pos);
2373
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
137 entry = playlist_get_entry_to_play(playlist_get_active());
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
138 playback_play_file(entry);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
139
2373
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
140 while (!playback_get_playing())
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
141 {
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
142 gtk_main_iteration();
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
143 g_message("waiting for audio system startup...");
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
144 }
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
145
2373
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
146 /* and signal a reseek */
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
147 if (playlist_get_current_length(playlist_get_active()) > -1 &&
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
148 time <= (playlist_get_current_length(playlist_get_active())))
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
149 playback_seek(time / 1000);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
150 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
151 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
152
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
153 GList *
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
154 get_output_list(void)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
155 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
156 return op_data.output_list;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
157 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
158
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
159 void
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
160 output_about(gint i)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
161 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
162 OutputPlugin *out = g_list_nth(op_data.output_list, i)->data;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
163 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
164 {
2b7a74fce100 Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents: 4259
diff changeset
165 plugin_set_current((Plugin *)out);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
166 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 }
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
168 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
169
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
170 void
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
171 output_configure(gint i)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
172 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
173 OutputPlugin *out = g_list_nth(op_data.output_list, i)->data;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
174 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
175 {
2b7a74fce100 Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents: 4259
diff changeset
176 plugin_set_current((Plugin *)out);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
177 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 }
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
179 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
180
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
181 void
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
182 output_get_volume(gint * l, gint * r)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
183 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
184 *l = *r = -1;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
185
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
186 if (!op_data.current_output_plugin)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
187 return;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
188
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
189 if (!op_data.current_output_plugin->get_volume)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
190 return;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
191
3546
fd4cd1945b91 Connect volumecontrol flow to the work pipeline.
William Pitcock <nenolod@atheme.org>
parents: 3486
diff changeset
192 if (cfg.software_volume_control)
fd4cd1945b91 Connect volumecontrol flow to the work pipeline.
William Pitcock <nenolod@atheme.org>
parents: 3486
diff changeset
193 volumecontrol_get_volume_state(l, r);
fd4cd1945b91 Connect volumecontrol flow to the work pipeline.
William Pitcock <nenolod@atheme.org>
parents: 3486
diff changeset
194 else
4266
2b7a74fce100 Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents: 4259
diff changeset
195 {
2b7a74fce100 Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents: 4259
diff changeset
196 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
197 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
198 }
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
199 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
200
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
201 void
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
202 output_set_volume(gint l, gint r)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
203 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
204 if (!op_data.current_output_plugin)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
205 return;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
206
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
207 if (!op_data.current_output_plugin->set_volume)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
208 return;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
209
3546
fd4cd1945b91 Connect volumecontrol flow to the work pipeline.
William Pitcock <nenolod@atheme.org>
parents: 3486
diff changeset
210 if (cfg.software_volume_control)
fd4cd1945b91 Connect volumecontrol flow to the work pipeline.
William Pitcock <nenolod@atheme.org>
parents: 3486
diff changeset
211 volumecontrol_set_volume_state(l, r);
fd4cd1945b91 Connect volumecontrol flow to the work pipeline.
William Pitcock <nenolod@atheme.org>
parents: 3486
diff changeset
212 else
4266
2b7a74fce100 Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents: 4259
diff changeset
213 {
2b7a74fce100 Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents: 4259
diff changeset
214 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
215 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
216 }
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
217 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
218
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
219 void
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
220 output_set_eq(gboolean active, gfloat pre, gfloat * bands)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
221 {
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
222 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
223 bands[5], bands[6], bands[7], bands[8], bands[9]);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
224
4306
172d49b1200b - equalizer sliders range changed to -12..12 dB
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4303
diff changeset
225 equalizer_flow_set_bands(pre, bands);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
226 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
227
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
228 /* called by input plugin to peek at the output plugin's write progress */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
229 gint
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
230 get_written_time(void)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
231 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
232 OutputPlugin *op = get_current_output_plugin();
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
233
4266
2b7a74fce100 Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents: 4259
diff changeset
234 plugin_set_current((Plugin *)op);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
235 return op->written_time();
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
236 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
237
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
238 /* called by input plugin to peek at the output plugin's output progress */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
239 gint
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
240 get_output_time(void)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
241 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
242 OutputPlugin *op = get_current_output_plugin();
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
243
4266
2b7a74fce100 Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents: 4259
diff changeset
244 plugin_set_current((Plugin *)op);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
245 return op->output_time();
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
246 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
247
4234
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4186
diff changeset
248 static SAD_dither_t *sad_state_to_float = NULL;
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4186
diff changeset
249 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
250 static float *sad_float_buf = NULL;
4234
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4186
diff changeset
251 static void *sad_out_buf = NULL;
4278
0a9e1d9eae7b Fix some warnings.
William Pitcock <nenolod@atheme.org>
parents: 4272
diff changeset
252 static gsize sad_float_buf_length = 0;
0a9e1d9eae7b Fix some warnings.
William Pitcock <nenolod@atheme.org>
parents: 4272
diff changeset
253 static gsize sad_out_buf_length = 0;
4237
8f6956130372 initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4235
diff changeset
254 static ReplayGainInfo replay_gain_info = {
8f6956130372 initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4235
diff changeset
255 .track_gain = 0.0,
8f6956130372 initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4235
diff changeset
256 .track_peak = 0.0,
8f6956130372 initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4235
diff changeset
257 .album_gain = 0.0,
8f6956130372 initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4235
diff changeset
258 .album_peak = 0.0,
8f6956130372 initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4235
diff changeset
259 };
4234
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4186
diff changeset
260
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4186
diff changeset
261 static void
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4186
diff changeset
262 freeSAD()
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4186
diff changeset
263 {
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4186
diff changeset
264 if (sad_state_from_float != NULL) {SAD_dither_free(sad_state_from_float); sad_state_from_float = NULL;}
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4186
diff changeset
265 if (sad_state_to_float != NULL) {SAD_dither_free(sad_state_to_float); sad_state_to_float = NULL;}
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4186
diff changeset
266 }
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4186
diff changeset
267
4286
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
268 static gboolean
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
269 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
270 {
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
271 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
272
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
273 if (op == NULL)
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
274 return FALSE;
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
275
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
276 /* 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
277 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
278 (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
279 {
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
280 /* 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
281 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
282 plugin_set_current((Plugin *)op);
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
283 op->flush(0);
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
284 return TRUE;
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
285 }
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
286 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
287 {
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
288 plugin_set_current((Plugin *)op);
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
289 op->close_audio();
4364
695e1c91be36 Reset op_state after calling close_audio to prevent possible future flushing.
Sascha Hlusiak <contact@saschahlusiak.de>
parents: 4323
diff changeset
290 op_state.fmt = 0;
695e1c91be36 Reset op_state after calling close_audio to prevent possible future flushing.
Sascha Hlusiak <contact@saschahlusiak.de>
parents: 4323
diff changeset
291 op_state.rate = 0;
695e1c91be36 Reset op_state after calling close_audio to prevent possible future flushing.
Sascha Hlusiak <contact@saschahlusiak.de>
parents: 4323
diff changeset
292 op_state.nch = 0;
4286
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
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
295 plugin_set_current((Plugin *)op);
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
296 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
297
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
298 if (ret == 1) /* Success? */
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
299 {
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
300 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
301 op_state.fmt = fmt;
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
302 op_state.rate = rate;
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
303 op_state.nch = nch;
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
304
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
305 return TRUE;
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
306 } else {
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
307 return FALSE;
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
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
311 gint
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
312 output_open_audio(AFormat fmt, gint rate, gint nch)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
313 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
314 gint ret;
4267
a41fb6bc632a - src stuff traveled to src_flow.c
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4259
diff changeset
315 AUDDBG("requested: fmt=%d, rate=%d, nch=%d\n", fmt, rate, nch);
4234
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4186
diff changeset
316
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4186
diff changeset
317 AFormat output_fmt;
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4186
diff changeset
318 int bit_depth;
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4186
diff changeset
319 SAD_buffer_format input_sad_fmt;
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4186
diff changeset
320 SAD_buffer_format output_sad_fmt;
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4186
diff changeset
321
4267
a41fb6bc632a - src stuff traveled to src_flow.c
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4259
diff changeset
322 decoder_srate = rate;
4286
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
323 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
324
4286
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
325 if (bypass_dsp) {
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
326 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
327 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
328 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
329 }
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
330
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
331 if (bypass_dsp) {
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
332 return TRUE;
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
333 } else {
4523
b3e4f5c31546 Conditional USE_SRC was changed to USE_SAMPLERATE earlier.
Matti Hamalainen <ccr@tnsp.org>
parents: 4364
diff changeset
334 #ifdef USE_SAMPLERATE
4290
5b277773870e don't change src settings in play time
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4287
diff changeset
335 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
336 #endif
719e0898ff3c [svn] - Patch to use libsamplerate for high-quality interpolated upsampling,
nenolod
parents: 2373
diff changeset
337
4286
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
338 bit_depth = cfg.output_bit_depth;
4234
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4186
diff changeset
339
4286
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
340 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
341 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
342
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
343 freeSAD();
4267
a41fb6bc632a - src stuff traveled to src_flow.c
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4259
diff changeset
344
4286
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
345 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
346 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
347 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
348 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
349 input_sad_fmt.channels = nch;
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
350 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
351 input_sad_fmt.samplerate = 0;
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
352
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
353 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
354 output_sad_fmt.fracbits = 0;
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
355 output_sad_fmt.channels = nch;
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
356 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
357 output_sad_fmt.samplerate = 0;
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
358
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
359 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
360 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
361 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
362 return FALSE;
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
363 }
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
364 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
365
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
366 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
367 input_sad_fmt.fracbits = 0;
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
368 input_sad_fmt.channels = nch;
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
369 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
370 input_sad_fmt.samplerate = 0;
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
371
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
372 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
373 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
374 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
375 output_sad_fmt.channels = nch;
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
376 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
377 output_sad_fmt.samplerate = 0;
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_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
380 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
381 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
382 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
383 return FALSE;
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
384 }
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
385 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
386
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
387 fmt = output_fmt;
4267
a41fb6bc632a - src stuff traveled to src_flow.c
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4259
diff changeset
388
4286
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
389 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
390 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
391 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
392 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
393 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
394 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
395 }
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
396 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
397
4286
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
398 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
399 } /* bypass_dsp */
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
400 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
401
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
402 void
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
403 output_write_audio(gpointer ptr, gint length)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
404 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
405 OutputPlugin *op = get_current_output_plugin();
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
406
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
407 /* Sanity check. */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
408 if (op == NULL)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
409 return;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
410
4266
2b7a74fce100 Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents: 4259
diff changeset
411 plugin_set_current((Plugin *)op);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
412 op->write_audio(ptr, length);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
413 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
414
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
415 void
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
416 output_close_audio(void)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
417 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
418 OutputPlugin *op = get_current_output_plugin();
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
419
4234
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4186
diff changeset
420 freeSAD();
4237
8f6956130372 initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4235
diff changeset
421
8f6956130372 initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4235
diff changeset
422 AUDDBG("clearing RG settings\n");
8f6956130372 initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4235
diff changeset
423 replay_gain_info.track_gain = 0.0;
8f6956130372 initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4235
diff changeset
424 replay_gain_info.track_peak = 0.0;
8f6956130372 initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4235
diff changeset
425 replay_gain_info.album_gain = 0.0;
8f6956130372 initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4235
diff changeset
426 replay_gain_info.album_peak = 0.0;
2538
719e0898ff3c [svn] - Patch to use libsamplerate for high-quality interpolated upsampling,
nenolod
parents: 2373
diff changeset
427
4523
b3e4f5c31546 Conditional USE_SRC was changed to USE_SAMPLERATE earlier.
Matti Hamalainen <ccr@tnsp.org>
parents: 4364
diff changeset
428 #ifdef USE_SAMPLERATE
4290
5b277773870e don't change src settings in play time
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4287
diff changeset
429 src_flow_free();
5b277773870e don't change src settings in play time
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4287
diff changeset
430 #endif
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
431 /* Do not close if there are still songs to play and the user has
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
432 * not requested a stop. --nenolod
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
433 */
4267
a41fb6bc632a - src stuff traveled to src_flow.c
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4259
diff changeset
434 Playlist *pl = playlist_get_active();
a41fb6bc632a - src stuff traveled to src_flow.c
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4259
diff changeset
435 if (ip_data.stop == FALSE &&
a41fb6bc632a - src stuff traveled to src_flow.c
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4259
diff changeset
436 (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
437 AUDDBG("leaving audio opened\n");
a41fb6bc632a - src stuff traveled to src_flow.c
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4259
diff changeset
438 return;
a41fb6bc632a - src stuff traveled to src_flow.c
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4259
diff changeset
439 }
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
440
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
441 /* Sanity check. */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
442 if (op == NULL)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
443 return;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
444
4266
2b7a74fce100 Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents: 4259
diff changeset
445 plugin_set_current((Plugin *)op);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
446 op->close_audio();
4267
a41fb6bc632a - src stuff traveled to src_flow.c
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4259
diff changeset
447 AUDDBG("done\n");
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
448
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
449 /* Reset the op_state. */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
450 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
451 equalizer_flow_free();
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
452 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
453
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
454 void
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
455 output_flush(gint time)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
456 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
457 OutputPlugin *op = get_current_output_plugin();
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
458
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
459 if (op == NULL)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
460 return;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
461
4266
2b7a74fce100 Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents: 4259
diff changeset
462 plugin_set_current((Plugin *)op);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
463 op->flush(time);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
464 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
465
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
466 void
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
467 output_pause(gshort paused)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
468 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
469 OutputPlugin *op = get_current_output_plugin();
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
470
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
471 if (op == NULL)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
472 return;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
473
4266
2b7a74fce100 Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents: 4259
diff changeset
474 plugin_set_current((Plugin *)op);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
475 op->pause(paused);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
476 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
477
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
478 gint
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
479 output_buffer_free(void)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
480 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
481 OutputPlugin *op = get_current_output_plugin();
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
482
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
483 if (op == NULL)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
484 return 0;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
485
4266
2b7a74fce100 Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents: 4259
diff changeset
486 plugin_set_current((Plugin *)op);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
487 return op->buffer_free();
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
488 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
489
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
490 gint
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
491 output_buffer_playing(void)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
492 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
493 OutputPlugin *op = get_current_output_plugin();
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
494
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
495 if (op == NULL)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
496 return 0;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
497
4266
2b7a74fce100 Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents: 4259
diff changeset
498 plugin_set_current((Plugin *)op);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
499 return op->buffer_playing();
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
500 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
501
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
502 /* called by input plugin when data is ready */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
503 void
3709
a89a12aa4f2c Add InputPlayback::pass_audio() which replaces produce_audio().
William Pitcock <nenolod@atheme.org>
parents: 3708
diff changeset
504 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
505 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
506 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
507 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
508 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
509 int *going /* 0 when time to stop */
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
510 )
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
511 {
4323
04ade98fafa3 vis moved to separate flow. works in passthrough mode too
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4307
diff changeset
512 static Flow *visualization_flow = NULL;
3553
a140fadd741d software volumecontrol->flow manager API
William Pitcock <nenolod@atheme.org>
parents: 3549
diff changeset
513 static Flow *postproc_flow = NULL;
4259
92642f860860 - added template for src_flow
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4258
diff changeset
514 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
515 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
516 gint writeoffs;
4267
a41fb6bc632a - src stuff traveled to src_flow.c
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4259
diff changeset
517 gpointer float_ptr;
4323
04ade98fafa3 vis moved to separate flow. works in passthrough mode too
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4307
diff changeset
518
04ade98fafa3 vis moved to separate flow. works in passthrough mode too
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4307
diff changeset
519 if (visualization_flow == NULL)
04ade98fafa3 vis moved to separate flow. works in passthrough mode too
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4307
diff changeset
520 {
04ade98fafa3 vis moved to separate flow. works in passthrough mode too
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4307
diff changeset
521 visualization_flow = flow_new();
04ade98fafa3 vis moved to separate flow. works in passthrough mode too
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4307
diff changeset
522 flow_link_element(visualization_flow, vis_flow);
04ade98fafa3 vis moved to separate flow. works in passthrough mode too
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4307
diff changeset
523 }
04ade98fafa3 vis moved to separate flow. works in passthrough mode too
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4307
diff changeset
524
04ade98fafa3 vis moved to separate flow. works in passthrough mode too
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4307
diff changeset
525 plugin_set_current((Plugin *)(playback->output));
04ade98fafa3 vis moved to separate flow. works in passthrough mode too
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4307
diff changeset
526 gint time = playback->output->written_time();
04ade98fafa3 vis moved to separate flow. works in passthrough mode too
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4307
diff changeset
527
04ade98fafa3 vis moved to separate flow. works in passthrough mode too
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4307
diff changeset
528 flow_execute(visualization_flow, time, &ptr, length, fmt, decoder_srate, nch);
4271
90282d9e4bec fix after merge...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4270
diff changeset
529
4286
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
530 if (!bypass_dsp) {
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
531
4286
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
532 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
533
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
534 if (legacy_flow == NULL)
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
535 {
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
536 legacy_flow = flow_new();
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
537 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
538 }
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
539
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
540 if (postproc_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 postproc_flow = flow_new();
4523
b3e4f5c31546 Conditional USE_SRC was changed to USE_SAMPLERATE earlier.
Matti Hamalainen <ccr@tnsp.org>
parents: 4364
diff changeset
543 #ifdef USE_SAMPLERATE
4286
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
544 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
545 #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
546 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
547 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
548 }
4267
a41fb6bc632a - src stuff traveled to src_flow.c
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4259
diff changeset
549
4286
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
550 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
551 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
552 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
553 sad_float_buf_length = len;
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
554 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
555 }
4267
a41fb6bc632a - src stuff traveled to src_flow.c
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4259
diff changeset
556
4286
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
557 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
558 float_ptr = sad_float_buf;
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
559
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
560 length = flow_execute(postproc_flow,
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
561 time,
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
562 &float_ptr,
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
563 len,
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
564 FMT_FLOAT,
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
565 decoder_srate,
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
566 nch);
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 frames = length / nch / sizeof(float);
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
569 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
570 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
571 sad_out_buf_length = len;
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
572 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
573 }
4234
b293ce14a01a partially works...
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4186
diff changeset
574
4286
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
575 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
576
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
577 length = len;
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
578 ptr = sad_out_buf;
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
579
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
580 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
581 (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
582 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
583 } else {
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
584 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
585 }
af324ff0a983 added passthrough mode. tested with ape and flac
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4278
diff changeset
586 } /* !bypass_dsp */
3546
fd4cd1945b91 Connect volumecontrol flow to the work pipeline.
William Pitcock <nenolod@atheme.org>
parents: 3486
diff changeset
587
4267
a41fb6bc632a - src stuff traveled to src_flow.c
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4259
diff changeset
588 /**** write it out ****/
a41fb6bc632a - src stuff traveled to src_flow.c
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4259
diff changeset
589
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
590 writeoffs = 0;
2373
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
591 while (writeoffs < length)
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
592 {
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
593 int writable = length - writeoffs;
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
594
2373
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
595 if (writable > 2048)
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
596 writable = 2048;
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
597
2813
49f3d1b43518 [svn] - code cleanups involving SRC patch and indentation
nenolod
parents: 2811
diff changeset
598 if (writable == 0)
2373
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
599 return;
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
600
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
601 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
602 {
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
603 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
604
418ac922ce87 Use a mutex/condvar/timed wait to allow tickless operation in the output loop.
William Pitcock <nenolod@atheme.org>
parents: 3686
diff changeset
605 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
606 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
607
2373
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
608 if (going && !*going) /* thread stopped? */
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
609 return; /* so finish */
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
610
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
611 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
612 return; /* yes, so finish */
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
613
3680
6615978ca88c Instead of waiting 10ms, wait half the time of the period buffer.
William Pitcock <nenolod@atheme.org>
parents: 3560
diff changeset
614 /* 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
615 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
616 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
617 g_mutex_unlock(playback->pb_change_mutex);
2373
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
618 }
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
619
2373
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
620 if (ip_data.stop)
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
621 return;
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
622
2373
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
623 if (going && !*going) /* thread stopped? */
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
624 return; /* so finish */
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
625
2373
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
626 /* do output */
4266
2b7a74fce100 Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents: 4259
diff changeset
627 plugin_set_current((Plugin *)op);
2373
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
628 op->write_audio(((guint8 *) ptr) + writeoffs, writable);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
629
2373
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
630 writeoffs += writable;
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
631 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
632 }
4235
2d4b4f13d10d set_replaygain_info added to PAPI
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
633
4237
8f6956130372 initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4235
diff changeset
634 /* 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
635 void
2d4b4f13d10d set_replaygain_info added to PAPI
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
636 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
637 {
4237
8f6956130372 initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4235
diff changeset
638 replay_gain_info = *rg_info;
8f6956130372 initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4235
diff changeset
639 apply_replaygain_info(rg_info);
4235
2d4b4f13d10d set_replaygain_info added to PAPI
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4234
diff changeset
640 }
4237
8f6956130372 initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4235
diff changeset
641
8f6956130372 initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4235
diff changeset
642 static void
8f6956130372 initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4235
diff changeset
643 apply_replaygain_info (ReplayGainInfo *rg_info)
8f6956130372 initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4235
diff changeset
644 {
8f6956130372 initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4235
diff changeset
645 SAD_replaygain_mode mode;
8f6956130372 initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4235
diff changeset
646 SAD_replaygain_info info;
8f6956130372 initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4235
diff changeset
647 gboolean rg_enabled;
8f6956130372 initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4235
diff changeset
648 gboolean album_mode;
8f6956130372 initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4235
diff changeset
649
4267
a41fb6bc632a - src stuff traveled to src_flow.c
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4259
diff changeset
650 if(sad_state_from_float == NULL) {
4237
8f6956130372 initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4235
diff changeset
651 AUDDBG("SAD not initialized!\n");
8f6956130372 initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4235
diff changeset
652 return;
8f6956130372 initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4235
diff changeset
653 }
8f6956130372 initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4235
diff changeset
654
8f6956130372 initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4235
diff changeset
655 rg_enabled = cfg.enable_replay_gain;
8f6956130372 initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4235
diff changeset
656 album_mode = cfg.replay_gain_album;
8f6956130372 initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4235
diff changeset
657 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
658 mode.hard_limit = FALSE;
b0ca963fd965 adaptive scaler added, disabled hard limiter
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4247
diff changeset
659 mode.adaptive_scaler = cfg.enable_adaptive_scaler;
4237
8f6956130372 initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4235
diff changeset
660
8f6956130372 initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4235
diff changeset
661 if(!rg_enabled) return;
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 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
664 mode.preamp = cfg.replay_gain_preamp;
4237
8f6956130372 initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4235
diff changeset
665
8f6956130372 initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4235
diff changeset
666 info.present = TRUE;
8f6956130372 initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4235
diff changeset
667 info.track_gain = rg_info->track_gain;
8f6956130372 initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4235
diff changeset
668 info.track_peak = rg_info->track_peak;
8f6956130372 initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4235
diff changeset
669 info.album_gain = rg_info->album_gain;
8f6956130372 initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4235
diff changeset
670 info.album_peak = rg_info->album_peak;
8f6956130372 initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4235
diff changeset
671
8f6956130372 initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4235
diff changeset
672 AUDDBG("Applying Replay Gain settings:\n");
8f6956130372 initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4235
diff changeset
673 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
674 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
675 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
676 AUDDBG("* preamp: %+f dB\n", mode.preamp);
8f6956130372 initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4235
diff changeset
677 AUDDBG("Replay Gain info for current track:\n");
8f6956130372 initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4235
diff changeset
678 AUDDBG("* track gain: %+f dB\n", info.track_gain);
8f6956130372 initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4235
diff changeset
679 AUDDBG("* track peak: %f\n", info.track_peak);
8f6956130372 initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4235
diff changeset
680 AUDDBG("* album gain: %+f dB\n", info.album_gain);
8f6956130372 initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4235
diff changeset
681 AUDDBG("* album peak: %f\n", info.album_peak);
8f6956130372 initial Replay Gain support
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4235
diff changeset
682
4267
a41fb6bc632a - src stuff traveled to src_flow.c
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4259
diff changeset
683 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
684 }