annotate src/audacious/output.c @ 2394:e2aaa7dca389 trunk

[svn] - tuple->file_name coming from input plugins have a string with filename + extension, but tuple->file_name coming from input plugins without a get_song_tuple have a string with filename without extension; fix this incongruency, always pass tuple->filename with a string containing filename + extension
author giacomo
date Tue, 23 Jan 2007 16:37:13 -0800
parents ad1d7687814c
children 719e0898ff3c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1 /* Audacious - Cross-platform multimedia player
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2 * Copyright (C) 2005-2007 Audacious team
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3 *
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
4 * Based on BMP:
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
5 * Copyright (C) 2003-2004 BMP development team.
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
6 *
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
7 * Based on XMMS:
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
8 * Copyright (C) 1998-2003 XMMS development team.
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
9 *
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
10 * This program is free software; you can redistribute it and/or modify
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
11 * it under the terms of the GNU General Public License as published by
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
12 * the Free Software Foundation; under version 2 of the License.
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
13 *
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
14 * This program is distributed in the hope that it will be useful,
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
17 * GNU General Public License for more details.
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
18 *
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
20 * along with this program; if not, write to the Free Software
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
22 */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
23
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
24 #ifdef HAVE_CONFIG_H
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
25 # include "config.h"
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
26 #endif
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
27
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
28 #include "output.h"
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
29 #include "iir.h"
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
30 #include "main.h"
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
31 #include "input.h"
2328
d88558b0de0a [svn] - Added script for migration to XDG basedir.
js
parents: 2313
diff changeset
32 #include "playback.h"
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
33
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
34 #include "playlist.h"
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
35
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
36 OutputPluginData op_data = {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
37 NULL,
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
38 NULL
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
39 };
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
40
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
41 OutputPluginState op_state = {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
42 0,
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
43 0,
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
44 0
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
45 };
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
46
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
47 OutputPlugin psuedo_output_plugin = {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
48 NULL,
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
49 NULL,
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
50 "XMMS reverse compatibility output plugin",
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
51 NULL,
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
52 NULL,
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
53 NULL,
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
54 NULL,
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
55 output_get_volume,
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
56 output_set_volume,
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
57 output_open_audio,
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
58 output_write_audio,
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
59 output_close_audio,
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
60
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
61 output_flush,
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
62 output_pause,
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
63 output_buffer_free,
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
64 output_buffer_playing,
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
65 get_output_time,
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
66 get_written_time,
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
67 NULL
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
68 };
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
69
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
70 OutputPlugin *
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
71 get_current_output_plugin(void)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
72 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
73 return op_data.current_output_plugin;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
74 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
75
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
76 void
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
77 set_current_output_plugin(gint i)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
78 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
79 gboolean playing;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
80 OutputPlugin *op = get_current_output_plugin();
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
81
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
82 GList *node = g_list_nth(op_data.output_list, i);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
83 if (!node) {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
84 op_data.current_output_plugin = NULL;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
85 return;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
86 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
87
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
88 op_data.current_output_plugin = node->data;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
89
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
90 playing = playback_get_playing();
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
91
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
92 if (playing == TRUE)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
93 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
94 guint time, pos;
2373
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
95 PlaylistEntry *entry;
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
96
2373
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
97 /* don't stop yet, get the seek time and playlist position first */
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
98 pos = playlist_get_position(playlist_get_active());
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
99 time = op->output_time();
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
100
2373
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
101 /* reset the audio system */
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
102 mainwin_stop_pushed();
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
103 op->close_audio();
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
104
2373
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
105 g_usleep(300000);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
106
2373
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
107 /* wait for the playback thread to come online */
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
108 while (playback_get_playing())
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
109 g_message("waiting for audio system shutdown...");
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
110
2373
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
111 /* wait for the playback thread to come online */
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
112 playlist_set_position(playlist_get_active(), pos);
2373
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
113 entry = playlist_get_entry_to_play(playlist_get_active());
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
114 playback_play_file(entry);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
115
2373
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
116 while (!playback_get_playing())
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
117 {
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
118 gtk_main_iteration();
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
119 g_message("waiting for audio system startup...");
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
120 }
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
121
2373
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
122 /* and signal a reseek */
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
123 if (playlist_get_current_length(playlist_get_active()) > -1 &&
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
124 time <= (playlist_get_current_length(playlist_get_active())))
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
125 playback_seek(time / 1000);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
126 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
127 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
128
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
129 GList *
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
130 get_output_list(void)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
131 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
132 return op_data.output_list;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
133 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
134
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
135 void
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
136 output_about(gint i)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
137 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
138 OutputPlugin *out = g_list_nth(op_data.output_list, i)->data;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
139 if (out && out->about)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
140 out->about();
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
141 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
142
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
143 void
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
144 output_configure(gint i)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
145 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
146 OutputPlugin *out = g_list_nth(op_data.output_list, i)->data;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
147 if (out && out->configure)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
148 out->configure();
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
149 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
150
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
151 void
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
152 output_get_volume(gint * l, gint * r)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
153 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
154 *l = *r = -1;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
155
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
156 if (!op_data.current_output_plugin)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
157 return;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
158
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
159 if (!op_data.current_output_plugin->get_volume)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
160 return;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
161
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
162 op_data.current_output_plugin->get_volume(l, r);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
163 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
164
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
165 void
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
166 output_set_volume(gint l, gint r)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
167 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
168 if (!op_data.current_output_plugin)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
169 return;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
170
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
171 if (!op_data.current_output_plugin->set_volume)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
172 return;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
173
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
174 op_data.current_output_plugin->set_volume(l, r);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
175 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
176
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
177 void
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
178 output_set_eq(gboolean active, gfloat pre, gfloat * bands)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
179 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
180 int i;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
181 preamp[0] = 1.0 + 0.0932471 * pre + 0.00279033 * pre * pre;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
182 preamp[1] = 1.0 + 0.0932471 * pre + 0.00279033 * pre * pre;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
183
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
184 for (i = 0; i < 10; ++i)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
185 {
2373
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
186 set_gain(i, 0, 0.03 * bands[i] + 0.000999999 * bands[i] * bands[i]);
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
187 set_gain(i, 1, 0.03 * bands[i] + 0.000999999 * bands[i] * bands[i]);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
188 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
189 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
190
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
191 /* this should be in BYTES, NOT gint16s */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
192 static void
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
193 byteswap(size_t size,
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
194 gint16 * buf)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
195 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
196 gint16 *it;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
197 size &= ~1; /* must be multiple of 2 */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
198 for (it = buf; it < buf + size / 2; ++it)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
199 *(guint16 *) it = GUINT16_SWAP_LE_BE(*(guint16 *) it);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
200 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
201
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
202 /* called by input plugin to peek at the output plugin's write progress */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
203 gint
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
204 get_written_time(void)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
205 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
206 OutputPlugin *op = get_current_output_plugin();
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
207
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
208 return op->written_time();
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
209 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
210
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
211 /* called by input plugin to peek at the output plugin's output progress */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
212 gint
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
213 get_output_time(void)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
214 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
215 OutputPlugin *op = get_current_output_plugin();
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
216
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
217 return op->output_time();
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
218 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
219
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
220 gint
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
221 output_open_audio(AFormat fmt, gint rate, gint nch)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
222 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
223 gint ret;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
224 OutputPlugin *op;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
225
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
226 op = get_current_output_plugin();
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
227
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
228 if (op == NULL)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
229 return -1;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
230
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
231 /* Is our output port already open? */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
232 if ((op_state.rate != 0 && op_state.nch != 0) &&
2373
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
233 (op_state.rate == rate && op_state.nch == nch && op_state.fmt == fmt))
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
234 {
2373
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
235 /* Yes, and it's the correct sampling rate. Reset the counter and go. */
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
236 op->flush(0);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
237 return 1;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
238 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
239 else if (op_state.rate != 0 && op_state.nch != 0)
2373
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
240 op->close_audio();
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
241
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
242 ret = op->open_audio(fmt, rate, nch);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
243
2373
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
244 if (ret == 1) /* Success? */
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
245 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
246 op_state.fmt = fmt;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
247 op_state.rate = rate;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
248 op_state.nch = nch;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
249 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
250
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
251 return ret;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
252 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
253
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
254 void
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
255 output_write_audio(gpointer ptr, gint length)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
256 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
257 OutputPlugin *op = get_current_output_plugin();
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
258
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
259 /* Sanity check. */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
260 if (op == NULL)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
261 return;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
262
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
263 op->write_audio(ptr, length);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
264 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
265
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
266 void
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
267 output_close_audio(void)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
268 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
269 OutputPlugin *op = get_current_output_plugin();
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
270
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
271 /* Do not close if there are still songs to play and the user has
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
272 * not requested a stop. --nenolod
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
273 */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
274 if (ip_data.stop == FALSE &&
2373
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
275 (playlist_get_position_nolock(playlist_get_active()) < playlist_get_length_nolock(playlist_get_active()) - 1))
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
276 return;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
277
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
278 /* Sanity check. */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
279 if (op == NULL)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
280 return;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
281
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
282 op->close_audio();
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
283
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
284 /* Reset the op_state. */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
285 op_state.fmt = op_state.rate = op_state.nch = 0;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
286 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
287
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
288 void
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
289 output_flush(gint time)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
290 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
291 OutputPlugin *op = get_current_output_plugin();
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
292
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
293 if (op == NULL)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
294 return;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
295
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
296 op->flush(time);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
297 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
298
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
299 void
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
300 output_pause(gshort paused)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
301 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
302 OutputPlugin *op = get_current_output_plugin();
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
303
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
304 if (op == NULL)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
305 return;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
306
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
307 op->pause(paused);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
308 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
309
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
310 gint
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
311 output_buffer_free(void)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
312 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
313 OutputPlugin *op = get_current_output_plugin();
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
314
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
315 if (op == NULL)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
316 return 0;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
317
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
318 return op->buffer_free();
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
319 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
320
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
321 gint
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
322 output_buffer_playing(void)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
323 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
324 OutputPlugin *op = get_current_output_plugin();
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
325
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
326 if (op == NULL)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
327 return 0;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
328
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
329 return op->buffer_playing();
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
330 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
331
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
332 /* called by input plugin when data is ready */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
333 void
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
334 produce_audio(gint time, /* position */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
335 AFormat fmt, /* output format */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
336 gint nch, /* channels */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
337 gint length, /* length of sample */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
338 gpointer ptr, /* data */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
339 int *going /* 0 when time to stop */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
340 )
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
341 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
342 static int init = 0;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
343 int swapped = 0;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
344 guint myorder = G_BYTE_ORDER == G_LITTLE_ENDIAN ? FMT_S16_LE : FMT_S16_BE;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
345 int caneq = (fmt == FMT_S16_NE || fmt == myorder);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
346 OutputPlugin *op = get_current_output_plugin();
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
347 int writeoffs;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
348
2373
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
349 if (!caneq && cfg.equalizer_active) { /* wrong byte order */
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
350 byteswap(length, ptr); /* so convert */
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
351 ++swapped;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
352 ++caneq;
2373
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
353 } /* can eq now, mark swapd */
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
354 else if (caneq && !cfg.equalizer_active) /* right order but no eq */
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
355 caneq = 0; /* so don't eq */
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
356
2373
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
357 if (caneq) { /* if eq enab */
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
358 if (!init) { /* if first run */
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
359 init_iir(); /* then init eq */
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
360 ++init;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
361 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
362
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
363 iir(&ptr, length, nch);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
364
2373
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
365 if (swapped) /* if was swapped */
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
366 byteswap(length, ptr); /* swap back for output */
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
367 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
368
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
369 /* do vis plugin(s) */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
370 input_add_vis_pcm(time, fmt, nch, length, ptr);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
371
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
372 writeoffs = 0;
2373
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
373 while (writeoffs < length)
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
374 {
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
375 int writable = length - writeoffs;
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
376
2373
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
377 if (writable > 2048)
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
378 writable = 2048;
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
379
2373
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
380 if (writable == 0)
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
381 return;
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
382
2373
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
383 while (op->buffer_free() < writable) { /* wait output buf */
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
384 if (going && !*going) /* thread stopped? */
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
385 return; /* so finish */
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
386
2373
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
387 if (ip_data.stop) /* has a stop been requested? */
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
388 return; /* yes, so finish */
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
389
2373
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
390 g_usleep(10000); /* else sleep for retry */
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
391 }
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
392
2373
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
393 if (ip_data.stop)
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
394 return;
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
395
2373
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
396 if (going && !*going) /* thread stopped? */
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
397 return; /* so finish */
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
398
2373
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
399 /* do output */
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
400 op->write_audio(((guint8 *) ptr) + writeoffs, writable);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
401
2373
ad1d7687814c [svn] made strings.h for existing strings.c, cleanups
mf0102
parents: 2328
diff changeset
402 writeoffs += writable;
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
403 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
404 }