[Mplayer-dev-eng] A few more fixes for today's CVS version

Juergen Keil jk at tools.de
Fri Jun 8 13:09:02 CEST 2001


Hi,

there are some minor issues after recent check-ins to the mplayer CVS version:


1. compiling on linux with old kernel header (2.2.16) fails, due to the use
   of 32-bit AFMT_S32_* defines in libao2/audio_out.c
  
   As far as I can tell, the 32-bit sample formats are not used inside mplayer,
   so it probably would not harm to check the availability of the AFMT_S32*
   with an #ifdef and just report them as an "Unknown" format, if these
   formats are not defined by sys/soundcard.h
   
   
2. compiling the same file (audio_out.c) on solaris fails, because the
   #ifdef USE_OSS_AUDIO around the include of sys/soundcard.h was removed.
   
   Of cause that will fail on all platforms that do not have the
   sys/soundcard.h header  (netbsd/openbsd/solaris).  
   
   Hmm, the CVS log entry for revision 1.7 by author al3x says
   
     par kozmetikai valtoztatas, meg van ami nem :) cvs diff..
     
   Unfortunatelly I don't understand that language (hungarian?), so I 
   can only guess.  My guess would be, that the change was intended just a
   "cosmetic change or cleanup of the source".  But I could be totally wrong
   and the #ifdef was removed due to build problems on some linux release...
   
   
   Thinking about it, the sys/soundcard.h header seems to be used for 
   two reasons:
   
   In mixer.c and libao2/ao_*.c it's used to actually talk to the audio device
   using the OSS sound API.  Especially the ioctl defines are needed in this
   case.
   
   In dec_audio.c and libao2/audio_out.c it's just used to get the AFMT_*
   defines to store information about the type of audio encoding used in a
   video's audio stream.
   
   In the first case, the use of a CPP define that enables a sound driver
   in the libao2 lib is appropriate (i.e. USE_OSS_AUDIO, USE_SUN_AUDIO,
   HAVE_ALSA5, HAVE_ALSA9, HAVE_ESD or HAVE_SDL).
   
   But for the second case (just to get the AFMT_* define) it's not
   appropriate to check if the OSS driver is enabled (in the libao2 lib).  We
   should probably just check for the availability of the header file
   sys/soundcard.h in the configure script and define something like
   HAVE_SYS_SOUNDCARD_H if it's present and use that define to protect the
   #include of sys/soundcard.h
   
   Comments?



Some other changes I've made:

3. NetBSD and OpenBSD implement the sun style audio interface, but the
   configure script does not detect this fact any more.  Solution is to
   include sys/types.h in addition to sys/audioio.h in the configure script
   for the _sun_audio test.

4. recent inclusion of network.c in the compilation if mplayer needs an
   additional library for solaris (libnsl, for gethostbyname).  I've updated
   the tests in configure.
   
5. translation of OSS sample formats to sun style sample encoding in
   dec_audio.c should be moved to the libao2/ao_sun.c sound driver.
 
--
Jürgen Keil          		jk at tools.de
Tools GmbH			+49 (228) 9858011
-------------- next part --------------
Index: configure
===================================================================
RCS file: /cvsroot/mplayer/main/configure,v
retrieving revision 1.77
diff -u -B -r1.77 configure
--- configure	2001/06/06 21:16:21	1.77
+++ configure	2001/06/08 08:45:56
@@ -573,9 +573,10 @@
 
 # ----------- Check X11 and related libs (GL, Xxf86vm, Xv, DGA) --------------
 
-# for Solaris:
+# for Solaris (socket stuff is in -lsocket, gethostbyname and friends in -lnsl):
 _socklib=
-$_cc $TMPC -o $TMPO -lsocket >/dev/null 2>&1 && _socklib=-lsocket
+$_cc $TMPC -o $TMPO $_socklib -lsocket >/dev/null 2>&1 && _socklib="$_socklib -lsocket"
+$_cc $TMPC -o $TMPO $_socklib -lnsl >/dev/null 2>&1 && _socklib="$_socklib -lnsl"
 
 if [ $_x11 = auto ]; then
   _x11=no
