From 6c1537277dfadfce437c5b9da1a04c4a77d0d206 Mon Sep 17 00:00:00 2001 From: waker Date: Sun, 27 Nov 2011 13:18:10 +0100 Subject: destroy streamer before mainloop terminates, to avoid unhandled messages --- main.c | 42 ++++++++++-------------------------------- 1 file changed, 10 insertions(+), 32 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index ee1007a2..0611bf23 100644 --- a/main.c +++ b/main.c @@ -426,8 +426,16 @@ player_mainloop (void) { conf_save (); break; case DB_EV_TERMINATE: - pl_playqueue_clear (); - term = 1; + { + pl_playqueue_clear (); + + // stop streaming and playback before unloading plugins + DB_output_t *output = plug_get_output (); + output->stop (); + streamer_free (); + output->free (); + term = 1; + } break; case DB_EV_PLAY_CURRENT: if (p1) { @@ -501,33 +509,9 @@ player_mainloop (void) { return; } messagepump_wait (); - //usleep(50000); - //plug_trigger_event (DB_EV_FRAMEUPDATE, 0); } } -#if 0 -static int sigterm_handled = 0; -void -atexit_handler (void) { - fprintf (stderr, "atexit_handler\n"); - if (!sigterm_handled) { - fprintf (stderr, "handling atexit.\n"); - pl_save_all (); - conf_save (); - } -} - -void -sigterm_handler (int sig) { - fprintf (stderr, "got sigterm.\n"); - atexit_handler (); - sigterm_handled = 1; - fprintf (stderr, "bye.\n"); - exit (0); -} -#endif - #ifdef __linux__ void sigsegv_handler (int sig) { @@ -909,12 +893,6 @@ main (int argc, char *argv[]) { // stop receiving messages from outside server_close (); - // stop streaming and playback before unloading plugins - DB_output_t *output = plug_get_output (); - output->stop (); - streamer_free (); - output->free (); - // plugins might still hood references to playitems, // and query configuration in background // so unload everything 1st before final cleanup -- cgit v1.2.3