comparison src/audacious/playback.c @ 3696:418ac922ce87

Use a mutex/condvar/timed wait to allow tickless operation in the output loop. Add suggestions on how to improve produce_audio() API.
author William Pitcock <nenolod@atheme.org>
date Sat, 06 Oct 2007 20:35:52 -0500
parents 30ef1287da19
children 38259e9394a2
comparison
equal deleted inserted replaced
3695:cad078740bef 3696:418ac922ce87
92 g_cond_wait(playback->pb_ready_cond, playback->pb_ready_mutex); 92 g_cond_wait(playback->pb_ready_cond, playback->pb_ready_mutex);
93 g_mutex_unlock(playback->pb_ready_mutex); 93 g_mutex_unlock(playback->pb_ready_mutex);
94 return 0; 94 return 0;
95 } 95 }
96 96
97 static void
98 playback_set_pb_change(InputPlayback *playback)
99 {
100 g_mutex_lock(playback->pb_change_mutex);
101 g_cond_signal(playback->pb_change_cond);
102 g_mutex_unlock(playback->pb_change_mutex);
103 }
104
97 void 105 void
98 playback_eof(void) 106 playback_eof(void)
99 { 107 {
100 event_queue("playback eof", playlist_get_active()); 108 event_queue("playback eof", playlist_get_active());
101 } 109 }
243 playback_pause(); 251 playback_pause();
244 } 252 }
245 253
246 ip_data.playing = FALSE; 254 ip_data.playing = FALSE;
247 255
256 /* TODO: i'm unsure if this will work. we might have to
257 signal the change in stop() (e.g. in the plugins
258 directly.) --nenolod */
259 playback->set_pb_change(playback);
260
248 if (playback->plugin->stop) 261 if (playback->plugin->stop)
249 playback->plugin->stop(playback); 262 playback->plugin->stop(playback);
250 263
251 if (playback->thread != NULL) 264 if (playback->thread != NULL)
252 { 265 {
366 playback->output = &psuedo_output_plugin; 379 playback->output = &psuedo_output_plugin;
367 playback->filename = g_strdup(entry->filename); 380 playback->filename = g_strdup(entry->filename);
368 playback->pb_ready_mutex = g_mutex_new(); 381 playback->pb_ready_mutex = g_mutex_new();
369 playback->pb_ready_cond = g_cond_new(); 382 playback->pb_ready_cond = g_cond_new();
370 playback->pb_ready_val = 0; 383 playback->pb_ready_val = 0;
384
385 playback->pb_change_mutex = g_mutex_new();
386 playback->pb_change_cond = g_cond_new();
387
388 /* init vtable functors */
371 playback->set_pb_ready = playback_set_pb_ready; 389 playback->set_pb_ready = playback_set_pb_ready;
390 playback->set_pb_change = playback_set_pb_change;
372 391
373 set_current_input_playback(playback); 392 set_current_input_playback(playback);
374 393
375 playback->thread = g_thread_create(playback_monitor_thread, playback, TRUE, NULL); 394 playback->thread = g_thread_create(playback_monitor_thread, playback, TRUE, NULL);
376 #ifdef USE_DBUS 395 #ifdef USE_DBUS
413 output_set_volume(0,0); 432 output_set_volume(0,0);
414 playback_pause(); 433 playback_pause();
415 } 434 }
416 435
417 playback->plugin->seek(playback, time); 436 playback->plugin->seek(playback, time);
437 playback->set_pb_change(playback);
418 free_vis_data(); 438 free_vis_data();
419 439
420 if (restore_pause) 440 if (restore_pause)
421 { 441 {
422 playback_pause(); 442 playback_pause();