@@ -632,6 +633,15 @@
 
 cat > $TMPC << EOF
 #include <sys/soundcard.h>
+int main( void ) { return 0; }
+EOF
+
+_sys_soundcard_h=no
+$_cc -o $TMPO $TMPC 2> /dev/null && _sys_soundcard_h=yes
+
+
+cat > $TMPC << EOF
+#include <sys/soundcard.h>
 int main( void ) {  int arg = SNDCTL_DSP_SETFRAGMENT; }
 EOF
 
@@ -640,6 +650,7 @@
 
 
 cat > $TMPC << EOF
+#include <sys/types.h>
 #include <sys/audioio.h>
 int main( void ) {  audio_info_t info; AUDIO_INITINFO(&info); }
 EOF
@@ -1150,6 +1161,13 @@
  _sunaudio='#undef USE_SUN_AUDIO'
 fi
 
+if [ "$_sys_soundcard_h" = "yes" ]; then
+ _have_soundcard_h='#define HAVE_SYS_SOUNDCARD_H 1'
+else
+ _have_soundcard_h='#undef  HAVE_SYS_SOUNDCARD_H'
+fi
+
+
 # Checking for CFLAGS
 if [ "$_profile" != "" ] || [ "$_debug" != "" ]; then
  CFLAGS="-O2 -march=$proc -mcpu=$proc $_debug $_profile"
@@ -1377,9 +1395,6 @@
    You can still change it runtime using -afm 1 (mpg123) or -afm 4 (l3codeca)*/
 $_mpg123
 
-/* AUDIO Support */
-$_ossaudio
-$_sunaudio
 
 /* XMMP support: (test code) */
 $_xmmpaudio
@@ -1398,6 +1413,10 @@
 #define OUTBURST 512
 #endif
 
+/* Define this if your system has the header file for the OSS sound interface */
+$_have_soundcard_h
+
+
 /* LIRC (remote control, see www.lirc.org) support: */
 $_lircdefs
 
@@ -1418,9 +1437,11 @@
 #define PREFIX "$_prefix"
 
 /* Audio lib drivers */
+$_ossaudio
 $_alsa5
 $_alsa9
 $_esdd
+$_sunaudio
 
 /* Enable fast OSD/SUB renderer (looks ugly, but uses less CPU power) */
 #undef FAST_OSD
Index: dec_audio.c
===================================================================
RCS file: /cvsroot/mplayer/main/dec_audio.c,v
retrieving revision 1.16
diff -u -B -r1.16 dec_audio.c
--- dec_audio.c	2001/06/05 18:40:44	1.16
+++ dec_audio.c	2001/06/08 08:45:56
@@ -4,17 +4,22 @@
 
 #include "config.h"
 
-#ifdef	USE_OSS_AUDIO
-#include <sys/soundcard.h>
-#endif
-#ifdef	USE_SUN_AUDIO
-#include <sys/types.h>
-#include <sys/audioio.h>
-#define AFMT_MU_LAW     AUDIO_ENCODING_ULAW
-#define AFMT_A_LAW      AUDIO_ENCODING_ALAW
-#define AFMT_S16_LE     AUDIO_ENCODING_LINEAR
-#define AFMT_IMA_ADPCM  AUDIO_ENCODING_DVI
-#define AFMT_U8         AUDIO_ENCODING_LINEAR8
+#ifdef	HAVE_SYS_SOUNDCARD_H
+#include <sys/soundcard.h>	/* Use the official OSS headers for AFMT_* */
+#else
+# define AFMT_MU_LAW              0x00000001
+# define AFMT_A_LAW               0x00000002
+# define AFMT_IMA_ADPCM           0x00000004
+# define AFMT_U8                  0x00000008
+# define AFMT_S16_LE              0x00000010      /* Little endian signed 16*/
+# define AFMT_S16_BE              0x00000020      /* Big endian signed 16 */
+# define AFMT_S8                  0x00000040
+# define AFMT_U16_LE              0x00000080      /* Little endian U16 */
+# define AFMT_U16_BE              0x00000100      /* Big endian U16 */
+# define AFMT_MPEG                0x00000200      /* MPEG (2) audio */
+/* 32 bit formats (MSB aligned) formats */
+# define AFMT_S32_LE              0x00001000
+# define AFMT_S32_BE              0x00002000
 #endif
 
 extern int verbose; // defined in mplayer.c
