diff options
author | Lars-Dominik Braun <lars@6xq.net> | 2014-09-19 18:01:48 +0200 |
---|---|---|
committer | Lars-Dominik Braun <lars@6xq.net> | 2014-09-19 18:01:48 +0200 |
commit | 5914baa00b1f5ae6afd4291a0ffc5c6698fa0806 (patch) | |
tree | b31933faa13bd061b07e4d1af2f9d4a077624051 /src | |
parent | 4f36797fb368cc30a648ed0a313b6f4ad6cb3927 (diff) | |
download | pianobar-5914baa00b1f5ae6afd4291a0ffc5c6698fa0806.tar.gz pianobar-5914baa00b1f5ae6afd4291a0ffc5c6698fa0806.tar.bz2 pianobar-5914baa00b1f5ae6afd4291a0ffc5c6698fa0806.zip |
Improve player pause/quit
Skipping/quitting while pausing does not play the current packet any
more. Avoid unneccessary calls to av_read_(play|pause).
Diffstat (limited to 'src')
-rw-r--r-- | src/player.c | 18 |
1 files 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); |