annotate audacious/output.c @ 807:df3412dc33c4 trunk

[svn] - add psuedo_output_plugin, a psuedo output plugin that will be used for reverse compatibility with old plugins. sort of.
author nenolod
date Wed, 08 Mar 2006 06:57:02 -0800
parents d51a251b542c
children 79da0e6ed790
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1 /* BMP - Cross-platform multimedia player
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
2 * Copyright (C) 2003-2004 BMP development team.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
3 *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
4 * Based on XMMS:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
5 * Copyright (C) 1998-2003 XMMS development team.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
6 *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
7 * This program is free software; you can redistribute it and/or modify
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
8 * it under the terms of the GNU General Public License as published by
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
9 * the Free Software Foundation; either version 2 of the License, or
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
10 * (at your option) any later version.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
11 *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
15 * GNU General Public License for more details.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
16 *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
17 * You should have received a copy of the GNU General Public License
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
18 * along with this program; if not, write to the Free Software
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
20 */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
21
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
22 #ifdef HAVE_CONFIG_H
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
23 # include "config.h"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
24 #endif
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
25
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
26 #include "output.h"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
27 #include "iir.h"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
28 #include "main.h"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
29 #include "input.h"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
30
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
31 #include "playlist.h"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
32 #include "libaudacious/util.h"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
33
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
34 OutputPluginData op_data = {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
35 NULL,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
36 NULL
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
37 };
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
38
807
df3412dc33c4 [svn] - add psuedo_output_plugin, a psuedo output plugin that will be used for reverse compatibility with old plugins.
nenolod
parents: 806
diff changeset
39 OutputPlugin psuedo_output_plugin {
df3412dc33c4 [svn] - add psuedo_output_plugin, a psuedo output plugin that will be used for reverse compatibility with old plugins.
nenolod
parents: 806
diff changeset
40 NULL,
df3412dc33c4 [svn] - add psuedo_output_plugin, a psuedo output plugin that will be used for reverse compatibility with old plugins.
nenolod
parents: 806
diff changeset
41 NULL,
df3412dc33c4 [svn] - add psuedo_output_plugin, a psuedo output plugin that will be used for reverse compatibility with old plugins.
nenolod
parents: 806
diff changeset
42 "XMMS reverse compatibility output plugin",
df3412dc33c4 [svn] - add psuedo_output_plugin, a psuedo output plugin that will be used for reverse compatibility with old plugins.
nenolod
parents: 806
diff changeset
43 NULL,
df3412dc33c4 [svn] - add psuedo_output_plugin, a psuedo output plugin that will be used for reverse compatibility with old plugins.
nenolod
parents: 806
diff changeset
44 NULL,
df3412dc33c4 [svn] - add psuedo_output_plugin, a psuedo output plugin that will be used for reverse compatibility with old plugins.
nenolod
parents: 806
diff changeset
45 NULL,
df3412dc33c4 [svn] - add psuedo_output_plugin, a psuedo output plugin that will be used for reverse compatibility with old plugins.
nenolod
parents: 806
diff changeset
46 NULL,
df3412dc33c4 [svn] - add psuedo_output_plugin, a psuedo output plugin that will be used for reverse compatibility with old plugins.
nenolod
parents: 806
diff changeset
47 output_get_volume,
df3412dc33c4 [svn] - add psuedo_output_plugin, a psuedo output plugin that will be used for reverse compatibility with old plugins.
nenolod
parents: 806
diff changeset
48 output_set_volume,
df3412dc33c4 [svn] - add psuedo_output_plugin, a psuedo output plugin that will be used for reverse compatibility with old plugins.
nenolod
parents: 806
diff changeset
49 NULL, /* XXX we need noop code for this */
df3412dc33c4 [svn] - add psuedo_output_plugin, a psuedo output plugin that will be used for reverse compatibility with old plugins.
nenolod
parents: 806
diff changeset
50 NULL,
df3412dc33c4 [svn] - add psuedo_output_plugin, a psuedo output plugin that will be used for reverse compatibility with old plugins.
nenolod
parents: 806
diff changeset
51 NULL,
df3412dc33c4 [svn] - add psuedo_output_plugin, a psuedo output plugin that will be used for reverse compatibility with old plugins.
nenolod
parents: 806
diff changeset
52
df3412dc33c4 [svn] - add psuedo_output_plugin, a psuedo output plugin that will be used for reverse compatibility with old plugins.
nenolod
parents: 806
diff changeset
53 NULL,
df3412dc33c4 [svn] - add psuedo_output_plugin, a psuedo output plugin that will be used for reverse compatibility with old plugins.
nenolod
parents: 806
diff changeset
54 NULL,
df3412dc33c4 [svn] - add psuedo_output_plugin, a psuedo output plugin that will be used for reverse compatibility with old plugins.
nenolod
parents: 806
diff changeset
55 NULL,
df3412dc33c4 [svn] - add psuedo_output_plugin, a psuedo output plugin that will be used for reverse compatibility with old plugins.
nenolod
parents: 806
diff changeset
56 NULL,
df3412dc33c4 [svn] - add psuedo_output_plugin, a psuedo output plugin that will be used for reverse compatibility with old plugins.
nenolod
parents: 806
diff changeset
57 get_output_time,
df3412dc33c4 [svn] - add psuedo_output_plugin, a psuedo output plugin that will be used for reverse compatibility with old plugins.
nenolod
parents: 806
diff changeset
58 get_written_time,
df3412dc33c4 [svn] - add psuedo_output_plugin, a psuedo output plugin that will be used for reverse compatibility with old plugins.
nenolod
parents: 806
diff changeset
59
df3412dc33c4 [svn] - add psuedo_output_plugin, a psuedo output plugin that will be used for reverse compatibility with old plugins.
nenolod
parents: 806
diff changeset
60 NULL
df3412dc33c4 [svn] - add psuedo_output_plugin, a psuedo output plugin that will be used for reverse compatibility with old plugins.
nenolod
parents: 806
diff changeset
61 };
df3412dc33c4 [svn] - add psuedo_output_plugin, a psuedo output plugin that will be used for reverse compatibility with old plugins.
nenolod
parents: 806
diff changeset
62
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
63 OutputPlugin *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
64 get_current_output_plugin(void)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
65 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
66 return op_data.current_output_plugin;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
67 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
68
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
69 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
70 set_current_output_plugin(gint i)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
71 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
72 #if 0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
73 gint time;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
74 gint pos;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
75 gboolean playing;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
76 #endif
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
77
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
78 GList *node = g_list_nth(op_data.output_list, i);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
79 if (!node) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
80 op_data.current_output_plugin = NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
81 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
82 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
83
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
84 op_data.current_output_plugin = node->data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
85
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
86
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
87 #if 0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
88 playing = bmp_playback_get_playing();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
89 if (playing) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
90
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
91 /* FIXME: we do all on our own here */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
92
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
93 guint min = 0, sec = 0, params, time, pos;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
94 gchar timestr[10];
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
95
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
96 bmp_playback_pause();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
97 pos = get_playlist_position();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
98 time = bmp_playback_get_time() / 1000;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
99 g_snprintf(timestr, sizeof(timestr), "%u:%2.2u",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
100 time / 60, time % 60);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
101
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
102 params = sscanf(timestr, "%u:%u", &min, &sec);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
103 if (params == 2)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
104 time = (min * 60) + sec;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
105 else if (params == 1)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
106 time = min;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
107 else
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
108 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
109
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
110 bmp_playback_stop();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
111 playlist_set_position(pos);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
112 bmp_playback_play_file(playlist_get_filename(pos));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
113
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
114 while (!bmp_playback_get_playing())
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
115 g_message("waiting...");
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
116
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
117 if (playlist_get_current_length() > -1 &&
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
118 time <= (playlist_get_current_length() / 1000)) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
119 /* Some time for things to cool down and heat up */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
120 g_usleep(1000000);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
121 bmp_playback_seek(time);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
122 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
123 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
124 #endif
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
125 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
126
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
127 GList *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
128 get_output_list(void)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
129 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
130 return op_data.output_list;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
131 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
132
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
133 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
134 output_about(gint i)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
135 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
136 OutputPlugin *out = g_list_nth(op_data.output_list, i)->data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
137 if (out && out->about)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
138 out->about();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
139 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
140
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
141 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
142 output_configure(gint i)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
143 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
144 OutputPlugin *out = g_list_nth(op_data.output_list, i)->data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
145 if (out && out->configure)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
146 out->configure();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
147 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
148
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
149 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
150 output_get_volume(gint * l, gint * r)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
151 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
152 *l = *r = -1;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
153
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
154 if (!op_data.current_output_plugin)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
155 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
156
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
157 if (!op_data.current_output_plugin->get_volume)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
158 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
159
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
160 op_data.current_output_plugin->get_volume(l, r);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
161 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
162
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
163 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
164 output_set_volume(gint l, gint r)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
165 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
166 if (!op_data.current_output_plugin)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
167 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
168
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
169 if (!op_data.current_output_plugin->set_volume)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
170 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
171
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
172 op_data.current_output_plugin->set_volume(l, r);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
173 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
174
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
175 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
176 output_set_eq(gboolean active, gfloat pre, gfloat * bands)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
177 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
178 int i;
430
67cd014f35a2 [svn] This commit rips out the old equalization engine with a dynamic engine
nenolod
parents: 0
diff changeset
179 preamp[0] = 1.0 + 0.0932471 * pre + 0.00279033 * pre * pre;
67cd014f35a2 [svn] This commit rips out the old equalization engine with a dynamic engine
nenolod
parents: 0
diff changeset
180 preamp[1] = 1.0 + 0.0932471 * pre + 0.00279033 * pre * pre;
67cd014f35a2 [svn] This commit rips out the old equalization engine with a dynamic engine
nenolod
parents: 0
diff changeset
181
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
182 for (i = 0; i < 10; ++i)
430
67cd014f35a2 [svn] This commit rips out the old equalization engine with a dynamic engine
nenolod
parents: 0
diff changeset
183 {
67cd014f35a2 [svn] This commit rips out the old equalization engine with a dynamic engine
nenolod
parents: 0
diff changeset
184 set_gain(i, 0, 0.03 * bands[i] + 0.000999999 * bands[i] * bands[i]);
67cd014f35a2 [svn] This commit rips out the old equalization engine with a dynamic engine
nenolod
parents: 0
diff changeset
185 set_gain(i, 1, 0.03 * bands[i] + 0.000999999 * bands[i] * bands[i]);
67cd014f35a2 [svn] This commit rips out the old equalization engine with a dynamic engine
nenolod
parents: 0
diff changeset
186 }
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
187 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
188
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
189 /* this should be in BYTES, NOT gint16s */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
190 static void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
191 byteswap(size_t size,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
192 gint16 * buf)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
193 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
194 gint16 *it;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
195 size &= ~1; /* must be multiple of 2 */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
196 for (it = buf; it < buf + size / 2; ++it)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
197 *(guint16 *) it = GUINT16_SWAP_LE_BE(*(guint16 *) it);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
198 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
199
806
d51a251b542c [svn] - add get_written_time(), get_output_time().
nenolod
parents: 625
diff changeset
200 /* called by input plugin to peek at the output plugin's write progress */
d51a251b542c [svn] - add get_written_time(), get_output_time().
nenolod
parents: 625
diff changeset
201 gint
d51a251b542c [svn] - add get_written_time(), get_output_time().
nenolod
parents: 625
diff changeset
202 get_written_time(void)
d51a251b542c [svn] - add get_written_time(), get_output_time().
nenolod
parents: 625
diff changeset
203 {
d51a251b542c [svn] - add get_written_time(), get_output_time().
nenolod
parents: 625
diff changeset
204 OutputPlugin *op = get_current_output_plugin();
d51a251b542c [svn] - add get_written_time(), get_output_time().
nenolod
parents: 625
diff changeset
205
d51a251b542c [svn] - add get_written_time(), get_output_time().
nenolod
parents: 625
diff changeset
206 return op->written_time();
d51a251b542c [svn] - add get_written_time(), get_output_time().
nenolod
parents: 625
diff changeset
207 }
d51a251b542c [svn] - add get_written_time(), get_output_time().
nenolod
parents: 625
diff changeset
208
d51a251b542c [svn] - add get_written_time(), get_output_time().
nenolod
parents: 625
diff changeset
209 /* called by input plugin to peek at the output plugin's output progress */
d51a251b542c [svn] - add get_written_time(), get_output_time().
nenolod
parents: 625
diff changeset
210 gint
d51a251b542c [svn] - add get_written_time(), get_output_time().
nenolod
parents: 625
diff changeset
211 get_output_time(void)
d51a251b542c [svn] - add get_written_time(), get_output_time().
nenolod
parents: 625
diff changeset
212 {
d51a251b542c [svn] - add get_written_time(), get_output_time().
nenolod
parents: 625
diff changeset
213 OutputPlugin *op = get_current_output_plugin();
d51a251b542c [svn] - add get_written_time(), get_output_time().
nenolod
parents: 625
diff changeset
214
d51a251b542c [svn] - add get_written_time(), get_output_time().
nenolod
parents: 625
diff changeset
215 return op->output_time();
d51a251b542c [svn] - add get_written_time(), get_output_time().
nenolod
parents: 625
diff changeset
216 }
d51a251b542c [svn] - add get_written_time(), get_output_time().
nenolod
parents: 625
diff changeset
217
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
218 /* called by input plugin when data is ready */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
219 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
220 produce_audio(gint time, /* position */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
221 AFormat fmt, /* output format */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
222 gint nch, /* channels */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
223 gint length, /* length of sample */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
224 gpointer ptr, /* data */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
225 int *going /* 0 when time to stop */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
226 )
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
227 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
228 static int init = 0;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
229 int swapped = 0;
625
0a73d1faeb4e [svn] GCC 4.1 warning fixes by Diego 'Flameeyes' Petteno from Gentoo.
chainsaw
parents: 519
diff changeset
230 guint myorder = G_BYTE_ORDER == G_LITTLE_ENDIAN ? FMT_S16_LE : FMT_S16_BE;
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
231 int caneq = (fmt == FMT_S16_NE || fmt == myorder);
518
6c28a04d1254 [svn] cleanup produce_audio() a bit.
nenolod
parents: 430
diff changeset
232 OutputPlugin *op = get_current_output_plugin();
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
233
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
234 if (!caneq && cfg.equalizer_active) { /* wrong byte order */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
235 byteswap(length, ptr); /* so convert */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
236 ++swapped;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
237 ++caneq;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
238 } /* can eq now, mark swapd */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
239 else if (caneq && !cfg.equalizer_active) /* right order but no eq */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
240 caneq = 0; /* so don't eq */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
241
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
242 if (caneq) { /* if eq enab */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
243 if (!init) { /* if first run */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
244 init_iir(); /* then init eq */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
245 ++init;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
246 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
247
430
67cd014f35a2 [svn] This commit rips out the old equalization engine with a dynamic engine
nenolod
parents: 0
diff changeset
248 iir(&ptr, length, nch);
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
249
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
250 if (swapped) /* if was swapped */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
251 byteswap(length, ptr); /* swap back for output */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
252 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
253
518
6c28a04d1254 [svn] cleanup produce_audio() a bit.
nenolod
parents: 430
diff changeset
254 /* do vis plugin(s) */
519
88e9a6a8336f [svn] whoever wrote output_to_audio() was a crackhead.
nenolod
parents: 518
diff changeset
255 input_add_vis_pcm(time, fmt, nch, length, ptr);
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
256
518
6c28a04d1254 [svn] cleanup produce_audio() a bit.
nenolod
parents: 430
diff changeset
257 while (op->buffer_free() < length) { /* wait output buf */
6c28a04d1254 [svn] cleanup produce_audio() a bit.
nenolod
parents: 430
diff changeset
258 if (going && !*going) /* thread stopped? */
6c28a04d1254 [svn] cleanup produce_audio() a bit.
nenolod
parents: 430
diff changeset
259 return; /* so finish */
6c28a04d1254 [svn] cleanup produce_audio() a bit.
nenolod
parents: 430
diff changeset
260
6c28a04d1254 [svn] cleanup produce_audio() a bit.
nenolod
parents: 430
diff changeset
261 g_usleep(10000); /* else sleep for retry */
6c28a04d1254 [svn] cleanup produce_audio() a bit.
nenolod
parents: 430
diff changeset
262 }
6c28a04d1254 [svn] cleanup produce_audio() a bit.
nenolod
parents: 430
diff changeset
263
519
88e9a6a8336f [svn] whoever wrote output_to_audio() was a crackhead.
nenolod
parents: 518
diff changeset
264 op->write_audio(ptr, length); /* do output */
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
265 }