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
|
|
|
|
|
|
|
extern ao_functions_t audio_out_oss;
|
2004-07-10 20:56:25 +00:00
|
|
|
extern ao_functions_t audio_out_macosx;
|
2002-05-28 01:52:40 +00:00
|
|
|
extern ao_functions_t audio_out_arts;
|
2002-12-27 16:02:57 +00:00
|
|
|
extern ao_functions_t audio_out_esd;
|
2007-10-18 13:34:26 +00:00
|
|
|
extern ao_functions_t audio_out_pulse;
|
2004-06-25 18:11:15 +00:00
|
|
|
extern ao_functions_t audio_out_jack;
|
2006-02-16 20:45:25 +00:00
|
|
|
extern ao_functions_t audio_out_openal;
|
2001-06-02 23:25:43 +00:00
|
|
|
extern ao_functions_t audio_out_null;
|
2008-03-01 09:04:00 +00:00
|
|
|
extern ao_functions_t audio_out_alsa5;
|
|
|
|
extern ao_functions_t audio_out_alsa;
|
2001-12-03 01:13:48 +00:00
|
|
|
extern ao_functions_t audio_out_nas;
|
2001-06-03 10:48:36 +00:00
|
|
|
extern ao_functions_t audio_out_sdl;
|
2001-06-05 18:40:44 +00:00
|
|
|
extern ao_functions_t audio_out_sun;
|
2001-10-24 14:02:19 +00:00
|
|
|
extern ao_functions_t audio_out_sgi;
|
2002-10-25 16:34:27 +00:00
|
|
|
extern ao_functions_t audio_out_win32;
|
2004-09-25 15:34:42 +00:00
|
|
|
extern ao_functions_t audio_out_dsound;
|
2002-05-13 13:15:40 +00:00
|
|
|
extern ao_functions_t audio_out_dxr2;
|
2006-07-28 21:36:03 +00:00
|
|
|
extern ao_functions_t audio_out_ivtv;
|
2007-07-29 19:20:55 +00:00
|
|
|
extern ao_functions_t audio_out_v4l2;
|
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
|
|
|
|
2008-02-01 20:11:14 +00:00
|
|
|
const ao_functions_t* const audio_out_drivers[] =
|
2001-06-02 23:25:43 +00:00
|
|
|
{
|
2002-10-06 01:08:04 +00:00
|
|
|
// 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
|
2008-03-15 08:54:21 +00:00
|
|
|
#ifdef HAVE_COREAUDIO
|
2008-03-01 09:04:00 +00:00
|
|
|
&audio_out_macosx,
|
2005-10-11 23:07:53 +00:00
|
|
|
#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
|
2008-03-01 09:45:38 +00:00
|
|
|
#if defined (HAVE_ALSA1X) || defined (HAVE_ALSA9)
|
2008-03-01 09:04:00 +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
|
2008-03-01 09:04:00 +00:00
|
|
|
&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
|
2007-10-18 13:34:26 +00:00
|
|
|
#ifdef USE_PULSE
|
|
|
|
&audio_out_pulse,
|
2004-11-05 14:02:41 +00:00
|
|
|
#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
|
2008-03-01 09:04:00 +00:00
|
|
|
&audio_out_nas,
|
2001-12-03 01:13:48 +00:00
|
|
|
#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-08-16 20:04:43 +00:00
|
|
|
#endif
|
2008-03-01 09:04:00 +00:00
|
|
|
&audio_out_mpegpes,
|
2006-08-16 20:04:43 +00:00
|
|
|
#ifdef HAVE_DXR2
|
|
|
|
&audio_out_dxr2,
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_IVTV
|
|
|
|
&audio_out_ivtv,
|
2007-07-29 19:20:55 +00:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_V4L2_DECODER
|
|
|
|
&audio_out_v4l2,
|
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:
|
2008-03-01 09:04:00 +00:00
|
|
|
&audio_out_pcm,
|
|
|
|
NULL
|
2001-06-02 23:25:43 +00:00
|
|
|
};
|
2001-11-24 05:21:22 +00:00
|
|
|
|
2006-02-09 14:08:03 +00:00
|
|
|
void list_audio_out(void){
|
2008-03-01 09:04:00 +00:00
|
|
|
int i=0;
|
|
|
|
mp_msg(MSGT_AO, MSGL_INFO, MSGTR_AvailableAudioOutputDrivers);
|
|
|
|
mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_AUDIO_OUTPUTS\n");
|
|
|
|
while (audio_out_drivers[i]) {
|
2002-09-29 22:57:54 +00:00
|
|
|
const ao_info_t *info = audio_out_drivers[i++]->info;
|
2008-03-01 09:04:00 +00:00
|
|
|
mp_msg(MSGT_GLOBAL, MSGL_INFO,"\t%s\t%s\n", info->short_name, info->name);
|
|
|
|
}
|
|
|
|
mp_msg(MSGT_GLOBAL, MSGL_INFO,"\n");
|
2002-09-29 22:57:54 +00:00
|
|
|
}
|
2001-11-24 05:21:22 +00:00
|
|
|
|
2008-02-01 20:11:14 +00:00
|
|
|
const ao_functions_t* init_best_audio_out(char** ao_list,int use_plugin,int rate,int channels,int format,int flags){
|
2002-09-29 22:57:54 +00:00
|
|
|
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) {
|
2008-03-01 09:04:00 +00:00
|
|
|
mp_msg(MSGT_AO, MSGL_FATAL, MSGTR_AO_ALSA9_1x_Removed);
|
|
|
|
exit_player(NULL);
|
2004-10-04 15:10:33 +00:00
|
|
|
}
|
2004-10-13 16:22:59 +00:00
|
|
|
if (ao_subdevice) {
|
2008-03-01 09:04:00 +00:00
|
|
|
free(ao_subdevice);
|
|
|
|
ao_subdevice = NULL;
|
|
|
|
}
|
|
|
|
ao_subdevice=strchr(ao,':');
|
|
|
|
if(ao_subdevice){
|
|
|
|
ao_len = ao_subdevice - ao;
|
|
|
|
ao_subdevice = strdup(&ao[ao_len + 1]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ao_len = strlen(ao);
|
2008-06-22 19:25:54 +00:00
|
|
|
|
|
|
|
mp_msg(MSGT_AO, MSGL_V, MSGTR_AO_TryingPreferredAudioDriver,
|
|
|
|
ao_len, ao, ao_subdevice ? ao_subdevice : "[none]");
|
|
|
|
|
2008-03-01 09:04:00 +00:00
|
|
|
for(i=0;audio_out_drivers[i];i++){
|
|
|
|
const ao_functions_t* audio_out=audio_out_drivers[i];
|
|
|
|
if(!strncmp(audio_out->info->short_name,ao,ao_len)){
|
|
|
|
// name matches, try it
|
|
|
|
if(audio_out->init(rate,channels,format,flags))
|
|
|
|
return audio_out; // success!
|
2008-06-22 19:25:54 +00:00
|
|
|
else
|
|
|
|
mp_msg(MSGT_AO, MSGL_WARN, MSGTR_AO_FailedInit, ao);
|
|
|
|
break;
|
2008-03-01 09:04:00 +00:00
|
|
|
}
|
2004-10-13 16:22:59 +00:00
|
|
|
}
|
2008-06-22 19:25:54 +00:00
|
|
|
if (!audio_out_drivers[i]) // we searched through the entire list
|
|
|
|
mp_msg(MSGT_AO, MSGL_WARN, MSGTR_AO_NoSuchDriver, ao_len, ao);
|
2002-09-29 22:57:54 +00:00
|
|
|
// continue...
|
2008-03-01 09:04:00 +00:00
|
|
|
++ao_list;
|
|
|
|
if(!(ao_list[0])) return NULL; // do NOT fallback to others
|
2002-09-29 22:57:54 +00:00
|
|
|
}
|
2004-10-13 16:22:59 +00:00
|
|
|
if (ao_subdevice) {
|
2008-03-01 09:04:00 +00:00
|
|
|
free(ao_subdevice);
|
|
|
|
ao_subdevice = NULL;
|
2004-10-13 16:22:59 +00:00
|
|
|
}
|
2008-06-22 19:25:54 +00:00
|
|
|
|
|
|
|
mp_msg(MSGT_AO, MSGL_V, MSGTR_AO_TryingEveryKnown);
|
|
|
|
|
2002-09-29 22:57:54 +00:00
|
|
|
// now try the rest...
|
|
|
|
for(i=0;audio_out_drivers[i];i++){
|
2008-03-01 09:04:00 +00:00
|
|
|
const ao_functions_t* audio_out=audio_out_drivers[i];
|
|
|
|
// if(audio_out->control(AOCONTROL_QUERY_FORMAT, (int)format) == CONTROL_TRUE)
|
|
|
|
if(audio_out->init(rate,channels,format,flags))
|
|
|
|
return audio_out; // success!
|
2002-09-29 22:57:54 +00:00
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
2001-11-24 05:21:22 +00:00
|
|
|
|