From 0f83b09ef7d2bba91e6ffe0605f7c24480d6da4c Mon Sep 17 00:00:00 2001 From: ejurgensen Date: Sat, 23 Feb 2019 21:26:04 +0100 Subject: [PATCH] [player] Fix incorrect setting of start timestamp The time stamp was getting set too late, because if pos was zero the first reads then it would be overwritten, but it shouldn't because the loop will catch up even if the initial reads have zero samples. --- src/player.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/player.c b/src/player.c index 3986ba41..d647d798 100644 --- a/src/player.c +++ b/src/player.c @@ -852,7 +852,7 @@ static inline void session_update_read(int nsamples) { // Did we just complete our first read? Then set the start timestamp - if (pb_session.pos == 0) + if (pb_session.start_ts.tv_sec == 0) { clock_gettime_with_res(CLOCK_MONOTONIC, &pb_session.start_ts, &player_timer_res); pb_session.pts = pb_session.start_ts; @@ -1089,7 +1089,10 @@ source_read(int *nbytes, int *nsamples, struct media_quality *quality, uint8_t * } if (*nbytes == 0 || quality->channels == 0) - return 0; + { + event_read(0); // This will set start_ts even if source isn't open yet + return 0; + } *nsamples = BTOS(*nbytes, quality->bits_per_sample, quality->channels);