annotate audacious/output.c @ 1252:ece68ef26b94 trunk

[svn] - we don't really have to unwire track 0 this way, as 0 will be selected by default if no subsong URI is given
author nenolod
date Thu, 15 Jun 2006 05:17:49 -0700
parents 86da433104a8
children f12d7e208b43
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
890
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
39 OutputPluginState op_state = {
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
40 0,
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
41 0,
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
42 0
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
43 };
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
44
809
79da0e6ed790 [svn] - fix typo
nenolod
parents: 807
diff changeset
45 OutputPlugin psuedo_output_plugin = {
807
df3412dc33c4 [svn] - add psuedo_output_plugin, a psuedo output plugin that will be used for reverse compatibility with old plugins.
nenolod
parents: 806
diff changeset
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 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
48 "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
49 NULL,
df3412dc33c4 [svn] - add psuedo_output_plugin, a psuedo output plugin that will be used for reverse compatibility with old plugins.
nenolod
parents: 806
diff changeset
50 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 NULL,
df3412dc33c4 [svn] - add psuedo_output_plugin, a psuedo output plugin that will be used for reverse compatibility with old plugins.
nenolod
parents: 806
diff changeset
53 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
54 output_set_volume,
890
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
55 output_open_audio,
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
56 output_write_audio,
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
57 output_close_audio,
807
df3412dc33c4 [svn] - add psuedo_output_plugin, a psuedo output plugin that will be used for reverse compatibility with old plugins.
nenolod
parents: 806
diff changeset
58
890
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
59 output_flush,
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
60 output_pause,
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
61 output_buffer_free,
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
62 output_buffer_playing,
807
df3412dc33c4 [svn] - add psuedo_output_plugin, a psuedo output plugin that will be used for reverse compatibility with old plugins.
nenolod
parents: 806
diff changeset
63 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
64 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
65 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
66 };
df3412dc33c4 [svn] - add psuedo_output_plugin, a psuedo output plugin that will be used for reverse compatibility with old plugins.
nenolod
parents: 806
diff changeset
67
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
68 OutputPlugin *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
69 get_current_output_plugin(void)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
70 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
71 return op_data.current_output_plugin;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
72 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
73
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
74 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
75 set_current_output_plugin(gint i)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
76 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
77 #if 0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
78 gint time;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
79 gint pos;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
80 gboolean playing;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
81 #endif
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
82
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
83 GList *node = g_list_nth(op_data.output_list, i);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
84 if (!node) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
85 op_data.current_output_plugin = NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
86 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
87 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
88
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
89 op_data.current_output_plugin = node->data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
90
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
91
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
92 #if 0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
93 playing = bmp_playback_get_playing();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
94 if (playing) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
95
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
96 /* FIXME: we do all on our own here */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
97
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
98 guint min = 0, sec = 0, params, time, pos;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
99 gchar timestr[10];
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
100
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
101 bmp_playback_pause();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
102 pos = get_playlist_position();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
103 time = bmp_playback_get_time() / 1000;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
104 g_snprintf(timestr, sizeof(timestr), "%u:%2.2u",
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
105 time / 60, time % 60);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
106
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
107 params = sscanf(timestr, "%u:%u", &min, &sec);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
108 if (params == 2)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
109 time = (min * 60) + sec;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
110 else if (params == 1)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
111 time = min;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
112 else
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
113 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
114
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
115 bmp_playback_stop();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
116 playlist_set_position(pos);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
117 bmp_playback_play_file(playlist_get_filename(pos));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
118
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
119 while (!bmp_playback_get_playing())
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
120 g_message("waiting...");
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
121
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
122 if (playlist_get_current_length() > -1 &&
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
123 time <= (playlist_get_current_length() / 1000)) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
124 /* Some time for things to cool down and heat up */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
125 g_usleep(1000000);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
126 bmp_playback_seek(time);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
127 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
128 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
129 #endif
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
130 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
131
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
132 GList *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
133 get_output_list(void)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
134 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
135 return op_data.output_list;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
136 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
137
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
138 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
139 output_about(gint i)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
140 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
141 OutputPlugin *out = g_list_nth(op_data.output_list, i)->data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
142 if (out && out->about)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
143 out->about();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
144 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
145
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
146 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
147 output_configure(gint i)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
148 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
149 OutputPlugin *out = g_list_nth(op_data.output_list, i)->data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
150 if (out && out->configure)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
151 out->configure();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
152 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
153
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
154 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
155 output_get_volume(gint * l, gint * r)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
156 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
157 *l = *r = -1;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
158
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
159 if (!op_data.current_output_plugin)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
160 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
161
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
162 if (!op_data.current_output_plugin->get_volume)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
163 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
164
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
165 op_data.current_output_plugin->get_volume(l, r);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
166 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
167
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
168 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
169 output_set_volume(gint l, gint r)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
170 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
171 if (!op_data.current_output_plugin)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
172 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
173
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
174 if (!op_data.current_output_plugin->set_volume)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
175 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
176
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
177 op_data.current_output_plugin->set_volume(l, r);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
178 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
179
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
180 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
181 output_set_eq(gboolean active, gfloat pre, gfloat * bands)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
182 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
183 int i;
430
67cd014f35a2 [svn] This commit rips out the old equalization engine with a dynamic engine
nenolod
parents: 0
diff changeset
184 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
185 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
186
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
187 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
188 {
67cd014f35a2 [svn] This commit rips out the old equalization engine with a dynamic engine
nenolod
parents: 0
diff changeset
189 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
190 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
191 }
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
192 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
193
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
194 /* this should be in BYTES, NOT gint16s */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
195 static void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
196 byteswap(size_t size,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
197 gint16 * buf)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
198 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
199 gint16 *it;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
200 size &= ~1; /* must be multiple of 2 */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
201 for (it = buf; it < buf + size / 2; ++it)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
202 *(guint16 *) it = GUINT16_SWAP_LE_BE(*(guint16 *) it);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
203 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
204
806
d51a251b542c [svn] - add get_written_time(), get_output_time().
nenolod
parents: 625
diff changeset
205 /* 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
206 gint
d51a251b542c [svn] - add get_written_time(), get_output_time().
nenolod
parents: 625
diff changeset
207 get_written_time(void)
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 OutputPlugin *op = get_current_output_plugin();
d51a251b542c [svn] - add get_written_time(), get_output_time().
nenolod
parents: 625
diff changeset
210
d51a251b542c [svn] - add get_written_time(), get_output_time().
nenolod
parents: 625
diff changeset
211 return op->written_time();
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
d51a251b542c [svn] - add get_written_time(), get_output_time().
nenolod
parents: 625
diff changeset
214 /* 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
215 gint
d51a251b542c [svn] - add get_written_time(), get_output_time().
nenolod
parents: 625
diff changeset
216 get_output_time(void)
d51a251b542c [svn] - add get_written_time(), get_output_time().
nenolod
parents: 625
diff changeset
217 {
d51a251b542c [svn] - add get_written_time(), get_output_time().
nenolod
parents: 625
diff changeset
218 OutputPlugin *op = get_current_output_plugin();
d51a251b542c [svn] - add get_written_time(), get_output_time().
nenolod
parents: 625
diff changeset
219
d51a251b542c [svn] - add get_written_time(), get_output_time().
nenolod
parents: 625
diff changeset
220 return op->output_time();
d51a251b542c [svn] - add get_written_time(), get_output_time().
nenolod
parents: 625
diff changeset
221 }
d51a251b542c [svn] - add get_written_time(), get_output_time().
nenolod
parents: 625
diff changeset
222
890
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
223 gint
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
224 output_open_audio(AFormat fmt, gint rate, gint nch)
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
225 {
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
226 gint ret;
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
227 OutputPlugin *op;
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
228
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
229 op = get_current_output_plugin();
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
230
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
231 if (op == NULL)
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
232 return -1;
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
233
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
234 /* Is our output port already open? */
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
235 if ((op_state.rate != 0 && op_state.nch != 0) &&
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
236 (op_state.rate == rate && op_state.nch == nch))
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
237 {
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
238 /* Yes, and it's the correct sampling rate. Reset the counter and go. */
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
239 op->flush(0);
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
240 return 1;
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
241 }
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
242 else if (op_state.rate != 0 && op_state.nch != 0)
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
243 op->close_audio();
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
244
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
245 ret = op->open_audio(fmt, rate, nch);
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
246
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
247 if (ret == 1) /* Success? */
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
248 {
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
249 op_state.fmt = fmt;
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
250 op_state.rate = rate;
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
251 op_state.nch = nch;
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
252 }
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
253
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
254 return ret;
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
255 }
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
256
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
257 void
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
258 output_write_audio(gpointer ptr, gint length)
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
259 {
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
260 OutputPlugin *op = get_current_output_plugin();
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
261
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
262 /* Sanity check. */
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
263 if (op == NULL)
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
264 return;
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
265
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
266 op->write_audio(ptr, length);
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
267 }
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
268
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
269 void
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
270 output_close_audio(void)
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
271 {
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
272 OutputPlugin *op = get_current_output_plugin();
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
273
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
274 /* Do not close if there are still songs to play and the user has
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
275 * not requested a stop. --nenolod
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
276 */
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
277 if (ip_data.stop == FALSE &&
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
278 (playlist_get_position_nolock() < playlist_get_length_nolock() - 1))
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
279 return;
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
280
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
281 /* Sanity check. */
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
282 if (op == NULL)
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
283 return;
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
284
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
285 #if 0
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
286 g_print("Requirements to close audio output have been met:\n"
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
287 "ip_data.stop = %d\n"
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
288 "playlist_get_position_nolock() = %d\n"
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
289 "playlist_get_length_nolock() - 1 = %d\n",
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
290 ip_data.stop, playlist_get_position_nolock(),
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
291 playlist_get_length_nolock() - 1);
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
292 #endif
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
293
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
294 op->close_audio();
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
295
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
296 /* Reset the op_state. */
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
297 op_state.fmt = op_state.rate = op_state.nch = 0;
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
298 }
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
299
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
300 void
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
301 output_flush(gint time)
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
302 {
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
303 OutputPlugin *op = get_current_output_plugin();
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
304
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
305 if (op == NULL)
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
306 return;
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
307
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
308 op->flush(time);
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
309 }
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
310
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
311 void
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
312 output_pause(gshort paused)
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
313 {
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
314 OutputPlugin *op = get_current_output_plugin();
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
315
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
316 if (op == NULL)
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
317 return;
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
318
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
319 op->pause(paused);
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
320 }
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
321
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
322 gint
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
323 output_buffer_free(void)
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
324 {
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
325 OutputPlugin *op = get_current_output_plugin();
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
326
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
327 if (op == NULL)
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
328 return 0;
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
329
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
330 return op->buffer_free();
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
331 }
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
332
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
333 gint
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
334 output_buffer_playing(void)
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
335 {
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
336 OutputPlugin *op = get_current_output_plugin();
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
337
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
338 if (op == NULL)
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
339 return 0;
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
340
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
341 return op->buffer_playing();
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
342 }
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
343
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
344 /* called by input plugin when data is ready */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
345 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
346 produce_audio(gint time, /* position */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
347 AFormat fmt, /* output format */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
348 gint nch, /* channels */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
349 gint length, /* length of sample */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
350 gpointer ptr, /* data */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
351 int *going /* 0 when time to stop */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
352 )
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
353 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
354 static int init = 0;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
355 int swapped = 0;
625
0a73d1faeb4e [svn] GCC 4.1 warning fixes by Diego 'Flameeyes' Petteno from Gentoo.
chainsaw
parents: 519
diff changeset
356 guint myorder = G_BYTE_ORDER == G_LITTLE_ENDIAN ? FMT_S16_LE : FMT_S16_BE;
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
357 int caneq = (fmt == FMT_S16_NE || fmt == myorder);
518
6c28a04d1254 [svn] cleanup produce_audio() a bit.
nenolod
parents: 430
diff changeset
358 OutputPlugin *op = get_current_output_plugin();
929
54b23650fac1 [svn] - experimental produce-audio changes via shd of the UADE team
nenolod
parents: 890
diff changeset
359 int writeoffs;
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
360
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
361 if (!caneq && cfg.equalizer_active) { /* wrong byte order */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
362 byteswap(length, ptr); /* so convert */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
363 ++swapped;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
364 ++caneq;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
365 } /* can eq now, mark swapd */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
366 else if (caneq && !cfg.equalizer_active) /* right order but no eq */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
367 caneq = 0; /* so don't eq */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
368
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
369 if (caneq) { /* if eq enab */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
370 if (!init) { /* if first run */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
371 init_iir(); /* then init eq */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
372 ++init;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
373 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
374
430
67cd014f35a2 [svn] This commit rips out the old equalization engine with a dynamic engine
nenolod
parents: 0
diff changeset
375 iir(&ptr, length, nch);
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
376
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
377 if (swapped) /* if was swapped */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
378 byteswap(length, ptr); /* swap back for output */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
379 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
380
518
6c28a04d1254 [svn] cleanup produce_audio() a bit.
nenolod
parents: 430
diff changeset
381 /* do vis plugin(s) */
519
88e9a6a8336f [svn] whoever wrote output_to_audio() was a crackhead.
nenolod
parents: 518
diff changeset
382 input_add_vis_pcm(time, fmt, nch, length, ptr);
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
383
929
54b23650fac1 [svn] - experimental produce-audio changes via shd of the UADE team
nenolod
parents: 890
diff changeset
384 writeoffs = 0;
54b23650fac1 [svn] - experimental produce-audio changes via shd of the UADE team
nenolod
parents: 890
diff changeset
385 while (writeoffs < length) {
54b23650fac1 [svn] - experimental produce-audio changes via shd of the UADE team
nenolod
parents: 890
diff changeset
386 int writable = length - writeoffs;
54b23650fac1 [svn] - experimental produce-audio changes via shd of the UADE team
nenolod
parents: 890
diff changeset
387
54b23650fac1 [svn] - experimental produce-audio changes via shd of the UADE team
nenolod
parents: 890
diff changeset
388 if (writable > 2048)
54b23650fac1 [svn] - experimental produce-audio changes via shd of the UADE team
nenolod
parents: 890
diff changeset
389 writable = 2048;
518
6c28a04d1254 [svn] cleanup produce_audio() a bit.
nenolod
parents: 430
diff changeset
390
1051
6e95edd16b43 [svn] - if writable == 0 then bail out of produce_audio() instead of segfault
nenolod
parents: 1036
diff changeset
391 if (writable == 0)
6e95edd16b43 [svn] - if writable == 0 then bail out of produce_audio() instead of segfault
nenolod
parents: 1036
diff changeset
392 return;
6e95edd16b43 [svn] - if writable == 0 then bail out of produce_audio() instead of segfault
nenolod
parents: 1036
diff changeset
393
1036
976a54334538 [svn] - abort out of produce_audio if a stop has been requested
nenolod
parents: 929
diff changeset
394 while (op->buffer_free() < writable) { /* wait output buf */
976a54334538 [svn] - abort out of produce_audio if a stop has been requested
nenolod
parents: 929
diff changeset
395 if (going && !*going) /* thread stopped? */
976a54334538 [svn] - abort out of produce_audio if a stop has been requested
nenolod
parents: 929
diff changeset
396 return; /* so finish */
929
54b23650fac1 [svn] - experimental produce-audio changes via shd of the UADE team
nenolod
parents: 890
diff changeset
397
1036
976a54334538 [svn] - abort out of produce_audio if a stop has been requested
nenolod
parents: 929
diff changeset
398 if (ip_data.stop) /* has a stop been requested? */
976a54334538 [svn] - abort out of produce_audio if a stop has been requested
nenolod
parents: 929
diff changeset
399 return; /* yes, so finish */
976a54334538 [svn] - abort out of produce_audio if a stop has been requested
nenolod
parents: 929
diff changeset
400
976a54334538 [svn] - abort out of produce_audio if a stop has been requested
nenolod
parents: 929
diff changeset
401 g_usleep(10000); /* else sleep for retry */
929
54b23650fac1 [svn] - experimental produce-audio changes via shd of the UADE team
nenolod
parents: 890
diff changeset
402 }
518
6c28a04d1254 [svn] cleanup produce_audio() a bit.
nenolod
parents: 430
diff changeset
403
1053
86da433104a8 [svn] - add an additional ip_data.stop check
nenolod
parents: 1051
diff changeset
404 if (ip_data.stop)
86da433104a8 [svn] - add an additional ip_data.stop check
nenolod
parents: 1051
diff changeset
405 return;
86da433104a8 [svn] - add an additional ip_data.stop check
nenolod
parents: 1051
diff changeset
406
929
54b23650fac1 [svn] - experimental produce-audio changes via shd of the UADE team
nenolod
parents: 890
diff changeset
407 /* do output */
54b23650fac1 [svn] - experimental produce-audio changes via shd of the UADE team
nenolod
parents: 890
diff changeset
408 op->write_audio(((guint8 *) ptr) + writeoffs, writable);
54b23650fac1 [svn] - experimental produce-audio changes via shd of the UADE team
nenolod
parents: 890
diff changeset
409
54b23650fac1 [svn] - experimental produce-audio changes via shd of the UADE team
nenolod
parents: 890
diff changeset
410 writeoffs += writable;
54b23650fac1 [svn] - experimental produce-audio changes via shd of the UADE team
nenolod
parents: 890
diff changeset
411 }
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
412 }