sound output for *BSD and Solaris


git-svn-id: http://svn.xiph.org/trunk/speex@4932 0101bb08-14d6-0310-b084-bc0e0c8e3800
diff --git a/TODO b/TODO
index 12a1a53..ab48069 100644
--- a/TODO
+++ b/TODO
@@ -1,17 +1,17 @@
 Features
 -Add maximum/minimum bit-rate control for VBR
 -Get the encoder to use the rate of packet loss (more conservative pitch gains)
+-Implement "packet terminator" with no overhead
+-Improve error handling (with perror-like call?)
 
 Long-term quality improvements
 -Improve perceptual enhancement (including wideband)
 
 Standards
-*Complete Speex RTP profile
+-Complete Speex RTP profile
 -MIME type registration
 -MS ACM wrapper
 
-*required for 1.0
-
 ideas:
 Peelable stream (double codebook, higher bands, stereo)
 LPC from spectral domain
diff --git a/configure.in b/configure.in
index 59f029f..6c7bbe8 100644
--- a/configure.in
+++ b/configure.in
@@ -26,7 +26,7 @@
 AM_PROG_LIBTOOL
 
 AC_C_BIGENDIAN
-AC_CHECK_HEADERS(sys/soundcard.h)
+AC_CHECK_HEADERS(sys/soundcard.h sys/audioio.h)
 
 AC_ARG_ENABLE(ogg,
       [  --enable-ogg=[yes/no]    Turn on or off the use of ogg
diff --git a/src/speexdec.c b/src/speexdec.c
index 6b3c813..7584baa 100644
--- a/src/speexdec.c
+++ b/src/speexdec.c
@@ -56,6 +56,16 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <sys/ioctl.h>
+
+#elif defined HAVE_SYS_AUDIOIO_H
+#include <sys/types.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <sys/audioio.h>
+#ifndef AUDIO_ENCODING_SLINEAR
+#define AUDIO_ENCODING_SLINEAR AUDIO_ENCODING_LINEAR /* Solaris */
+#endif
+
 #endif
 
 #include <string.h>
@@ -167,6 +177,31 @@
          exit(1);
       }
       fout = fdopen(audio_fd, "w");
+#elif defined HAVE_SYS_AUDIOIO_H
+      audio_info_t info;
+      int audio_df;
+      
+      audio_fd = open("/dev/audio", O_WRONLY);
+      if (audio_fd<0)
+      {
+         perror("Cannot open /dev/audio");
+         exit(1);
+      }
+
+      AUDIO_INITINFO(&info);
+#ifdef AUMODE_PLAY    /* NetBSD/OpenBSD */
+      info.mode = AUMODE_PLAY;
+#endif
+      info.play.encoding = AUDIO_ENCODING_SLINEAR;
+      info.play.precision = 16;
+      info.play.channels = *channels;
+      
+      if (ioctl(audio_fd, AUDIO_SETINFO, &info) < 0)
+      {
+         perror ("AUDIO_SETINFO");
+         exit(1);
+      }
+      fout = fdopen(audio_fd, "w");
 #elif defined WIN32 || defined _WIN32
       {
          unsigned int speex_channels = *channels;