comparison src/audacious/playback.c @ 2436:f346d30bf5ab trunk

[svn] Change the input plugin API to use a struct for the currently-playing file.
author iabervon
date Sun, 28 Jan 2007 17:02:15 -0800
parents b23f52fe132f
children 8750a62abed8
comparison
equal deleted inserted replaced
2435:5b23e9b07317 2436:f346d30bf5ab
69 69
70 gint 70 gint
71 playback_get_time(void) 71 playback_get_time(void)
72 { 72 {
73 g_return_val_if_fail(playback_get_playing(), -1); 73 g_return_val_if_fail(playback_get_playing(), -1);
74 g_return_val_if_fail(get_current_input_plugin(), -1); 74 g_return_val_if_fail(get_current_input_playback(), -1);
75 75
76 return get_current_input_plugin()->get_time(); 76 return get_current_input_playback()->plugin->get_time(get_current_input_playback());
77 } 77 }
78 78
79 void 79 void
80 playback_initiate(void) 80 playback_initiate(void)
81 { 81 {
140 playback_pause(void) 140 playback_pause(void)
141 { 141 {
142 if (!playback_get_playing()) 142 if (!playback_get_playing())
143 return; 143 return;
144 144
145 if (!get_current_input_plugin()) 145 if (!get_current_input_playback())
146 return; 146 return;
147 147
148 ip_data.paused = !ip_data.paused; 148 ip_data.paused = !ip_data.paused;
149 149
150 if (get_current_input_plugin()->pause) 150 if (get_current_input_playback()->plugin->pause)
151 get_current_input_plugin()->pause(ip_data.paused); 151 get_current_input_playback()->plugin->pause(get_current_input_playback(),
152 ip_data.paused);
152 153
153 g_return_if_fail(mainwin_playstatus != NULL); 154 g_return_if_fail(mainwin_playstatus != NULL);
154 155
155 if (ip_data.paused) 156 if (ip_data.paused)
156 playstatus_set_status(mainwin_playstatus, STATUS_PAUSE); 157 playstatus_set_status(mainwin_playstatus, STATUS_PAUSE);
159 } 160 }
160 161
161 void 162 void
162 playback_stop(void) 163 playback_stop(void)
163 { 164 {
164 if (ip_data.playing && get_current_input_plugin()) { 165 if (ip_data.playing && get_current_input_playback()) {
165 166
166 if (playback_get_paused()) { 167 if (playback_get_paused()) {
167 output_flush(get_written_time()); /* to avoid noise */ 168 output_flush(get_written_time()); /* to avoid noise */
168 playback_pause(); 169 playback_pause();
169 } 170 }
170 171
171 ip_data.playing = FALSE; 172 ip_data.playing = FALSE;
172 173
173 if (get_current_input_plugin()->stop) 174 if (get_current_input_playback()->plugin->stop)
174 get_current_input_plugin()->stop(); 175 get_current_input_playback()->plugin->stop(get_current_input_playback());
175 176
176 free_vis_data(); 177 free_vis_data();
177 ip_data.paused = FALSE; 178 ip_data.paused = FALSE;
178 179
179 if (input_info_text) { 180 if (input_info_text) {
180 g_free(input_info_text); 181 g_free(input_info_text);
181 input_info_text = NULL; 182 input_info_text = NULL;
182 mainwin_set_info_text(); 183 mainwin_set_info_text();
183 } 184 }
185
186 g_free(get_current_input_playback());
187 set_current_input_playback(NULL);
184 } 188 }
185 189
186 ip_data.buffering = FALSE; 190 ip_data.buffering = FALSE;
187 ip_data.playing = FALSE; 191 ip_data.playing = FALSE;
188 192
208 } 212 }
209 213
210 gboolean 214 gboolean
211 playback_play_file(PlaylistEntry *entry) 215 playback_play_file(PlaylistEntry *entry)
212 { 216 {
217 InputPlayback * playback;
213 g_return_val_if_fail(entry != NULL, FALSE); 218 g_return_val_if_fail(entry != NULL, FALSE);
214 219
215 if (!get_current_output_plugin()) { 220 if (!get_current_output_plugin()) {
216 run_no_output_plugin_dialog(); 221 run_no_output_plugin_dialog();
217 mainwin_stop_pushed(); 222 mainwin_stop_pushed();
230 (((entry->decoder = input_check_file(entry->filename, FALSE)) == NULL) || 235 (((entry->decoder = input_check_file(entry->filename, FALSE)) == NULL) ||
231 !input_is_enabled(entry->decoder->filename))) 236 !input_is_enabled(entry->decoder->filename)))
232 { 237 {
233 input_file_not_playable(entry->filename); 238 input_file_not_playable(entry->filename);
234 239
235 set_current_input_plugin(NULL); 240 set_current_input_playback(NULL);
236 mainwin_set_info_text(); 241 mainwin_set_info_text();
237 242
238 return FALSE; 243 return FALSE;
239 } 244 }
240 245
241 set_current_input_plugin(entry->decoder); 246 playback = g_new0(InputPlayback, 1);
247
242 entry->decoder->output = &psuedo_output_plugin; 248 entry->decoder->output = &psuedo_output_plugin;
243 entry->decoder->play_file(entry->filename); 249
250 playback->plugin = entry->decoder;
251 playback->output = &psuedo_output_plugin;
252 playback->filename = entry->filename;
253
254 set_current_input_playback(playback);
255
256 entry->decoder->play_file(playback);
244 257
245 ip_data.playing = TRUE; 258 ip_data.playing = TRUE;
246 259
247 return TRUE; 260 return TRUE;
248 } 261 }
264 { 277 {
265 gboolean restore_pause = FALSE; 278 gboolean restore_pause = FALSE;
266 gint l=0, r=0; 279 gint l=0, r=0;
267 280
268 g_return_if_fail(ip_data.playing); 281 g_return_if_fail(ip_data.playing);
269 g_return_if_fail(get_current_input_plugin()); 282 g_return_if_fail(get_current_input_playback());
270 283
271 /* FIXME WORKAROUND...that should work with all plugins 284 /* FIXME WORKAROUND...that should work with all plugins
272 * mute the volume, start playback again, do the seek, then pause again 285 * mute the volume, start playback again, do the seek, then pause again
273 * -Patrick Sudowe 286 * -Patrick Sudowe
274 */ 287 */
279 output_set_volume(0,0); 292 output_set_volume(0,0);
280 playback_pause(); 293 playback_pause();
281 } 294 }
282 295
283 free_vis_data(); 296 free_vis_data();
284 get_current_input_plugin()->seek(time); 297 get_current_input_playback()->plugin->seek(get_current_input_playback(), time);
285 298
286 if (restore_pause) 299 if (restore_pause)
287 { 300 {
288 playback_pause(); 301 playback_pause();
289 output_set_volume(l, r); 302 output_set_volume(l, r);