[Mplayer-cvslog] CVS: main/libao2 audio_out.c,1.25,1.26 audio_out.h,1.10,1.11

Arpi of Ize arpi at mplayerhq.hu
Mon Sep 30 00:57:57 CEST 2002


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

Modified Files:
	audio_out.c audio_out.h 
Log Message:
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)


Index: audio_out.c
===================================================================
RCS file: /cvsroot/mplayer/main/libao2/audio_out.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- audio_out.c	28 May 2002 01:52:40 -0000	1.25
+++ audio_out.c	29 Sep 2002 22:57:54 -0000	1.26
@@ -5,6 +5,9 @@
 #include "audio_out.h"
 #include "afmt.h"
 
+#include "../mp_msg.h"
+#include "../help_mp.h"
+
 // there are some globals:
 ao_data_t ao_data={0,0,0,0,OUTBURST,-1,0};
 char *ao_subdevice = NULL;
@@ -85,5 +88,54 @@
 	NULL
 };
 
+void list_audio_out(){
+      int i=0;
+      mp_msg(MSGT_AO, MSGL_INFO, MSGTR_AvailableAudioOutputDrivers);
+      while (audio_out_drivers[i]) {
+        const ao_info_t *info = audio_out_drivers[i++]->info;
+	printf("\t%s\t%s\n", info->short_name, info->name);
+      }
+      printf("\n");
+}
 
+ao_functions_t* init_best_audio_out(char** ao_list,int use_plugin,int rate,int channels,int format,int flags){
+    int i;
+    // first try the preferred drivers, with their optional subdevice param:
+    if(ao_list && ao_list[0])
+      while(ao_list[0][0]){
+        char* ao=strdup(ao_list[0]);
+	ao_subdevice=strchr(ao,':');
+	if(ao_subdevice){
+	    ao_subdevice[0]=0;
+	    ++ao_subdevice;
+	}
+	for(i=0;audio_out_drivers[i];i++){
+	    ao_functions_t* audio_out=audio_out_drivers[i];
+	    if(!strcmp(audio_out->info->short_name,ao)){
+		// name matches, try it
+		if(use_plugin){
+		    audio_out_plugin.control(AOCONTROL_SET_PLUGIN_DRIVER,(int)audio_out);
+		    audio_out=&audio_out_plugin;
+		}
+		if(audio_out->init(rate,channels,format,flags))
+		    return audio_out; // success!
+	    }
+	}
+        // continue...
+	++ao_list;
+	if(!(ao_list[0])) return NULL; // do NOT fallback to others
+      }
+    // now try the rest...
+    ao_subdevice=NULL;
+    for(i=0;audio_out_drivers[i];i++){
+	ao_functions_t* audio_out=audio_out_drivers[i];
+	if(use_plugin){
+	    audio_out_plugin.control(AOCONTROL_SET_PLUGIN_DRIVER,(int)audio_out);
+	    audio_out=&audio_out_plugin;
+	}
+	if(audio_out->init(rate,channels,format,flags))
+	    return audio_out; // success!
+    }
+    return NULL;
+}
 

Index: audio_out.h
===================================================================
RCS file: /cvsroot/mplayer/main/libao2/audio_out.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- audio_out.h	25 Jul 2002 20:28:47 -0000	1.10
+++ audio_out.h	29 Sep 2002 22:57:54 -0000	1.11
@@ -48,9 +48,11 @@
 extern char *audio_out_format_name(int format);
 extern int   audio_out_format_bits(int format);
 
+void list_audio_out();
+ao_functions_t* init_best_audio_out(char** ao_list,int use_plugin,int rate,int channels,int format,int flags);
+
 // NULL terminated array of all drivers
 extern ao_functions_t* audio_out_drivers[];
-
 
 #define CONTROL_OK 1
 #define CONTROL_TRUE 1




More information about the MPlayer-cvslog mailing list