annotate libao2/audio_out.c @ 7897:7674e94baff7

Change SDL_(Un)lockAudio to PauseAudio() (works better) checked by Arpi
author colin
date Thu, 24 Oct 2002 18:13:24 +0000
parents 3c1d30a1afc0
children 01198a05d97c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
954
db20b90dd34d audio out drivers
arpi_esp
parents:
diff changeset
1 #include <stdio.h>
db20b90dd34d audio out drivers
arpi_esp
parents:
diff changeset
2 #include <stdlib.h>
7848
3c1d30a1afc0 compiler warning fixes by Dominik
arpi
parents: 7609
diff changeset
3 #include <string.h>
954
db20b90dd34d audio out drivers
arpi_esp
parents:
diff changeset
4
db20b90dd34d audio out drivers
arpi_esp
parents:
diff changeset
5 #include "../config.h"
db20b90dd34d audio out drivers
arpi_esp
parents:
diff changeset
6 #include "audio_out.h"
1058
cab5ba9ffc6c fixed AFMT_ stuff (inclue afmt.h)
arpi_esp
parents: 1047
diff changeset
7 #include "afmt.h"
1038
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1032
diff changeset
8
7563
e9e4398029de audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents: 6214
diff changeset
9 #include "../mp_msg.h"
e9e4398029de audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents: 6214
diff changeset
10 #include "../help_mp.h"
e9e4398029de audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents: 6214
diff changeset
11
954
db20b90dd34d audio out drivers
arpi_esp
parents:
diff changeset
12 // there are some globals:
3095
981a9e5118ce interface to libao2 changed ao_plugin added
anders
parents: 2900
diff changeset
13 ao_data_t ao_data={0,0,0,0,OUTBURST,-1,0};
1185
e21c96e28062 ao_subdevice implemented
al3x
parents: 1121
diff changeset
14 char *ao_subdevice = NULL;
954
db20b90dd34d audio out drivers
arpi_esp
parents:
diff changeset
15
1038
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1032
diff changeset
16 #ifdef USE_OSS_AUDIO
954
db20b90dd34d audio out drivers
arpi_esp
parents:
diff changeset
17 extern ao_functions_t audio_out_oss;
1038
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1032
diff changeset
18 #endif
6214
0398cb49fe5e aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents: 6069
diff changeset
19 #ifdef USE_ARTS
0398cb49fe5e aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents: 6069
diff changeset
20 extern ao_functions_t audio_out_arts;
0398cb49fe5e aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents: 6069
diff changeset
21 #endif
954
db20b90dd34d audio out drivers
arpi_esp
parents:
diff changeset
22 extern ao_functions_t audio_out_null;
1007
e2de3386725f fixed HAVE_ALSA5 var. bug. sorry :(
pontscho
parents: 995
diff changeset
23 #ifdef HAVE_ALSA5
e2de3386725f fixed HAVE_ALSA5 var. bug. sorry :(
pontscho
parents: 995
diff changeset
24 extern ao_functions_t audio_out_alsa5;
e2de3386725f fixed HAVE_ALSA5 var. bug. sorry :(
pontscho
parents: 995
diff changeset
25 #endif
1032
e34336f4feaf add esd support and disabled default.
pontscho
parents: 1007
diff changeset
26 #ifdef HAVE_ALSA9
e34336f4feaf add esd support and disabled default.
pontscho
parents: 1007
diff changeset
27 extern ao_functions_t audio_out_alsa9;
e34336f4feaf add esd support and disabled default.
pontscho
parents: 1007
diff changeset
28 #endif
3276
e279cc05f189 -ao NAS support by Tobias Diedrich <ranma@gmx.at>
arpi
parents: 3095
diff changeset
29 #ifdef HAVE_NAS
e279cc05f189 -ao NAS support by Tobias Diedrich <ranma@gmx.at>
arpi
parents: 3095
diff changeset
30 extern ao_functions_t audio_out_nas;
e279cc05f189 -ao NAS support by Tobias Diedrich <ranma@gmx.at>
arpi
parents: 3095
diff changeset
31 #endif
966
69b4f944ce08 Added support for sdl audio out (buggy pre-alpha).
atmosfear
parents: 954
diff changeset
32 #ifdef HAVE_SDL
69b4f944ce08 Added support for sdl audio out (buggy pre-alpha).
atmosfear
parents: 954
diff changeset
33 extern ao_functions_t audio_out_sdl;
69b4f944ce08 Added support for sdl audio out (buggy pre-alpha).
atmosfear
parents: 954
diff changeset
34 #endif
1038
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1032
diff changeset
35 #ifdef USE_SUN_AUDIO
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1032
diff changeset
36 extern ao_functions_t audio_out_sun;
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1032
diff changeset
37 #endif
2450
f51307170f69 MIPS support by oliver.schoenbrunner@jku.at
arpi
parents: 1725
diff changeset
38 #ifdef USE_SGI_AUDIO
f51307170f69 MIPS support by oliver.schoenbrunner@jku.at
arpi
parents: 1725
diff changeset
39 extern ao_functions_t audio_out_sgi;
f51307170f69 MIPS support by oliver.schoenbrunner@jku.at
arpi
parents: 1725
diff changeset
40 #endif
6069
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents: 5192
diff changeset
41 #ifdef HAVE_DXR2
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents: 5192
diff changeset
42 extern ao_functions_t audio_out_dxr2;
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents: 5192
diff changeset
43 #endif
4788
d678ce495a75 Moved HW dependent mixer stuff to libao and removed master switch
anders
parents: 4097
diff changeset
44 extern ao_functions_t audio_out_mpegpes;
1107
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents: 1058
diff changeset
45 extern ao_functions_t audio_out_pcm;
1185
e21c96e28062 ao_subdevice implemented
al3x
parents: 1121
diff changeset
46 extern ao_functions_t audio_out_pss;
3095
981a9e5118ce interface to libao2 changed ao_plugin added
anders
parents: 2900
diff changeset
47 extern ao_functions_t audio_out_plugin;
954
db20b90dd34d audio out drivers
arpi_esp
parents:
diff changeset
48
db20b90dd34d audio out drivers
arpi_esp
parents:
diff changeset
49 ao_functions_t* audio_out_drivers[] =
db20b90dd34d audio out drivers
arpi_esp
parents:
diff changeset
50 {
7609
arpi
parents: 7563
diff changeset
51 // vo-related: will fail unless you also do -vo mpegpes/dxr2
arpi
parents: 7563
diff changeset
52 &audio_out_mpegpes,
arpi
parents: 7563
diff changeset
53 #ifdef HAVE_DXR2
arpi
parents: 7563
diff changeset
54 &audio_out_dxr2,
arpi
parents: 7563
diff changeset
55 #endif
arpi
parents: 7563
diff changeset
56 // native:
1038
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1032
diff changeset
57 #ifdef USE_OSS_AUDIO
954
db20b90dd34d audio out drivers
arpi_esp
parents:
diff changeset
58 &audio_out_oss,
1038
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1032
diff changeset
59 #endif
7609
arpi
parents: 7563
diff changeset
60 #ifdef HAVE_ALSA9
arpi
parents: 7563
diff changeset
61 &audio_out_alsa9,
6214
0398cb49fe5e aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents: 6069
diff changeset
62 #endif
7609
arpi
parents: 7563
diff changeset
63 #ifdef HAVE_ALSA5
arpi
parents: 7563
diff changeset
64 &audio_out_alsa5,
1725
24e75b632740 Move the sun audio driver near the start of the list of audio drivers, so
jkeil
parents: 1528
diff changeset
65 #endif
2450
f51307170f69 MIPS support by oliver.schoenbrunner@jku.at
arpi
parents: 1725
diff changeset
66 #ifdef USE_SGI_AUDIO
f51307170f69 MIPS support by oliver.schoenbrunner@jku.at
arpi
parents: 1725
diff changeset
67 &audio_out_sgi,
f51307170f69 MIPS support by oliver.schoenbrunner@jku.at
arpi
parents: 1725
diff changeset
68 #endif
7609
arpi
parents: 7563
diff changeset
69 #ifdef USE_SUN_AUDIO
arpi
parents: 7563
diff changeset
70 &audio_out_sun,
6069
8e88e92fe331 Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents: 5192
diff changeset
71 #endif
7609
arpi
parents: 7563
diff changeset
72 // wrappers:
arpi
parents: 7563
diff changeset
73 #ifdef USE_ARTS
arpi
parents: 7563
diff changeset
74 &audio_out_arts,
1032
e34336f4feaf add esd support and disabled default.
pontscho
parents: 1007
diff changeset
75 #endif
3276
e279cc05f189 -ao NAS support by Tobias Diedrich <ranma@gmx.at>
arpi
parents: 3095
diff changeset
76 #ifdef HAVE_NAS
e279cc05f189 -ao NAS support by Tobias Diedrich <ranma@gmx.at>
arpi
parents: 3095
diff changeset
77 &audio_out_nas,
e279cc05f189 -ao NAS support by Tobias Diedrich <ranma@gmx.at>
arpi
parents: 3095
diff changeset
78 #endif
966
69b4f944ce08 Added support for sdl audio out (buggy pre-alpha).
atmosfear
parents: 954
diff changeset
79 #ifdef HAVE_SDL
69b4f944ce08 Added support for sdl audio out (buggy pre-alpha).
atmosfear
parents: 954
diff changeset
80 &audio_out_sdl,
69b4f944ce08 Added support for sdl audio out (buggy pre-alpha).
atmosfear
parents: 954
diff changeset
81 #endif
7609
arpi
parents: 7563
diff changeset
82 &audio_out_null,
arpi
parents: 7563
diff changeset
83 // should not be auto-selected:
1107
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents: 1058
diff changeset
84 &audio_out_pcm,
3095
981a9e5118ce interface to libao2 changed ao_plugin added
anders
parents: 2900
diff changeset
85 &audio_out_plugin,
954
db20b90dd34d audio out drivers
arpi_esp
parents:
diff changeset
86 NULL
db20b90dd34d audio out drivers
arpi_esp
parents:
diff changeset
87 };
3095
981a9e5118ce interface to libao2 changed ao_plugin added
anders
parents: 2900
diff changeset
88
7563
e9e4398029de audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents: 6214
diff changeset
89 void list_audio_out(){
e9e4398029de audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents: 6214
diff changeset
90 int i=0;
e9e4398029de audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents: 6214
diff changeset
91 mp_msg(MSGT_AO, MSGL_INFO, MSGTR_AvailableAudioOutputDrivers);
e9e4398029de audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents: 6214
diff changeset
92 while (audio_out_drivers[i]) {
e9e4398029de audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents: 6214
diff changeset
93 const ao_info_t *info = audio_out_drivers[i++]->info;
e9e4398029de audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents: 6214
diff changeset
94 printf("\t%s\t%s\n", info->short_name, info->name);
e9e4398029de audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents: 6214
diff changeset
95 }
e9e4398029de audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents: 6214
diff changeset
96 printf("\n");
e9e4398029de audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents: 6214
diff changeset
97 }
3095
981a9e5118ce interface to libao2 changed ao_plugin added
anders
parents: 2900
diff changeset
98
7563
e9e4398029de audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents: 6214
diff changeset
99 ao_functions_t* init_best_audio_out(char** ao_list,int use_plugin,int rate,int channels,int format,int flags){
e9e4398029de audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents: 6214
diff changeset
100 int i;
e9e4398029de audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents: 6214
diff changeset
101 // first try the preferred drivers, with their optional subdevice param:
e9e4398029de audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents: 6214
diff changeset
102 if(ao_list && ao_list[0])
e9e4398029de audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents: 6214
diff changeset
103 while(ao_list[0][0]){
e9e4398029de audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents: 6214
diff changeset
104 char* ao=strdup(ao_list[0]);
e9e4398029de audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents: 6214
diff changeset
105 ao_subdevice=strchr(ao,':');
e9e4398029de audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents: 6214
diff changeset
106 if(ao_subdevice){
e9e4398029de audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents: 6214
diff changeset
107 ao_subdevice[0]=0;
e9e4398029de audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents: 6214
diff changeset
108 ++ao_subdevice;
e9e4398029de audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents: 6214
diff changeset
109 }
e9e4398029de audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents: 6214
diff changeset
110 for(i=0;audio_out_drivers[i];i++){
e9e4398029de audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents: 6214
diff changeset
111 ao_functions_t* audio_out=audio_out_drivers[i];
e9e4398029de audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents: 6214
diff changeset
112 if(!strcmp(audio_out->info->short_name,ao)){
e9e4398029de audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents: 6214
diff changeset
113 // name matches, try it
e9e4398029de audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents: 6214
diff changeset
114 if(use_plugin){
e9e4398029de audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents: 6214
diff changeset
115 audio_out_plugin.control(AOCONTROL_SET_PLUGIN_DRIVER,(int)audio_out);
e9e4398029de audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents: 6214
diff changeset
116 audio_out=&audio_out_plugin;
e9e4398029de audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents: 6214
diff changeset
117 }
e9e4398029de audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents: 6214
diff changeset
118 if(audio_out->init(rate,channels,format,flags))
e9e4398029de audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents: 6214
diff changeset
119 return audio_out; // success!
e9e4398029de audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents: 6214
diff changeset
120 }
e9e4398029de audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents: 6214
diff changeset
121 }
e9e4398029de audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents: 6214
diff changeset
122 // continue...
e9e4398029de audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents: 6214
diff changeset
123 ++ao_list;
e9e4398029de audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents: 6214
diff changeset
124 if(!(ao_list[0])) return NULL; // do NOT fallback to others
e9e4398029de audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents: 6214
diff changeset
125 }
e9e4398029de audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents: 6214
diff changeset
126 // now try the rest...
e9e4398029de audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents: 6214
diff changeset
127 ao_subdevice=NULL;
e9e4398029de audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents: 6214
diff changeset
128 for(i=0;audio_out_drivers[i];i++){
e9e4398029de audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents: 6214
diff changeset
129 ao_functions_t* audio_out=audio_out_drivers[i];
e9e4398029de audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents: 6214
diff changeset
130 if(use_plugin){
e9e4398029de audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents: 6214
diff changeset
131 audio_out_plugin.control(AOCONTROL_SET_PLUGIN_DRIVER,(int)audio_out);
e9e4398029de audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents: 6214
diff changeset
132 audio_out=&audio_out_plugin;
e9e4398029de audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents: 6214
diff changeset
133 }
e9e4398029de audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents: 6214
diff changeset
134 if(audio_out->init(rate,channels,format,flags))
e9e4398029de audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents: 6214
diff changeset
135 return audio_out; // success!
e9e4398029de audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents: 6214
diff changeset
136 }
e9e4398029de audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents: 6214
diff changeset
137 return NULL;
e9e4398029de audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents: 6214
diff changeset
138 }
3095
981a9e5118ce interface to libao2 changed ao_plugin added
anders
parents: 2900
diff changeset
139