mirror of
https://codeberg.org/dnkl/yambar.git
synced 2025-04-24 12:55:41 +02:00
module/mpd: only auto-progress 'elapsed' when state is PLAYING
This commit is contained in:
parent
5a2f4a3ece
commit
bd251cbf9f
1 changed files with 13 additions and 2 deletions
|
@ -3,6 +3,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <inttypes.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <threads.h>
|
#include <threads.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
@ -108,8 +109,18 @@ content(struct module *mod)
|
||||||
mtx_lock(&mod->lock);
|
mtx_lock(&mod->lock);
|
||||||
|
|
||||||
/* Calculate what 'elapsed' is now */
|
/* Calculate what 'elapsed' is now */
|
||||||
uint64_t elapsed = m->elapsed.value +
|
uint64_t elapsed = m->elapsed.value;
|
||||||
timespec_diff_milli_seconds(&now, &m->elapsed.when);
|
|
||||||
|
if (m->state == STATE_PLAY) {
|
||||||
|
elapsed += timespec_diff_milli_seconds(&now, &m->elapsed.when);
|
||||||
|
if (elapsed > m->duration) {
|
||||||
|
LOG_WARN(
|
||||||
|
"dynamic update of elapsed overflowed: "
|
||||||
|
"elapsed=%"PRIu64", duration=%"PRIu64, elapsed, m->duration);
|
||||||
|
elapsed = m->duration;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
unsigned elapsed_secs = elapsed / 1000;
|
unsigned elapsed_secs = elapsed / 1000;
|
||||||
unsigned duration_secs = m->duration / 1000;
|
unsigned duration_secs = m->duration / 1000;
|
||||||
|
|
Loading…
Add table
Reference in a new issue