From 5914baa00b1f5ae6afd4291a0ffc5c6698fa0806 Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Fri, 19 Sep 2014 18:01:48 +0200 Subject: Improve player pause/quit Skipping/quitting while pausing does not play the current packet any more. Avoid unneccessary calls to av_read_(play|pause). --- src/player.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/player.c b/src/player.c index 0476a6b..8d325ea 100644 --- a/src/player.c +++ b/src/player.c @@ -319,18 +319,16 @@ static int play (player_t * const player) { /* pausing */ pthread_mutex_lock (&player->pauseMutex); - while (true) { - if (!player->doPause) { - av_read_play (player->fctx); - break; - } else { - av_read_pause (player->fctx); - } - pthread_cond_wait (&player->pauseCond, &player->pauseMutex); + if (player->doPause) { + av_read_pause (player->fctx); + do { + pthread_cond_wait (&player->pauseCond, &player->pauseMutex); + } while (player->doPause); + av_read_play (player->fctx); } pthread_mutex_unlock (&player->pauseMutex); - do { + while (pkt.size > 0 && !player->doQuit) { int got_frame = 0; const int decoded = avcodec_decode_audio4 (player->st->codec, @@ -376,7 +374,7 @@ static int play (player_t * const player) { pkt.data += decoded; pkt.size -= decoded; - } while (pkt.size > 0); + }; av_free_packet (&pkt_orig); -- cgit v1.2.3