make use_spacer an enum
[monky] / src / mpd.c
index 28e7548..6c7cebe 100644 (file)
--- a/src/mpd.c
+++ b/src/mpd.c
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *
- * $Id$ */
+ */
 
 #include "conky.h"
+#include "logging.h"
 
 void init_mpd_stats(struct mpd_s *mpd)
 {
@@ -113,6 +114,7 @@ void clear_mpd_stats(struct mpd_s *mpd)
        *mpd->repeat = 0;
        *mpd->track = 0;
        *mpd->status = 0;
+       mpd->is_playing = 0;
        mpd->bitrate = 0;
        mpd->progress = 0;
        mpd->elapsed = 0;
@@ -121,11 +123,13 @@ void clear_mpd_stats(struct mpd_s *mpd)
 
 void *update_mpd(void *arg)
 {
+       struct mpd_s *mpd;
+
        if (arg == NULL) {
                CRIT_ERR("update_mpd called with a null argument!");
        }
 
-       struct mpd_s *mpd = (struct mpd_s *) arg;
+       mpd = (struct mpd_s *) arg;
 
        while (1) {
                mpd_Status *status;
@@ -152,7 +156,7 @@ void *update_mpd(void *arg)
                        strncpy(mpd->status, "MPD not responding",
                                text_buffer_size - 1);
                        timed_thread_unlock(mpd->timed_thread);
-                       if (timed_thread_test(mpd->timed_thread)) {
+                       if (timed_thread_test(mpd->timed_thread, 0)) {
                                timed_thread_exit(mpd->timed_thread);
                        }
                        continue;
@@ -168,7 +172,7 @@ void *update_mpd(void *arg)
                        strncpy(mpd->status, "MPD not responding",
                                text_buffer_size - 1);
                        timed_thread_unlock(mpd->timed_thread);
-                       if (timed_thread_test(mpd->timed_thread)) {
+                       if (timed_thread_test(mpd->timed_thread, 0)) {
                                timed_thread_exit(mpd->timed_thread);
                        }
                        continue;
@@ -179,7 +183,7 @@ void *update_mpd(void *arg)
                        mpd_closeConnection(mpd->conn);
                        mpd->conn = 0;
                        timed_thread_unlock(mpd->timed_thread);
-                       if (timed_thread_test(mpd->timed_thread)) {
+                       if (timed_thread_test(mpd->timed_thread, 0)) {
                                timed_thread_exit(mpd->timed_thread);
                        }
                        continue;
@@ -206,6 +210,7 @@ void *update_mpd(void *arg)
                }
                if (status->state == MPD_STATUS_STATE_PLAY
                                || status->state == MPD_STATUS_STATE_PAUSE) {
+                       mpd->is_playing = 1;
                        mpd->bitrate = status->bitRate;
                        mpd->progress = (float) status->elapsedTime /
                                status->totalTime;
@@ -232,7 +237,7 @@ void *update_mpd(void *arg)
                        mpd_closeConnection(mpd->conn);
                        mpd->conn = 0;
                        timed_thread_unlock(mpd->timed_thread);
-                       if (timed_thread_test(mpd->timed_thread)) {
+                       if (timed_thread_test(mpd->timed_thread, 0)) {
                                timed_thread_exit(mpd->timed_thread);
                        }
                        continue;
@@ -298,7 +303,7 @@ void *update_mpd(void *arg)
                        mpd_closeConnection(mpd->conn);
                        mpd->conn = 0;
                        timed_thread_unlock(mpd->timed_thread);
-                       if (timed_thread_test(mpd->timed_thread)) {
+                       if (timed_thread_test(mpd->timed_thread, 0)) {
                                timed_thread_exit(mpd->timed_thread);
                        }
                        continue;
@@ -309,7 +314,7 @@ void *update_mpd(void *arg)
                        // fprintf(stderr, "%s\n", mpd->conn->errorStr);
                        mpd_closeConnection(mpd->conn);
                        mpd->conn = 0;
-                       if (timed_thread_test(mpd->timed_thread)) {
+                       if (timed_thread_test(mpd->timed_thread, 0)) {
                                timed_thread_exit(mpd->timed_thread);
                        }
                        continue;
@@ -320,7 +325,7 @@ void *update_mpd(void *arg)
                        mpd_closeConnection(mpd->conn);
                        mpd->conn = 0;
                } */
-               if (timed_thread_test(mpd->timed_thread)) {
+               if (timed_thread_test(mpd->timed_thread, 0)) {
                        timed_thread_exit(mpd->timed_thread);
                }
                continue;