summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorGravatar waker <wakeroid@gmail.com>2011-11-27 13:18:10 +0100
committerGravatar waker <wakeroid@gmail.com>2011-11-27 13:18:10 +0100
commit6c1537277dfadfce437c5b9da1a04c4a77d0d206 (patch)
treef9fbe0dab824d2d68df995d240706df49b434b0f /main.c
parent204f39c855a62d6b9239716eec4a37fb81fcd624 (diff)
destroy streamer before mainloop terminates, to avoid unhandled messages
Diffstat (limited to 'main.c')
-rw-r--r--main.c42
1 files changed, 10 insertions, 32 deletions
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