[Mplayer-cvslog] CVS: main/libao2 ao_sun.c,1.5,1.6

Jürgen Keil jkeil at mplayer.dev.hu
Sat Jul 14 18:58:57 CEST 2001


Update of /cvsroot/mplayer/main/libao2
In directory mplayer:/var/tmp.root/cvs-serv9602/libao2

Modified Files:
	ao_sun.c 
Log Message:
On big-endian architectures, all audio decoders default to big-endian 16-bit
audio sample format.

Add support to play both big- and little-endian 16-bit audio format to the
sun audio_out driver.


Index: ao_sun.c
===================================================================
RCS file: /cvsroot/mplayer/main/libao2/ao_sun.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ao_sun.c	12 Jul 2001 15:30:15 -0000	1.5
+++ ao_sun.c	14 Jul 2001 16:58:55 -0000	1.6
@@ -72,6 +72,7 @@
 	return AUDIO_ENCODING_ULAW;
     case AFMT_A_LAW:
 	return AUDIO_ENCODING_ALAW;
+    case AFMT_S16_BE:
     case AFMT_S16_LE:
 	return AUDIO_ENCODING_LINEAR;
     case AFMT_U8:
@@ -248,7 +249,10 @@
 
     AUDIO_INITINFO(&info);
     info.play.encoding = oss2sunfmt(ao_format = format);
-    info.play.precision = (format==AFMT_S16_LE? AUDIO_PRECISION_16:AUDIO_PRECISION_8);
+    info.play.precision =
+	(format==AFMT_S16_LE || format==AFMT_S16_BE
+	 ? AUDIO_PRECISION_16
+	 : AUDIO_PRECISION_8);
     info.play.channels = ao_channels = channels;
     info.play.sample_rate = ao_samplerate = rate;
     if(ioctl (audio_fd, AUDIO_SETINFO, &info)<0)
@@ -331,7 +335,10 @@
 
     AUDIO_INITINFO(&info);
     info.play.encoding = oss2sunfmt(ao_format);
-    info.play.precision = (ao_format==AFMT_S16_LE? AUDIO_PRECISION_16:AUDIO_PRECISION_8);
+    info.play.precision =
+	(ao_format==AFMT_S16_LE || ao_format==AFMT_S16_BE 
+	 ? AUDIO_PRECISION_16
+	 : AUDIO_PRECISION_8);
     info.play.channels = ao_channels;
     info.play.sample_rate = ao_samplerate;
     info.play.samples = 0;
@@ -390,16 +397,22 @@
 // it should round it down to outburst*n
 // return: number of bytes played
 static int play(void* data,int len,int flags){
+#if	WORDS_BIGENDIAN
+    int native_endian = AFMT_S16_BE;
+#else
+    int native_endian = AFMT_S16_LE;
+#endif
 
     if (len < ao_outburst) return 0;
     len /= ao_outburst;
     len *= ao_outburst;
 
-#if	WORDS_BIGENDIAN
-    {
+    /* 16-bit format using the 'wrong' byteorder?  swap words */
+    if ((ao_format == AFMT_S16_LE || ao_format == AFMT_S16_BE)
+	&& ao_format != native_endian) {
 	static void *swab_buf;
 	static int swab_len;
-	if (ao_format == AFMT_S16_LE && len > swab_len) {
+	if (len > swab_len) {
 	    if (swab_buf)
 		swab_buf = realloc(swab_buf, len);
 	    else
@@ -410,7 +423,6 @@
 	swab(data, swab_buf, len);
 	data = swab_buf;
     }
-#endif
 
     len = write(audio_fd, data, len);
     if(len > 0) {




More information about the MPlayer-cvslog mailing list