LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 08-12-2008, 02:21 PM   #1
tanoatlq
Member
 
Registered: Mar 2007
Posts: 157

Rep: Reputation: 30
latency and audio programming in real-time


Hello,
I am not an expert about real-time programming issues, so I am here :-)
Suppose I have to play audio while displaying some stuff on the screen, and
that this displaying should go in time with the audio output. Now, my tools
to achieve this task is libsdl and alsa (I cannot use libsdl audio for various reasons),
however I would like to maintain discussion abstract from my solutions. From
what I read the best thing to do to avoid latency problem is run the code that
should output audio in a separate thread, but how to sync what I have to display
on the screen? I.e. how can other threads know how many samples were flushed
to audio output stream? I think a simple variable should solve (Perhaps this var
could even not need to be protected from race courses, because only the audio
thread update it, while the others read it only, isn't it?).
Any suggestion or papers?
Thanks,
tano
 
Old 08-12-2008, 02:38 PM   #2
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,536

Rep: Reputation: 148Reputation: 148
Most people would not synchronize it, just assume that when then started at the same time and the environment is more or less real-time, their latencies will be also the same. That may lead, of course, to problems.

Variable is a good idea, with atomic read/write operations it will be also very fast and protected from races (if you haven't used variables with atomic operations before, you may want to read more about them, but that's really simple: just a variable that is modified always in one step - there are special functions to perform such operations). You may set the variable in one thread and check it from time to time in the other one and re-synchronize if needed.
 
Old 08-12-2008, 05:01 PM   #3
tanoatlq
Member
 
Registered: Mar 2007
Posts: 157

Original Poster
Rep: Reputation: 30
Thanks! I will do another question more specific about the atomicity issue when
I will end studying the subject.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Real Time Clock & Real Time Timer jiramak Linux - Newbie 1 09-05-2007 06:43 PM
LXer: Real-time garbage collection with Real-time Java LXer Syndicated Linux News 0 05-05-2007 12:16 PM
LXer: Real-time Linux gains real-time JVM LXer Syndicated Linux News 0 10-12-2006 10:54 AM
Real Time Programming cyberX Ubuntu 3 09-04-2006 10:19 AM
Real-Time programming javpogon Programming 5 09-04-2003 08:25 AM


All times are GMT -5. The time now is 11:48 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration