[Mplayer-cvslog] CVS: main/libao2 ao_sdl.c,1.19,1.20

Colin Leroy CVS colin at mplayerhq.hu
Fri Oct 25 12:27:44 CEST 2002


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

Modified Files:
	ao_sdl.c 
Log Message:
Check what we obtain in SDL_OpenAudio() - allows to build the
correct audio filter chain if soundcard doesn't support what is
requested.
Checked by Arpi


Index: ao_sdl.c
===================================================================
RCS file: /cvsroot/mplayer/main/libao2/ao_sdl.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- ao_sdl.c	24 Oct 2002 18:13:24 -0000	1.19
+++ ao_sdl.c	25 Oct 2002 10:27:20 -0000	1.20
@@ -147,7 +147,7 @@
 static int init(int rate,int channels,int format,int flags){
 
 	/* SDL Audio Specifications */
-	SDL_AudioSpec aspec;
+	SDL_AudioSpec aspec, obtained;
 	
 	int i;
 	/* Allocate ring-buffer memory */
@@ -216,13 +216,41 @@
         }
 
 	/* Open the audio device and start playing sound! */
-	if(SDL_OpenAudio(&aspec, NULL) < 0) {
+	if(SDL_OpenAudio(&aspec, &obtained) < 0) {
         	printf("SDL: Unable to open audio: %s\n", SDL_GetError());
         	return(0);
 	} 
-	
-	if(verbose) printf("SDL: buf size = %d\n",aspec.size);
-	if(ao_data.buffersize==-1) ao_data.buffersize=aspec.size;
+
+	/* did we got what we wanted ? */
+	ao_data.channels=obtained.channels;
+	ao_data.samplerate=obtained.freq;
+
+	switch(obtained.format) {
+	    case AUDIO_U8 :
+		ao_data.format = AFMT_U8;
+	    break;
+	    case AUDIO_S16LSB :
+		ao_data.format = AFMT_S16_LE;
+	    break;
+	    case AUDIO_S16MSB :
+		ao_data.format = AFMT_S16_BE;
+	    break;
+	    case AUDIO_S8 :
+		ao_data.format = AFMT_S8;
+	    break;
+	    case AUDIO_U16LSB :
+		ao_data.format = AFMT_U16_LE;
+	    break;
+	    case AUDIO_U16MSB :
+		ao_data.format = AFMT_U16_BE;
+	    break;
+	    default:
+                printf("SDL: Unsupported SDL audio format: 0x%x.\n", obtained.format);
+                return 0;
+	}
+
+	if(verbose) printf("SDL: buf size = %d\n",obtained.size);
+	ao_data.buffersize=obtained.size;
 	
 	/* unsilence audio, if callback is ready */
 	SDL_PauseAudio(0);




More information about the MPlayer-cvslog mailing list