From a07c24d625b585954dc8c8ed8b84dc450b7c7a14 Mon Sep 17 00:00:00 2001 From: ejurgensen Date: Thu, 14 Apr 2016 08:55:59 +0200 Subject: [PATCH] [player] Fix possible segfault after playback stop on FreeBSD/machines with lo-res timers --- src/player.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/player.c b/src/player.c index 5de52db4..f0ad0b35 100644 --- a/src/player.c +++ b/src/player.c @@ -1438,6 +1438,13 @@ source_check(void) return 0; } + if (player_state == PLAY_STOPPED) + { + DPRINTF(E_LOG, L_PLAYER, "Bug! source_check called but playback has already stopped\n"); + + return pos; + } + /* If cur_playing is NULL, we are still in the first two seconds after starting the stream */ if (!cur_playing) { @@ -1674,7 +1681,7 @@ player_playback_cb(int fd, short what, void *arg) packet_timer_last = timespec_add(packet_timer_last, packet_time); } - while (timespec_cmp(packet_timer_last, next_tick) < 0); + while ((timespec_cmp(packet_timer_last, next_tick) < 0) && (player_state == PLAY_PLAYING)); /* Make sure playback is still running */ if (player_state == PLAY_STOPPED)