Juhana Sadeharju wrote:
From: Tim Hockin <[EMAIL PROTECTED]>
Quick question: disk thread may suspend if there are no disk use.Semaphore. Every time you put something into the buffer, up() the
How the disk thread is woken up to read the lock-free buffer?
How this all is done in Ardour? I browsed the source but there are
a lot of stuff there. How about LinuxSampler?
We use a very simple approach in LinuxSampler: in the disk thread if all ringbuffers are filled or no voice is active then
we sleep for 30msec. It could be done with a semaphore too (or waiting for a byte from a FIFO) but it's simply not worth
the trouble changing the current approach.
When the disk streamer gets busy the usleep() is not called and if it is idle then periodical sleeps of 30msec aren't going
stressing the process scheduler in any way.
I know sleeping is not the "elegantest" method but it is the simplest one and since we plan to support multiple disk threads
(one per physical disk) adding all the needed IPC in the audio thread to communicate with the disk threads
(and since the datarate of the disk streams is dynamic (user moves the pitchbender etc) the disk thread has no easy way to exactly
figure out when to wake up other than looking at the fill amount of each active ringbuffer.
Just open the file
engines/gig/DiskThread.cpp
and search for: IsIdle (a boolean variable that indicates if the diskthread needs to sleep a bit or if it did perform
disk I/O during the current cycle).
The idling/sleeping mechanism consist of 3 lines of code, not that complex I'd say, and it works very well :)
cheers, Benno http://www.linuxsampler.org
Juhana
