From 709640422c07b8f79c9ffad6ffde0d1f5f317523 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 13 Nov 2008 02:09:33 +0100 Subject: player: chop the tail of the music pipe after CANCEL When a CANCEL command is received, the player should drop all chunks of the next song. Added new funciton music_pipe_chop() which is used for that. --- src/pipe.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/pipe.c') diff --git a/src/pipe.c b/src/pipe.c index 7afbefcb1..23a23469c 100644 --- a/src/pipe.c +++ b/src/pipe.c @@ -301,6 +301,18 @@ void music_pipe_skip(unsigned num) music_pipe_shift(); } +void music_pipe_chop(unsigned first) +{ + for (unsigned i = first; i != music_pipe.end; i = successor(i)) + music_chunk_free(&music_pipe.chunks[i]); + + music_chunk_free(&music_pipe.chunks[music_pipe.end]); + + music_pipe.end = first; + music_chunk_init(&music_pipe.chunks[first]); + +} + #ifndef NDEBUG void music_pipe_check_format(const struct audio_format *current, int next_index, const struct audio_format *next) -- cgit v1.2.3