
On Thu, 16 Dec 2004 18:20:52 +0000, Keean Schupke
In which case I would assume the whole sample is copied to the sound cards buffer before the play call returns, so you don't have to worry and just let it be garbage collected.
What do you mean? Yes the sample is copied to memory when loaded, but I still have to "worry" because if it's garbage colleced (ie, a "free" call is called on it) then the sound can not be played anymore (because the data is gone). /S
Keean
Sebastian Sylvan wrote:
On Thu, 16 Dec 2004 12:35:55 +0000, Keean Schupke
wrote: Okay, you want to poll to see if the sound is still playing... This is not very easy to do...
You really want to use the low-buffer callback from the soundcard driver to load the next sample into the buffer using DMA. (IE you can pass a function to the driver to call when you sample has been copied completely to the sound-cards memory). This is the way to do it...
play_then_free = do set_callback (free_sample my_sample) play_sample my_sample
You can see that this provides the interface you want to the user (IE samples are freed once they are finished with)...
Keean.
This is exactly how I do it for the Stream sound type, since this type of sound supplies a callback for when it reaches the end. The sound sample does not, though. (stream is streamed from disk, sound sample is loaded into memory).
/S
-- Sebastian Sylvan +46(0)736-818655 UIN: 44640862