Re: Thread-safe AudioBuffer queue
Re: Thread-safe AudioBuffer queue
- Subject: Re: Thread-safe AudioBuffer queue
- From: SKoT McDonald <email@hidden>
- Date: Wed, 9 Jan 2002 13:08:45 -0500
Hey ho,
The SndKit's SndStreamClients have thread-safe buffer in/out queues
for their synthesis/processing threads. The class name is
SndAudioBufferQueue.
musickit.sourceforge.net has the code.
- SKoT
On Wednesday, January 9, 2002, at 12:34 PM, Lieven Dekeyser wrote:
Hi!
I'm trying to make a sound converter class which uses SoundConverter
from
<Carbon/Sound.h> to convert any files QuickTime can read to CoreAudio's
Float32 format and play back the converted data through the default
audio
device.
I'm doing this using a thread (started by [NSThread
detachNewThreadSelector])
that does the actual converting and then there's the thread that runs
the
output device's IOProc when needed. In the converter thread the
converted
stuff is malloced & enqueued, in the IOProc it's dequeued, memcpyd to
the
audio device's first buffer and then freed.
I'm using the extra thread & queue because I tried to do the
conversion in the IOProc, but this resulted in skipping playback, so I
guess the conversion is too heavy for the IOProc.
My approach works fine... most of the time :-(
tough sometimes it crashes telling me I have accessed the memory
illegally
(EXC_BAD_ACCESS)
I suspect this has something to do with my queue not being completely
thread safe. I tried to make the enqueue & dequeue operations as safe as
possible with virtually no critical operations, but I guess that's not
enough.
Has anyone tried & succeeded to do something similar?
greetz & thanks!
--Lieven
ps: as soon as it gets stable, I'll put the source code on my website
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.