Re: Question about CoreAudio and threading
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