~ubuntu-branches/debian/sid/mplayer/sid

« back to all changes in this revision

Viewing changes to libao2/audio_out.c

  • Committer: Bazaar Package Importer
  • Author(s): A Mennucc1
  • Date: 2009-03-23 10:05:45 UTC
  • mfrom: (4.1.4 sid)
  • Revision ID: james.westby@ubuntu.com-20090323100545-x8h79obawnnte7kk
Tags: 1.0~rc2+svn20090303-5
debian/control : move docbook-xml,docbook-xsl,xsltproc from 
Build-Depends-Indep to Build-Depends, since they are needed to run
configure

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * This file is part of MPlayer.
 
3
 *
 
4
 * MPlayer is free software; you can redistribute it and/or modify
 
5
 * it under the terms of the GNU General Public License as published by
 
6
 * the Free Software Foundation; either version 2 of the License, or
 
7
 * (at your option) any later version.
 
8
 *
 
9
 * MPlayer is distributed in the hope that it will be useful,
 
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
 * GNU General Public License for more details.
 
13
 *
 
14
 * You should have received a copy of the GNU General Public License along
 
15
 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
 
16
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
17
 */
 
18
 
1
19
#include <stdio.h>
2
20
#include <stdlib.h>
3
21
#include <string.h>
13
31
ao_data_t ao_data={0,0,0,0,OUTBURST,-1,0};
14
32
char *ao_subdevice = NULL;
15
33
 
16
 
#ifdef USE_OSS_AUDIO
17
34
extern ao_functions_t audio_out_oss;
18
 
#endif
19
 
#ifdef MACOSX
20
35
extern ao_functions_t audio_out_macosx;
21
 
#endif
22
 
#ifdef USE_ARTS
23
36
extern ao_functions_t audio_out_arts;
24
 
#endif
25
 
#ifdef USE_ESD
26
37
extern ao_functions_t audio_out_esd;
27
 
#endif
28
 
#ifdef USE_POLYP
29
 
extern ao_functions_t audio_out_polyp;
30
 
#endif
31
 
#ifdef USE_JACK
 
38
extern ao_functions_t audio_out_pulse;
32
39
extern ao_functions_t audio_out_jack;
33
 
#endif
34
 
#ifdef USE_OPENAL
35
40
extern ao_functions_t audio_out_openal;
36
 
#endif
37
41
extern ao_functions_t audio_out_null;
38
 
#ifdef HAVE_ALSA5
39
 
 extern ao_functions_t audio_out_alsa5;
40
 
#endif
41
 
#ifdef HAVE_ALSA9
42
 
 extern ao_functions_t audio_out_alsa;
43
 
#endif
44
 
#ifdef HAVE_ALSA1X
45
 
 extern ao_functions_t audio_out_alsa;
46
 
#endif
47
 
#ifdef HAVE_NAS
 
42
extern ao_functions_t audio_out_alsa5;
 
43
extern ao_functions_t audio_out_alsa;
48
44
extern ao_functions_t audio_out_nas;
49
 
#endif
50
 
#ifdef HAVE_SDL
51
45
extern ao_functions_t audio_out_sdl;
52
 
#endif
53
 
#ifdef USE_SUN_AUDIO
54
46
extern ao_functions_t audio_out_sun;
55
 
#endif
56
 
#ifdef USE_SGI_AUDIO
57
47
extern ao_functions_t audio_out_sgi;
58
 
#endif
59
 
#ifdef HAVE_WIN32WAVEOUT
60
48
extern ao_functions_t audio_out_win32;
61
 
#endif
62
 
#ifdef HAVE_DIRECTX
63
49
extern ao_functions_t audio_out_dsound;
64
 
#endif
65
 
#ifdef HAVE_DXR2
 
50
extern ao_functions_t audio_out_dart;
66
51
extern ao_functions_t audio_out_dxr2;
67
 
#endif
68
 
#ifdef HAVE_IVTV
69
52
extern ao_functions_t audio_out_ivtv;
70
 
#endif
71
 
#ifdef HAVE_V4L2_DECODER
72
53
extern ao_functions_t audio_out_v4l2;
73
 
#endif
74
54
extern ao_functions_t audio_out_mpegpes;
75
55
extern ao_functions_t audio_out_pcm;
76
56
extern ao_functions_t audio_out_pss;
77
57
 
78
 
ao_functions_t* audio_out_drivers[] =
 
