[Openal] Problems with streams and threads.

Jason Daly jdaly at ist.ucf.edu
Mon Aug 20 08:48:06 PDT 2007


Leben Ojanen wrote:
> Hi all,
>
> I'm having a bit of trouble playing a streaming sound (music) and a
> normal buffered sound (sound effect) at the same time.  Since the
> stream contains a while loop (to handle it's buffers) it locks the
> program up.
>
> I put it into it's own thread and it works fine. The problem comes
> when I try to play the buffered sound effect while the music is
> playing.  It will play once, but during the second playthrough the
> thread around the streaming music crashes.
>   

I've got a similar setup in our software.  The streaming sounds are 
updated by a thread that runs periodically (about 30Hz).  I've tested 
this with multiple streams and static sounds using both the SI and and 
Creative OpenAL implementation, and it works OK.


> I'll be the first to admit I'm new to some of the threading business,
> but I believe I'm doing everything correctly. I'm just not sure why
> the second play of a buffered sound would crash the thread.
>   

You definitely have to be careful messing with threads, especially if 
you're new to it.  Concurrency problems are very subtle, so they're 
really easy to cause and really hard to find.  I'd try to get your test 
case down to as little code as possible, and see if you can't localize 
the issue.


> For reference, both "sounds" are instances of an openal wrapper object
> I created, so they're not using the same memory or anything.  

It's more likely a concurrency problem than a memory problem (you're 
trying to do two things at the same time that really have to be done 
sequentially).

-- 

--"J"

"I'm a castaway stranded in a desolate land,
 I can see the footprints in the virtual sand."
	--Neil Peart



More information about the Openal mailing list