@@ -172,12 +177,8 @@
     switch(sh_audio->format){ // hardware formats:
     case 0x6:  sh_audio->sample_format=AFMT_A_LAW;break;
     case 0x7:  sh_audio->sample_format=AFMT_MU_LAW;break;
-#if !defined(__NetBSD__)
     case 0x11: sh_audio->sample_format=AFMT_IMA_ADPCM;break;
-#endif
-#if !defined(__sun) && !defined(__NetBSD__)
     case 0x50: sh_audio->sample_format=AFMT_MPEG;break;
-#endif
 //    case 0x2000: sh_audio->sample_format=AFMT_AC3;
     default: sh_audio->sample_format=(sh_audio->samplesize==2)?AFMT_S16_LE:AFMT_U8;
     }
Index: mixer.c
===================================================================
RCS file: /cvsroot/mplayer/main/mixer.c,v
retrieving revision 1.7
diff -u -B -r1.7 mixer.c
--- mixer.c	2001/06/05 18:40:44	1.7
+++ mixer.c	2001/06/08 08:45:56
@@ -6,18 +6,17 @@
 #include <unistd.h>
 
 #include "config.h"
+#include "mixer.h"
 
-#ifdef USE_OSS_AUDIO
-#include <sys/soundcard.h>
-#endif
 
-#ifdef USE_SUN_AUDIO
-#include <sys/audioio.h>
-#endif
+#if	defined(USE_OSS_AUDIO)
 
-#include "mixer.h"
+/*
+ * Mixer interface using OSS style soundcard commands.
+ */
 
-#if	defined(USE_OSS_AUDIO)
+#include <sys/soundcard.h>
+
 
 char * mixer_device=DEV_MIXER;
 int    mixer_usemaster=0;
@@ -66,8 +65,16 @@
    close( fd );
   }
 }
+
 #elif	defined(USE_SUN_AUDIO)
 
+/*
+ * Mixer interface using Sun style soundcard commands.
+ */
+
+#include <sys/audioio.h>
+
+
 char * mixer_device="/dev/audioctl";
 int    mixer_usemaster=0;
 
@@ -101,6 +108,23 @@
    close( fd );
   }
 }
+
+#else
+
+/*
+ * No usable Mixer interface selected.
+ * Just some stub routines.
+ */
+
+char * mixer_device=NULL;
+int    mixer_usemaster=0;
+
+void mixer_getvolume( float *l,float *r ){
+ *l = *r = 50.0;
+}
+void mixer_setvolume( float l,float r ){
+}
+
 #endif
 
 
Index: mplayer.c
===================================================================
RCS file: /cvsroot/mplayer/main/mplayer.c,v
retrieving revision 1.157
diff -u -B -r1.157 mplayer.c
--- mplayer.c	2001/06/07 13:22:06	1.157
+++ mplayer.c	2001/06/08 08:45:56
@@ -20,11 +20,6 @@
 #include "version.h"
 #include "config.h"
 
-#if defined(USE_OSS_AUDIO)
-#include <sys/soundcard.h>
-#elif defined(USE_SUN_AUDIO)
-#endif
-
 #if	defined(sun)
 #define	DEFAULT_CDROM_DEVICE	"/vol/dev/aliases/cdrom0"
 #else
Index: vcd_read.c
===================================================================
RCS file: /cvsroot/mplayer/main/vcd_read.c,v
retrieving revision 1.5
diff -u -B -r1.5 vcd_read.c
--- vcd_read.c	2001/06/05 18:40:44	1.5
+++ vcd_read.c	2001/06/08 08:45:56
@@ -175,7 +175,7 @@
 		      (error_field << 1);
   cdb.cdb_opaque[10] = sub_channel;
 
-  sc.uscsi_cdb = &cdb;
+  sc.uscsi_cdb = (caddr_t)&cdb;
   sc.uscsi_cdblen = 12;
   sc.uscsi_bufaddr = vcd_buf;
   sc.uscsi_buflen = 2336;
