• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Thread count strangeness using PlayAudioFile sample code
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
  • Follow-Ups:
    • Re: Thread count strangeness using PlayAudioFile sample code
      • From: James McCartney <email@hidden>
References: 
 >Re: Thread count strangeness using PlayAudioFile sample code (From: Evan Gross <email@hidden>)

  • Prev by Date: Re: Thread count strangeness using PlayAudioFile sample code
  • Next by Date: Chain of Audio Units and Sample Rate
  • Previous by thread: Re: Thread count strangeness using PlayAudioFile sample code
  • Next by thread: Re: Thread count strangeness using PlayAudioFile sample code
  • Index(es):
    • Date
    • Thread