int ret;
struct command_task *ct = container_of(t, struct command_task, task);
static struct timeval last_status_dump;
- struct timeval tmp, delay = {0, 500 * 1000};
+ struct timeval tmp, delay = {5, 0};
+ bool force = false;
tv_add(&last_status_dump, &delay, &tmp);
if (tv_diff(&tmp, now, NULL) < 0) {
- audiod_status_dump();
last_status_dump = *now;
+ force = true;
}
ret = handle_connect(ct->fd, &s->rfds);
if (ret < 0)
PARA_ERROR_LOG("%s\n", para_strerror(-ret));
- audiod_status_dump();
+ else if (ret > 0)
+ force = true;
+ audiod_status_dump(force);
return 0;
}
stat_task->offset_seconds = 0;
stat_task->vss_status = 0;
stat_task->current_audio_format_num = -1;
- audiod_status_dump();
+ audiod_status_dump(true);
}
/* avoid busy loop if server is down */
void __noreturn clean_exit(int status, const char *msg);
int handle_connect(int accept_fd, fd_set *rfds);
-void audiod_status_dump(void);
+void audiod_status_dump(bool force);
char *get_time_string(int slot_num);
struct btr_node *audiod_get_btr_root(void);
/**
* Send the current audiod status to all connected stat clients.
+ *
+ * \param force Whether to write unchanged items.
*/
-void audiod_status_dump(void)
+void audiod_status_dump(bool force)
{
int slot_num = get_play_time_slot_num();
char *old, *new;
old = stat_item_values[SI_PLAY_TIME];
new = get_time_string(slot_num);
if (new) {
- if (!old || strcmp(old, new)) {
+ if (force || !old || strcmp(old, new)) {
free(old);
stat_item_values[SI_PLAY_TIME] = new;
stat_client_write_item(SI_PLAY_TIME);
new = get_server_uptime_str(now);
old = stat_item_values[SI_AUDIOD_UPTIME];
- if (!old || strcmp(old, new)) {
+ if (force || !old || strcmp(old, new)) {
free(old);
stat_item_values[SI_AUDIOD_UPTIME] = new;
stat_client_write_item(SI_AUDIOD_UPTIME);
old = stat_item_values[SI_AUDIOD_STATUS];
new = audiod_status_string();
- if (!old || strcmp(old, new)) {
+ if (force || !old || strcmp(old, new)) {
free(old);
stat_item_values[SI_AUDIOD_STATUS] = new;
stat_client_write_item(SI_AUDIOD_STATUS);
old = stat_item_values[SI_DECODER_FLAGS];
new = decoder_flags();
- if (!old || strcmp(old, new)) {
+ if (force || !old || strcmp(old, new)) {
free(old);
stat_item_values[SI_DECODER_FLAGS] = new;
stat_client_write_item(SI_DECODER_FLAGS);