diff options
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | deadbeef.h | 2 | ||||
-rw-r--r-- | main.c | 6 | ||||
-rw-r--r-- | plugins.c | 2 | ||||
-rw-r--r-- | plugins/mpris/mpris.c | 20 | ||||
-rw-r--r-- | plugins/notify/notify.c | 71 | ||||
-rw-r--r-- | scripts/pluginstall.sh | 37 | ||||
-rw-r--r-- | threading.h | 6 | ||||
-rw-r--r-- | threading_pthread.c | 15 |
10 files changed, 110 insertions, 53 deletions
diff --git a/Makefile.am b/Makefile.am index eb1eb738..fb4a7b5f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -36,7 +36,7 @@ deadbeef_SOURCES =\ sdkdir = $(pkgincludedir) sdk_HEADERS = deadbeef.h -deadbeef_LDADD = $(LDADD) $(DEPS_LIBS) $(ICONV_LIB) -lm +deadbeef_LDADD = $(LDADD) $(DEPS_LIBS) $(ICONV_LIB) -lm -ldl -lpthread AM_CFLAGS = $(DEPS_CFLAGS) -std=c99 AM_CPPFLAGS = $(DEPS_CFLAGS) diff --git a/configure.ac b/configure.ac index 2a364423..8bd8d57d 100644 --- a/configure.ac +++ b/configure.ac @@ -481,7 +481,7 @@ fi fi if test "x$enable_mpris" != "xno" ; then - PKG_CHECK_MODULES(MPRIS_DEPS, gio-2.0 glib-2.0 >= 2.26.0, HAVE_MPRIS=yes, HAVE_MPRIS=no) + PKG_CHECK_MODULES(MPRIS_DEPS, indicate >= 0.4.4 glib-2.0 >= 2.26.0, HAVE_MPRIS=yes, HAVE_MPRIS=no) fi PLUGINS_DIRS="plugins/lastfm plugins/mpgmad plugins/vorbis plugins/flac plugins/wavpack plugins/sndfile plugins/vfs_curl plugins/cdda plugins/gtkui plugins/alsa plugins/ffmpeg plugins/hotkeys plugins/oss plugins/artwork plugins/adplug plugins/ffap plugins/sid plugins/nullout plugins/supereq plugins/vtx plugins/gme plugins/dumb plugins/pulse plugins/notify plugins/musepack plugins/wildmidi plugins/tta plugins/dca plugins/aac plugins/mms plugins/shn plugins/ao plugins/shellexec plugins/mpris" @@ -332,6 +332,8 @@ typedef struct { intptr_t (*thread_start) (void (*fn)(void *ctx), void *ctx); intptr_t (*thread_start_low_priority) (void (*fn)(void *ctx), void *ctx); int (*thread_join) (intptr_t tid); + int (*thread_detach) (intptr_t tid); + void (*thread_exit) (void *retval); uintptr_t (*mutex_create) (void); uintptr_t (*mutex_create_nonrecursive) (void); void (*mutex_free) (uintptr_t mtx); @@ -534,7 +534,11 @@ main (int argc, char *argv[]) { bind_textdomain_codeset (PACKAGE, "UTF-8"); textdomain (PACKAGE); #endif - fprintf (stderr, "starting deadbeef " VERSION "%s\n", PORTABLE ? " [portable build]" : ""); + int portable = 0; +#if PORTABLE + portable = 1; +#endif + fprintf (stderr, "starting deadbeef " VERSION "%s\n", portable ? " [portable build]" : ""); srand (time (NULL)); #ifdef __linux__ prctl (PR_SET_NAME, "deadbeef-main", 0, 0, 0, 0); @@ -100,6 +100,8 @@ static DB_functions_t deadbeef_api = { .thread_start = thread_start, .thread_start_low_priority = thread_start_low_priority, .thread_join = thread_join, + .thread_detach = thread_detach, + .thread_exit = thread_exit, .mutex_create = mutex_create, .mutex_create_nonrecursive = mutex_create_nonrecursive, .mutex_free = mutex_free, diff --git a/plugins/mpris/mpris.c b/plugins/mpris/mpris.c index 040de84c..37b6e4c9 100644 --- a/plugins/mpris/mpris.c +++ b/plugins/mpris/mpris.c @@ -19,7 +19,7 @@ #include <time.h> #include <gio/gio.h> -//#include <libindicate/server.h> +#include <libindicate/server.h> #include <deadbeef/deadbeef.h> #include "../artwork/artwork.h" @@ -36,7 +36,7 @@ DB_functions_t *deadbeef; static short enabled = 0; DB_artwork_plugin_t *coverart_plugin = NULL; -//static IndicateServer *indicate_server; +static IndicateServer *indicate_server; static GDBusConnection *connection; static guint name_own_id; static guint root_id; @@ -1087,10 +1087,10 @@ name_lost_cb (GDBusConnection *connection, const char *name, gpointer *user_data static gboolean mpris_begin () { -// indicate_server = indicate_server_ref_default (); -// indicate_server_set_type (indicate_server, "music.deadbeef"); -// indicate_server_set_desktop_file (indicate_server, DESKTOP_FILE); -// indicate_server_show (indicate_server); + indicate_server = indicate_server_ref_default (); + indicate_server_set_type (indicate_server, "music.deadbeef"); + indicate_server_set_desktop_file (indicate_server, DESKTOP_FILE); + indicate_server_show (indicate_server); GError *error = NULL; GDBusInterfaceInfo *ifaceinfo; @@ -1201,7 +1201,7 @@ mpris_end () name_own_id = 0; } -// indicate_server_hide (indicate_server); + indicate_server_hide (indicate_server); deadbeef->mutex_lock(emit_id_mtx); if (player_property_emit_id != 0) { @@ -1291,9 +1291,9 @@ static DB_dsp_t plugin = { .plugin.api_vmajor = DB_API_VERSION_MAJOR, .plugin.api_vminor = DB_API_VERSION_MINOR, .plugin.type = DB_PLUGIN_MISC, - .plugin.id = "mpris", - .plugin.name = "MPRIS", - .plugin.descr = "MPRIS", + .plugin.id = "Sound Menu", + .plugin.name = "Sound Menu", + .plugin.descr = "Ubuntu Sound Menu plugin", .plugin.author = "Robert Y", .plugin.email = "Decatf@gmail.com", .plugin.website = "http://deadbeef.sf.net", 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); } } diff --git a/scripts/pluginstall.sh b/scripts/pluginstall.sh index cb296fac..6b1e432b 100644 --- a/scripts/pluginstall.sh +++ b/scripts/pluginstall.sh @@ -1,36 +1,3 @@ -./scripts/portable_postbuild.sh +#./scripts/portable_postbuild.sh +./scripts/quickinstall.sh -#sudo cp ./deadbeef /usr/local/bin/ -#sudo cp ./plugins/nullout/.libs/nullout.so /usr/local/lib/deadbeef/ -#sudo cp ./plugins/cdda/.libs/cdda.so /usr/local/lib/deadbeef/ -#sudo cp ./plugins/flac/.libs/flac.so /usr/local/lib/deadbeef/ -#sudo cp ./plugins/alsa/.libs/alsa.so /usr/local/lib/deadbeef/ -#sudo cp ./plugins/mpgmad/.libs/mpgmad.so /usr/local/lib/deadbeef/ -#sudo cp ./plugins/hotkeys/.libs/hotkeys.so /usr/local/lib/deadbeef/ -#sudo cp ./plugins/vtx/.libs/vtx.so /usr/local/lib/deadbeef/ -#sudo cp ./plugins/ffap/.libs/ffap.so /usr/local/lib/deadbeef/ -#sudo cp ./plugins/wavpack/.libs/wavpack.so /usr/local/lib/deadbeef/ -#sudo cp ./plugins/vorbis/.libs/vorbis.so /usr/local/lib/deadbeef/ -#sudo cp ./plugins/oss/.libs/oss.so /usr/local/lib/deadbeef/ -#sudo cp ./plugins/vfs_curl/.libs/vfs_curl.so /usr/local/lib/deadbeef/ -#sudo cp ./plugins/ffmpeg/.libs/ffmpeg.so /usr/local/lib/deadbeef/ -#sudo cp ./plugins/lastfm/.libs/lastfm.so /usr/local/lib/deadbeef/ -#sudo cp ./plugins/sid/.libs/sid.so /usr/local/lib/deadbeef/ -#sudo cp ./plugins/adplug/.libs/adplug.so /usr/local/lib/deadbeef/ -#sudo cp ./plugins/gtkui/.libs/gtkui.so /usr/local/lib/deadbeef/ -#sudo cp ./plugins/sndfile/.libs/sndfile.so /usr/local/lib/deadbeef/ -#sudo cp ./plugins/pulse/.libs/pulse.so /usr/local/lib/deadbeef/ -#sudo cp ./plugins/artwork/.libs/artwork.so /usr/local/lib/deadbeef/ -#sudo cp ./plugins/supereq/.libs/supereq.so /usr/local/lib/deadbeef/ -#sudo cp ./plugins/gme/.libs/gme.so /usr/local/lib/deadbeef/ -#sudo cp ./plugins/dumb/.libs/dumb.so /usr/local/lib/deadbeef/ -#sudo cp ./plugins/notify/.libs/notify.so /usr/local/lib/deadbeef/ -#sudo cp ./plugins/musepack/.libs/musepack.so /usr/local/lib/deadbeef/ -#sudo cp ./plugins/wildmidi/.libs/wildmidi.so /usr/local/lib/deadbeef/ -#sudo cp ./plugins/tta/.libs/tta.so /usr/local/lib/deadbeef/ -#sudo cp ./plugins/dca/.libs/dca.so /usr/local/lib/deadbeef/ -#sudo cp ./plugins/aac/.libs/aac.so /usr/local/lib/deadbeef/ -#sudo cp ./plugins/mms/.libs/mms.so /usr/local/lib/deadbeef/ -#sudo cp ./plugins/shn/.libs/shn.so /usr/local/lib/deadbeef/ -#sudo cp ./plugins/ao/.libs/ao.so /usr/local/lib/deadbeef/ -#sudo cp ./plugins/shellexec/.libs/shellexec.so /usr/local/lib/deadbeef/ diff --git a/threading.h b/threading.h index dee1cc3c..6ceca641 100644 --- a/threading.h +++ b/threading.h @@ -29,6 +29,12 @@ thread_start_low_priority (void (*fn)(void *ctx), void *ctx); int thread_join (intptr_t tid); +int +thread_detach (intptr_t tid); + +void +thread_exit (void *retval); + uintptr_t mutex_create (void); diff --git a/threading_pthread.c b/threading_pthread.c index 9b6cc277..0705128c 100644 --- a/threading_pthread.c +++ b/threading_pthread.c @@ -104,6 +104,21 @@ thread_join (intptr_t tid) { return 0; } +int +thread_detach (intptr_t tid) { + int s = pthread_detach ((pthread_t)tid); + if (s) { + fprintf (stderr, "pthread_detach failed: %s\n", strerror (s)); + return -1; + } + return 0; +} + +void +thread_exit (void *retval) { + pthread_exit (retval); +} + uintptr_t mutex_create_nonrecursive (void) { pthread_mutex_t *mtx = malloc (sizeof (pthread_mutex_t)); |