2001-06-02 23:25:43 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2002-10-22 16:24:26 +00:00
|
|
|
#include <string.h>
|
2001-06-02 23:25:43 +00:00
|
|
|
|
2004-12-07 02:24:15 +00:00
|
|
|
#include "config.h"
|
2001-06-02 23:25:43 +00:00
|
|
|
#include "audio_out.h"
|
2001-06-05 18:40:44 +00:00
|
|
|
|
2004-12-07 02:24:15 +00:00
|
|
|
#include "mp_msg.h"
|
|
|
|
#include "help_mp.h"
|
2005-04-06 11:57:10 +00:00
|
|
|
#include "mplayer.h" /* for exit_player() */
|
2002-09-29 22:57:54 +00:00
|
|
|
|
2001-06-02 23:25:43 +00:00
|
|
|
// there are some globals:
|
2001-11-24 05:21:22 +00:00
|
|
|
ao_data_t ao_data={0,0,0,0,OUTBURST,-1,0};
|
2001-06-21 22:34:58 +00:00
|
|
|
char *ao_subdevice = NULL;
|
2001-06-02 23:25:43 +00:00
|
|
|
|
2001-06-05 18:40:44 +00:00
|
|
|
#ifdef USE_OSS_AUDIO
|
2001-06-02 23:25:43 +00:00
|
|
|
extern ao_functions_t audio_out_oss;
|
2001-06-05 18:40:44 +00:00
|
|
|
#endif
|
2004-07-10 20:56:25 +00:00
|
|
|
#ifdef MACOSX
|
|
|
|
extern ao_functions_t audio_out_macosx;
|
|
|
|
#endif
|
2002-05-28 01:52:40 +00:00
|
|
|
#ifdef USE_ARTS
|
|
|
|
extern ao_functions_t audio_out_arts;
|
|
|
|
#endif
|
2002-12-27 16:02:57 +00:00
|
|
|
#ifdef USE_ESD
|
|
|
|
extern ao_functions_t audio_out_esd;
|
|
|
|
#endif
|
2004-11-05 14:02:41 +00:00
|
|
|
#ifdef USE_POLYP
|
|
|
|
extern ao_functions_t audio_out_polyp;
|
|
|
|
#endif
|
2004-06-25 18:11:15 +00:00
|
|
|
#ifdef USE_JACK
|
|
|
|
extern ao_functions_t audio_out_jack;
|
|
|
|
#endif
|
2006-02-16 22:35:04 +00:00
|
|
|
#ifdef USE_OPENAL
|
2006-02-16 20:45:25 +00:00
|
|
|
extern ao_functions_t audio_out_openal;
|
2006-02-16 22:35:04 +00:00
|
|
|
#endif
|
2001-06-02 23:25:43 +00:00
|
|
|
extern ao_functions_t audio_out_null;
|
2001-06-04 18:42:31 +00:00
|
|
|
#ifdef HAVE_ALSA5
|
|
|
|
extern ao_functions_t audio_out_alsa5;
|
|
|
|
#endif
|
2001-06-05 10:37:50 +00:00
|
|
|
#ifdef HAVE_ALSA9
|
2004-05-12 22:48:15 +00:00
|
|
|
extern ao_functions_t audio_out_alsa;
|
2001-06-05 10:37:50 +00:00
|
|
|
#endif
|
2004-01-11 17:07:32 +00:00
|
|
|
#ifdef HAVE_ALSA1X
|
2004-05-12 22:48:15 +00:00
|
|
|
extern ao_functions_t audio_out_alsa;
|
2004-01-11 17:07:32 +00:00
|
|
|
#endif
|
2001-12-03 01:13:48 +00:00
|
|
|
#ifdef HAVE_NAS
|
|
|
|
extern ao_functions_t audio_out_nas;
|
|
|
|
#endif
|
2001-06-03 10:48:36 +00:00
|
|
|
#ifdef HAVE_SDL
|
|
|
|
extern ao_functions_t audio_out_sdl;
|
|
|
|
#endif
|
2001-06-05 18:40:44 +00:00
|
|
|
#ifdef USE_SUN_AUDIO
|
|
|
|
extern ao_functions_t audio_out_sun;
|
|
|
|
#endif
|
2001-10-24 14:02:19 +00:00
|
|
|
#ifdef USE_SGI_AUDIO
|
|
|
|
extern ao_functions_t audio_out_sgi;
|
|
|
|
#endif
|
2002-10-25 16:34:27 +00:00
|
|
|
#ifdef HAVE_WIN32WAVEOUT
|
|
|
|
extern ao_functions_t audio_out_win32;
|
|
|
|
#endif
|
2004-09-25 15:34:42 +00:00
|
|
|
#ifdef HAVE_DIRECTX
|
|
|
|
extern ao_functions_t audio_out_dsound;
|
|
|
|
#endif
|
2002-05-13 13:15:40 +00:00
|
|
|
#ifdef HAVE_DXR2
|
|
|
|
extern ao_functions_t audio_out_dxr2;
|
|
|
|
#endif
|
2001-11-05 03:01:11 +00:00
|
|
|
extern ao_functions_t audio_out_mpegpes;
|
2002-02-21 16:02:26 +00:00
|
|
|
extern ao_functions_t audio_out_pcm;
|
2001-06-21 22:34:58 +00:00
|
|
|
extern ao_functions_t audio_out_pss;
|
2001-06-02 23:25:43 +00:00
|
|
|
|
|
|
|
ao_functions_t* audio_out_drivers[] =
|
|
|
|
{
|
2002-10-06 01:08:04 +00:00
|
|
|
// vo-related: will fail unless you also do -vo mpegpes/dxr2
|
|
|
|
&audio_out_mpegpes,
|
|
|
|
#ifdef HAVE_DXR2
|
|
|
|
&audio_out_dxr2,
|
|
|
|
#endif
|
|
|
|
// native:
|
2004-09-25 15:34:42 +00:00
|
|
|
#ifdef HAVE_DIRECTX
|
|
|
|
&audio_out_dsound,
|
|
|
|
#endif
|
2003-01-03 05:10:44 +00:00
|
|
|
#ifdef HAVE_WIN32WAVEOUT
|
|
|
|
&audio_out_win32,
|
|
|
|
#endif
|
2005-10-11 23:07:53 +00:00
|
|
|
#ifdef MACOSX
|
|
|
|
&audio_out_macosx,
|
|
|
|
#endif
|
2001-06-05 18:40:44 +00:00
|
|
|
#ifdef USE_OSS_AUDIO
|
2001-06-02 23:25:43 +00:00
|
|
|
&audio_out_oss,
|
2001-08-28 10:54:31 +00:00
|
|
|
#endif
|
2004-01-11 17:07:32 +00:00
|
|
|
#ifdef HAVE_ALSA1X
|
2004-05-12 22:48:15 +00:00
|
|
|
&audio_out_alsa,
|
2004-01-11 17:07:32 +00:00
|
|
|
#endif
|
2002-10-06 01:08:04 +00:00
|
|
|
#ifdef HAVE_ALSA9
|
2004-05-12 22:48:15 +00:00
|
|
|
&audio_out_alsa,
|
2002-05-28 01:52:40 +00:00
|
|
|
#endif
|
2002-10-06 01:08:04 +00:00
|
|
|
#ifdef HAVE_ALSA5
|
|
|
|
&audio_out_alsa5,
|
2001-10-24 14:02:19 +00:00
|
|
|
#endif
|
|
|
|
#ifdef USE_SGI_AUDIO
|
|
|
|
&audio_out_sgi,
|
2002-05-13 13:15:40 +00:00
|
|
|
#endif
|
2002-10-06 01:08:04 +00:00
|
|
|
#ifdef USE_SUN_AUDIO
|
|
|
|
&audio_out_sun,
|
2001-06-05 10:37:50 +00:00
|
|
|
#endif
|
2002-10-06 01:08:04 +00:00
|
|
|
// wrappers:
|
|
|
|
#ifdef USE_ARTS
|
|
|
|
&audio_out_arts,
|
2001-06-05 10:37:50 +00:00
|
|
|
#endif
|
2002-12-27 16:02:57 +00:00
|
|
|
#ifdef USE_ESD
|
|
|
|
&audio_out_esd,
|
|
|
|
#endif
|
2004-11-05 14:02:41 +00:00
|
|
|
#ifdef USE_POLYP
|
|
|
|
&audio_out_polyp,
|
|
|
|
#endif
|
2004-06-25 18:11:15 +00:00
|
|
|
#ifdef USE_JACK
|
|
|
|
&audio_out_jack,
|
|
|
|
#endif
|
2001-12-03 01:13:48 +00:00
|
|
|
#ifdef HAVE_NAS
|
|
|
|
&audio_out_nas,
|
|
|
|
#endif
|
2001-06-03 10:48:36 +00:00
|
|
|
#ifdef HAVE_SDL
|
|
|
|
&audio_out_sdl,
|
|
|
|
#endif
|
2006-02-16 22:35:04 +00:00
|
|
|
#ifdef USE_OPENAL
|
2006-02-16 20:45:25 +00:00
|
|
|
&audio_out_openal,
|
2006-02-16 22:35:04 +00:00
|
|
|
#endif
|
2002-10-06 01:08:04 +00:00
|
|
|
&audio_out_null,
|
|
|
|
// should not be auto-selected:
|
2002-02-21 16:02:26 +00:00
|
|
|
&audio_out_pcm,
|
2001-06-02 23:25:43 +00:00
|
|
|
NULL
|
|
|
|
};
|
2001-11-24 05:21:22 +00:00
|
|
|
|
2006-02-09 14:08:03 +00:00
|
|
|
void list_audio_out(void){
|
2002-09-29 22:57:54 +00:00
|
|
|
int i=0;
|
|
|
|
mp_msg(MSGT_AO, MSGL_INFO, MSGTR_AvailableAudioOutputDrivers);
|
2006-04-24 07:20:34 +00:00
|
|
|
mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_AUDIO_OUTPUTS\n");
|
2002-09-29 22:57:54 +00:00
|
|
|
while (audio_out_drivers[i]) {
|
|
|
|
const ao_info_t *info = audio_out_drivers[i++]->info;
|
2006-03-30 06:40:58 +00:00
|
|
|
mp_msg(MSGT_GLOBAL, MSGL_INFO,"\t%s\t%s\n", info->short_name, info->name);
|
2002-09-29 22:57:54 +00:00
|
|
|
}
|
2006-03-30 06:40:58 +00:00
|
|
|
mp_msg(MSGT_GLOBAL, MSGL_INFO,"\n");
|
2002-09-29 22:57:54 +00:00
|
|
|
}
|
2001-11-24 05:21:22 +00:00
|
|
|
|
2002-09-29 22:57:54 +00:00
|
|
|
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]){
|
2004-10-13 16:22:59 +00:00
|
|
|
char* ao=ao_list[0];
|
|
|
|
int ao_len;
|
2004-10-04 15:10:33 +00:00
|
|
|
if (strncmp(ao, "alsa9", 5) == 0 || strncmp(ao, "alsa1x", 6) == 0) {
|
|
|
|
mp_msg(MSGT_AO, MSGL_FATAL, MSGTR_AO_ALSA9_1x_Removed);
|
|
|
|
exit_player(NULL);
|
|
|
|
}
|
2004-10-13 16:22:59 +00:00
|
|
|
if (ao_subdevice) {
|
|
|
|
free(ao_subdevice);
|
|
|
|
ao_subdevice = NULL;
|
|
|
|
}
|
2002-09-29 22:57:54 +00:00
|
|
|
ao_subdevice=strchr(ao,':');
|
|
|
|
if(ao_subdevice){
|
2004-10-13 16:22:59 +00:00
|
|
|
ao_len = ao_subdevice - ao;
|
|
|
|
ao_subdevice = strdup(&ao[ao_len + 1]);
|
2002-09-29 22:57:54 +00:00
|
|
|
}
|
2004-10-13 16:22:59 +00:00
|
|
|
else
|
|
|
|
ao_len = strlen(ao);
|
2002-09-29 22:57:54 +00:00
|
|
|
for(i=0;audio_out_drivers[i];i++){
|
|
|
|
ao_functions_t* audio_out=audio_out_drivers[i];
|
2004-10-13 16:22:59 +00:00
|
|
|
if(!strncmp(audio_out->info->short_name,ao,ao_len)){
|
2002-09-29 22:57:54 +00:00
|
|
|
// name matches, try it
|
|
|
|
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
|
|
|
|
}
|
2004-10-13 16:22:59 +00:00
|
|
|
if (ao_subdevice) {
|
|
|
|
free(ao_subdevice);
|
|
|
|
ao_subdevice = NULL;
|
|
|
|
}
|
2002-09-29 22:57:54 +00:00
|
|
|
// now try the rest...
|
|
|
|
for(i=0;audio_out_drivers[i];i++){
|
|
|
|
ao_functions_t* audio_out=audio_out_drivers[i];
|
2004-12-27 17:30:15 +00:00
|
|
|
// if(audio_out->control(AOCONTROL_QUERY_FORMAT, (int)format) == CONTROL_TRUE)
|
2002-09-29 22:57:54 +00:00
|
|
|
if(audio_out->init(rate,channels,format,flags))
|
|
|
|
return audio_out; // success!
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
2001-11-24 05:21:22 +00:00
|
|
|
|