changeset 1456:6fe7ba6e5489 trunk

[svn] - Don't poll the config database if not using TCP sockets.
author nhjm449
date Mon, 31 Jul 2006 17:06:44 -0700
parents 04730ff1693d
children bbd5869239e5
files ChangeLog audacious/controlsocket.c libaudacious/beepctrl.c libaudacious/beepctrl.h
diffstat 4 files changed, 41 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sat Jul 29 16:23:16 2006 -0700
+++ b/ChangeLog	Mon Jul 31 17:06:44 2006 -0700
@@ -1,3 +1,13 @@
+2006-07-29 23:23:16 +0000  Yoshiki Yazawa <yaz@cc.rim.or.jp>
+  revision [1824]
+  changes link order to avoid linkage with installed library.
+  
+
+  Changes:        Modified:
+  +3 -3           trunk/audacious/Makefile  
+  +3 -3           trunk/audtool/Makefile  
+
+
 2006-07-28 21:13:59 +0000  William Pitcock <nenolod@nenolod.net>
   revision [1822]
   - fix the other bug exposed by strace
--- a/audacious/controlsocket.c	Sat Jul 29 16:23:16 2006 -0700
+++ b/audacious/controlsocket.c	Mon Jul 31 17:06:44 2006 -0700
@@ -98,6 +98,8 @@
     gint i;
     gint fd;
 
+    audacious_set_session_type((gint *) AUDACIOUS_TYPE_UNIX);
+
     if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) {
         g_critical("ctrlsocket_setup(): Failed to open socket: %s",
                    strerror(errno));
@@ -154,6 +156,8 @@
     gint i;
     gint fd;
 
+    audacious_set_session_type((gint *) AUDACIOUS_TYPE_TCP);
+
     if ((fd = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
         g_critical("ctrlsocket_setup(): Failed to open socket: %s",
                    strerror(errno));
--- a/libaudacious/beepctrl.c	Sat Jul 29 16:23:16 2006 -0700
+++ b/libaudacious/beepctrl.c	Mon Jul 31 17:06:44 2006 -0700
@@ -39,6 +39,7 @@
 
 /* overrides audacious_get_session_uri(). */
 gchar *audacious_session_uri = NULL;
+gint *audacious_session_type = NULL;
 
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
@@ -314,11 +315,14 @@
 	return audacious_session_uri;
     }
 
-    db = bmp_cfg_db_open();
+    if (audacious_session_type != AUDACIOUS_TYPE_UNIX)
+    {
+        db = bmp_cfg_db_open();
 
-    bmp_cfg_db_get_string(db, NULL, "listen_uri_base", &value);
+        bmp_cfg_db_get_string(db, NULL, "listen_uri_base", &value);
 
-    bmp_cfg_db_close(db);
+        bmp_cfg_db_close(db);
+    }
 
     if (value == NULL)
         return g_strdup_printf("unix://localhost/%s/%s_%s.%d", g_get_tmp_dir(),
@@ -329,19 +333,33 @@
     return value;
 }
 
-gint
+void
+audacious_set_session_type(gint *type)
+{
+   audacious_session_type = type;
+}
+
+gint *
 audacious_determine_session_type(gint session)
 {
     gchar *uri;
 
+    if (audacious_session_type != NULL)
+    {
+        return audacious_session_type;
+    }
+
     uri = audacious_get_session_uri(session);
 
     if (!g_strncasecmp(uri, "tcp://", 6))
-        return AUDACIOUS_TYPE_TCP;
+        audacious_session_type = (gint *) AUDACIOUS_TYPE_TCP;
     else
-        return AUDACIOUS_TYPE_UNIX;
+        audacious_session_type = (gint *) AUDACIOUS_TYPE_UNIX;
 
-    return AUDACIOUS_TYPE_UNIX;
+    if (audacious_session_type == NULL)
+        audacious_session_type = (gint *) AUDACIOUS_TYPE_UNIX;
+
+    return audacious_session_type;
 }
 
 /* tcp://192.168.100.1:5900/zyzychynxi389xvmfewqaxznvnw */
@@ -400,7 +418,7 @@
 xmms_connect_to_session(gint session)
 {
     gint fd;
-    gint type = audacious_determine_session_type(session);
+    gint *type = audacious_determine_session_type(session);
     gchar *uri = audacious_get_session_uri(session);
 
     if (type == AUDACIOUS_TYPE_UNIX)
--- a/libaudacious/beepctrl.h	Sat Jul 29 16:23:16 2006 -0700
+++ b/libaudacious/beepctrl.h	Mon Jul 31 17:06:44 2006 -0700
@@ -117,6 +117,7 @@
 /* Added in Audacious 1.2 */
     void audacious_set_session_uri(gchar *uri);
     gchar *audacious_get_session_uri(gint session);
+    void audacious_set_session_type(gint *type);
 
 #ifdef __cplusplus
 };