• 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: Notification after AudioDeviceStart
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Notification after AudioDeviceStart


  • Subject: Re: Notification after AudioDeviceStart
  • From: Jeff Moore <email@hidden>
  • Date: Mon, 18 Apr 2005 12:13:06 -0700

I'm not sure I understand the question. The HAL provides notifications for when the various properties of a given AudioObject change. This is not your IOProc, however. It has to be a different function since both the tread context in which it is called and the information that needs to be passed to it are very different.

You can safely call AudioDeviceStop() from any listener proc. In fact, you can safely call AudioDeviceStop() from anywhere.

If you are asking how can you tell your IOProc to do something from another thread, then that's really a problem for your app to solve. I see someone else just posted a question about lockless queues. Such a data structure would be a great way to message your IOProc. There are other ways too.

Another way I've seen work is to use a message queue that has a mutex associated with it. Whenever you want to send your IOProc a message, you lock the mutex, add the message to the queue and unlock the mutex. In your IOProc, you need to be a bit careful when fetching messages from the queue since blocking is a very bad thing to do. So, when you lock the mutex to read from the queue, you do so using pthread_mutex_trylock(). This call will lock the mutex if it is free, otherwise, it will return immediately with an error code of EBUSY. If the IOProc can't lock the mutex, it doesn't process any messages for that cycle. Otherwise it processes as many messages as it wants and unlocks the mutex when it is done.

This scheme has the advantage of being easy to code. It has the disadvantage of messages not being handled immediately.

Hope this helps.

On Apr 17, 2005, at 1:26 AM, Gerald Hanks wrote:

I have an application that I would like to be notified if certain conditions change after calling AudioDeviceStart(device, appIOProc); Basically, while playing the audio, things could change such that I would like to be able to programmatically call AudioDeviceStop(device, appIOProc)

How can I set up a notification in my appIOProc callback so that I can notify myself if certain conditions occur?


--

Jeff Moore
Core Audio
Apple


_______________________________________________ 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
References: 
 >Notification after AudioDeviceStart (From: Gerald Hanks <email@hidden>)

  • Prev by Date: Re: AC3/ DTS play-through
  • Next by Date: re: thread-safe FIFO queue
  • Previous by thread: thread-safe FIFO queue
  • Next by thread: kAUGraphErr_NodeNotFound SOLVED
  • Index(es):
    • Date
    • Thread