summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars-Dominik Braun <lars@6xq.net>2019-02-12 09:57:12 +0100
committerLars-Dominik Braun <lars@6xq.net>2019-02-14 09:24:25 +0100
commit553a8dc6d726a19b30da8ee4a08dcfea2c444a52 (patch)
tree9a0c9798188a32f7a00bd9727d2371a57d047fb9
parent24852ca110c7240dd5c57aa7201d802302a097ce (diff)
downloadpianobar-553a8dc6d726a19b30da8ee4a08dcfea2c444a52.tar.gz
pianobar-553a8dc6d726a19b30da8ee4a08dcfea2c444a52.tar.bz2
pianobar-553a8dc6d726a19b30da8ee4a08dcfea2c444a52.zip
player: Fix buffering issue with mp3
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.
-rw-r--r--src/player.c6
1 files changed, 5 insertions, 1 deletions
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);