Skip to contentSkip to conversation

Possible solution for the alsa-oss fopen problem.

DISCUSSION James Courtier-Dutton 3 participants 5 messages Jun 9, 2004 – Jun 10, 2004

lore
Share & tools
lore
#0 lore raw

I have found out that the artsdsp /dev/oss redirector supports fopen and friends. I looked at the artsdsp, (find it inside arts-1.2.2.tar.bz2)
It uses a function called fopencookie()

Extract from /arts-1.2.2/artsc/stdioemu.c below.

Would this be useable in the alsa-oss redirector?

Cheers
James

static FILE *fake_fopen(const char *path, const char *mode) {
cookie_io_functions_t fns = { fdc_read, fdc_write, fdc_seek,

fdc_clean };
        struct fd_cookie *fdc =
                (struct fd_cookie *)malloc(sizeof(struct fd_cookie));
        const char *mptr;
        int open_mode = 0;
        FILE *result = 0;

        for(mptr = mode; *mptr; mptr++)
        {
                if(*mptr == 'r') open_mode |= 1; /* 1 = read */
                if(*mptr == 'w') open_mode |= 2; /* 2 = write */
                if(*mptr == '+') open_mode |= 3; /* 3 = readwrite */
                if(*mptr == 'a') open_mode |= 2; /* append -> write */
        }
        if(open_mode == 1) fdc->fd = open(path,O_RDONLY,0666);
        if(open_mode == 2) fdc->fd = open(path,O_WRONLY,0666);
        if(open_mode == 3) fdc->fd = open(path,O_RDWR,0666);

        if(open_mode && fdc->fd > 0)
        {
                result = fopencookie (fdc,"w", fns);
                result->_fileno = fdc->fd;              /* ugly patchy 
slimy kludgy hack */
        }
        return result;
}

-------------------------------------------------------
This SF.Net email is sponsored by: GNOME Foundation
Hackers Unite! GUADEC: The world's #1 Open Source Desktop Event. GNOME Users and Developers European Conference, 28-30th June in Norway
http://2004/guadec.org

#1 lore raw
Quoted 3 lines · James Courtier-Dutton

I have found out that the artsdsp /dev/oss redirector supports fopen and friends. I looked at the artsdsp, (find it inside arts-1.2.2.tar.bz2) It uses a function called fopencookie()

Does it work for sox and teamspeak?

Jaroslav

-----
Jaroslav Kysela <[email protected]>
Linux Kernel Sound Maintainer
ALSA Project, SuSE Labs

-------------------------------------------------------
This SF.Net email is sponsored by: GNOME Foundation
Hackers Unite! GUADEC: The world's #1 Open Source Desktop Event. GNOME Users and Developers European Conference, 28-30th June in Norway
http://2004/guadec.org

#2 lore raw
Quoted 12 lines · Jaroslav Kysela
Quoted 3 lines · James Courtier-Dutton

I have found out that the artsdsp /dev/oss redirector supports fopen and friends. I looked at the artsdsp, (find it inside arts-1.2.2.tar.bz2) It uses a function called fopencookie()

Does it work for sox and teamspeak?

Jaroslav

I don't use KDE, so I can't really test it.
I just heard someone say on irc "It works on artsdsp, but not aoss" I can't remember which app "It" was.

Has anyone created a test app that uses fopen and friends so that testing these features would be easier?

Cheers
James

-------------------------------------------------------
This SF.Net email is sponsored by: GNOME Foundation
Hackers Unite! GUADEC: The world's #1 Open Source Desktop Event. GNOME Users and Developers European Conference, 28-30th June in Norway
http://2004/guadec.org

#3 lore raw
In reply to James Courtier-Dutton
Quoted 8 lines · On Wed, 09 Jun 2004 12:10:45 +0100 James Courtier-Dutton…

I have found out that the artsdsp /dev/oss redirector supports fopen and friends.
I looked at the artsdsp, (find it inside arts-1.2.2.tar.bz2) It uses a function called fopencookie()

Extract from /arts-1.2.2/artsc/stdioemu.c below.

Would this be useable in the alsa-oss redirector?

This fopencookie seems to be a libc thing to implement custom streams.. See

http://wwwwbs.cs.tu-berlin.de/user-taipan/kraxel/gnuinfo/libc/Streams_and_Cookies.html

Might be exctly the thing which is needed to intercept fopen() and friends AND handle the intercepted calls gracefully..

I have a question though: If this works for alsa-oss, then the libc problem with the internal symbols of open() and friends is solved. But i wonder if there are any other libs which are as "evil" in this regard as libc is. The basic problem persists: If a lib uses internal symbols for open() and friends and an app uses that lib to access /dev/dsp, etc., then we're screwed again..

On the other hand: How many libs besides libc do stuff like this? And how many apps use such a lib? I would guess: very very few.. If this is the case, i suppose it will work well (tm)

Florian Schmidt

Signature · 9 lines
Palimm Palimm!



-------------------------------------------------------
This SF.Net email is sponsored by: GNOME Foundation
Hackers Unite!  GUADEC: The world's #1 Open Source Desktop Event.
GNOME Users and Developers European Conference, 28-30th June in Norway
http://2004/guadec.org
#4 lore raw
Quoted 17 lines · Florian Schmidt
Quoted 7 lines · On Wed, 09 Jun 2004 12:10:45 +0100 James Courtier-Dutton…

I have found out that the artsdsp /dev/oss redirector supports fopen and friends. I looked at the artsdsp, (find it inside arts-1.2.2.tar.bz2)
It uses a function called fopencookie()

Extract from /arts-1.2.2/artsc/stdioemu.c below.

Would this be useable in the alsa-oss redirector?

This fopencookie seems to be a libc thing to implement custom streams.. See

http://wwwwbs.cs.tu-berlin.de/user-taipan/kraxel/gnuinfo/libc/Streams_and_Cookies.html

Quoted 8 lines

Might be exctly the thing which is needed to intercept fopen() and friends AND handle the intercepted calls gracefully..

I have a question though: If this works for alsa-oss, then the libc problem with the internal symbols of open() and friends is solved. But i wonder if there are any other libs which are as "evil" in this regard as libc is. The basic problem persists: If a lib uses internal symbols for open() and friends and an app uses that lib to access /dev/dsp, etc., then we're screwed again..

On the other hand: How many libs besides libc do stuff like this? And how many apps use such a lib? I would guess: very very few.. If this is the case, i suppose it will work well (tm)

Florian Schmidt

Does anyone have a small test app that uses fopen and friends, so that I could test them if I add fopencookie() to aoss.

Hopefully, the test app should use the fopen and friends calls in the same way that know "problem" apps use.

If there is not a test app out there, can someone please tell me more details about the problem, so that I could build a test app myself.

I need to know which fcalls lead to a failure, so that if I get those fcalls working, these "problem" apps will be guaranteed to work.

Cheers
James

-------------------------------------------------------
This SF.Net email is sponsored by: GNOME Foundation
Hackers Unite! GUADEC: The world's #1 Open Source Desktop Event. GNOME Users and Developers European Conference, 28-30th June in Norway
http://2004/guadec.org