From 1839edf64ad0a4b6d96a5dd5ce24ab8075954dc6 Mon Sep 17 00:00:00 2001 From: Nicolas Pennequin Date: Sat, 27 Oct 2007 18:08:18 +0000 Subject: Add queue_peek to the kernel (written by Mike Sevakis), and use it to improve upon my previous commit. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15336 a1c6a512-1295-4272-9138-f99709370657 --- apps/playback.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'apps/playback.c') diff --git a/apps/playback.c b/apps/playback.c index 2ac54e7d74..3c1dd37d3f 100644 --- a/apps/playback.c +++ b/apps/playback.c @@ -2569,6 +2569,7 @@ static void low_buffer_callback(void) static void audio_fill_file_buffer(bool start_play, size_t offset) { + struct queue_event ev; bool had_next_track = audio_next_track() != NULL; bool continue_buffering; @@ -2591,9 +2592,14 @@ static void audio_fill_file_buffer(bool start_play, size_t offset) start_play = false; offset = 0; sleep(1); - if (!queue_empty(&audio_queue)) { - /* There's a message in the queue. break the loop to treat it, - and go back to filling after that. */ + if (queue_peek(&audio_queue, &ev)) { + if (ev.id != Q_AUDIO_FILL_BUFFER) + { + /* There's a message in the queue. break the loop to treat it, + and go back to filling after that. */ + LOGFQUEUE("buffering > audio Q_AUDIO_FILL_BUFFER"); + queue_post(&audio_queue, Q_AUDIO_FILL_BUFFER, 0); + } break; } } while (continue_buffering); -- cgit v1.2.3