All of lore.kernel.org
 help / color / mirror / Atom feed
* Possible solution for the alsa-oss fopen problem.
@ 2004-06-09 11:10 James Courtier-Dutton
  2004-06-09 11:33 ` Jaroslav Kysela
  2004-06-10 12:09 ` Florian Schmidt
  0 siblings, 2 replies; 5+ messages in thread
From: James Courtier-Dutton @ 2004-06-09 11:10 UTC (permalink / raw)
  To: ALSA development

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2004-06-10 12:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-06-09 11:10 Possible solution for the alsa-oss fopen problem James Courtier-Dutton
2004-06-09 11:33 ` Jaroslav Kysela
2004-06-09 11:56   ` James Courtier-Dutton
2004-06-10 12:09 ` Florian Schmidt
2004-06-10 12:49   ` James Courtier-Dutton

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.