58
const ao_functions_t* const audio_out_drivers[] =
79
59
{
80
60
// native:
81
 
#ifdef HAVE_DIRECTX
 
61
#ifdef CONFIG_DIRECTX
82
62
        &audio_out_dsound,
83
63
#endif
84
 
#ifdef HAVE_WIN32WAVEOUT
 
64
#ifdef CONFIG_WIN32WAVEOUT
85
65
        &audio_out_win32,
86
66
#endif
87
 
#ifdef MACOSX
88
 
        &audio_out_macosx,
89
 
#endif
90
 
#ifdef USE_OSS_AUDIO
 
67
#ifdef CONFIG_DART
 
68
        &audio_out_dart,
 
69
#endif
 
70
#ifdef CONFIG_COREAUDIO
 
71
        &audio_out_macosx,
 
72
#endif
 
73
#ifdef CONFIG_OSS_AUDIO
91
74
        &audio_out_oss,
92
75
#endif
93
 
#ifdef HAVE_ALSA1X
94
 
        &audio_out_alsa,
95
 
#endif
96
 
#ifdef HAVE_ALSA9
97
 
        &audio_out_alsa,
98
 
#endif
99
 
#ifdef HAVE_ALSA5
100
 
        &audio_out_alsa5,
101
 
#endif
102
 
#ifdef USE_SGI_AUDIO
 
76
#ifdef CONFIG_ALSA
 
77
        &audio_out_alsa,
 
78
#endif
 
79
#ifdef CONFIG_ALSA5
 
80
        &audio_out_alsa5,
 
81
#endif
 
82
#ifdef CONFIG_SGI_AUDIO
103
83
        &audio_out_sgi,
104
84
#endif
105
 
#ifdef USE_SUN_AUDIO
 
85
#ifdef CONFIG_SUN_AUDIO
106
86
        &audio_out_sun,
107
87
#endif
108
88
// wrappers:
109
 
#ifdef USE_ARTS
 
89
#ifdef CONFIG_ARTS
110
90
        &audio_out_arts,
111
91
#endif
112
 
#ifdef USE_ESD
 
92
#ifdef CONFIG_ESD
113
93
        &audio_out_esd,
114
94
#endif
115
 
#ifdef USE_POLYP
116
 
        &audio_out_polyp,
 
95
#ifdef CONFIG_PULSE
 
96
        &audio_out_pulse,
117
97
#endif
118
 
#ifdef USE_JACK
 
98
#ifdef CONFIG_JACK
119
99
        &audio_out_jack,
120
100
#endif
121
 
#ifdef HAVE_NAS
122
 
        &audio_out_nas,
 
101
#ifdef CONFIG_NAS
 
102
        &audio_out_nas,
123
103
#endif
124
 
#ifdef HAVE_SDL
 
104
#ifdef CONFIG_SDL
125
105
        &audio_out_sdl,
126
106
#endif
127
 
#ifdef USE_OPENAL
 
107
#ifdef CONFIG_OPENAL
128
108
        &audio_out_openal,
129
109
#endif
130
 
        &audio_out_mpegpes,
131
 
#ifdef HAVE_DXR2
 
110
        &audio_out_mpegpes,
 
111
#ifdef CONFIG_DXR2
132
112
        &audio_out_dxr2,
133
113
#endif
134
 
#ifdef HAVE_IVTV
 
114
#ifdef CONFIG_IVTV
135
115
        &audio_out_ivtv,
136
116
#endif
137
 
#ifdef HAVE_V4L2_DECODER
 
117
#ifdef CONFIG_V4L2_DECODER
138
118
        &audio_out_v4l2,
139
119
#endif
140
120
        &audio_out_null,
141
121
// should not be auto-selected:
142
 
        &audio_out_pcm,
143
 
        NULL
 
122
        &audio_out_pcm,
 
123
        NULL
144
124
};
145
125
 
146
126
void list_audio_out(void){
147
 
      int i=0;
148
 
      mp_msg(MSGT_AO, MSGL_INFO, MSGTR_AvailableAudioOutputDrivers);
149
 
      mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_AUDIO_OUTPUTS\n");
150
 
      while (audio_out_drivers[i]) {
 
127
    int i=0;
 
128
    mp_msg(MSGT_AO, MSGL_INFO, MSGTR_AvailableAudioOutputDrivers);
 
129
    mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_AUDIO_OUTPUTS\n");
 
130
    while (audio_out_drivers[i]) {
151
131
        const ao_info_t *info = audio_out_drivers[i++]->info;
152
 
        mp_msg(MSGT_GLOBAL, MSGL_INFO,"\t%s\t%s\n", info->short_name, info->name);
153
 
      }
154
 
      mp_msg(MSGT_GLOBAL, MSGL_INFO,"\n");
 
132
        mp_msg(MSGT_GLOBAL, MSGL_INFO,"\t%s\t%s\n", info->short_name, info->name);
 
133
    }
 
134
    mp_msg(MSGT_GLOBAL, MSGL_INFO,"\n");
155
135
}
156
136
 