Index: DOCS/SOLARIS
===================================================================
RCS file: /cvsroot/mplayer/main/DOCS/SOLARIS,v
retrieving revision 1.3
diff -u -B -r1.3 SOLARIS
--- DOCS/SOLARIS	2001/06/06 21:20:17	1.3
+++ DOCS/SOLARIS	2001/06/08 08:45:56
@@ -1,13 +1,16 @@
 Notes for Solaris users
 =======================
 
-1. To build the package you will need GNU make (gmake, /opt/sfw/gmake), 
-native Solaris make will not work.
+1. It *only* works on Solaris x86.  It can't work on SPARC systems due to
+   the use of win32 codecs.
 
-2. For DVD support you must have the patched libcss installed. Patch:
+2. To build the package you will need GNU make (gmake, /opt/sfw/gmake), 
+   native Solaris make will not work.
+
+3. For DVD support you must have the patched libcss installed. Patch:
    http://www.tools.de/solaris/mplayer/
 
-3. Due to two bugs in solaris 8 x86,  you cannot reliably play DVDs using a
+4. Due to two bugs in solaris 8 x86,  you cannot reliably play DVDs using a
    capacity >4GB: 
 
    - The sd(7D) driver on solaris 8 x86 driver has bug when accessing a
Index: libao2/ao_sun.c
===================================================================
RCS file: /cvsroot/mplayer/main/libao2/ao_sun.c,v
retrieving revision 1.1
diff -u -B -r1.1 ao_sun.c
--- libao2/ao_sun.c	2001/06/06 19:10:47	1.1
+++ libao2/ao_sun.c	2001/06/08 08:45:57
@@ -28,6 +28,24 @@
 LIBAO_EXTERN(sun)
 
 
+#ifdef	HAVE_SYS_SOUNDCARD_H
+#include <sys/soundcard.h>
+#else
+# define AFMT_MU_LAW              0x00000001
+# define AFMT_A_LAW               0x00000002
+# define AFMT_IMA_ADPCM           0x00000004
+# define AFMT_U8                  0x00000008
+# define AFMT_S16_LE              0x00000010      /* Little endian signed 16*/
+# define AFMT_S16_BE              0x00000020      /* Big endian signed 16 */
+# define AFMT_S8                  0x00000040
+# define AFMT_U16_LE              0x00000080      /* Little endian U16 */
+# define AFMT_U16_BE              0x00000100      /* Big endian U16 */
+# define AFMT_MPEG                0x00000200      /* MPEG (2) audio */
+/* 32 bit formats (MSB aligned) formats */
+# define AFMT_S32_LE              0x00001000
+# define AFMT_S32_BE              0x00002000
+#endif
+
 #ifndef	AUDIO_PRECISION_8
 #define AUDIO_PRECISION_8  8
 #define AUDIO_PRECISION_16 16
@@ -46,6 +65,27 @@
 static int queued_bursts = 0;
 static int audio_fd=-1;
 
