[LAD] Real-time plotting of audio/ oscilloscope.

David Olofson david at olofson.net
Fri Jun 18 00:37:20 UTC 2010


On Friday 18 June 2010, at 02.09.43, Jeremy <jeremybubs at gmail.com> wrote:
[...]
> After doing some more experimenting, I realize that SDL does not in fact
> cause any xruns if I don't ask it to refresh.

Of course. Depending on how you set up the SDL display, the pixel plotting may 
actually just be raw memory access in a system RAM shadow buffer. No 
scheduling/xrun issues with that, obviously. Refreshing, however, is where the 
real work is done. Whether you're using SDL or the underlying APIs directly is 
of no relevance here.

Realistically, for reliable operation in your average environment (X11, 
Windows GDI, whatever...), there is only one solution: You need to move the 
plotting into a separate thread. Could be a global GUI thread. What's critical 
is that it's NOT the audio thread.

You may get away with just passing the coordinates (or raw samples) from the 
audio thread to the rendering thread via a shared buffer, but the proper, 
solid solution is to pass it in some synchronized manner, preferably lock-
free.


-- 
//David Olofson - Developer, Artist, Open Source Advocate

.--- Games, examples, libraries, scripting, sound, music, graphics ---.
|  http://olofson.net   http://kobodeluxe.com   http://audiality.org  |
|  http://eel.olofson.net  http://zeespace.net   http://reologica.se  |
'---------------------------------------------------------------------'



More information about the Linux-audio-dev mailing list