summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGravatar waker <wakeroid@gmail.com>2010-11-20 11:50:11 +0100
committerGravatar waker <wakeroid@gmail.com>2010-11-20 11:50:11 +0100
commit5a5025ff2086e01c2f0164d9c9bb1b3e20a279d1 (patch)
treeecdb74e123f1f32f993c0547368af6088a2fc310 /plugins
parent21e46269269b82e756fef0051e0953c52d6be3ca (diff)
parent4f4cf2190aef650ad6e93a9ad86ed0207101f0a7 (diff)
Merge branch 'master' into static
Conflicts: plugins/artwork/artwork.c plugins/gtkui/coverart.c
Diffstat (limited to 'plugins')
-rw-r--r--plugins/artwork/artwork.c11
-rw-r--r--plugins/cdda/cdda.c3
-rw-r--r--plugins/gtkui/coverart.c57
-rw-r--r--plugins/gtkui/ddbcellrenderertextmultiline.c4
-rw-r--r--plugins/gtkui/ddbcellrenderertextmultiline.h2
-rw-r--r--plugins/gtkui/ddbequalizer.c2
-rw-r--r--plugins/gtkui/ddbequalizer.h2
-rw-r--r--plugins/gtkui/ddbseekbar.c4
-rw-r--r--plugins/gtkui/ddbseekbar.h2
-rw-r--r--plugins/notify/notify.c71
10 files changed, 103 insertions, 55 deletions
diff --git a/plugins/artwork/artwork.c b/plugins/artwork/artwork.c
index 6786b27a..34bac6dd 100644
--- a/plugins/artwork/artwork.c
+++ b/plugins/artwork/artwork.c
@@ -6,6 +6,7 @@
#include <dirent.h>
#include <unistd.h>
#include <fnmatch.h>
+#include <inttypes.h>
#include "../../deadbeef.h"
#include "artwork.h"
#include "lastfm.h"
@@ -45,7 +46,7 @@ static int artwork_enable_embedded;
static int artwork_enable_local;
static int artwork_enable_lfm;
static int artwork_enable_aao;
-static int artwork_reset_time;
+static time_t artwork_reset_time;
static char artwork_filemask[200];
static const char *get_default_cover (void) {
@@ -593,7 +594,7 @@ get_album_art (const char *fname, const char *artist, const char *album, artwork
return strdup (get_default_cover ());
}
- trace ("found %s in cache\n", path);
+// trace ("found %s in cache, resettime %" PRId64 ", filetime %" PRId64 ", time %" PRId64 "\n", path, artwork_reset_time, stat_buf.st_mtime, tm);
return strdup (path);
}
@@ -652,13 +653,15 @@ artwork_on_configchanged (DB_event_t *ev, uintptr_t data) {
|| new_artwork_enable_lfm != artwork_enable_lfm
|| new_artwork_enable_aao != artwork_enable_aao
|| strcmp (new_artwork_filemask, artwork_filemask)) {
+ printf ("artwork config changed, invalidating cache...\n");
artwork_enable_embedded = new_artwork_enable_embedded;
artwork_enable_local = new_artwork_enable_local;
artwork_enable_lfm = new_artwork_enable_lfm;
artwork_enable_aao = new_artwork_enable_aao;
artwork_reset_time = time (NULL);
strcpy (artwork_filemask, new_artwork_filemask);
- deadbeef->conf_set_int ("artwork.cache_reset_time", artwork_reset_time);
+ deadbeef->conf_set_int64 ("artwork.cache_reset_time", artwork_reset_time);
+ artwork_reset (0);
deadbeef->sendmessage (M_PLAYLISTREFRESH, 0, 0, 0);
}
@@ -681,7 +684,7 @@ artwork_plugin_start (void)
artwork_enable_local = deadbeef->conf_get_int ("artwork.enable_localfolder", 1);
artwork_enable_lfm = deadbeef->conf_get_int ("artwork.enable_lastfm", 0);
artwork_enable_aao = deadbeef->conf_get_int ("artwork.enable_albumartorg", 0);
- artwork_reset_time = deadbeef->conf_get_int ("artwork.cache_reset_time", 0);
+ artwork_reset_time = deadbeef->conf_get_int64 ("artwork.cache_reset_time", 0);
strncpy (artwork_filemask, deadbeef->conf_get_str ("artwork.filemask", DEFAULT_FILEMASK), sizeof (artwork_filemask));
artwork_filemask[sizeof(artwork_filemask)-1] = 0;
diff --git a/plugins/cdda/cdda.c b/plugins/cdda/cdda.c
index 20d12dcf..e69adfa7 100644
--- a/plugins/cdda/cdda.c
+++ b/plugins/cdda/cdda.c
@@ -549,8 +549,7 @@ static int
cda_action_add_cd (DB_plugin_action_t *act, DB_playItem_t *it)
{
deadbeef->pl_add_file ("all.cda", NULL, NULL);
- //Wtf?
- //playlist_refresh ();
+ deadbeef->plug_trigger_event_playlistchanged ();
}
static DB_plugin_action_t add_cd_action = {
diff --git a/plugins/gtkui/coverart.c b/plugins/gtkui/coverart.c
index ffd2c2b2..0a8865a1 100644
--- a/plugins/gtkui/coverart.c
+++ b/plugins/gtkui/coverart.c
@@ -21,6 +21,7 @@
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
+#include <sys/stat.h>
#include "coverart.h"
#include "../artwork/artwork.h"
#include "gtkui.h"
@@ -36,6 +37,7 @@ extern DB_artwork_plugin_t *coverart_plugin;
typedef struct {
struct timeval tm;
char *fname;
+ time_t filetime;
int width;
GdkPixbuf *pixbuf;
} cached_pixbuf_t;
@@ -138,7 +140,10 @@ loading_thread (void *none) {
usleep (500000);
continue;
}
-
+ struct stat stat_buf;
+ if (stat (queue->fname, &stat_buf) < 0) {
+ trace ("failed to stat file %s\n", queue->fname);
+ }
// GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file (queue->fname, NULL);
GError *error = NULL;
GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file_at_scale (queue->fname, queue->width, queue->width, TRUE, &error);
@@ -150,6 +155,9 @@ loading_thread (void *none) {
error = NULL;
}
const char *defpath = coverart_plugin->get_default_cover ();
+ if (stat (defpath, &stat_buf) < 0) {
+ trace ("failed to stat file %s\n", queue->fname);
+ }
pixbuf = gdk_pixbuf_new_from_file_at_scale (defpath, queue->width, queue->width, TRUE, &error);
if (!pixbuf) {
fprintf (stderr, "gdk_pixbuf_new_from_file_at_scale %s %d failed, error: %s\n", defpath, queue->width, error->message);
@@ -162,43 +170,16 @@ loading_thread (void *none) {
if (!pixbuf) {
// make default empty image
pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, 2, 2);
+ stat_buf.st_mtime = 0;
}
-#if 0
- else {
- int w, h;
- w = gdk_pixbuf_get_width (pixbuf);
- h = gdk_pixbuf_get_height (pixbuf);
- int width = queue->width;
- if (w != width) {
- int height;
- if (w > h) {
- height = width * h / w;
- }
- else if (h > w) {
- height = width;
- width = height * w / h;
- }
- else {
- height = width;
- }
- if (width < 5 || height < 5) {
- trace ("will not scale to %dx%d\n", width, height);
- queue_pop ();
- continue;
- }
- trace ("scaling %dx%d -> %dx%d\n", w, h, width, height);
- GdkPixbuf *scaled = gdk_pixbuf_scale_simple (pixbuf, width, height, GDK_INTERP_BILINEAR);
- g_object_unref (pixbuf);
- pixbuf = scaled;
- }
- }
-#endif
if (cache_min != -1) {
deadbeef->mutex_lock (mutex);
+ cache[cache_min].filetime = stat_buf.st_mtime;
cache[cache_min].pixbuf = pixbuf;
cache[cache_min].fname = strdup (queue->fname);
gettimeofday (&cache[cache_min].tm, NULL);
cache[cache_min].width = queue->width;
+ struct stat stat_buf;
deadbeef->mutex_unlock (mutex);
}
queue_pop ();
@@ -230,11 +211,15 @@ get_pixbuf (const char *fname, int width) {
for (int i = 0; i < CACHE_SIZE; i++) {
if (cache[i].pixbuf) {
if (!strcmp (fname, cache[i].fname) && cache[i].width == width) {
- gettimeofday (&cache[i].tm, NULL);
- GdkPixbuf *pb = cache[i].pixbuf;
- g_object_ref (pb);
- deadbeef->mutex_unlock (mutex);
- return pb;
+ // check if cached filetime hasn't changed
+ struct stat stat_buf;
+ if (!stat (fname, &stat_buf) && stat_buf.st_mtime == cache[i].filetime) {
+ gettimeofday (&cache[i].tm, NULL);
+ GdkPixbuf *pb = cache[i].pixbuf;
+ g_object_ref (pb);
+ deadbeef->mutex_unlock (mutex);
+ return pb;
+ }
}
}
}
diff --git a/plugins/gtkui/ddbcellrenderertextmultiline.c b/plugins/gtkui/ddbcellrenderertextmultiline.c
index 867c70e4..335faf7c 100644
--- a/plugins/gtkui/ddbcellrenderertextmultiline.c
+++ b/plugins/gtkui/ddbcellrenderertextmultiline.c
@@ -1,4 +1,4 @@
-/* ddbcellrenderertextmultiline.c generated by valac 0.10.0, the Vala compiler
+/* ddbcellrenderertextmultiline.c generated by valac 0.10.1, the Vala compiler
* generated from ddbcellrenderertextmultiline.vala, do not modify */
/*
@@ -213,7 +213,7 @@ static void ddb_cell_renderer_text_multiline_gtk_cell_renderer_text_editing_done
buf = _g_object_ref0 (gtk_text_view_get_buffer ((GtkTextView*) entry));
gtk_text_buffer_get_iter_at_offset (buf, &begin, 0);
gtk_text_buffer_get_iter_at_offset (buf, &end, -1);
- new_text = g_strdup (gtk_text_buffer_get_text (buf, &begin, &end, TRUE));
+ new_text = gtk_text_buffer_get_text (buf, &begin, &end, TRUE);
g_signal_emit_by_name ((GtkCellRendererText*) _self_, "edited", entry->tree_path, new_text);
_g_free0 (new_text);
_g_object_unref0 (buf);
diff --git a/plugins/gtkui/ddbcellrenderertextmultiline.h b/plugins/gtkui/ddbcellrenderertextmultiline.h
index 787beb50..aec8fc09 100644
--- a/plugins/gtkui/ddbcellrenderertextmultiline.h
+++ b/plugins/gtkui/ddbcellrenderertextmultiline.h
@@ -1,4 +1,4 @@
-/* ddbcellrenderertextmultiline.h generated by valac 0.10.0, the Vala compiler, do not modify */
+/* ddbcellrenderertextmultiline.h generated by valac 0.10.1, the Vala compiler, do not modify */
#ifndef __DDBCELLRENDERERTEXTMULTILINE_H__
diff --git a/plugins/gtkui/ddbequalizer.c b/plugins/gtkui/ddbequalizer.c
index 201277ad..24c3a992 100644
--- a/plugins/gtkui/ddbequalizer.c
+++ b/plugins/gtkui/ddbequalizer.c
@@ -1,4 +1,4 @@
-/* ddbequalizer.c generated by valac 0.10.0, the Vala compiler
+/* ddbequalizer.c generated by valac 0.10.1, the Vala compiler
* generated from ddbequalizer.vala, do not modify */
/*
diff --git a/plugins/gtkui/ddbequalizer.h b/plugins/gtkui/ddbequalizer.h
index 19f98c23..8f957648 100644
--- a/plugins/gtkui/ddbequalizer.h
+++ b/plugins/gtkui/ddbequalizer.h
@@ -1,4 +1,4 @@
-/* ddbequalizer.h generated by valac 0.10.0, the Vala compiler, do not modify */
+/* ddbequalizer.h generated by valac 0.10.1, the Vala compiler, do not modify */
#ifndef __DDBEQUALIZER_H__
diff --git a/plugins/gtkui/ddbseekbar.c b/plugins/gtkui/ddbseekbar.c
index 407b347c..44aae86f 100644
--- a/plugins/gtkui/ddbseekbar.c
+++ b/plugins/gtkui/ddbseekbar.c
@@ -1,4 +1,4 @@
-/* ddbseekbar.c generated by valac 0.10.0, the Vala compiler
+/* ddbseekbar.c generated by valac 0.10.1, the Vala compiler
* generated from ddbseekbar.vala, do not modify */
/*
@@ -138,7 +138,7 @@ static gboolean ddb_seekbar_real_configure_event (GtkWidget* base, GdkEventConfi
DdbSeekbar* ddb_seekbar_construct (GType object_type) {
- DdbSeekbar * self;
+ DdbSeekbar * self = NULL;
self = (DdbSeekbar*) gtk_widget_new (object_type, NULL);
return self;
}
diff --git a/plugins/gtkui/ddbseekbar.h b/plugins/gtkui/ddbseekbar.h
index f501a00c..84cf6e88 100644
--- a/plugins/gtkui/ddbseekbar.h
+++ b/plugins/gtkui/ddbseekbar.h
@@ -1,4 +1,4 @@
-/* ddbseekbar.h generated by valac 0.10.0, the Vala compiler, do not modify */
+/* ddbseekbar.h generated by valac 0.10.1, the Vala compiler, do not modify */
#ifndef __DDBSEEKBAR_H__
diff --git a/plugins/notify/notify.c b/plugins/notify/notify.c
index 3e66b7cb..dd946062 100644
--- a/plugins/notify/notify.c
+++ b/plugins/notify/notify.c
@@ -30,8 +30,60 @@
DB_functions_t *deadbeef;
DB_misc_t plugin;
+static dbus_uint32_t replaces_id = 0;
+
#define NOTIFY_DEFAULT_FORMAT "%a - %t"
+static void
+notify_thread (void *ctx) {
+
+ DBusMessage *msg = (DBusMessage*) ctx;
+ DBusMessage *reply = NULL;
+
+ DBusError error;
+ dbus_error_init (&error);
+ DBusConnection *conn = dbus_bus_get (DBUS_BUS_SESSION, &error);
+ if(dbus_error_is_set (&error)) {
+ fprintf(stderr, "connection failed: %s",error.message);
+ dbus_error_free(&error);
+ dbus_message_unref (msg);
+ deadbeef->thread_exit(NULL);
+ }
+
+ reply = dbus_connection_send_with_reply_and_block (conn, msg, -1, &error);
+ if (dbus_error_is_set (&error)) {
+ fprintf(stderr, "send_with_reply_and_block error: (%s)\n", error.message);
+ dbus_error_free(&error);
+ dbus_message_unref (msg);
+ deadbeef->thread_exit(NULL);
+ }
+
+ if (reply != NULL) {
+ // Process the reply message
+ DBusMessageIter args;
+
+ dbus_uint32_t id = 0;
+ if (dbus_message_iter_init(reply, &args)) {
+ if (DBUS_TYPE_UINT32 == dbus_message_iter_get_arg_type(&args)) {
+ dbus_message_iter_get_basic(&args, &id);
+ if (id != replaces_id) {
+ replaces_id = id;
+ }
+ dbus_message_unref (reply);
+ } else {
+ fprintf(stderr, "Argument is not uint32\n");
+ }
+ } else {
+ fprintf(stderr, "Reply has no arguments\n");
+ }
+ }
+
+ dbus_message_unref (msg);
+ dbus_connection_unref (conn);
+ deadbeef->thread_exit(NULL);
+
+}
+
#if 0
static void
notify_marshal_dict_byte(DBusMessageIter *iter, const char *key, char value)
@@ -122,7 +174,7 @@ on_songchanged (DB_event_trackchange_t *ev, uintptr_t data) {
}
}
*dst = 0;
-
+/*
DBusError error;
dbus_error_init (&error);
DBusConnection *conn = dbus_bus_get (DBUS_BUS_SESSION, &error);
@@ -130,6 +182,7 @@ on_songchanged (DB_event_trackchange_t *ev, uintptr_t data) {
printf("connection failed: %s",error.message);
exit(1);
}
+*/
DBusMessage *msg = dbus_message_new_method_call (E_NOTIFICATION_BUS_NAME, E_NOTIFICATION_PATH, E_NOTIFICATION_INTERFACE, "Notify");
const char *v_appname = "DeaDBeeF";
@@ -141,7 +194,8 @@ on_songchanged (DB_event_trackchange_t *ev, uintptr_t data) {
dbus_message_append_args (msg
, DBUS_TYPE_STRING, &v_appname
- , DBUS_TYPE_UINT32, &v_id
+// , DBUS_TYPE_UINT32, &v_id
+ , DBUS_TYPE_UINT32, &replaces_id
, DBUS_TYPE_STRING, &v_iconname
, DBUS_TYPE_STRING, &v_summary
, DBUS_TYPE_STRING, &v_body
@@ -159,9 +213,16 @@ on_songchanged (DB_event_trackchange_t *ev, uintptr_t data) {
dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &v_timeout);
- int serial;
- dbus_bool_t retval = dbus_connection_send(conn,msg,&serial);
- dbus_connection_flush (conn);
+ //int serial;
+ //dbus_bool_t retval = dbus_connection_send(conn,msg,&serial);
+ //dbus_connection_flush (conn);
+ //dbus_message_unref (msg);
+
+ intptr_t tid = NULL;
+ if ((tid=deadbeef->thread_start(notify_thread, msg)) != 0) {
+ dbus_message_ref (msg);
+ deadbeef->thread_detach (tid);
+ }
dbus_message_unref (msg);
}
}