LinuxQuestions.org
Review your favorite Linux distribution.
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 09-15-2004, 10:11 AM   #1
don_pingu
Member
 
Registered: May 2003
Distribution: slackware-current
Posts: 34

Rep: Reputation: 15
Alsa capturing buffer underruns


Hi,

I'm trying to write a simple alsa/gtk recording application in C that will record directly to an Ogg Vorbis file. (originally intended for recording my own dj sets)

It sort of "works" already. But I can't use the real-time scheduling when not running as root. It runs great as root, but as a normal user with normal scheduling I always get buffer underruns.

You can get the source at http://www.student.kuleuven.ac.be/~m...-0.0.3.tar.bz2

Capturing is done in capt_alsa.c (capture_auto)

I've looked into asynchroneous capturing which might be the answer, but I couldn't find enough documentation to figure it out myself.

This is my first C application to span more than a file or two, so any other suggestion welcome too

Thanks

Last edited by don_pingu; 09-16-2004 at 10:05 AM.
 
Old 09-15-2004, 10:32 AM   #2
don_pingu
Member
 
Registered: May 2003
Distribution: slackware-current
Posts: 34

Original Poster
Rep: Reputation: 15
Erm, of course I'm talking about buffer OVERruns causing dropped samples Sorry about that.
 
Old 09-15-2004, 04:27 PM   #3
vasudevadas
Member
 
Registered: Jul 2003
Location: Bedford, UK
Distribution: Slackware 11.0, LFS 6.1
Posts: 519

Rep: Reputation: 30
I'm surprised to hear you're getting overruns. I wrote a program to play back modfiles and I never get buffer underruns, whether I have realtime scheduling priorities or not. Even if I'm compiling a kernel at the same time! And my program is seriously inefficient too.

When you say it records directly to an Ogg Vorbis, how have you implemented that? Do you write it as a wav (or equivalent) first and then run oggenc on it? (The obvious, and probably sensible way).
 
Old 09-16-2004, 10:00 AM   #4
don_pingu
Member
 
Registered: May 2003
Distribution: slackware-current
Posts: 34

Original Poster
Rep: Reputation: 15
No no, I just use libvorbis and feed it the captured stream through a FIFO buffer. The whole idea is to save time (for having to encode it afterwards) and space (for the temporary wave).

Works great, but there's a problem with the capturing as I said. Appearently I can't get the capturing thread to make the snd_pcm_readi call in time (before the hardware (?) buffer is full). I'm using two threads besides the main one, one for capturing, one for encoding. Take a look at the source code if you like.

All help appreciated.
 
  


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
Best Capturing tool. mayankjohri Linux - Enterprise 0 01-30-2005 03:12 PM
Burning Linux Problems with Buffer underruns Rawr101 Linux - Software 1 10-30-2004 11:38 PM
Screen Capturing monohouse Linux - Software 3 10-30-2004 11:14 AM
Capturing X Events phrontist Linux - Software 1 10-28-2004 08:56 AM
Capturing video with Cinelerra works, capturing video with Xawtv doesn't! seaelf Slackware 0 06-27-2004 05:18 PM


All times are GMT -5. The time now is 01:46 AM.

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