[Haskell-cafe] FFI woes!
Jules Bean
jules at jellybean.co.uk
Thu Dec 16 07:38:26 EST 2004
On 16 Dec 2004, at 06:57, Sebastian Sylvan wrote:
> Here's the problem though. If the SamplePlaybackRaw is currently
> playing sound when it gets garbage collected, I want to keep the sound
> resource (SoundSample) alive until the playback has finished.
>
I probably haven't understood the details correctly but why not just
spawn a thread in your 'start playback' function. This thread (a) keeps
a reference to the soundsample (which guarantees it will never be
GC'ed) and (b) checks every second or so to see if the playing has
finished. If the playing has finished, it arranges to no longer hold
the reference, and in due course GC will take it out.
Jules
More information about the Haskell-Cafe
mailing list