Mercurial > mplayer.hg
changeset 7563:e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
author | arpi |
---|---|
date | Sun, 29 Sep 2002 22:57:54 +0000 |
parents | 92188b57a062 |
children | 24165f770c0d |
files | libao2/audio_out.c libao2/audio_out.h mplayer.c |
diffstat | 3 files changed, 77 insertions(+), 86 deletions(-) [+] |
line wrap: on
line diff
--- a/libao2/audio_out.c Sun Sep 29 21:53:05 2002 +0000 +++ b/libao2/audio_out.c Sun Sep 29 22:57:54 2002 +0000 @@ -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; +}
--- a/libao2/audio_out.h Sun Sep 29 21:53:05 2002 +0000 +++ b/libao2/audio_out.h Sun Sep 29 22:57:54 2002 +0000 @@ -48,10 +48,12 @@ 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 #define CONTROL_FALSE 0
--- a/mplayer.c Sun Sep 29 21:53:05 2002 +0000 +++ b/mplayer.c Sun Sep 29 22:57:54 2002 +0000 @@ -34,7 +34,6 @@ #endif #include "libvo/video_out.h" -//extern void* mDisplay; // Display* mDisplay; #include "libvo/font_load.h" #include "libvo/sub.h" @@ -42,9 +41,6 @@ #include "libao2/audio_out.h" #include "libao2/audio_plugin.h" -#include "libmpeg2/mpeg2.h" -#include "libmpeg2/mpeg2_internal.h" - #include "codec-cfg.h" #ifdef HAVE_LIBCSS @@ -59,9 +55,7 @@ #include "vobsub.h" #include "linux/getch2.h" -//#include "linux/keycodes.h" #include "linux/timer.h" -//#include "linux/shmem.h" #include "cpudetect.h" @@ -73,7 +67,7 @@ int slave_mode=0; int verbose=0; -int quiet=0; +static int quiet=0; #define ABS(x) (((x)>=0)?(x):(-(x))) @@ -83,7 +77,6 @@ #ifdef USE_TV #include "libmpdemux/tv.h" - extern int tv_param_on; #endif @@ -483,7 +476,6 @@ int file_format=DEMUXER_TYPE_UNKNOWN; int delay_corrected=1; -//char* title="MPlayer"; // movie info: int eof=0; @@ -598,15 +590,8 @@ exit(0); } - audio_driver=audio_driver_list?audio_driver_list[0]:NULL; - if(audio_driver && strcmp(audio_driver,"help")==0){ - mp_msg(MSGT_CPLAYER, MSGL_INFO, MSGTR_AvailableAudioOutputDrivers); - i=0; - 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"); + if(audio_driver_list && strcmp(audio_driver_list[0],"help")==0){ + list_audio_out(); exit(0); } @@ -846,56 +831,6 @@ if(vo_vobsub) sub_auto=0; // don't do autosub for textsubs if vobsub found -//==================== Init Audio Out ============================ - -// check audio_out driver name: -{ - char* ao = audio_driver ? strdup(audio_driver) : NULL; - if(ao_subdevice) { - free(ao_subdevice); - ao_subdevice = NULL; - } - if (audio_driver) - if ((i = strcspn(audio_driver, ":")) > 0) - { - size_t i2 = strlen(audio_driver); - - if (audio_driver[i] == ':') - { - ao_subdevice = malloc(i2-i); - if (ao_subdevice != NULL) - strncpy(ao_subdevice, (char *)(audio_driver+i+1), i2-i); - ao[i] = '\0'; - } -// printf("audio_driver: %s, subdevice: %s\n", audio_driver, ao_subdevice); - } - if(!audio_driver) - audio_out=audio_out_drivers[0]; - else - for (i=0; audio_out_drivers[i] != NULL; i++){ - const ao_info_t *info = audio_out_drivers[i]->info; - if(strcmp(info->short_name,ao) == 0){ - audio_out = audio_out_drivers[i];break; - } - } - if (!audio_out){ - mp_msg(MSGT_CPLAYER,MSGL_FATAL,MSGTR_InvalidAOdriver,ao?ao:"?"); - exit_player(MSGTR_Exit_error); - } - if(ao) - free(ao); - /* Initailize audio plugin interface if used */ - if(ao_plugin_cfg.plugin_list){ - for (i=0; audio_out_drivers[i] != NULL; i++){ - const ao_info_t *info = audio_out_drivers[i]->info; - if(strcmp(info->short_name,"plugin") == 0){ - audio_out_drivers[i]->control(AOCONTROL_SET_PLUGIN_DRIVER,(int)audio_out); - audio_out = audio_out_drivers[i]; - break; - } - } - } -} //============ Open & Sync STREAM --- fork cache2 ==================== stream=NULL; @@ -1296,25 +1231,27 @@ //================ SETUP AUDIO ========================== if(sh_audio){ - const ao_info_t *info=audio_out->info; - current_module="setup_audio"; - mp_msg(MSGT_CPLAYER,MSGL_INFO,"AO: [%s] %iHz %dch %s\n", - info->short_name, + //const ao_info_t *info=audio_out->info; + current_module="ao2_init"; + if(!(audio_out=init_best_audio_out(audio_driver_list, + (ao_plugin_cfg.plugin_list), // plugin flag + force_srate?force_srate:sh_audio->samplerate, + sh_audio->channels,sh_audio->sample_format,0))){ + // FAILED: + mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_CannotInitAO); + sh_audio=d_audio->sh=NULL; // -> nosound + } else { + // SUCCESS: + inited_flags|=INITED_AO; + mp_msg(MSGT_CPLAYER,MSGL_INFO,"AO: [%s] %iHz %dch %s\n", + audio_out->info->short_name, force_srate?force_srate:sh_audio->samplerate, sh_audio->channels, - audio_out_format_name(sh_audio->sample_format) - ); - mp_msg(MSGT_CPLAYER,MSGL_V,MSGTR_AODescription_AOAuthor, - info->name, info->author); - if(strlen(info->comment) > 0) - mp_msg(MSGT_CPLAYER,MSGL_V,MSGTR_AOComment, info->comment); - - if(!audio_out->init(force_srate?force_srate:sh_audio->samplerate, - sh_audio->channels,sh_audio->sample_format,0)){ - mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_CannotInitAO); - sh_audio=d_audio->sh=NULL; - } else { - inited_flags|=INITED_AO; + audio_out_format_name(sh_audio->sample_format)); + mp_msg(MSGT_CPLAYER,MSGL_V,MSGTR_AODescription_AOAuthor, + audio_out->info->name, audio_out->info->author); + if(strlen(audio_out->info->comment) > 0) + mp_msg(MSGT_CPLAYER,MSGL_V,MSGTR_AOComment, audio_out->info->comment); } }