• 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
Thread count strangeness using PlayAudioFile sample code
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Thread count strangeness using PlayAudioFile sample code


  • Subject: Thread count strangeness using PlayAudioFile sample code
  • From: Robert Martin <email@hidden>
  • Date: Tue, 29 Mar 2005 09:29:08 -0500

<newbieAlert>

I'm writing a really simple little Cocoa app which is a glorified sample browser - it plays audio files the moment you click on them in its 'finder-like' browser window.

It works fine, but I ran top and noticed that after each call to PlayAudioFile, my thread count permanently increases by 1. I'm new to threads and cannot figure out what's causing this - or even whether I should worry about it.

Each pass through PlayAudioFile seems to create 2 threads but release only one: AFP_Connect(player) creates a fileReader thread which is released, but the thread created in AudioOutputUnitStart(theUnit) does not seem to be released in AudioOutputUnitStop(theUnit) even if I follow this with CloseComponent(theUnit).

I modified PlayAudioFile so that it calls the app back when it's finished, and has an entry point to stop play. On stop, I call AFP_Disconnect (player), but I leave the cleanup for the next time I call so that I can return to the app immediately - so the PlayAudioFile entry method starts with this:

// only 1 thread is released here, though 2 were allocated if(player){ // it was created last time we called
AudioOutputUnitStop (theUnit);
AFP_Disconnect (player);
DisposeAudioFilePlayID (player);
player = nil;
}


I noticed the same increment on the unmodified code - the cleanup routines (after play stops) leave you with one more thread than when you started.

Can anyone point me in a direction to understand what's going on? I've spent days thinking about this and stepping through the code with the debugger - but I seem to be going around in circles.

Thanks, Rob

</newbieAlert>

_______________________________________________
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: Shawn Erickson <email@hidden>
  • Prev by Date: AUBufferList::CopyBufferContentsTo()
  • Next by Date: Re: Thread count strangeness using PlayAudioFile sample code
  • Previous by thread: Re: AUBufferList::CopyBufferContentsTo()
  • Next by thread: Re: Thread count strangeness using PlayAudioFile sample code
  • Index(es):
    • Date
    • Thread