+// convert an OSS audio format specification into a sun audio encoding
+static int oss2sunfmt(int oss_format)
+{
+  switch (oss_format){
+  case AFMT_MU_LAW:
+    return AUDIO_ENCODING_ULAW;
+  case AFMT_A_LAW:
+    return AUDIO_ENCODING_ALAW;
+  case AFMT_S16_LE:
+    return AUDIO_ENCODING_LINEAR;
+  case AFMT_U8:
+    return AUDIO_ENCODING_LINEAR8;
+#ifdef	AUDIO_ENCODING_DVI	// Missing on NetBSD...
+  case AFMT_IMA_ADPCM:
+    return AUDIO_ENCODING_DVI;
+#endif
+  default:
+    return AUDIO_ENCODING_NONE;
+  }
+}
+
 // to set/get/query special features/parameters
 static int control(int cmd,int arg){
     switch(cmd){
@@ -76,18 +116,16 @@
   ioctl(audio_fd, AUDIO_DRAIN, 0);
 
   AUDIO_INITINFO(&info);
-  info.play.encoding = ao_format = format;
-  info.play.precision = (format==AUDIO_ENCODING_LINEAR? AUDIO_PRECISION_16:AUDIO_PRECISION_8);
+  info.play.encoding = oss2sunfmt(ao_format = format);
+  info.play.precision = (format==AFMT_S16_LE? AUDIO_PRECISION_16:AUDIO_PRECISION_8);
   info.play.channels = ao_channels = channels;
   --ao_channels;
   info.play.sample_rate = ao_samplerate = rate;
   info.play.samples = 0;
   info.play.eof = 0;
   if(ioctl (audio_fd, AUDIO_SETINFO, &info)<0)
-    printf("audio_setup: your card doesn't support %d Hz samplerate\n",rate);
-  byte_per_sec = (channels
-		  * (format==AUDIO_ENCODING_LINEAR ? 16 : 8)
-		  * rate);
+    printf("audio_setup: your card doesn't support %d channel, %s, %d Hz samplerate\n",channels,audio_out_format_name(format),rate);
+  byte_per_sec = (channels * info.play.precision * rate);
   ao_outburst=byte_per_sec > 100000 ? 16384 : 8192;
   queued_bursts = 0;
 
@@ -113,6 +151,8 @@
         return 0;
     }
 #ifdef	__svr4__
+    // remove the 0 bytes from the above ao_buffersize measurement from the
+    // audio driver's STREAMS queue
     ioctl(audio_fd, I_FLUSH, FLUSHW);
 #endif
     ioctl(audio_fd, AUDIO_DRAIN, 0);
@@ -132,6 +172,7 @@
     audio_info_t info;
 
 #ifdef	__svr4__
+    // throw away buffered data in the audio driver's STREAMS queue
     ioctl(audio_fd, I_FLUSH, FLUSHW);
 #endif
     uninit();
@@ -144,8 +185,8 @@
     ioctl(audio_fd, AUDIO_DRAIN, 0);
 
     AUDIO_INITINFO(&info);
-    info.play.encoding = ao_format;
-    info.play.precision = (ao_format==AUDIO_ENCODING_LINEAR? AUDIO_PRECISION_16:AUDIO_PRECISION_8);
+    info.play.encoding = oss2sunfmt(ao_format);
+    info.play.precision = (ao_format==AFMT_S16_LE? AUDIO_PRECISION_16:AUDIO_PRECISION_8);
     info.play.channels = ao_channels+1;
     info.play.sample_rate = ao_samplerate;
     info.play.samples = 0;
Index: libao2/audio_out.c
===================================================================
RCS file: /cvsroot/mplayer/main/libao2/audio_out.c,v
retrieving revision 1.7
diff -u -B -r1.7 audio_out.c
--- libao2/audio_out.c	2001/06/07 13:06:03	1.7
+++ libao2/audio_out.c	2001/06/08 08:45:57
@@ -5,9 +5,9 @@
 
 #include "audio_out.h"
 
-#include <sys/soundcard.h> /* AFMT_* */
-
-#ifndef SOUNCARD_H
+#ifdef	HAVE_SYS_SOUNDCARD_H
+#include <sys/soundcard.h>	/* For AFMT_* on linux */
+#else
 # define AFMT_MU_LAW              0x00000001
 # define AFMT_A_LAW               0x00000002
 # define AFMT_IMA_ADPCM           0x00000004
@@ -99,10 +99,16 @@
 	    return("Unsigned 16-bit (Big-Endian)");
 	case AFMT_MPEG:
 	    return("MPEG (2) audio");
+	// the following two formats are not available with old linux kernel
+	// headers (e.g. in 2.2.16)
+#ifdef AFMT_S32_LE
 	case AFMT_S32_LE:
-	    return("Signed 32-bit (Little-Endian");
+	    return("Signed 32-bit (Little-Endian)");
+#endif
+#ifdef AFMT_S32_BE
 	case AFMT_S32_BE:
-	    return("Signed 32-bit (Big-Endian");
+	    return("Signed 32-bit (Big-Endian)");
+#endif
     }
     return("Unknown");
 }


More information about the MPlayer-dev-eng mailing list