From 483c40285bbad64835122da3967f74a8ca061a4a Mon Sep 17 00:00:00 2001 From: Nicolas Pennequin Date: Tue, 12 Feb 2008 23:15:59 +0000 Subject: [PATCH] Notify the buffering thread when a handle is added, so it can go into filling mode. This is some sort of a replacement for the ATA idle callback. It will interrupt an ongoing buffering process (buffer_handle), but not for long enough to be a problem. Should fix a problem reported by Dave Hooper where inserting tracks into the playlist would flush the buffer and not refill it, sometimes causing the inserted tracks to be skipped. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16295 a1c6a512-1295-4272-9138-f99709370657 --- apps/buffering.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/apps/buffering.c b/apps/buffering.c index 2d7ca22368..64f522c52f 100644 --- a/apps/buffering.c +++ b/apps/buffering.c @@ -177,6 +177,8 @@ enum { Q_SET_WATERMARK, Q_START_FILL, /* Request that the buffering thread initiate a buffer fill at its earliest convenience */ + Q_HANDLE_ADDED, /* Inform the buffering thread that a handle was added, + (which means the disk is spinning) */ }; /* Buffering thread */ @@ -936,6 +938,10 @@ int bufopen(const char *file, size_t offset, enum data_type type) /* Other types will get buffered in the course of normal operations */ h->fd = -1; close(fd); + + /* Inform the buffering thread that we added a handle */ + LOGFQUEUE("buffering > Q_HANDLE_ADDED %d", h->id); + queue_post(&buffering_queue, Q_HANDLE_ADDED, h->id); } logf("bufopen: new hdl %d", h->id); @@ -1358,6 +1364,12 @@ void buffering_thread(void) queue_reply(&buffering_queue, close_handle((int)ev.data)); break; + case Q_HANDLE_ADDED: + LOGFQUEUE("buffering < Q_HANDLE_ADDED %d", (int)ev.data); + /* A handle was added: the disk is spinning, so we can fill */ + filling = true; + break; + case Q_BASE_HANDLE: LOGFQUEUE("buffering < Q_BASE_HANDLE"); base_handle_id = (int)ev.data; -- 2.11.4.GIT