Skip to contentSkip to conversation

Patch for AOSS

PATCH Mike Hearn 2 participants 2 messages Apr 4, 2005 – Apr 5, 2005

lore
Share & tools
lore

Mike Hearn

author
#0 lore raw

Hi,

The following patch makes SOX work with the "aoss" program.

Unfortunately I originally wanted aoss for a game, zap! (www.zapthegame.com) so I could listen to music using XMMS at the same time as playing, but aoss+dmix introduces far too much latency for that. It's on the order of a second or two for some reason. Do you know of any fix?

[mike@littlegreen Zap-v1.166.0]$ cat /proc/asound/cards
0 [SI7012 ]: ICH - SiS SI7012

                     SiS SI7012 at 0xdc00, irq 11

thanks -mike

alsa-oss.c 2005-02-13 00:02:37.710981560 +0000 renamed from alsa-oss.c~ 2004-09-13 17:07:57.000000000 +0100 +35 -24
@@ -62,6 +62,10 @@
 #endif
 #endif
 
+#ifndef O_LARGEFILE
+#define O_LARGEFILE 0100000
+#endif
+
 int (*_select)(int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout);
 int (*_poll)(struct pollfd *ufds, unsigned int nfds, int timeout);
 int (*_open)(const char *file, int oflag, ...);
@@ -689,32 +693,28 @@
 
 #include "stdioemu.c"
 
-FILE *fopen(const char* path, const char *mode) {
-
+FILE *fopen(const char* path, const char *mode)
+{
        if (!initialized)
                initialize();
 
        if(!is_dsp_device(path)) 
                return _fopen (path, mode);
        
-       return fake_fopen(path, mode);
+       return fake_fopen(path, mode, 0);
+}
+
+FILE *fopen64(const char* path, const char *mode)
+{
+       if (!initialized)
+               initialize();
+
+       if(!is_dsp_device(path)) 
+               return _fopen (path, mode);
+
+       return fake_fopen(path, mode, O_LARGEFILE);
 }
 
-#if 1
-# define strong_alias(name, aliasname) \
-  extern __typeof (name) aliasname __attribute__ ((alias (#name)));
-strong_alias(open, __open);
-strong_alias(close, __close);
-strong_alias(write, __write);
-strong_alias(read, __read);
-strong_alias(ioctl, __ioctl);
-strong_alias(fcntl, __fcntl);
-strong_alias(mmap, __mmap);
-strong_alias(munmap, __munmap);
-strong_alias(poll, __poll);
-strong_alias(select, __select);
-strong_alias(fopen, __fopen);
-#else
 int dup(int fd)
 {
        return fcntl(fd, F_DUPFD, 0);
@@ -742,10 +742,6 @@
        return fcntl(fd, F_DUPFD, fd2);
 }
 
-#ifndef O_LARGEFILE
-#define O_LARGEFILE 0100000
-#endif
-
 int open64(const char *file, int oflag, ...)
 {
        va_list args;
@@ -758,10 +754,25 @@
        }
        return open(file, oflag | O_LARGEFILE, mode);
 }
-#endif
 
-static void initialize() __attribute__ ((constructor));
+# define strong_alias(name, aliasname) \
+  extern __typeof (name) aliasname __attribute__ ((alias (#name)));
+
+strong_alias(open, __open);
+strong_alias(open64, __open64);
+strong_alias(close, __close);
+strong_alias(write, __write);
+strong_alias(read, __read);
+strong_alias(ioctl, __ioctl);
+strong_alias(fcntl, __fcntl);
+strong_alias(mmap, __mmap);
+strong_alias(munmap, __munmap);
+strong_alias(poll, __poll);
+strong_alias(select, __select);
+strong_alias(fopen, __fopen);
+strong_alias(fopen64, __fopen64);
 
+/* called by each override if needed */
 static void initialize()
 {
        char *s = getenv("ALSA_OSS_DEBUG");
stdioemu.c 2005-02-12 23:26:28.000000000 +0000 renamed from stdioemu.c~ 2004-06-25 17:26:51.000000000 +0100 +7 -6
@@ -1,4 +1,4 @@
-    /*
+/*
 
     Copyright (C) 2000 Stefan Westerfeld
                        [email protected]
@@ -18,7 +18,8 @@
     the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
     Boston, MA 02111-1307, USA.
 
-    */
+    Modified to add support for 64 bit fopen by Mike Hearn <[email protected]>
+*/
 
 /*
  * This source only exists because some very special programs think that
@@ -67,7 +68,7 @@
        return result;
 }
 
-static FILE *fake_fopen(const char *path, const char *mode)
+static FILE *fake_fopen(const char *path, const char *mode, int flags)
 {
        cookie_io_functions_t fns = { fdc_read, fdc_write, fdc_seek, fdc_clean };
        struct fd_cookie *fdc =
@@ -83,9 +84,9 @@
                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 == 1) fdc->fd = open(path, O_RDONLY | flags, 0666);
+       if(open_mode == 2) fdc->fd = open(path, O_WRONLY | flags, 0666);
+       if(open_mode == 3) fdc->fd = open(path, O_RDWR | flags, 0666);
 
        if(open_mode && fdc->fd > 0)
        {

-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click

#1 lore raw
Quoted 3 lines · Mike Hearn

Hi,

The following patch makes SOX work with the "aoss" program.

Thanks. Applied to CVS.

Quoted 5 lines

Unfortunately I originally wanted aoss for a game, zap! (www.zapthegame.com) so I could listen to music using XMMS at the same time as playing, but aoss+dmix introduces far too much latency for that. It's on the order of a second or two for some reason. Do you know of any fix?

You may try to force some lower values in SNDCTL_DSP_SETFRAGMENT (alsa-oss/alsa/pcm.c). It seems that the OSS ring buffer is too large. Perhaps, having an environment variable allowing to force the ring buffer size would be nice.

Jaroslav

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

-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click