mirror of
https://codeberg.org/dnkl/yambar.git
synced 2025-04-23 20:35:42 +02:00
module/mpd: refresh thread calls bar->refresh() directly
This is possible, since content() now calculates the correct 'elapsed' time, based on the time the original elapsed value was received from MPD.
This commit is contained in:
parent
f74f2ad031
commit
ba31a557f5
1 changed files with 4 additions and 29 deletions
|
@ -31,7 +31,6 @@ struct private {
|
||||||
struct particle *label;
|
struct particle *label;
|
||||||
|
|
||||||
struct mpd_connection *conn;
|
struct mpd_connection *conn;
|
||||||
int refresh_fd;
|
|
||||||
|
|
||||||
enum state state;
|
enum state state;
|
||||||
char *album;
|
char *album;
|
||||||
|
@ -58,7 +57,6 @@ destroy(struct module *mod)
|
||||||
free(m->album);
|
free(m->album);
|
||||||
free(m->artist);
|
free(m->artist);
|
||||||
free(m->title);
|
free(m->title);
|
||||||
close(m->refresh_fd);
|
|
||||||
assert(m->conn == NULL);
|
assert(m->conn == NULL);
|
||||||
|
|
||||||
m->label->destroy(m->label);
|
m->label->destroy(m->label);
|
||||||
|
@ -236,12 +234,6 @@ run(struct module_run_context *ctx)
|
||||||
const struct bar *bar = mod->bar;
|
const struct bar *bar = mod->bar;
|
||||||
struct private *m = mod->private;
|
struct private *m = mod->private;
|
||||||
|
|
||||||
m->refresh_fd = eventfd(0, EFD_CLOEXEC);
|
|
||||||
if (m->refresh_fd == -1) {
|
|
||||||
LOG_ERRNO("failed to create eventfd (for refresh)");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool aborted = false;
|
bool aborted = false;
|
||||||
|
|
||||||
while (!aborted) {
|
while (!aborted) {
|
||||||
|
@ -291,7 +283,6 @@ run(struct module_run_context *ctx)
|
||||||
struct pollfd fds[] = {
|
struct pollfd fds[] = {
|
||||||
{.fd = ctx->abort_fd, .events = POLLIN},
|
{.fd = ctx->abort_fd, .events = POLLIN},
|
||||||
{.fd = mpd_connection_get_fd(m->conn), .events = POLLIN},
|
{.fd = mpd_connection_get_fd(m->conn), .events = POLLIN},
|
||||||
{.fd = m->refresh_fd, .events = POLLIN},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!mpd_send_idle(m->conn)) {
|
if (!mpd_send_idle(m->conn)) {
|
||||||
|
@ -300,7 +291,7 @@ run(struct module_run_context *ctx)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
poll(fds, 3, -1);
|
poll(fds, 2, -1);
|
||||||
|
|
||||||
if (fds[0].revents & POLLIN) {
|
if (fds[0].revents & POLLIN) {
|
||||||
aborted = true;
|
aborted = true;
|
||||||
|
@ -321,21 +312,6 @@ run(struct module_run_context *ctx)
|
||||||
|
|
||||||
bar->refresh(bar);
|
bar->refresh(bar);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fds[2].revents & POLLIN) {
|
|
||||||
LOG_DBG("got refresh event");
|
|
||||||
|
|
||||||
uint64_t v;
|
|
||||||
read(m->refresh_fd, &v, sizeof(v));
|
|
||||||
LOG_DBG("v = 0x%lx", v);
|
|
||||||
|
|
||||||
mpd_run_noidle(m->conn);
|
|
||||||
|
|
||||||
if (!update_status(mod))
|
|
||||||
break;
|
|
||||||
|
|
||||||
bar->refresh(bar);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -384,9 +360,9 @@ refresh_in_thread(void *arg)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Timeout - signal refresh to module main thread */
|
LOG_DBG("timed refresh");
|
||||||
/* TODO: could juse call bar->refresh()? */
|
mod->bar->refresh(mod->bar);
|
||||||
write(m->refresh_fd, &(uint64_t){1}, sizeof(uint64_t));
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -438,7 +414,6 @@ module_mpd(const char *host, uint16_t port, struct particle *label)
|
||||||
priv->port = port;
|
priv->port = port;
|
||||||
priv->label = label;
|
priv->label = label;
|
||||||
priv->conn = NULL;
|
priv->conn = NULL;
|
||||||
priv->refresh_fd = -1;
|
|
||||||
priv->state = STATE_OFFLINE;
|
priv->state = STATE_OFFLINE;
|
||||||
priv->album = NULL;
|
priv->album = NULL;
|
||||||
priv->artist = NULL;
|
priv->artist = NULL;
|
||||||
|
|
Loading…
Add table
Reference in a new issue