1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-12-26 04:17:33 +00:00

fix clearing issue with mpd

git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky1@944 7f574dfc-610e-0410-a909-a81674777703
This commit is contained in:
Brenden Matthews 2007-08-31 23:45:41 +00:00
parent 6c052dae9b
commit 0ae51e37ee
3 changed files with 11 additions and 4 deletions

View File

@ -233,7 +233,7 @@ void update_stuff()
#ifdef MPD
if (NEED(INFO_MPD)) {
if (!mpd_timed_thread) {
clear_mpd_stats(&info);
init_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 timed thread");

View File

@ -619,7 +619,7 @@ char *get_apm_battery_time(void);
/* in mpd.c */
#ifdef MPD
extern void clear_mpd_stats(struct information *current_info);
extern void init_mpd_stats(struct information *current_info);
void *update_mpd(void);
extern timed_thread *mpd_timed_thread;
#endif /* MPD */

View File

@ -32,8 +32,9 @@
#include "libmpdclient.h"
timed_thread *mpd_timed_thread = NULL;
void clear_mpd_stats(struct information *current_info);
void clear_mpd_stats(struct information *current_info)
void init_mpd_stats(struct information *current_info)
{
if (current_info->mpd.artist == NULL)
current_info->mpd.artist = malloc(TEXT_BUFFER_SIZE);
@ -53,7 +54,11 @@ void clear_mpd_stats(struct information *current_info)
current_info->mpd.name = malloc(TEXT_BUFFER_SIZE);
if (current_info->mpd.file == NULL)
current_info->mpd.file = malloc(TEXT_BUFFER_SIZE);
clear_mpd_stats(current_info);
}
void clear_mpd_stats(struct information *current_info)
{
*current_info->mpd.name=0;
*current_info->mpd.file=0;
*current_info->mpd.artist=0;
@ -82,6 +87,9 @@ void *update_mpd(void)
mpd_finishCommand(current_info->conn);
}
timed_thread_lock(mpd_timed_thread);
clear_mpd_stats(current_info);
if (current_info->conn->error || current_info->conn == NULL) {
//ERR("%MPD error: s\n", current_info->conn->errorStr);
mpd_closeConnection(current_info->conn);
@ -92,7 +100,6 @@ void *update_mpd(void)
continue;
}
timed_thread_lock(mpd_timed_thread);
mpd_Status *status;
mpd_InfoEntity *entity;
mpd_sendStatusCommand(current_info->conn);