[Mplayer-cvslog] CVS: main/libao2 ao_oss.c,1.13,1.14

Stephen Davies steve at mplayer.dev.hu
Wed Nov 28 13:46:25 CET 2001


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

Modified Files:
	ao_oss.c 
Log Message:
Extended oss output driver and libac3 to support 4 and 6 channel output mixes.  added -channels command line option

Index: ao_oss.c
===================================================================
RCS file: /cvsroot/mplayer/main/libao2/ao_oss.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- ao_oss.c	26 Nov 2001 11:30:35 -0000	1.13
+++ ao_oss.c	28 Nov 2001 12:46:23 -0000	1.14
@@ -26,6 +26,8 @@
 	""
 };
 
+/* Support for >2 output channels added 2001-11-25 - Steve Davies <steve at daviesfam.org> */
+
 LIBAO_EXTERN(oss)
 
 static char *dsp="/dev/dsp";
@@ -95,8 +97,8 @@
 // return: 1=success 0=fail
 static int init(int rate,int channels,int format,int flags){
 
-//  printf("ao2: %d Hz  %d chans  %s\n",rate,channels,
-//    audio_out_format_name(format));
+  printf("ao2: %d Hz  %d chans  %s\n",rate,channels,
+    audio_out_format_name(format));
 
   if (ao_subdevice)
     dsp = ao_subdevice;
@@ -124,13 +126,26 @@
     audio_out_format_name(ao_data.format), audio_out_format_name(format));
   
   if(format != AFMT_AC3) {
-  ao_data.channels=channels-1;
-  ioctl (audio_fd, SNDCTL_DSP_STEREO, &ao_data.channels);
-  
-  // set rate
-  ao_data.samplerate=rate;
-  ioctl (audio_fd, SNDCTL_DSP_SPEED, &ao_data.samplerate);
-  printf("audio_setup: using %d Hz samplerate (requested: %d)\n",ao_data.samplerate,rate);
+    // We only use SNDCTL_DSP_CHANNELS for >2 channels, in case some drivers don't have it
+    ao_data.channels = channels;
+    if (ao_data.channels > 2) {
+      if (ioctl (audio_fd, SNDCTL_DSP_CHANNELS, &ao_data.channels) == -1) {
+	printf("audio_setup: Failed to set audio device to %d channels\n", ao_data.channels);
+	return 0;
+      }
+    }
+    else {
+      int c = ao_data.channels-1;
+      if (ioctl (audio_fd, SNDCTL_DSP_STEREO, &c) == -1) {
+	printf("audio_setup: Failed to set audio device to %d channels\n", ao_data.channels);
+	return 0;
+      }
+    }
+    printf("audio_setup: using %d channels (requested: %d)\n", ao_data.channels, ao_data.channels);
+    // set rate
+    ao_data.samplerate=rate;
+    ioctl (audio_fd, SNDCTL_DSP_SPEED, &ao_data.samplerate);
+    printf("audio_setup: using %d Hz samplerate (requested: %d)\n",ao_data.samplerate,rate);
   }
 
   if(ioctl(audio_fd, SNDCTL_DSP_GETOSPACE, &zz)==-1){
@@ -195,8 +210,13 @@
 
   ioctl (audio_fd, SNDCTL_DSP_SETFMT, &ao_data.format);
   if(ao_data.format != AFMT_AC3) {
-  ioctl (audio_fd, SNDCTL_DSP_STEREO, &ao_data.channels);
-  ioctl (audio_fd, SNDCTL_DSP_SPEED, &ao_data.samplerate);
+    if (ao_data.channels > 2)
+      ioctl (audio_fd, SNDCTL_DSP_CHANNELS, &ao_data.channels);
+    else {
+      int c = ao_data.channels-1;
+      ioctl (audio_fd, SNDCTL_DSP_STEREO, &c);
+    }
+    ioctl (audio_fd, SNDCTL_DSP_SPEED, &ao_data.samplerate);
   }
 }
 
@@ -267,7 +287,3 @@
   }
   return ((float)ao_data.buffersize)/(float)ao_data.bps;
 }
-
-
-
-




More information about the MPlayer-cvslog mailing list