diff options
author | waker <wakeroid@gmail.com> | 2011-04-22 22:03:08 +0200 |
---|---|---|
committer | waker <wakeroid@gmail.com> | 2011-04-22 22:03:08 +0200 |
commit | b5985e32982f2720d0217c55e3f8dc34348608db (patch) | |
tree | c0d80c6539b15bcf5300fe3ce411019bc3abea10 /plugins/notify | |
parent | 653f1b85e4658fa8c7c5957c0c97d8f57079349a (diff) |
refresh notification when cover art has been loaded
Diffstat (limited to 'plugins/notify')
-rw-r--r-- | plugins/notify/notify.c | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/plugins/notify/notify.c b/plugins/notify/notify.c index a273a3a1..9aef30bf 100644 --- a/plugins/notify/notify.c +++ b/plugins/notify/notify.c @@ -175,10 +175,21 @@ esc_xml (const char *cmd, char *esc, int size) { *dst = 0; } +static void show_notification (DB_playItem_t *track); +static DB_playItem_t *last_track = NULL; +static time_t request_timer = 0; static void cover_avail_callback (const char *fname, const char *artist, const char *album, void *user_data) { -// show_notification (track); + deadbeef->pl_lock (); + if (last_track && (time (NULL) - request_timer < 4)) { + show_notification (last_track); + } + if (last_track) { + deadbeef->pl_item_unref (last_track); + last_track = NULL; + } + deadbeef->pl_unlock (); } static void show_notification (DB_playItem_t *track) { @@ -196,6 +207,16 @@ static void show_notification (DB_playItem_t *track) { esc_xml (content, esc_content, sizeof (esc_content)); DBusMessage *msg = dbus_message_new_method_call (E_NOTIFICATION_BUS_NAME, E_NOTIFICATION_PATH, E_NOTIFICATION_INTERFACE, "Notify"); + deadbeef->pl_lock (); + if (last_track) { + deadbeef->pl_item_unref (last_track); + last_track = 0; + } + last_track = track; + deadbeef->pl_item_ref (last_track); + request_timer = time (NULL); + deadbeef->pl_unlock (); + const char *v_appname = "DeaDBeeF"; dbus_uint32_t v_id = 0; char *v_iconname = NULL; @@ -270,6 +291,12 @@ notify_start (void) { int notify_stop (void) { + deadbeef->pl_lock (); + if (last_track) { + deadbeef->pl_item_unref (last_track); + last_track = NULL; + } + deadbeef->pl_unlock (); return 0; } |