summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuli Suominen <ssuominen@gentoo.org>2009-05-11 22:08:53 +0000
committerSamuli Suominen <ssuominen@gentoo.org>2009-05-11 22:08:53 +0000
commit57214ba55ae6e538a5d29b6bc6e3e209b5045b27 (patch)
tree8f2e12d5336085c6b79792eb1193d72803bb211e /media-plugins/gkrellmpc
parentNew version for GNOME 2.26. Clean up old revisions. (diff)
downloadgentoo-2-57214ba55ae6e538a5d29b6bc6e3e209b5045b27.tar.gz
gentoo-2-57214ba55ae6e538a5d29b6bc6e3e209b5045b27.tar.bz2
gentoo-2-57214ba55ae6e538a5d29b6bc6e3e209b5045b27.zip
Use separate thread to init connection patch by dimonb wrt #264986.
(Portage version: 2.1.6.13/cvs/Linux x86_64)
Diffstat (limited to 'media-plugins/gkrellmpc')
-rw-r--r--media-plugins/gkrellmpc/ChangeLog11
-rw-r--r--media-plugins/gkrellmpc/files/gkrellmpc-0.1_beta9-mt.patch152
-rw-r--r--media-plugins/gkrellmpc/gkrellmpc-0.1_beta9-r1.ebuild26
-rw-r--r--media-plugins/gkrellmpc/gkrellmpc-0.1_beta9.ebuild18
4 files changed, 199 insertions, 8 deletions
diff --git a/media-plugins/gkrellmpc/ChangeLog b/media-plugins/gkrellmpc/ChangeLog
index 935a69db761f..e88c854f89ea 100644
--- a/media-plugins/gkrellmpc/ChangeLog
+++ b/media-plugins/gkrellmpc/ChangeLog
@@ -1,6 +1,13 @@
# ChangeLog for media-plugins/gkrellmpc
-# Copyright 1999-2008 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/media-plugins/gkrellmpc/ChangeLog,v 1.8 2008/05/30 06:59:59 phreak Exp $
+# Copyright 1999-2009 Gentoo Foundation; Distributed under the GPL v2
+# $Header: /var/cvsroot/gentoo-x86/media-plugins/gkrellmpc/ChangeLog,v 1.9 2009/05/11 22:08:53 ssuominen Exp $
+
+*gkrellmpc-0.1_beta9-r1 (11 May 2009)
+
+ 11 May 2009; Samuli Suominen <ssuominen@gentoo.org>
+ gkrellmpc-0.1_beta9.ebuild, +gkrellmpc-0.1_beta9-r1.ebuild,
+ +files/gkrellmpc-0.1_beta9-mt.patch:
+ Use separate thread to init connection patch by dimonb wrt #264986.
30 May 2008; Christian Heim <phreak@gentoo.org> metadata.xml:
Removing Andrej Kacian (Ticho) from metadata.xml (as per #59986).
diff --git a/media-plugins/gkrellmpc/files/gkrellmpc-0.1_beta9-mt.patch b/media-plugins/gkrellmpc/files/gkrellmpc-0.1_beta9-mt.patch
new file mode 100644
index 000000000000..4de5688a2b5e
--- /dev/null
+++ b/media-plugins/gkrellmpc/files/gkrellmpc-0.1_beta9-mt.patch
@@ -0,0 +1,152 @@
+diff -uNr gkrellmpc-0.1_beta9/gkrellmpc.c gkrellmpc-0.1_beta9.mine/gkrellmpc.c
+--- gkrellmpc-0.1_beta9/gkrellmpc.c 2005-01-05 22:33:16.000000000 +0300
++++ gkrellmpc-0.1_beta9.mine/gkrellmpc.c 2009-04-05 19:51:12.000000000 +0400
+@@ -132,7 +132,7 @@
+ /* Create the status decal */
+ mpc_status_decal = gkrellm_create_decal_pixmap(mpc_panel, gkrellm_decal_misc_pixmap(), gkrellm_decal_misc_mask(), N_MISC_DECALS, style, 0, t);
+ mpc_status_decal->x = w - mpc_status_decal->w;
+- gkrellm_draw_decal_pixmap(mpc_panel, mpc_status_decal, (mpc_mpd ? D_MISC_LED1 : D_MISC_LED0));
++ gkrellm_draw_decal_pixmap(mpc_panel, mpc_status_decal, (mpc_mpd_connected() ? D_MISC_LED1 : D_MISC_LED0));
+
+ /* Update t */
+ t += mpc_label_decal->h > mpc_status_decal->h ? mpc_label_decal->h : mpc_status_decal->h;
+@@ -254,7 +254,7 @@
+ static gint x_scroll;
+
+ /* Try to connect to mpd */
+- if (!mpc_mpd && mpc_ticker->ten_second_tick) {
++ if (!mpc_mpd_connected() && mpc_ticker->ten_second_tick) {
+ mpc_mpd_connect();
+ }
+
+@@ -428,7 +428,7 @@
+ status = mpc_mpd_get("status\n");
+ currentsong = mpc_mpd_get("currentsong\n");
+
+- if (!mpc_mpd) {
++ if (!mpc_mpd_connected()) {
+ mpc_update_label("NO MPD");
+ mpc_update_songname("");
+ }
+diff -uNr gkrellmpc-0.1_beta9/mpd.c gkrellmpc-0.1_beta9.mine/mpd.c
+--- gkrellmpc-0.1_beta9/mpd.c 2005-01-05 22:33:16.000000000 +0300
++++ gkrellmpc-0.1_beta9.mine/mpd.c 2009-04-05 20:30:38.000000000 +0400
+@@ -12,18 +12,32 @@
+ #include <sys/socket.h>
+ #include <netdb.h>
+
++#include <errno.h>
++#include <pthread.h>
++
+ GIOChannel * mpc_mpd = NULL;
++pthread_mutex_t mpc_mutex = { { 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP, 0, { 0 } } }; //PTHREAD_MUTEX_INITIALIZER;
++
++gboolean mpc_mpd_connected() {
++ if(pthread_mutex_trylock(&mpc_mutex)){
++ return (FALSE);
++ }
++ pthread_mutex_unlock(&mpc_mutex);
++ return (gboolean)mpc_mpd;
++}
+
+ /*
+ * Connects to the MPD server, sets up the mpd object, sets the status decal to ON
+ */
+-gboolean mpc_mpd_connect() {
++void* mpc_mpd_connect_worker(void* arg) {
+ int sockfd;
+ struct hostent *server;
+ struct sockaddr_in serv_addr;
+ gchar * line;
+ gchar ** parts;
+ gboolean retval;
++
++ pthread_mutex_lock(&mpc_mutex);
+
+ if (mpc_mpd) {
+ /*
+@@ -33,11 +47,11 @@
+ }
+
+ if (!mpc_conf_hostname || !mpc_conf_port) {
+- return (FALSE);
++ goto err;
+ }
+
+- if ((sockfd = socket(PF_INET, SOCK_STREAM, 0)) == -1) return(FALSE);
+- if (!(server = gethostbyname(mpc_conf_hostname))) return(FALSE);
++ if ((sockfd = socket(PF_INET, SOCK_STREAM, 0)) == -1) goto err;
++ if (!(server = gethostbyname(mpc_conf_hostname))) goto err;
+
+ bzero((char *) &serv_addr, sizeof(serv_addr));
+ serv_addr.sin_family = AF_INET;
+@@ -46,7 +60,7 @@
+ server->h_length);
+ serv_addr.sin_port = htons(mpc_conf_port);
+
+- if (connect(sockfd, (struct sockaddr*)&serv_addr, sizeof(serv_addr)) < 0) return(FALSE);
++ if (connect(sockfd, (struct sockaddr*)&serv_addr, sizeof(serv_addr)) < 0) goto err;
+
+ /* Getup the mpd object */
+ mpc_mpd = g_io_channel_unix_new(sockfd);
+@@ -72,29 +86,40 @@
+ retval = FALSE;
+ }
+
+- if (retval) {
+- gkrellm_draw_decal_pixmap(mpc_panel, mpc_status_decal, D_MISC_LED1);
+- mpc_update_label("MPD");
+- mpc_update_songname("");
+- }
+
+- return(retval);
++err:
++ pthread_mutex_unlock(&mpc_mutex);
++ return NULL;
++}
++
++gboolean mpc_mpd_connect() {
++ pthread_attr_t attr;
++ pthread_t thread_id;
++
++ if(pthread_mutex_trylock(&mpc_mutex)){
++ return (FALSE);
++ }
++
++ pthread_attr_init(&attr);
++ pthread_create(&thread_id, &attr, mpc_mpd_connect_worker, NULL);
++
++ pthread_mutex_unlock(&mpc_mutex);
++
++ return (FALSE);
+ }
+
+ /*
+ * Disconnects from MPD, destroys the mpd object, sets the status decal to off
+ */
+ gboolean mpc_mpd_disconnect() {
+-
++ pthread_mutex_lock(&mpc_mutex);
+ if (mpc_mpd) {
+ g_io_channel_shutdown(mpc_mpd, FALSE, NULL);
+ free(mpc_mpd);
+ mpc_mpd = NULL;
+ }
+
+- gkrellm_draw_decal_pixmap(mpc_panel, mpc_status_decal, D_MISC_LED0);
+- mpc_update_label("NO MPD");
+- mpc_update_songname("");
++ pthread_mutex_unlock(&mpc_mutex);
+ return (TRUE);
+ }
+
+diff -uNr gkrellmpc-0.1_beta9/mpd.h gkrellmpc-0.1_beta9.mine/mpd.h
+--- gkrellmpc-0.1_beta9/mpd.h 2005-01-05 22:33:16.000000000 +0300
++++ gkrellmpc-0.1_beta9.mine/mpd.h 2009-04-05 19:51:25.000000000 +0400
+@@ -10,5 +10,6 @@
+ gboolean mpc_mpd_do(gchar *);
+ GHashTable * mpc_mpd_get(gchar *);
+ GPtrArray * mpc_mpd_get_clumps(gchar *, gboolean);
++gboolean mpc_mpd_connected();
+
+ #endif
diff --git a/media-plugins/gkrellmpc/gkrellmpc-0.1_beta9-r1.ebuild b/media-plugins/gkrellmpc/gkrellmpc-0.1_beta9-r1.ebuild
new file mode 100644
index 000000000000..28889261792c
--- /dev/null
+++ b/media-plugins/gkrellmpc/gkrellmpc-0.1_beta9-r1.ebuild
@@ -0,0 +1,26 @@
+# Copyright 1999-2009 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/media-plugins/gkrellmpc/gkrellmpc-0.1_beta9-r1.ebuild,v 1.1 2009/05/11 22:08:53 ssuominen Exp $
+
+EAPI=2
+inherit eutils gkrellm-plugin toolchain-funcs
+
+DESCRIPTION="A gkrellm plugin to control the MPD (Music Player Daemon)"
+HOMEPAGE="http://mpd.wikicities.com/wiki/Client:GKrellMPC"
+SRC_URI="http://www.topfx.com/dist/${P}.tar.gz"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="~amd64 ~x86"
+IUSE=""
+
+RDEPEND="net-misc/curl"
+
+src_prepare() {
+ epatch "${FILESDIR}"/${P}-mt.patch
+}
+
+src_compile() {
+ tc-export CC
+ emake || die "emake failed"
+}
diff --git a/media-plugins/gkrellmpc/gkrellmpc-0.1_beta9.ebuild b/media-plugins/gkrellmpc/gkrellmpc-0.1_beta9.ebuild
index b46740acba7d..ee97006c886c 100644
--- a/media-plugins/gkrellmpc/gkrellmpc-0.1_beta9.ebuild
+++ b/media-plugins/gkrellmpc/gkrellmpc-0.1_beta9.ebuild
@@ -1,16 +1,22 @@
-# Copyright 1999-2007 Gentoo Foundation
+# Copyright 1999-2009 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/media-plugins/gkrellmpc/gkrellmpc-0.1_beta9.ebuild,v 1.7 2007/07/10 23:08:59 mr_bones_ Exp $
+# $Header: /var/cvsroot/gentoo-x86/media-plugins/gkrellmpc/gkrellmpc-0.1_beta9.ebuild,v 1.8 2009/05/11 22:08:53 ssuominen Exp $
-inherit gkrellm-plugin
+EAPI=2
+inherit gkrellm-plugin toolchain-funcs
DESCRIPTION="A gkrellm plugin to control the MPD (Music Player Daemon)"
HOMEPAGE="http://mpd.wikicities.com/wiki/Client:GKrellMPC"
SRC_URI="http://www.topfx.com/dist/${P}.tar.gz"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="~amd64 x86"
IUSE=""
RDEPEND="net-misc/curl"
-SLOT="0"
-LICENSE="GPL-2"
-KEYWORDS="x86 ~amd64"
+src_compile() {
+ tc-export CC
+ emake || die "emake failed"
+}