mirror of
https://github.com/owntone/owntone-server.git
synced 2025-07-14 03:11:55 -04:00
[pipe] Fix issue where Shairport progress metadata was ignored
Sometimes the progress has a negative position, which we were incorrectly disregarding.
This commit is contained in:
parent
1921a2401f
commit
63ab446bd5
@ -340,29 +340,33 @@ handle_progress(struct input_metadata *m, char *progress)
|
|||||||
{
|
{
|
||||||
char *s;
|
char *s;
|
||||||
char *ptr;
|
char *ptr;
|
||||||
uint64_t start;
|
// Below must be signed to avoid casting in the calculations of pos_ms/len_ms
|
||||||
uint64_t pos;
|
int64_t start;
|
||||||
uint64_t end;
|
int64_t pos;
|
||||||
|
int64_t end;
|
||||||
|
|
||||||
if (!(s = strtok_r(progress, "/", &ptr)))
|
if (!(s = strtok_r(progress, "/", &ptr)))
|
||||||
return;
|
return;
|
||||||
safe_atou64(s, &start);
|
safe_atoi64(s, &start);
|
||||||
|
|
||||||
if (!(s = strtok_r(NULL, "/", &ptr)))
|
if (!(s = strtok_r(NULL, "/", &ptr)))
|
||||||
return;
|
return;
|
||||||
safe_atou64(s, &pos);
|
safe_atoi64(s, &pos);
|
||||||
|
|
||||||
if (!(s = strtok_r(NULL, "/", &ptr)))
|
if (!(s = strtok_r(NULL, "/", &ptr)))
|
||||||
return;
|
return;
|
||||||
safe_atou64(s, &end);
|
safe_atoi64(s, &end);
|
||||||
|
|
||||||
if (!start || !pos || !end)
|
if (!start || !pos || !end)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (pos > start)
|
// Note that negative positions are allowed and supported. A negative position
|
||||||
|
// of e.g. -1000 means that the track will start in one second.
|
||||||
|
m->pos_is_updated = true;
|
||||||
m->pos_ms = (pos - start) * 1000 / pipe_sample_rate;
|
m->pos_ms = (pos - start) * 1000 / pipe_sample_rate;
|
||||||
if (end > start)
|
m->len_ms = (end > start) ? (end - start) * 1000 / pipe_sample_rate : 0;
|
||||||
m->len_ms = (end - start) * 1000 / pipe_sample_rate;
|
|
||||||
|
DPRINTF(E_DBG, L_PLAYER, "Received Shairport metadata progress: %ld/%ld/%ld => %d/%u ms\n", start, pos, end, m->pos_ms, m->len_ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
x
Reference in New Issue
Block a user