annotate audacious/output.c @ 2257:af716dc0cdb9 trunk

[svn] - do not create GtkAccelGroup anymore; use ui_manager_get_accel_group to get accelerator groups from ui_manager
author giacomo
date Thu, 04 Jan 2007 03:58:58 -0800
parents 4bc65cec8f7a
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2252
4bc65cec8f7a [svn] Update copyright notices
kiyoshi
parents: 2228
diff changeset
1 /* Audacious - Cross-platform multimedia player
2067
0b0a12ea9dd9 [svn] - allow the output plugin to be changed while playing.
nenolod
parents: 2017
diff changeset
2 * Copyright (C) 2005-2007 Audacious team
0b0a12ea9dd9 [svn] - allow the output plugin to be changed while playing.
nenolod
parents: 2017
diff changeset
3 *
2252
4bc65cec8f7a [svn] Update copyright notices
kiyoshi
parents: 2228
diff changeset
4 * Based on BMP:
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
5 * Copyright (C) 2003-2004 BMP development team.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
6 *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
7 * Based on XMMS:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
8 * Copyright (C) 1998-2003 XMMS development team.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
9 *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
10 * This program is free software; you can redistribute it and/or modify
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
11 * it under the terms of the GNU General Public License as published by
2105
f18a5b617c34 [svn] - move to GPLv2-only. Based on my interpretation of the license, we are
nenolod
parents: 2089
diff changeset
12 * the Free Software Foundation; under version 2 of the License.
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
13 *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
14 * This program is distributed in the hope that it will be useful,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
17 * GNU General Public License for more details.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
18 *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
20 * along with this program; if not, write to the Free Software
1459
705d4c089fce [svn] Fix postal code.
chainsaw
parents: 1458
diff changeset
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
22 */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
23
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
24 #ifdef HAVE_CONFIG_H
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
25 # include "config.h"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
26 #endif
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
27
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
28 #include "output.h"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
29 #include "iir.h"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
30 #include "main.h"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
31 #include "input.h"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
32
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
33 #include "playlist.h"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
34 #include "libaudacious/util.h"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
35
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
36 OutputPluginData op_data = {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
37 NULL,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
38 NULL
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
39 };
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
40
890
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
41 OutputPluginState op_state = {
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 0,
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
44 0
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
45 };
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
46
809
79da0e6ed790 [svn] - fix typo
nenolod
parents: 807
diff changeset
47 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
48 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
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 "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
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 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 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
56 output_set_volume,
890
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
57 output_open_audio,
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
58 output_write_audio,
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
59 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
60
890
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
61 output_flush,
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
62 output_pause,
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
63 output_buffer_free,
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
64 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
65 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
66 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
67 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
68 };
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
69
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
70 OutputPlugin *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
71 get_current_output_plugin(void)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
72 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
73 return op_data.current_output_plugin;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
74 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
75
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
76 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
77 set_current_output_plugin(gint i)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
78 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
79 gint time;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
80 gint pos;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
81 gboolean playing;
2067
0b0a12ea9dd9 [svn] - allow the output plugin to be changed while playing.
nenolod
parents: 2017
diff changeset
82 OutputPlugin *op = get_current_output_plugin();
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
83
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
84 GList *node = g_list_nth(op_data.output_list, i);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
85 if (!node) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
86 op_data.current_output_plugin = NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
87 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
88 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
89
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
90 op_data.current_output_plugin = node->data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
91
2228
894f7aa46f83 [svn] - bmp_playback_* -> playback_* -- i knew something smelled rotten here, hmm.
nenolod
parents: 2105
diff changeset
92 playing = playback_get_playing();
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
93
2067
0b0a12ea9dd9 [svn] - allow the output plugin to be changed while playing.
nenolod
parents: 2017
diff changeset
94 if (playing == TRUE)
0b0a12ea9dd9 [svn] - allow the output plugin to be changed while playing.
nenolod
parents: 2017
diff changeset
95 {
0b0a12ea9dd9 [svn] - allow the output plugin to be changed while playing.
nenolod
parents: 2017
diff changeset
96 gint i = 99;
0b0a12ea9dd9 [svn] - allow the output plugin to be changed while playing.
nenolod
parents: 2017
diff changeset
97 guint time, pos;
0b0a12ea9dd9 [svn] - allow the output plugin to be changed while playing.
nenolod
parents: 2017
diff changeset
98 PlaylistEntry *entry;
0b0a12ea9dd9 [svn] - allow the output plugin to be changed while playing.
nenolod
parents: 2017
diff changeset
99
0b0a12ea9dd9 [svn] - allow the output plugin to be changed while playing.
nenolod
parents: 2017
diff changeset
100 /* don't stop yet, get the seek time and playlist position first */
2089
ef095eb43578 [svn] Add playlist_get_active where required.
chainsaw
parents: 2067
diff changeset
101 pos = playlist_get_position(playlist_get_active());
2067
0b0a12ea9dd9 [svn] - allow the output plugin to be changed while playing.
nenolod
parents: 2017
diff changeset
102 time = op->output_time();
0b0a12ea9dd9 [svn] - allow the output plugin to be changed while playing.
nenolod
parents: 2017
diff changeset
103
0b0a12ea9dd9 [svn] - allow the output plugin to be changed while playing.
nenolod
parents: 2017
diff changeset
104 /* reset the audio system */
0b0a12ea9dd9 [svn] - allow the output plugin to be changed while playing.
nenolod
parents: 2017
diff changeset
105 mainwin_stop_pushed();
0b0a12ea9dd9 [svn] - allow the output plugin to be changed while playing.
nenolod
parents: 2017
diff changeset
106 op->close_audio();
0b0a12ea9dd9 [svn] - allow the output plugin to be changed while playing.
nenolod
parents: 2017
diff changeset
107
0b0a12ea9dd9 [svn] - allow the output plugin to be changed while playing.
nenolod
parents: 2017
diff changeset
108 g_usleep(300000);
0b0a12ea9dd9 [svn] - allow the output plugin to be changed while playing.
nenolod
parents: 2017
diff changeset
109
0b0a12ea9dd9 [svn] - allow the output plugin to be changed while playing.
nenolod
parents: 2017
diff changeset
110 /* wait for the playback thread to come online */
2228
894f7aa46f83 [svn] - bmp_playback_* -> playback_* -- i knew something smelled rotten here, hmm.
nenolod
parents: 2105
diff changeset
111 while (playback_get_playing())
2067
0b0a12ea9dd9 [svn] - allow the output plugin to be changed while playing.
nenolod
parents: 2017
diff changeset
112 g_message("waiting for audio system shutdown...");
0b0a12ea9dd9 [svn] - allow the output plugin to be changed while playing.
nenolod
parents: 2017
diff changeset
113
0b0a12ea9dd9 [svn] - allow the output plugin to be changed while playing.
nenolod
parents: 2017
diff changeset
114 /* wait for the playback thread to come online */
2089
ef095eb43578 [svn] Add playlist_get_active where required.
chainsaw
parents: 2067
diff changeset
115 playlist_set_position(playlist_get_active(), pos);
ef095eb43578 [svn] Add playlist_get_active where required.
chainsaw
parents: 2067
diff changeset
116 entry = playlist_get_entry_to_play(playlist_get_active());
2228
894f7aa46f83 [svn] - bmp_playback_* -> playback_* -- i knew something smelled rotten here, hmm.
nenolod
parents: 2105
diff changeset
117 playback_play_file(entry);
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
118
2228
894f7aa46f83 [svn] - bmp_playback_* -> playback_* -- i knew something smelled rotten here, hmm.
nenolod
parents: 2105
diff changeset
119 while (!playback_get_playing())
2067
0b0a12ea9dd9 [svn] - allow the output plugin to be changed while playing.
nenolod
parents: 2017
diff changeset
120 {
0b0a12ea9dd9 [svn] - allow the output plugin to be changed while playing.
nenolod
parents: 2017
diff changeset
121 gtk_main_iteration();
0b0a12ea9dd9 [svn] - allow the output plugin to be changed while playing.
nenolod
parents: 2017
diff changeset
122 g_message("waiting for audio system startup...");
0b0a12ea9dd9 [svn] - allow the output plugin to be changed while playing.
nenolod
parents: 2017
diff changeset
123 }
0b0a12ea9dd9 [svn] - allow the output plugin to be changed while playing.
nenolod
parents: 2017
diff changeset
124
0b0a12ea9dd9 [svn] - allow the output plugin to be changed while playing.
nenolod
parents: 2017
diff changeset
125 /* and signal a reseek */
2089
ef095eb43578 [svn] Add playlist_get_active where required.
chainsaw
parents: 2067
diff changeset
126 if (playlist_get_current_length(playlist_get_active()) > -1 &&
ef095eb43578 [svn] Add playlist_get_active where required.
chainsaw
parents: 2067
diff changeset
127 time <= (playlist_get_current_length(playlist_get_active())))
2067
0b0a12ea9dd9 [svn] - allow the output plugin to be changed while playing.
nenolod
parents: 2017
diff changeset
128 {
0b0a12ea9dd9 [svn] - allow the output plugin to be changed while playing.
nenolod
parents: 2017
diff changeset
129 gint i;
0b0a12ea9dd9 [svn] - allow the output plugin to be changed while playing.
nenolod
parents: 2017
diff changeset
130
2228
894f7aa46f83 [svn] - bmp_playback_* -> playback_* -- i knew something smelled rotten here, hmm.
nenolod
parents: 2105
diff changeset
131 playback_seek(time / 1000);
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
132 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
133 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
134 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
135
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
136 GList *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
137 get_output_list(void)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
138 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
139 return op_data.output_list;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
140 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
141
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
142 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
143 output_about(gint i)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
144 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
145 OutputPlugin *out = g_list_nth(op_data.output_list, i)->data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
146 if (out && out->about)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
147 out->about();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
148 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
149
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
150 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
151 output_configure(gint i)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
152 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
153 OutputPlugin *out = g_list_nth(op_data.output_list, i)->data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
154 if (out && out->configure)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
155 out->configure();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
156 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
157
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
158 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
159 output_get_volume(gint * l, gint * r)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
160 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
161 *l = *r = -1;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
162
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
163 if (!op_data.current_output_plugin)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
164 return;
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->get_volume)
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 op_data.current_output_plugin->get_volume(l, r);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
170 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
171
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
172 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
173 output_set_volume(gint l, gint r)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
174 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
175 if (!op_data.current_output_plugin)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
176 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
177
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
178 if (!op_data.current_output_plugin->set_volume)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
179 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
180
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
181 op_data.current_output_plugin->set_volume(l, r);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
182 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
183
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
184 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
185 output_set_eq(gboolean active, gfloat pre, gfloat * bands)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
186 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
187 int i;
430
67cd014f35a2 [svn] This commit rips out the old equalization engine with a dynamic engine
nenolod
parents: 0
diff changeset
188 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
189 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
190
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
191 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
192 {
67cd014f35a2 [svn] This commit rips out the old equalization engine with a dynamic engine
nenolod
parents: 0
diff changeset
193 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
194 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
195 }
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
196 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
197
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
198 /* this should be in BYTES, NOT gint16s */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
199 static void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
200 byteswap(size_t size,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
201 gint16 * buf)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
202 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
203 gint16 *it;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
204 size &= ~1; /* must be multiple of 2 */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
205 for (it = buf; it < buf + size / 2; ++it)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
206 *(guint16 *) it = GUINT16_SWAP_LE_BE(*(guint16 *) it);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
207 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
208
806
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 write 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_written_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->written_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
d51a251b542c [svn] - add get_written_time(), get_output_time().
nenolod
parents: 625
diff changeset
218 /* 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
219 gint
d51a251b542c [svn] - add get_written_time(), get_output_time().
nenolod
parents: 625
diff changeset
220 get_output_time(void)
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 OutputPlugin *op = get_current_output_plugin();
d51a251b542c [svn] - add get_written_time(), get_output_time().
nenolod
parents: 625
diff changeset
223
d51a251b542c [svn] - add get_written_time(), get_output_time().
nenolod
parents: 625
diff changeset
224 return op->output_time();
d51a251b542c [svn] - add get_written_time(), get_output_time().
nenolod
parents: 625
diff changeset
225 }
d51a251b542c [svn] - add get_written_time(), get_output_time().
nenolod
parents: 625
diff changeset
226
890
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
227 gint
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
228 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
229 {
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
230 gint ret;
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
231 OutputPlugin *op;
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
232
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
233 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
234
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
235 if (op == NULL)
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
236 return -1;
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 /* 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
239 if ((op_state.rate != 0 && op_state.nch != 0) &&
1768
def887eae029 [svn] - remove some old debugging notices
nenolod
parents: 1459
diff changeset
240 (op_state.rate == rate && op_state.nch == nch && op_state.fmt == fmt))
890
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 /* 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
243 op->flush(0);
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
244 return 1;
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
245 }
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
246 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
247 op->close_audio();
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 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
250
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
251 if (ret == 1) /* Success? */
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 op_state.fmt = fmt;
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
254 op_state.rate = rate;
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
255 op_state.nch = nch;
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
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
258 return ret;
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
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
261 void
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
262 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
263 {
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
264 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
265
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
266 /* Sanity check. */
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
267 if (op == NULL)
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
268 return;
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
269
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
270 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
271 }
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
272
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
273 void
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
274 output_close_audio(void)
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
275 {
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
276 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
277
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
278 /* 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
279 * 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
280 */
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
281 if (ip_data.stop == FALSE &&
2089
ef095eb43578 [svn] Add playlist_get_active where required.
chainsaw
parents: 2067
diff changeset
282 (playlist_get_position_nolock(playlist_get_active()) < playlist_get_length_nolock(playlist_get_active()) - 1))
890
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 /* Sanity check. */
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
286 if (op == NULL)
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
287 return;
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
288
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
289 op->close_audio();
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
290
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
291 /* Reset the op_state. */
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
292 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
293 }
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
294
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
295 void
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
296 output_flush(gint time)
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
297 {
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
298 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
299
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
300 if (op == NULL)
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
301 return;
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 op->flush(time);
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
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
306 void
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
307 output_pause(gshort paused)
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
308 {
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
309 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
310
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
311 if (op == NULL)
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
312 return;
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 op->pause(paused);
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
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
317 gint
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
318 output_buffer_free(void)
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
319 {
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
320 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
321
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
322 if (op == NULL)
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
323 return 0;
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 return op->buffer_free();
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
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
328 gint
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
329 output_buffer_playing(void)
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
330 {
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
331 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
332
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
333 if (op == NULL)
ed26947bbf57 [svn] Gapless support. This comes with a few caveats, that I will mention here:
nenolod
parents: 809
diff changeset
334 return 0;
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 return op->buffer_playing();
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
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
339 /* called by input plugin when data is ready */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
340 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
341 produce_audio(gint time, /* position */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
342 AFormat fmt, /* output format */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
343 gint nch, /* channels */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
344 gint length, /* length of sample */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
345 gpointer ptr, /* data */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
346 int *going /* 0 when time to stop */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
347 )
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
348 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
349 static int init = 0;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
350 int swapped = 0;
625
0a73d1faeb4e [svn] GCC 4.1 warning fixes by Diego 'Flameeyes' Petteno from Gentoo.
chainsaw
parents: 519
diff changeset
351 guint myorder = G_BYTE_ORDER == G_LITTLE_ENDIAN ? FMT_S16_LE : FMT_S16_BE;
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
352 int caneq = (fmt == FMT_S16_NE || fmt == myorder);
518
6c28a04d1254 [svn] cleanup produce_audio() a bit.
nenolod
parents: 430
diff changeset
353 OutputPlugin *op = get_current_output_plugin();
929
54b23650fac1 [svn] - experimental produce-audio changes via shd of the UADE team
nenolod
parents: 890
diff changeset
354 int writeoffs;
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
355
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
356 if (!caneq && cfg.equalizer_active) { /* wrong byte order */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
357 byteswap(length, ptr); /* so convert */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
358 ++swapped;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
359 ++caneq;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
360 } /* can eq now, mark swapd */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
361 else if (caneq && !cfg.equalizer_active) /* right order but no eq */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
362 caneq = 0; /* so don't eq */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
363
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
364 if (caneq) { /* if eq enab */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
365 if (!init) { /* if first run */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
366 init_iir(); /* then init eq */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
367 ++init;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
368 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
369
430
67cd014f35a2 [svn] This commit rips out the old equalization engine with a dynamic engine
nenolod
parents: 0
diff changeset
370 iir(&ptr, length, nch);
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
371
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
372 if (swapped) /* if was swapped */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
373 byteswap(length, ptr); /* swap back for output */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
374 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
375
518
6c28a04d1254 [svn] cleanup produce_audio() a bit.
nenolod
parents: 430
diff changeset
376 /* do vis plugin(s) */
519
88e9a6a8336f [svn] whoever wrote output_to_audio() was a crackhead.
nenolod
parents: 518
diff changeset
377 input_add_vis_pcm(time, fmt, nch, length, ptr);
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
378
929
54b23650fac1 [svn] - experimental produce-audio changes via shd of the UADE team
nenolod
parents: 890
diff changeset
379 writeoffs = 0;
54b23650fac1 [svn] - experimental produce-audio changes via shd of the UADE team
nenolod
parents: 890
diff changeset
380 while (writeoffs < length) {
54b23650fac1 [svn] - experimental produce-audio changes via shd of the UADE team
nenolod
parents: 890
diff changeset
381 int writable = length - writeoffs;
54b23650fac1 [svn] - experimental produce-audio changes via shd of the UADE team
nenolod
parents: 890
diff changeset
382
54b23650fac1 [svn] - experimental produce-audio changes via shd of the UADE team
nenolod
parents: 890
diff changeset
383 if (writable > 2048)
54b23650fac1 [svn] - experimental produce-audio changes via shd of the UADE team
nenolod
parents: 890
diff changeset
384 writable = 2048;
518
6c28a04d1254 [svn] cleanup produce_audio() a bit.
nenolod
parents: 430
diff changeset
385
1051
6e95edd16b43 [svn] - if writable == 0 then bail out of produce_audio() instead of segfault
nenolod
parents: 1036
diff changeset
386 if (writable == 0)
6e95edd16b43 [svn] - if writable == 0 then bail out of produce_audio() instead of segfault
nenolod
parents: 1036
diff changeset
387 return;
6e95edd16b43 [svn] - if writable == 0 then bail out of produce_audio() instead of segfault
nenolod
parents: 1036
diff changeset
388
1036
976a54334538 [svn] - abort out of produce_audio if a stop has been requested
nenolod
parents: 929
diff changeset
389 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
390 if (going && !*going) /* thread stopped? */
976a54334538 [svn] - abort out of produce_audio if a stop has been requested
nenolod
parents: 929
diff changeset
391 return; /* so finish */
929
54b23650fac1 [svn] - experimental produce-audio changes via shd of the UADE team
nenolod
parents: 890
diff changeset
392
1036
976a54334538 [svn] - abort out of produce_audio if a stop has been requested
nenolod
parents: 929
diff changeset
393 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
394 return; /* yes, so finish */
976a54334538 [svn] - abort out of produce_audio if a stop has been requested
nenolod
parents: 929
diff changeset
395
976a54334538 [svn] - abort out of produce_audio if a stop has been requested
nenolod
parents: 929
diff changeset
396 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
397 }
518
6c28a04d1254 [svn] cleanup produce_audio() a bit.
nenolod
parents: 430
diff changeset
398
1053
86da433104a8 [svn] - add an additional ip_data.stop check
nenolod
parents: 1051
diff changeset
399 if (ip_data.stop)
86da433104a8 [svn] - add an additional ip_data.stop check
nenolod
parents: 1051
diff changeset
400 return;
86da433104a8 [svn] - add an additional ip_data.stop check
nenolod
parents: 1051
diff changeset
401
2017
a99862e5bd65 [svn] - avoid a race condition in produce_audio() where we have closed output,
nenolod
parents: 1768
diff changeset
402 if (going && !*going) /* thread stopped? */
a99862e5bd65 [svn] - avoid a race condition in produce_audio() where we have closed output,
nenolod
parents: 1768
diff changeset
403 return; /* so finish */
a99862e5bd65 [svn] - avoid a race condition in produce_audio() where we have closed output,
nenolod
parents: 1768
diff changeset
404
929
54b23650fac1 [svn] - experimental produce-audio changes via shd of the UADE team
nenolod
parents: 890
diff changeset
405 /* do output */
54b23650fac1 [svn] - experimental produce-audio changes via shd of the UADE team
nenolod
parents: 890
diff changeset
406 op->write_audio(((guint8 *) ptr) + writeoffs, writable);
54b23650fac1 [svn] - experimental produce-audio changes via shd of the UADE team
nenolod
parents: 890
diff changeset
407
54b23650fac1 [svn] - experimental produce-audio changes via shd of the UADE team
nenolod
parents: 890
diff changeset
408 writeoffs += writable;
54b23650fac1 [svn] - experimental produce-audio changes via shd of the UADE team
nenolod
parents: 890
diff changeset
409 }
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
410 }