• 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: Audio stuttering under CPU load
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Audio stuttering under CPU load


  • Subject: Re: Audio stuttering under CPU load
  • From: "Paul Sanders" <email@hidden>
  • Date: Wed, 10 Feb 2010 19:49:07 -0000

Bertrand, Pierre-Luc wrote:


> Now I only lock to signal the processing thread to start
> processing a
> chunk of 800ms.


Well, I can't really comment on your code because I can't see
it, but the way I play audio is this (and it doesn't stutter):

1.  In the processing thread - i.e. the thread preparing the
audio to be streamed - I fill buffers and put them on a queue.
When the queue reaches a certain length, I stall.

2.  In the IOProc, I pull buffers from the queue until I have
filled the output buffer passed to me by CoreAudio.  Then I
return, remembering the fact that I am part-way through an input
buffer.  Each time I consume an input buffer, I signal the
processing thread (I use my own, posix-based primitives for
this, but I'm sure there are other ways).

3.  *Absolutely* no mallocs in the IOProc.  This includes
instantiating any Cocoa objects (obviously) and, I imagine,
calling NSLog.  I found with even one malloc in there, I got the
occasional hiccup.

You can do quite a lot of processing in an IOProc.  I resample
the audio, which is quite heavyweight.  The key is to be
deterministic about it (i.e. never exceeed a certain amount of
time, per buffer-full), and resampling fits that constraint.

HTH - Paul Sanders.




 _______________________________________________
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: Audio stuttering under CPU load
      • From: "Bertrand, Pierre-Luc" <email@hidden>
References: 
 >Audio stuttering under CPU load (From: "Bertrand, Pierre-Luc" <email@hidden>)
 >Re: Audio stuttering under CPU load (From: Doug Wyatt <email@hidden>)
 >RE: Audio stuttering under CPU load (From: "Bertrand, Pierre-Luc" <email@hidden>)
 >Re: Audio stuttering under CPU load (From: "Ross Bencina" <email@hidden>)
 >RE: Audio stuttering under CPU load (From: "Bertrand, Pierre-Luc" <email@hidden>)

  • Prev by Date: Re: ExtAudioFileConvert.cpp: can I get rid of mutex and thread handling?
  • Next by Date: RE: Audio stuttering under CPU load
  • Previous by thread: RE: Audio stuttering under CPU load
  • Next by thread: RE: Audio stuttering under CPU load
  • Index(es):
    • Date
    • Thread