Hi all,

Today's email re bug #376525 made me look at this bug again and do
a little research on the OSS ioctls. The following patch may fix the
issue.

Previously, I just set the bitwidth to 16 bits, without specifying
the endian-ness. My suspicion is that OSS and the ALSA behave slightly
differently when I just specify 16 bits.

To fix this issue, this patch, sets 16 bits with the endian-ness of
the host CPU.

I'll be testing this on my ancient banged up ibook as soon as I
get it up and running again. If anyone else wants to play with
this, please do.

Erik

--- examples/sndfile-play.c.old
+++ examples/sndfile-play.c
@@ -406,7 +406,7 @@
 
 static int
 linux_open_dsp_device (int channels, int srate)
-{      int fd, stereo, temp, error ;
+{      int fd, stereo, fmt, error ;
 
        if ((fd = open ("/dev/dsp", O_WRONLY, 0)) == -1 &&
                (fd = open ("/dev/sound/dsp", O_WRONLY, 0)) == -1)
@@ -426,11 +426,11 @@
                exit (1) ;
                } ;
 
-       temp = 16 ;
-       if ((error = ioctl (fd, SOUND_PCM_WRITE_BITS, &temp)) != 0)
-       {       perror ("linux_open_dsp_device : bitwidth ") ;
-               exit (1) ;
-               } ;
+       fmt = CPU_IS_BIG_ENDIAN ? AFMT_S16_BE : AFMT_S16_LE ;
+       if (ioctl (fd, SOUND_PCM_SETFMT, &fmt))
+       {       perror ("linux_open_dsp_device : set format ") ;
+           exit (1) ;
+               } ;
 
        if ((error = ioctl (fd, SOUND_PCM_WRITE_CHANNELS, &channels)) != 0)
        {       perror ("linux_open_dsp_device : channels ") ;





-- 
+-----------------------------------------------------------+
  Erik de Castro Lopo
+-----------------------------------------------------------+
"It's not that perl programmers are idiots, it's that the
language rewards idiotic behavior in a way that no other
language or tool has ever done." --  Erik Naggum
-- 
+-----------------------------------------------------------+
  Erik de Castro Lopo
+-----------------------------------------------------------+
"Attacks by Microsoft Chairman Bill Gates on the GNU General
Public License, under which much open source and free software is
distributed, have been driven by a fear that the GPL creates a
domain of software that Microsoft cannot privatize and control"
   -- Richard Stallman


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to