summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorGravatar waker <wakeroid@gmail.com>2009-08-13 22:38:35 +0200
committerGravatar waker <wakeroid@gmail.com>2009-08-13 22:38:35 +0200
commit06c9fe1c21c7de0c9985dff30891d6cf64ed46b8 (patch)
tree078cd367e67f22e97d276466120d058049dfb839 /main.c
parent2ee926470f70b6d5cf3566683aae8376b5aa7010 (diff)
proper exiting without crashing
Diffstat (limited to 'main.c')
-rw-r--r--main.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/main.c b/main.c
index b96099b1..13479019 100644
--- a/main.c
+++ b/main.c
@@ -39,8 +39,6 @@ GtkWidget *searchwin;
gtkplaylist_t main_playlist;
gtkplaylist_t search_playlist;
-int psdl_terminate = 0;
-
// update status bar and window title
static int sb_context_id = -1;
static char sb_text[512];
@@ -48,9 +46,6 @@ static float last_songpos = -1;
void
update_songinfo (void) {
- if (!mainwin) {
- return;
- }
char sbtext_new[512] = "-";
float songpos = last_songpos;
if (p_ispaused ()) {
@@ -107,15 +102,19 @@ update_songinfo (void) {
}
void
-psdl_thread (uintptr_t ctx) {
- p_play ();
- while (!psdl_terminate) {
+player_thread (uintptr_t ctx) {
+ for (;;) {
uint32_t msg;
uintptr_t ctx;
uint32_t p1;
uint32_t p2;
while (messagepump_pop(&msg, &ctx, &p1, &p2) != -1) {
switch (msg) {
+ case M_TERMINATE:
+ GDK_THREADS_ENTER();
+ gtk_main_quit ();
+ GDK_THREADS_LEAVE();
+ return;
case M_SONGCHANGED:
GDK_THREADS_ENTER();
// update window title
@@ -222,7 +221,7 @@ main (int argc, char *argv[]) {
codec_init_locking ();
streamer_init ();
p_init ();
- thread_start (psdl_thread, 0);
+ thread_start (player_thread, 0);
g_thread_init (NULL);
add_pixmap_directory ("/usr/share/deadbeef/images");
@@ -241,10 +240,8 @@ main (int argc, char *argv[]) {
search_playlist_init (lookup_widget (searchwin, "searchlist"));
gtk_widget_show (mainwin);
gtk_main ();
- mainwin = NULL;
gdk_threads_leave ();
messagepump_free ();
- psdl_terminate = 1;
p_free ();
streamer_free ();
codec_free_locking ();