Re: Thread count strangeness using PlayAudioFile sample code
Re: Thread count strangeness using PlayAudioFile sample code
- Subject: Re: Thread count strangeness using PlayAudioFile sample code
- From: Robert Martin <email@hidden>
- Date: Sat, 2 Apr 2005 08:46:42 -0500
Evan - Thanks so much. This works!!
-Rob.
On Apr 1, 2005, at 11:54 PM, Evan Gross wrote:
On 3/29/05 9:29 AM, "Robert Martin" <email@hidden> wrote:
<snip>
Each pass through PlayAudioFile seems to create 2 threads but release
only one:<snip>
I ran into this as well. I would also classify this as a bug, or at
least an
undesirable thing. Play a sound 100 times, see 100 threads more (in
Activity
Viewer or whatever) than when the first sound was played? Not OK for a
shipping app!
Anyway, I wasn't thrilled with this, so made a couple of changes to
AudioFileReaderThread.cpp and all seems to be well (my modified
version has
been shipping in my product for a couple of months now - no problem
reported
in this area).
The fundamental change was to FileReaderThread::ReadNextChunk (),
specifically:
while (mFileData.empty()) {
fileReadLock.Wait();
}
change to:
while (mFileData.empty() && !mThreadShouldDie) {
fileReadLock.Wait();
}
and while perhaps not absolutely necessary, I changed:
static FileReaderThread sReaderThread;
to:
static FileReaderThread *sReaderThread = nil;
then in AudioFileReaderThread::AudioFileReaderThread added:
if (sReaderThread == nil)
sReaderThread = new FileReaderThread;
and accordingly changed all the sReaderThread.whatever's to
sReaderThread->whatever's.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden