summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8a7c442)
raw | patch | inline | side by side (parent: 8a7c442)
author | Kalle Wallin <kaw@linux.se> | |
Sun, 28 Mar 2004 23:25:00 +0000 (23:25 +0000) | ||
committer | Kalle Wallin <kaw@linux.se> | |
Sun, 28 Mar 2004 23:25:00 +0000 (23:25 +0000) |
main.c | patch | blob | history |
index 56c18a31652bc4cebb16bb0d37075a7c60eca3be..92e40b6dda539f92833a144d3594bb3ec3a28a6e 100644 (file)
--- a/main.c
+++ b/main.c
#include "conf.h"
-static mpd_client_t *mpc = NULL;
+#define MPD_UPDATE_TIME 1.0
+
+static mpd_client_t *mpc = NULL;
+static GTimer *timer = NULL;
void
exit_and_cleanup(void)
mpc_close(mpc);
}
g_free(options.host);
+ if( timer )
+ g_timer_destroy(timer);
}
void
{
options_t *options;
struct sigaction act;
- int counter, connected;
+ int connected;
/* initialize options */
options = options_init();
/* initialize curses */
screen_init();
-
- counter=0;
+
+ /* initialize timer */
+ timer = g_timer_new();
+
connected=1;
while( connected || options->reconnect )
{
- command_t cmd;
+ static gdouble t = G_MAXDOUBLE;
- if( connected && counter==0 )
+ if( connected && t>=MPD_UPDATE_TIME )
{
mpc_update(mpc);
if( mpc_error(mpc) )
}
else
mpd_finishCommand(mpc->connection);
- counter=10;
+ g_timer_start(timer);
}
if( connected )
{
+ command_t cmd;
+
screen_update(mpc);
if( (cmd=get_keyboard_command()) != CMD_NONE )
{
screen_cmd(mpc, cmd);
if( cmd==CMD_VOLUME_UP || cmd==CMD_VOLUME_DOWN)
- counter=10; /* make shure we dont update the volume yet */
- else
- counter=0;
+ /* make shure we dont update the volume yet */
+ g_timer_start(timer);
}
}
else if( options->reconnect )
{
screen_status_printf("Connected to %s!", options->host);
connected=1;
- counter=0;
}
doupdate();
}
- if( counter>0 )
- counter--;
+ t = g_timer_elapsed(timer, NULL);
}
exit(EXIT_FAILURE);