LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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-24-2004, 05:00 PM   #1
sibtay
Member
 
Registered: Aug 2004
Location: U.S
Distribution: Ubuntu
Posts: 145

Rep: Reputation: 15
Force opening of /dev/audio


Hi,

I am developing a real time application

I open /dev/audio with this command

int fd=open("/dev/audio",O_WRONLY);

sometimes it opens in the first attempt but most of the time
the opening fails...so currently i m using this code to open the device

while (fd < 0 )
{
fd=open("/dev/audio",O_WRONLY);

}

it does work but mostly it takes a very long time (more than a minute)...
to open this device. (i know the reason i.e. cz of that loop).

Is there any method available through which i could open this device for writing (playing) on first attempt

I would like to mention that currently i am using to ioctl() call for any purpose

Thank you

Last edited by sibtay; 09-24-2004 at 05:04 PM.
 
Old 09-24-2004, 05:40 PM   #2
rjlee
Senior Member
 
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,994

Rep: Reputation: 76
The first thing you need to do is find out why the call is failing. #include errno.h and string.h, and set errno = 0 before the call to open(). Then, if the open() fails, call something like printf("%s\n",strerror(errno));

You'll find a list of possible errors, and what they mean, in the man-page for open
Code:
man 2 open
Hope that's of some help,

— Robert J. Lee
 
  


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
/dev/audio not there? Weirdofreak Mandriva 2 09-09-2004 11:39 AM
How can I force audio cd's to automatically launch and run in xmms? corso64 Linux - Newbie 1 08-29-2004 12:44 AM
An error occurred opening /dev/audio (RedHat 9) mjkchi Linux - Hardware 2 05-04-2004 11:11 PM
OSS API - opening /dev/dsp when device busy vasudevadas Programming 10 12-02-2003 12:11 PM
Arts: error while opening /dev/dsp (after make modules_install) mep]-[isto Linux - Newbie 5 11-28-2003 11:51 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration