• 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: Question about CoreAudio and threading
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Question about CoreAudio and threading


  • Subject: Re: Question about CoreAudio and threading
  • From: Paul Davis <email@hidden>
  • Date: Sun, 08 May 2011 15:48:22 -0400

the simplest solution to this (rather common) problem is to use double
buffering with an atomic swap.

there should be two buffers to hold FFT data, preferably in a element
array of pointers, plus an index that tells you which buffer to use
for the view. you start with the index set to 1, so that the the
rendering thread (we'll get back to that) writes into buffer[0] and
the view reads buffer[1] (which will be empty). once the rendering
thread has completed a write, atomically flip the index to 1, and the
next time(s) that the view goes to read, it will get buffer[0] and the
rendering thread will write to buffer[1]. the view never modifies the
index, so its possible that it may sometimes grab the same buffer
twice (if it is naive).

note that you should not really be computing FFT data in the rendering
thread, but i'm not in the right frame of mind to get into that here.
 _______________________________________________
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: Question about CoreAudio and threading
      • From: Per Bull Holmen <email@hidden>
References: 
 >Question about CoreAudio and threading (From: Per Bull Holmen <email@hidden>)

  • Prev by Date: Re: Getting and setting the play time on a DefaultOutputUnit
  • Next by Date: Re: Question about CoreAudio and threading
  • Previous by thread: Question about CoreAudio and threading
  • Next by thread: Re: Question about CoreAudio and threading
  • Index(es):
    • Date
    • Thread