diff options
author | Alexey Yakovenko <wakeroid@gmail.com> | 2010-04-25 15:09:26 +0200 |
---|---|---|
committer | Alexey Yakovenko <wakeroid@gmail.com> | 2010-04-25 15:09:26 +0200 |
commit | dbe80fed40789b58890d70831f71a525585241b7 (patch) | |
tree | 8d85cfb7fd2896127dfb9c0fc8941ab250eb6e05 | |
parent | 5a59ffc070744e94675201d6e8164befec6d9813 (diff) |
fixed issues with deletion of current track
-rw-r--r-- | playlist.c | 4 | ||||
-rw-r--r-- | plugins.c | 1 | ||||
-rw-r--r-- | plugins/gtkui/callbacks.c | 12 | ||||
-rw-r--r-- | plugins/gtkui/gtkui.c | 46 | ||||
-rw-r--r-- | streamer.c | 44 |
5 files changed, 44 insertions, 63 deletions
@@ -1444,7 +1444,7 @@ void pl_item_ref (playItem_t *it) { LOCK; it->_refc++; - //trace ("\033[0;34m+it %p: refc=%d: %s\033[37;0m\n", it, it->_refc, it->fname); + trace ("\033[0;34m+it %p: refc=%d: %s\033[37;0m\n", it, it->_refc, it->fname); UNLOCK; } @@ -1471,7 +1471,7 @@ void pl_item_unref (playItem_t *it) { LOCK; it->_refc--; - //trace ("\033[0;31m-it %p: refc=%d: %s\033[37;0m\n", it, it->_refc, it->fname); + trace ("\033[0;31m-it %p: refc=%d: %s\033[37;0m\n", it, it->_refc, it->fname); if (it->_refc < 0) { trace ("\033[0;31mplaylist: bad refcount on item %p\033[37;0m\n", it); } @@ -474,6 +474,7 @@ void plug_trigger_event_trackchange (playItem_t *from, playItem_t *to) { DB_event_trackchange_t event; event.ev.event = DB_EV_SONGCHANGED; + //printf ("plug_trigger_event_trackchange %p %d %p %d\n", from, from ? from->_refc : -1, to, to ? to->_refc : -1); event.from = (DB_playItem_t *)from; event.to = (DB_playItem_t *)to; plug_event_call (DB_EVENT (&event)); diff --git a/plugins/gtkui/callbacks.c b/plugins/gtkui/callbacks.c index 7dd8e86f..a51c5136 100644 --- a/plugins/gtkui/callbacks.c +++ b/plugins/gtkui/callbacks.c @@ -558,16 +558,6 @@ on_seekbar_configure_event (GtkWidget *widget, #endif gboolean -on_seekbar_expose_event (GtkWidget *widget, - GdkEventExpose *event, - gpointer user_data) -{ - //seekbar_expose (widget, event->area.x, event->area.y, event->area.width, event->area.height); - seekbar_draw (widget); - return FALSE; -} - -gboolean on_seekbar_motion_notify_event (GtkWidget *widget, GdkEventMotion *event) { @@ -598,8 +588,6 @@ on_seekbar_button_release_event (GtkWidget *widget, { seekbar_moving = 0; gtk_widget_queue_draw (widget); - //seekbar_draw (widget); - //seekbar_expose (widget, 0, 0, widget->allocation.width, widget->allocation.height); DB_playItem_t *trk = deadbeef->streamer_get_playing_track (); if (trk) { float time = (event->x - widget->allocation.x) * deadbeef->pl_get_item_duration (trk) / (widget->allocation.width); diff --git a/plugins/gtkui/gtkui.c b/plugins/gtkui/gtkui.c index b9471b4d..61f0f48e 100644 --- a/plugins/gtkui/gtkui.c +++ b/plugins/gtkui/gtkui.c @@ -21,9 +21,6 @@ #ifdef HAVE_CONFIG_H #include "../../config.h" #endif -#if HAVE_NOTIFY -#include <libnotify/notify.h> -#endif #include <string.h> #include <stdlib.h> #include <math.h> @@ -90,8 +87,6 @@ gtkpl_free (DdbListview *pl) { #endif } - - struct fromto_t { DB_playItem_t *from; DB_playItem_t *to; @@ -347,10 +342,7 @@ gtkpl_songchanged_wrapper (DB_playItem_t *from, DB_playItem_t *to) { deadbeef->pl_item_ref (to); } g_idle_add (update_win_title_idle, ft); - if (to) { - // redraw seekbar - g_idle_add (redraw_seekbar_cb, NULL); - } + g_idle_add (redraw_seekbar_cb, NULL); g_idle_add (redraw_queued_tracks_cb, NULL); } @@ -609,10 +601,6 @@ songchanged (DdbListview *ps, DB_playItem_t *from, DB_playItem_t *to) { } } -#if HAVE_NOTIFY -static NotifyNotification* notification; -#endif - static gboolean update_win_title_idle (gpointer data) { struct fromto_t *ft = (struct fromto_t *)data; @@ -620,28 +608,6 @@ update_win_title_idle (gpointer data) { DB_playItem_t *to = ft->to; free (ft); - // show notification -#if HAVE_NOTIFY - if (to && deadbeef->conf_get_int ("gtkui.notify.enable", 0)) { - DB_playItem_t *track = deadbeef->streamer_get_playing_track ();//deadbeef->pl_get_for_idx (to); - if (track) { - char cmd [1024]; - deadbeef->pl_format_title (track, -1, cmd, sizeof (cmd), -1, deadbeef->conf_get_str ("gtkui.notify.format", NOTIFY_DEFAULT_FORMAT)); - if (notify_is_initted ()) { - if (notification) { - notify_notification_close (notification, NULL); - } - notification = notify_notification_new ("DeaDBeeF", cmd, NULL, NULL); - if (notification) { - notify_notification_set_timeout (notification, NOTIFY_EXPIRES_DEFAULT); - notify_notification_show (notification, NULL); - } - } - deadbeef->pl_item_unref (track); - } - } -#endif - // update window title if (from || to) { if (to) { @@ -727,9 +693,6 @@ gtkui_thread (void *ctx) { gdk_threads_init (); gdk_threads_enter (); gtk_set_locale (); -#if HAVE_NOTIFY - notify_init ("DeaDBeeF"); -#endif int argc = 2; const char **argv = alloca (sizeof (char *) * argc); @@ -864,9 +827,6 @@ gtkui_thread (void *ctx) { trkproperties_destroy (); gtk_widget_destroy (mainwin); gtk_widget_destroy (searchwin); -#if HAVE_NOTIFY - notify_uninit (); -#endif gdk_threads_leave (); } @@ -932,10 +892,6 @@ gtkui_load (DB_functions_t *api) { static const char settings_dlg[] = "property \"Run gtk_init with --sync (debug mode)\" checkbox gtkui.sync 0;\n" -#if HAVE_NOTIFY - "property \"Enable OSD notifications\" checkbox gtkui.notify.enable 0;\n" - "property \"Notification format\" entry gtkui.notify.format \"" NOTIFY_DEFAULT_FORMAT "\";\n" -#endif ; // define plugin interface @@ -114,6 +114,12 @@ src_unlock (void) { void streamer_start_playback (playItem_t *from, playItem_t *it) { + if (from) { + pl_item_ref (from); + } + if (it) { + pl_item_ref (it); + } // free old copy of playing if (playing_track) { pl_item_unref (playing_track); @@ -130,6 +136,12 @@ streamer_start_playback (playItem_t *from, playItem_t *it) { trace ("from=%p, to=%p[2]\n", from, it); plug_trigger_event_trackchange (from, it); } + if (from) { + pl_item_unref (from); + } + if (it) { + pl_item_unref (it); + } } playItem_t * @@ -440,9 +452,17 @@ streamer_song_removed_notify (playItem_t *it) { // that must be called after last sample from str_playing_song was done reading static int streamer_set_current (playItem_t *it) { + int err = 0; playItem_t *from, *to; + // need to add refs here, because streamer_start_playback can destroy items from = playing_track; to = it; + if (from) { + pl_item_ref (from); + } + if (to) { + pl_item_ref (to); + } if (!playing_track || p_isstopped ()) { trace ("buffering = on\n"); streamer_buffering = 1; @@ -480,7 +500,7 @@ streamer_set_current (playItem_t *it) { if (fp) { const char *ct = vfs_get_content_type (fp); if (ct) { - fprintf (stderr, "got content-type: %s\n", ct); + trace ("got content-type: %s\n", ct); if (!strcmp (ct, "audio/mpeg")) { plug = "stdmpg"; } @@ -518,7 +538,8 @@ streamer_set_current (playItem_t *it) { trace ("redraw track %d; playing_track=%p; playlist_track=%p\n", to, playing_track, playlist_track); plug_trigger_event_trackinfochanged (to); } - return -1; + err = -1; + goto error; } else { mutex_lock (decodemutex); @@ -549,7 +570,16 @@ streamer_set_current (playItem_t *it) { // } success: plug_trigger_event_trackinfochanged (to); - return 0; + +error: + if (from) { + pl_item_unref (from); + } + if (to) { + pl_item_unref (to); + } + + return err; } float @@ -683,12 +713,18 @@ streamer_thread (void *ctx) { trace ("sending songfinished to plugins [1]\n"); plug_trigger_event (DB_EV_SONGFINISHED, 0); } + if (from) { + pl_item_ref (from); + } streamer_set_current (NULL); if (playing_track) { pl_item_unref (playing_track); playing_track = NULL; } plug_trigger_event_trackchange (from, NULL); + if (from) { + pl_item_unref (from); + } continue; } else if (p_isstopped ()) { @@ -1476,7 +1512,7 @@ streamer_configchanged (void) { int q = conf_get_int ("src_quality", 2); if (q != src_quality && q >= SRC_SINC_BEST_QUALITY && q <= SRC_LINEAR) { src_lock (); - fprintf (stderr, "changing src_quality from %d to %d\n", src_quality, q); + trace ("changing src_quality from %d to %d\n", src_quality, q); src_quality = q; if (src) { src_delete (src); |