Threads or suggestion?

Stephen Pair spair at acm.org
Thu Aug 8 20:18:57 UTC 2002


Jason,

Have a look at BlockContext>>fork (and forkAt:)

If I do:

[StreamingMp3Sound onFileNamed: 'yourfile.mp3') playAndWaitUntilDone]
	forkAt: Processor userBackgroundPriority

The mp3 file is played at a lower priority than the user processes
(which makes the UI responsive)...just forking it (at the user priority)
will cause the UI to be noticeably impacted.

You might also check out the Process and ProcessorScheduler classes if
you want more info on Squeak's processor scheduling capabilities (both
cooperative and preemptive scheduling is possible in Squeak).

- Stephen

> -----Original Message-----
> From: squeak-dev-admin at lists.squeakfoundation.org 
> [mailto:squeak-dev-admin at lists.squeakfoundation.org] On 
> Behalf Of Jason Dufair
> Sent: Thursday, August 08, 2002 4:02 PM
> To: squeak-dev at lists.squeakfoundation.org
> Subject: Threads or suggestion?
> 
> 
> Hi all -
> 
> I poked around for threads in Squeak and didn't find much.  
> I'm looking 
> for suggestions.
> 
> I have Playlist object that holds a ReadStream on a 
> collection of (mp3) 
> files.  I want to play the stream, song after song.  So I set up a 
> StreamingMp3Sound on the first one and tell it to play.  No problem. 
>  Now, I want the next one to play when this one is done playing.  I 
> don't want to use playAndWaitUntilDone, because operations need to be 
> asynchronous (i.e. I may want to pause, go to the next track, 
> etc.).  My 
> instinct is to create a thread that monitors the 
> StreamingMp3Sound and 
> has the Playlist start the next track when the current track's 
> samplesRemaining are 0.  But I can't figure out a way to set up this 
> monitoring thread.
> 
> Ideas?
> 
> -- 
> Jason Dufair - jase at dufair.org
> http://www.dufair.org/
> "Every word is like an unnecessary stain on silence and nothingness."
> -- Beckett
> 
> 
> 
> 




More information about the Squeak-dev mailing list