some small fixes for mpd stuff
authorBrenden Matthews <brenden1@rty.ca>
Fri, 31 Aug 2007 02:05:02 +0000 (02:05 +0000)
committerBrenden Matthews <brenden1@rty.ca>
Fri, 31 Aug 2007 02:05:02 +0000 (02:05 +0000)
git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky1@935 7f574dfc-610e-0410-a909-a81674777703

configure.ac.in
src/common.c
src/conky.c
src/conky.h
src/mpd.c

index 8024698..e00a60b 100644 (file)
@@ -4,7 +4,7 @@ dnl major, minor and micro version macros.
 m4_define([conky_version_major], [1])
 m4_define([conky_version_minor], [4])
 m4_define([conky_version_micro], [7])
-m4_define([conky_version_tag], [svn]) dnl [] for releases
+m4_define([conky_version_tag], []) dnl [] for releases
 m4_define([conky_version_revision],[r@REVISION@])
 m4_define([conky_version], 
     [conky_version_major().conky_version_minor().conky_version_micro()ifelse(
index bed9901..c2c9522 100644 (file)
@@ -233,7 +233,12 @@ void update_stuff()
 #ifdef MPD
        if (NEED(INFO_MPD)) {
                if (!mpd_timed_thread) {
+                       clear_mpd_stats(&info); 
                        mpd_timed_thread = timed_thread_create((void*)update_mpd, (void*) NULL, update_interval * 1000000);
+                       if (!mpd_timed_thread) {
+                               ERR("Failed to create MPD thread");
+                       }
+                       timed_thread_register(mpd_timed_thread, &mpd_timed_thread);
                }
        }
 #endif
index a79720d..959e7fd 100644 (file)
@@ -3140,13 +3140,15 @@ static struct text_object *construct_text_object(const char *s, const char *arg,
                OBJ(mpd_artist, INFO_MPD) END
                OBJ(mpd_title, INFO_MPD)
                {
-                       if (arg)
-                       {
-                           sscanf (arg, "%d", &info.mpd.max_title_len);
-                           if (info.mpd.max_title_len > 0)
-                               info.mpd.max_title_len++;
-                           else
-                               CRIT_ERR ("mpd_title: invalid length argument");
+                       if (arg) {
+                               sscanf (arg, "%d", &info.mpd.max_title_len);
+                               if (info.mpd.max_title_len > 0) {
+                                       info.mpd.max_title_len++;
+                               } else {
+                                       CRIT_ERR ("mpd_title: invalid length argument");
+                               }
+                       } else {
+                               info.mpd.max_title_len = 0;
                        }
                }
                END OBJ(mpd_random, INFO_MPD)
@@ -3192,13 +3194,15 @@ static struct text_object *construct_text_object(const char *s, const char *arg,
                OBJ(audacious_status, INFO_AUDACIOUS) END
                OBJ(audacious_title, INFO_AUDACIOUS) 
                {
-                       if (arg)
-                       {
-                           sscanf (arg, "%d", &info.audacious.max_title_len);
-                           if (info.audacious.max_title_len > 0)
+                       if (arg) {
+                               sscanf (arg, "%d", &info.audacious.max_title_len);
+                               if (info.audacious.max_title_len > 0) {
+                                       info.audacious.max_title_len++;
+                               }                   else {
+                                       CRIT_ERR ("audacious_title: invalid length argument");
+                               }
+                       } else {
                                info.audacious.max_title_len++;
-                           else
-                               CRIT_ERR ("audacious_title: invalid length argument");
                        }
                }
                END
@@ -4967,7 +4971,7 @@ static void generate_text_internal(char *p, int p_max_size, struct text_object *
                                               255.0f));
                        }
                        OBJ(mpd_smart) {
-                               if (strlen(cur->mpd.title) < 2 && strlen(cur->mpd.title) < 2) {
+                               if (strlen(cur->mpd.title) < 2 && strlen(cur->mpd.artist) < 2) {
                                        snprintf(p, p_max_size, "%s", cur->mpd.file);
                                } else {
                                        snprintf(p, p_max_size, "%s - %s", cur->mpd.artist, cur->mpd.title);
@@ -7428,7 +7432,7 @@ int main(int argc, char **argv)
        struct sigaction act, oact;
 
        g_signal_pending=0;
-       memset(&info, 0, sizeof(info) );
+       memset(&info, 0, sizeof(info));
 
 #ifdef TCP_PORT_MONITOR
        tcp_port_monitor_args.max_port_monitor_connections = MAX_PORT_MONITOR_CONNECTIONS_DEFAULT;
index 0d893b7..ce8722c 100644 (file)
@@ -619,6 +619,7 @@ char *get_apm_battery_time(void);
 
 /* in mpd.c */
 #ifdef MPD
+extern void clear_mpd_stats(struct information *current_info);
 void *update_mpd(void);
 extern timed_thread *mpd_timed_thread;
 #endif /* MPD */
index 60bec0a..a1cd39c 100644 (file)
--- a/src/mpd.c
+++ b/src/mpd.c
@@ -33,7 +33,7 @@
 
 timed_thread *mpd_timed_thread = NULL;
 
-static void clear_mpd_stats(struct information *current_info)
+void clear_mpd_stats(struct information *current_info)
 {
        if (current_info->mpd.artist == NULL)
                current_info->mpd.artist = malloc(TEXT_BUFFER_SIZE);
@@ -90,8 +90,7 @@ void *update_mpd(void)
                        current_info->conn = 0;
 
                        strncpy(current_info->mpd.status, "MPD not responding", TEXT_BUFFER_SIZE - 1);
-                       if (timed_thread_test(mpd_timed_thread))
-                               timed_thread_exit(mpd_timed_thread);
+                       if (timed_thread_test(mpd_timed_thread)) timed_thread_exit(mpd_timed_thread);
                        continue;
                }
 
@@ -109,8 +108,7 @@ void *update_mpd(void)
 
                        strncpy(current_info->mpd.status, "MPD not responding", TEXT_BUFFER_SIZE - 1);
                        timed_thread_unlock(mpd_timed_thread);
-                       if (timed_thread_test(mpd_timed_thread))
-                               timed_thread_exit(mpd_timed_thread);
+                       if (timed_thread_test(mpd_timed_thread)) timed_thread_exit(mpd_timed_thread);
                        continue;
                }
 
@@ -161,8 +159,7 @@ void *update_mpd(void)
                        mpd_closeConnection(current_info->conn);
                        current_info->conn = 0;
                        timed_thread_unlock(mpd_timed_thread);
-                       if (timed_thread_test(mpd_timed_thread))
-                               timed_thread_exit(mpd_timed_thread);
+                       if (timed_thread_test(mpd_timed_thread)) timed_thread_exit(mpd_timed_thread);
                        continue;
                }
 
@@ -226,8 +223,7 @@ void *update_mpd(void)
                        //fprintf(stderr, "%s\n", current_info->conn->errorStr);
                        mpd_closeConnection(current_info->conn);
                        current_info->conn = 0;
-                       if (timed_thread_test(mpd_timed_thread))
-                               timed_thread_exit(mpd_timed_thread);
+                       if (timed_thread_test(mpd_timed_thread)) timed_thread_exit(mpd_timed_thread);
                        continue;
                }
 
@@ -236,8 +232,7 @@ void *update_mpd(void)
                        //fprintf(stderr, "%s\n", current_info->conn->errorStr);
                        mpd_closeConnection(current_info->conn);
                        current_info->conn = 0;
-                       if (timed_thread_test(mpd_timed_thread))
-                               timed_thread_exit(mpd_timed_thread);
+                       if (timed_thread_test(mpd_timed_thread)) timed_thread_exit(mpd_timed_thread);
                        continue;
                }
                mpd_freeStatus(status);
@@ -245,9 +240,8 @@ void *update_mpd(void)
                        mpd_closeConnection(current_info->conn);
                        current_info->conn = 0;
                }
-               if (timed_thread_test(mpd_timed_thread))
-                       timed_thread_exit(mpd_timed_thread);
-                       continue;
+               if (timed_thread_test(mpd_timed_thread)) timed_thread_exit(mpd_timed_thread);
+               continue;
        }
        return 0;
 }