From 553a8dc6d726a19b30da8ee4a08dcfea2c444a52 Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Tue, 12 Feb 2019 09:57:12 +0100 Subject: player: Fix buffering issue with mp3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Again, I used the wrong time_base. Since lastTimestamp and the decoder’s frame->pts used different time_base’s, the buffer health was wrong, resulting in an indefinite stall (“buffer is full” when it was not). See #678. --- src/player.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/player.c') diff --git a/src/player.c b/src/player.c index 92f230e..d8ff969 100644 --- a/src/player.c +++ b/src/player.c @@ -557,9 +557,13 @@ void *BarAoPlayThread (void *data) { } pthread_mutex_unlock (&player->lock); + /* lastTimestamp must be the last pts, but expressed in terms of + * st->time_base, not the sink’s time_base. */ + AVRational lastTimestampQ = av_mul_q (timestampQ, av_inv_q (player->st->time_base)); + const int64_t lastTimestamp = lastTimestampQ.num/lastTimestampQ.den; /* notify download thread, we might need more data */ pthread_mutex_lock (&player->aoplayLock); - player->lastTimestamp = filteredFrame->pts; + player->lastTimestamp = lastTimestamp; pthread_cond_broadcast (&player->aoplayCond); pthread_mutex_unlock (&player->aoplayLock); -- cgit v1.2.3