157
 
ao_functions_t* init_best_audio_out(char** ao_list,int use_plugin,int rate,int channels,int format,int flags){
 
137
const ao_functions_t* init_best_audio_out(char** ao_list,int use_plugin,int rate,int channels,int format,int flags){
158
138
    int i;
159
139
    // first try the preferred drivers, with their optional subdevice param:
160
140
    if(ao_list && ao_list[0])
162
142
        char* ao=ao_list[0];
163
143
        int ao_len;
164
144
        if (strncmp(ao, "alsa9", 5) == 0 || strncmp(ao, "alsa1x", 6) == 0) {
165
 
          mp_msg(MSGT_AO, MSGL_FATAL, MSGTR_AO_ALSA9_1x_Removed);
166
 
          exit_player(NULL);
 
145
            mp_msg(MSGT_AO, MSGL_FATAL, MSGTR_AO_ALSA9_1x_Removed);
 
146
            exit_player(NULL);
167
147
        }
168
148
        if (ao_subdevice) {
169
 
          free(ao_subdevice);
170
 
          ao_subdevice = NULL;
171
 
        }
172
 
        ao_subdevice=strchr(ao,':');
173
 
        if(ao_subdevice){
174
 
            ao_len = ao_subdevice - ao;
175
 
            ao_subdevice = strdup(&ao[ao_len + 1]);
176
 
        }
177
 
        else
178
 
            ao_len = strlen(ao);
179
 
        for(i=0;audio_out_drivers[i];i++){
180
 
            ao_functions_t* audio_out=audio_out_drivers[i];
181
 
            if(!strncmp(audio_out->info->short_name,ao,ao_len)){
182
 
                // name matches, try it
183
 
                if(audio_out->init(rate,channels,format,flags))
184
 
                    return audio_out; // success!
185
 
            }
186
 
        }
 
149
            free(ao_subdevice);
 
150
            ao_subdevice = NULL;
 
151
        }
 
152
        ao_subdevice=strchr(ao,':');
 
153
        if(ao_subdevice){
 
154
            ao_len = ao_subdevice - ao;
 
155
            ao_subdevice = strdup(&ao[ao_len + 1]);
 
156
        }
 
157
        else
 
158
            ao_len = strlen(ao);
 
159
 
 
160
        mp_msg(MSGT_AO, MSGL_V, MSGTR_AO_TryingPreferredAudioDriver,
 
161
               ao_len, ao, ao_subdevice ? ao_subdevice : "[none]");
 
162
 
 
163
        for(i=0;audio_out_drivers[i];i++){
 
164
            const ao_functions_t* audio_out=audio_out_drivers[i];
 
165
            if(!strncmp(audio_out->info->short_name,ao,ao_len)){
 
166
                // name matches, try it
 
167
                if(audio_out->init(rate,channels,format,flags))
 
168
                    return audio_out; // success!
 
169
                else
 
170
                    mp_msg(MSGT_AO, MSGL_WARN, MSGTR_AO_FailedInit, ao);
 
171
                break;
 
172
            }
 
173
        }
 
174
        if (!audio_out_drivers[i]) // we searched through the entire list
 
175
            mp_msg(MSGT_AO, MSGL_WARN, MSGTR_AO_NoSuchDriver, ao_len, ao);
187
176
        // continue...
188
 
        ++ao_list;
189
 
        if(!(ao_list[0])) return NULL; // do NOT fallback to others
 
177
        ++ao_list;
 
178
        if(!(ao_list[0])) return NULL; // do NOT fallback to others
190
179
      }
191
180
    if (ao_subdevice) {
192
 
      free(ao_subdevice);
193
 
      ao_subdevice = NULL;
 
181
        free(ao_subdevice);
 
182
        ao_subdevice = NULL;
194
183
    }
 
184
 
 
185
    mp_msg(MSGT_AO, MSGL_V, MSGTR_AO_TryingEveryKnown);
 
186
 
195
187
    // now try the rest...
196
188
    for(i=0;audio_out_drivers[i];i++){
197
 
        ao_functions_t* audio_out=audio_out_drivers[i];
198
 
//      if(audio_out->control(AOCONTROL_QUERY_FORMAT, (int)format) == CONTROL_TRUE)
199
 
        if(audio_out->init(rate,channels,format,flags))
200
 
            return audio_out; // success!
 
189
        const ao_functions_t* audio_out=audio_out_drivers[i];
 
190
//        if(audio_out->control(AOCONTROL_QUERY_FORMAT, (int)format) == CONTROL_TRUE)
 
191
        if(audio_out->init(rate,channels,format,flags))
 
192
            return audio_out; // success!
201
193
    }
202
194
    return NULL;
203
195
}