X-Git-Url: https://vcs.maemo.org/git/?a=blobdiff_plain;f=src%2Faudacious.c;h=49342e8afb79edbca257d13b8c47550083fa1bf4;hb=174c256c81a027a2ea406f5f37dc036fac0a524b;hp=866d3c1540ad780261eab8e1413cf0f1dce337b3;hpb=40f2fcfd7b47f2454ac368a0e1a92e0ea946ad04;p=monky diff --git a/src/audacious.c b/src/audacious.c index 866d3c1..49342e8 100644 --- a/src/audacious.c +++ b/src/audacious.c @@ -1,6 +1,7 @@ -/* $Id$ */ - -/* audacious.c: conky support for audacious music player +/* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*- + * vim: ts=4 sw=4 noet ai cindent syntax=c + * + * audacious.c: conky support for audacious music player * * Copyright (C) 2005-2007 Philip Kovacs pkovacs@users.sourceforge.net * @@ -17,11 +18,14 @@ * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 - * USA. */ + * USA. + * + */ -#ifdef HAVE_CONFIG_H -#include -#endif +#include "config.h" +#include "conky.h" +#include "logging.h" +#include "audacious.h" #include #ifndef AUDACIOUS_LEGACY @@ -52,16 +56,13 @@ xmms_remote_get_playlist_length(x) #endif -#include "conky.h" -#include "audacious.h" - /* access to this item array is synchronized */ static audacious_t audacious_items; /* ----------------------------------------- * Conky update function for audacious data. * ----------------------------------------- */ -void update_audacious(void) +int update_audacious(void) { /* The worker thread is updating audacious_items array asynchronously * to the main conky thread. @@ -69,7 +70,7 @@ void update_audacious(void) * structure when the main thread's update cycle fires. */ if (!info.audacious.p_timed_thread) { if (create_audacious_thread() != 0) { - CRIT_ERR("unable to create audacious thread!"); + CRIT_ERR(NULL, NULL, "unable to create audacious thread!"); } timed_thread_register(info.audacious.p_timed_thread, &info.audacious.p_timed_thread); @@ -78,6 +79,7 @@ void update_audacious(void) timed_thread_lock(info.audacious.p_timed_thread); memcpy(&info.audacious.items, audacious_items, sizeof(audacious_items)); timed_thread_unlock(info.audacious.p_timed_thread); + return 0; } /* --------------------------------------------------------- @@ -109,13 +111,11 @@ int create_audacious_thread(void) int destroy_audacious_thread(void) { /* Is a worker is thread running? If not, no error. */ - if (!info.audacious.p_timed_thread) { - return 0; + if (info.audacious.p_timed_thread) { + timed_thread_destroy(info.audacious.p_timed_thread, + &info.audacious.p_timed_thread); } - timed_thread_destroy(info.audacious.p_timed_thread, - &info.audacious.p_timed_thread); - return 0; } @@ -127,7 +127,7 @@ void *audacious_thread_func(void *pvoid) { static audacious_t items; gint playpos, frames, length; - gint rate, freq, chans; + gint rate, freq, chans, vol; gchar *psong, *pfilename; #ifndef AUDACIOUS_LEGACY @@ -146,12 +146,12 @@ void *audacious_thread_func(void *pvoid) g_type_init(); connection = dbus_g_bus_get(DBUS_BUS_SESSION, NULL); if (!connection) { - CRIT_ERR("unable to establish dbus connection"); + CRIT_ERR(NULL, NULL, "unable to establish dbus connection"); } session = dbus_g_proxy_new_for_name(connection, AUDACIOUS_DBUS_SERVICE, AUDACIOUS_DBUS_PATH, AUDACIOUS_DBUS_INTERFACE); if (!session) { - CRIT_ERR("unable to create dbus proxy"); + CRIT_ERR(NULL, NULL, "unable to create dbus proxy"); } #endif /* AUDACIOUS_LEGACY */ @@ -235,13 +235,18 @@ void *audacious_thread_func(void *pvoid) /* Playlist position (index of song) */ snprintf(items[AUDACIOUS_PLAYLIST_POSITION], sizeof(items[AUDACIOUS_PLAYLIST_POSITION]) - 1, "%d", playpos + 1); + /* Main volume */ + vol = audacious_remote_get_main_volume(session); + snprintf(items[AUDACIOUS_MAIN_VOLUME], + sizeof(items[AUDACIOUS_MAIN_VOLUME]) - 1, "%d", vol); + } while (0); /* Deliver the refreshed items array to audacious_items. */ timed_thread_lock(info.audacious.p_timed_thread); memcpy(&audacious_items, items, sizeof(items)); timed_thread_unlock(info.audacious.p_timed_thread); - if (timed_thread_test(info.audacious.p_timed_thread)) { + if (timed_thread_test(info.audacious.p_timed_thread, 0)) { #ifndef AUDACIOUS_LEGACY /* release reference to dbus proxy */ g_object_unref(session);