annotate libao2/ao_alsa5.c @ 28820:0581bb91e78e

get rid of full_buffers variable, if the check it is used for is triggered something is seriously wrong and the ao will not work right anyway.
author reimar
date Fri, 06 Mar 2009 19:07:50 +0000
parents e45b08f2f5d3
children 9a5b8c2ed6de
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
996
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
1 /*
28343
e45b08f2f5d3 Add standard license headers.
diego
parents: 26757
diff changeset
2 * ALSA 0.5.x audio output driver
e45b08f2f5d3 Add standard license headers.
diego
parents: 26757
diff changeset
3 *
e45b08f2f5d3 Add standard license headers.
diego
parents: 26757
diff changeset
4 * Copyright (C) 2001 Alex Beregszaszi
e45b08f2f5d3 Add standard license headers.
diego
parents: 26757
diff changeset
5 *
e45b08f2f5d3 Add standard license headers.
diego
parents: 26757
diff changeset
6 * Thanks to Arpi for helping me ;)
e45b08f2f5d3 Add standard license headers.
diego
parents: 26757
diff changeset
7 *
e45b08f2f5d3 Add standard license headers.
diego
parents: 26757
diff changeset
8 * MPlayer is free software; you can redistribute it and/or modify
e45b08f2f5d3 Add standard license headers.
diego
parents: 26757
diff changeset
9 * it under the terms of the GNU General Public License as published by
e45b08f2f5d3 Add standard license headers.
diego
parents: 26757
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
e45b08f2f5d3 Add standard license headers.
diego
parents: 26757
diff changeset
11 * (at your option) any later version.
e45b08f2f5d3 Add standard license headers.
diego
parents: 26757
diff changeset
12 *
e45b08f2f5d3 Add standard license headers.
diego
parents: 26757
diff changeset
13 * MPlayer is distributed in the hope that it will be useful,
e45b08f2f5d3 Add standard license headers.
diego
parents: 26757
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
e45b08f2f5d3 Add standard license headers.
diego
parents: 26757
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
e45b08f2f5d3 Add standard license headers.
diego
parents: 26757
diff changeset
16 * GNU General Public License for more details.
e45b08f2f5d3 Add standard license headers.
diego
parents: 26757
diff changeset
17 *
e45b08f2f5d3 Add standard license headers.
diego
parents: 26757
diff changeset
18 * You should have received a copy of the GNU General Public License along
e45b08f2f5d3 Add standard license headers.
diego
parents: 26757
diff changeset
19 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
e45b08f2f5d3 Add standard license headers.
diego
parents: 26757
diff changeset
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
e45b08f2f5d3 Add standard license headers.
diego
parents: 26757
diff changeset
21 */
996
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
22
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
23 #include <errno.h>
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
24 #include <sys/asoundlib.h>
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
25
14123
a92101a7eb49 Make include paths consistent.
diego
parents: 13383
diff changeset
26 #include "config.h"
996
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
27
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
28 #include "audio_out.h"
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
29 #include "audio_out_internal.h"
14245
815f03b7cee5 removing AFMT_ dependancy
alex
parents: 14123
diff changeset
30 #include "libaf/af_format.h"
996
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
31
14123
a92101a7eb49 Make include paths consistent.
diego
parents: 13383
diff changeset
32 #include "mp_msg.h"
a92101a7eb49 Make include paths consistent.
diego
parents: 13383
diff changeset
33 #include "help_mp.h"
5902
2639d60fe5c2 play() fix by Jimen Ching <jching@flex.com>, additional printf->mp_msg conversions (for coming i18n support)
alex
parents: 5790
diff changeset
34
996
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
35 static ao_info_t info =
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
36 {
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
37 "ALSA-0.5.x audio output",
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
38 "alsa5",
10366
faa09ea4ed6d removing my (non-working) email address
alex
parents: 9670
diff changeset
39 "Alex Beregszaszi",
996
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
40 ""
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
41 };
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
42
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
43 LIBAO_EXTERN(alsa5)
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
44
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
45 static snd_pcm_t *alsa_handler;
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
46 static snd_pcm_format_t alsa_format;
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
47 static int alsa_rate = SND_PCM_RATE_CONTINUOUS;
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
48
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
49 /* to set/get/query special features/parameters */
9633
12b1790038b0 64bit libao2 fix by Jens Axboe <mplayer-dev@kernel.dk>
alex
parents: 8027
diff changeset
50 static int control(int cmd, void *arg)
996
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
51 {
26757
0fdf04b07ecb cosmetics: Remove pointless parentheses from return statements.
diego
parents: 18915
diff changeset
52 return CONTROL_UNKNOWN;
996
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
53 }
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
54
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
55 /*
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
56 open & setup audio device
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
57 return: 1=success 0=fail
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
58 */
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
59 static int init(int rate_hz, int channels, int format, int flags)
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
60 {
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
61 int err;
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
62 int cards = -1;
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
63 snd_pcm_channel_params_t params;
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
64 snd_pcm_channel_setup_t setup;
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
65 snd_pcm_info_t info;
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
66 snd_pcm_channel_info_t chninfo;
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
67
13383
c1955840883d mp_msg transition of unmaintained audio output drivers.
ivo
parents: 12145
diff changeset
68 mp_msg(MSGT_AO, MSGL_INFO, MSGTR_AO_ALSA5_InitInfo, rate_hz,
14264
cb5fbade8a5c af_fmt2str_short
alex
parents: 14255
diff changeset
69 channels, af_fmt2str_short(format));
996
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
70
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
71 alsa_handler = NULL;
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
72
5902
2639d60fe5c2 play() fix by Jimen Ching <jching@flex.com>, additional printf->mp_msg conversions (for coming i18n support)
alex
parents: 5790
diff changeset
73 mp_msg(MSGT_AO, MSGL_V, "alsa-init: compiled for ALSA-%s (%d)\n", SND_LIB_VERSION_STR,
2639d60fe5c2 play() fix by Jimen Ching <jching@flex.com>, additional printf->mp_msg conversions (for coming i18n support)
alex
parents: 5790
diff changeset
74 SND_LIB_VERSION);
996
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
75
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
76 if ((cards = snd_cards()) < 0)
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
77 {
13383
c1955840883d mp_msg transition of unmaintained audio output drivers.
ivo
parents: 12145
diff changeset
78 mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_ALSA5_SoundCardNotFound);
26757
0fdf04b07ecb cosmetics: Remove pointless parentheses from return statements.
diego
parents: 18915
diff changeset
79 return 0;
996
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
80 }
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
81
3095
981a9e5118ce interface to libao2 changed ao_plugin added
anders
parents: 3087
diff changeset
82 ao_data.format = format;
7659
b10df387019c updated for libaf...
arpi
parents: 5902
diff changeset
83 ao_data.channels = channels;
3095
981a9e5118ce interface to libao2 changed ao_plugin added
anders
parents: 3087
diff changeset
84 ao_data.samplerate = rate_hz;
7659
b10df387019c updated for libaf...
arpi
parents: 5902
diff changeset
85 ao_data.bps = ao_data.samplerate*ao_data.channels;
3095
981a9e5118ce interface to libao2 changed ao_plugin added
anders
parents: 3087
diff changeset
86 ao_data.outburst = OUTBURST;
981a9e5118ce interface to libao2 changed ao_plugin added
anders
parents: 3087
diff changeset
87 ao_data.buffersize = 16384;
996
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
88
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
89 memset(&alsa_format, 0, sizeof(alsa_format));
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
90 switch (format)
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
91 {
14245
815f03b7cee5 removing AFMT_ dependancy
alex
parents: 14123
diff changeset
92 case AF_FORMAT_S8:
996
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
93 alsa_format.format = SND_PCM_SFMT_S8;
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
94 break;
14245
815f03b7cee5 removing AFMT_ dependancy
alex
parents: 14123
diff changeset
95 case AF_FORMAT_U8:
996
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
96 alsa_format.format = SND_PCM_SFMT_U8;
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
97 break;
14245
815f03b7cee5 removing AFMT_ dependancy
alex
parents: 14123
diff changeset
98 case AF_FORMAT_U16_LE:
996
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
99 alsa_format.format = SND_PCM_SFMT_U16_LE;
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
100 break;
14245
815f03b7cee5 removing AFMT_ dependancy
alex
parents: 14123
diff changeset
101 case AF_FORMAT_U16_BE:
996
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
102 alsa_format.format = SND_PCM_SFMT_U16_BE;
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
103 break;
5790
d141f1e9cc36 AFMT_AC3 autodetect/fallback to S16
arpi
parents: 3700
diff changeset
104 #ifndef WORDS_BIGENDIAN
14245
815f03b7cee5 removing AFMT_ dependancy
alex
parents: 14123
diff changeset
105 case AF_FORMAT_AC3:
5790
d141f1e9cc36 AFMT_AC3 autodetect/fallback to S16
arpi
parents: 3700
diff changeset
106 #endif
14245
815f03b7cee5 removing AFMT_ dependancy
alex
parents: 14123
diff changeset
107 case AF_FORMAT_S16_LE:
996
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
108 alsa_format.format = SND_PCM_SFMT_S16_LE;
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
109 break;
5790
d141f1e9cc36 AFMT_AC3 autodetect/fallback to S16
arpi
parents: 3700
diff changeset
110 #ifdef WORDS_BIGENDIAN
14245
815f03b7cee5 removing AFMT_ dependancy
alex
parents: 14123
diff changeset
111 case AF_FORMAT_AC3:
5790
d141f1e9cc36 AFMT_AC3 autodetect/fallback to S16
arpi
parents: 3700
diff changeset
112 #endif
14245
815f03b7cee5 removing AFMT_ dependancy
alex
parents: 14123
diff changeset
113 case AF_FORMAT_S16_BE:
996
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
114 alsa_format.format = SND_PCM_SFMT_S16_BE;
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
115 break;
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
116 default:
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
117 alsa_format.format = SND_PCM_SFMT_MPEG;
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
118 break;
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
119 }
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
120
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
121 switch(alsa_format.format)
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
122 {
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
123 case SND_PCM_SFMT_S16_LE:
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
124 case SND_PCM_SFMT_U16_LE:
3095
981a9e5118ce interface to libao2 changed ao_plugin added
anders
parents: 3087
diff changeset
125 ao_data.bps *= 2;
996
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
126 break;
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
127 case -1:
14264
cb5fbade8a5c af_fmt2str_short
alex
parents: 14255
diff changeset
128 mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_ALSA5_InvalidFormatReq,af_fmt2str_short(format));
26757
0fdf04b07ecb cosmetics: Remove pointless parentheses from return statements.
diego
parents: 18915
diff changeset
129 return 0;
1111
a3c3e1de6f02 little -Wall fix
al3x
parents: 1058
diff changeset
130 default:
a3c3e1de6f02 little -Wall fix
al3x
parents: 1058
diff changeset
131 break;
996
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
132 }
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
133
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
134 switch(rate_hz)
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
135 {
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
136 case 8000:
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
137 alsa_rate = SND_PCM_RATE_8000;
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
138 break;
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
139 case 11025:
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
140 alsa_rate = SND_PCM_RATE_11025;
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
141 break;
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
142 case 16000:
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
143 alsa_rate = SND_PCM_RATE_16000;
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
144 break;
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
145 case 22050:
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
146 alsa_rate = SND_PCM_RATE_22050;
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
147 break;
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
148 case 32000:
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
149 alsa_rate = SND_PCM_RATE_32000;
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
150 break;
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
151 case 44100:
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
152 alsa_rate = SND_PCM_RATE_44100;
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
153 break;
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
154 case 48000:
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
155 alsa_rate = SND_PCM_RATE_48000;
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
156 break;
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
157 case 88200:
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
158 alsa_rate = SND_PCM_RATE_88200;
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
159 break;
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
160 case 96000:
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
161 alsa_rate = SND_PCM_RATE_96000;
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
162 break;
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
163 case 176400:
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
164 alsa_rate = SND_PCM_RATE_176400;
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
165 break;
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
166 case 192000:
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
167 alsa_rate = SND_PCM_RATE_192000;
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
168 break;
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
169 default:
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
170 alsa_rate = SND_PCM_RATE_CONTINUOUS;
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
171 break;
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
172 }
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
173
3095
981a9e5118ce interface to libao2 changed ao_plugin added
anders
parents: 3087
diff changeset
174 alsa_format.rate = ao_data.samplerate;
9670
88e4f274df48 10l to arpi with commit r1.12, noticed by Daniel Mario Vega <dv5a@dc.uba.ar>
alex
parents: 9633
diff changeset
175 alsa_format.voices = ao_data.channels;
996
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
176 alsa_format.interleave = 1;
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
177
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
178 if ((err = snd_pcm_open(&alsa_handler, 0, 0, SND_PCM_OPEN_PLAYBACK)) < 0)
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
179 {
13383
c1955840883d mp_msg transition of unmaintained audio output drivers.
ivo
parents: 12145
diff changeset
180 mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_ALSA5_PlayBackError, snd_strerror(err));
26757
0fdf04b07ecb cosmetics: Remove pointless parentheses from return statements.
diego
parents: 18915
diff changeset
181 return 0;
996
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
182 }
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
183
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
184 if ((err = snd_pcm_info(alsa_handler, &info)) < 0)
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
185 {
13383
c1955840883d mp_msg transition of unmaintained audio output drivers.
ivo
parents: 12145
diff changeset
186 mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_ALSA5_PcmInfoError, snd_strerror(err));
26757
0fdf04b07ecb cosmetics: Remove pointless parentheses from return statements.
diego
parents: 18915
diff changeset
187 return 0;
996
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
188 }
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
189
13383
c1955840883d mp_msg transition of unmaintained audio output drivers.
ivo
parents: 12145
diff changeset
190 mp_msg(MSGT_AO, MSGL_INFO, MSGTR_AO_ALSA5_SoundcardsFound,
5902
2639d60fe5c2 play() fix by Jimen Ching <jching@flex.com>, additional printf->mp_msg conversions (for coming i18n support)
alex
parents: 5790
diff changeset
191 cards, info.name);
996
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
192
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
193 if (info.flags & SND_PCM_INFO_PLAYBACK)
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
194 {
3700
91f801a94a59 memset is more portable than bzero ("BSD"ism)
pl
parents: 3095
diff changeset
195 memset(&chninfo, 0, sizeof(chninfo));
996
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
196 chninfo.channel = SND_PCM_CHANNEL_PLAYBACK;
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
197 if ((err = snd_pcm_channel_info(alsa_handler, &chninfo)) < 0)
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
198 {
13383
c1955840883d mp_msg transition of unmaintained audio output drivers.
ivo
parents: 12145
diff changeset
199 mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_ALSA5_PcmChanInfoError, snd_strerror(err));
26757
0fdf04b07ecb cosmetics: Remove pointless parentheses from return statements.
diego
parents: 18915
diff changeset
200 return 0;
996
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
201 }
3095
981a9e5118ce interface to libao2 changed ao_plugin added
anders
parents: 3087
diff changeset
202
3087
08947e067d80 compiling under qnx, hope it works on all qnx release :)
alex
parents: 1111
diff changeset
203 #ifndef __QNX__
996
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
204 if (chninfo.buffer_size)
3095
981a9e5118ce interface to libao2 changed ao_plugin added
anders
parents: 3087
diff changeset
205 ao_data.buffersize = chninfo.buffer_size;
3087
08947e067d80 compiling under qnx, hope it works on all qnx release :)
alex
parents: 1111
diff changeset
206 #endif
3095
981a9e5118ce interface to libao2 changed ao_plugin added
anders
parents: 3087
diff changeset
207
5902
2639d60fe5c2 play() fix by Jimen Ching <jching@flex.com>, additional printf->mp_msg conversions (for coming i18n support)
alex
parents: 5790
diff changeset
208 mp_msg(MSGT_AO, MSGL_V, "alsa-init: setting preferred buffer size from driver: %d bytes\n",
2639d60fe5c2 play() fix by Jimen Ching <jching@flex.com>, additional printf->mp_msg conversions (for coming i18n support)
alex
parents: 5790
diff changeset
209 ao_data.buffersize);
996
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
210 }
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
211
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
212 memset(&params, 0, sizeof(params));
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
213 params.channel = SND_PCM_CHANNEL_PLAYBACK;
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
214 params.mode = SND_PCM_MODE_STREAM;
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
215 params.format = alsa_format;
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
216 params.start_mode = SND_PCM_START_DATA;
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
217 params.stop_mode = SND_PCM_STOP_ROLLOVER;
3095
981a9e5118ce interface to libao2 changed ao_plugin added
anders
parents: 3087
diff changeset
218 params.buf.stream.queue_size = ao_data.buffersize;
996
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
219 params.buf.stream.fill = SND_PCM_FILL_NONE;
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
220
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
221 if ((err = snd_pcm_channel_params(alsa_handler, &params)) < 0)
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
222 {
13383
c1955840883d mp_msg transition of unmaintained audio output drivers.
ivo
parents: 12145
diff changeset
223 mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_ALSA5_CantSetParms, snd_strerror(err));
26757
0fdf04b07ecb cosmetics: Remove pointless parentheses from return statements.
diego
parents: 18915
diff changeset
224 return 0;
996
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
225 }
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
226
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
227 memset(&setup, 0, sizeof(setup));
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
228 setup.channel = SND_PCM_CHANNEL_PLAYBACK;
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
229 setup.mode = SND_PCM_MODE_STREAM;
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
230 setup.format = alsa_format;
3095
981a9e5118ce interface to libao2 changed ao_plugin added
anders
parents: 3087
diff changeset
231 setup.buf.stream.queue_size = ao_data.buffersize;
981a9e5118ce interface to libao2 changed ao_plugin added
anders
parents: 3087
diff changeset
232 setup.msbits_per_sample = ao_data.bps;
996
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
233
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
234 if ((err = snd_pcm_channel_setup(alsa_handler, &setup)) < 0)
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
235 {
13383
c1955840883d mp_msg transition of unmaintained audio output drivers.
ivo
parents: 12145
diff changeset
236 mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_ALSA5_CantSetChan, snd_strerror(err));
26757
0fdf04b07ecb cosmetics: Remove pointless parentheses from return statements.
diego
parents: 18915
diff changeset
237 return 0;
996
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
238 }
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
239
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
240 if ((err = snd_pcm_channel_prepare(alsa_handler, SND_PCM_CHANNEL_PLAYBACK)) < 0)
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
241 {
13383
c1955840883d mp_msg transition of unmaintained audio output drivers.
ivo
parents: 12145
diff changeset
242 mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_ALSA5_ChanPrepareError, snd_strerror(err));
26757
0fdf04b07ecb cosmetics: Remove pointless parentheses from return statements.
diego
parents: 18915
diff changeset
243 return 0;
996
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
244 }
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
245
5902
2639d60fe5c2 play() fix by Jimen Ching <jching@flex.com>, additional printf->mp_msg conversions (for coming i18n support)
alex
parents: 5790
diff changeset
246 mp_msg(MSGT_AO, MSGL_INFO, "AUDIO: %d Hz/%d channels/%d bps/%d bytes buffer/%s\n",
7659
b10df387019c updated for libaf...
arpi
parents: 5902
diff changeset
247 ao_data.samplerate, ao_data.channels, ao_data.bps, ao_data.buffersize,
996
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
248 snd_pcm_get_format_name(alsa_format.format));
26757
0fdf04b07ecb cosmetics: Remove pointless parentheses from return statements.
diego
parents: 18915
diff changeset
249 return 1;
996
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
250 }
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
251
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
252 /* close audio device */
12145
99798c3cdb93 uninit immed flag
alex
parents: 11678
diff changeset
253 static void uninit(int immed)
996
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
254 {
1055
50c49c976f23 Added missing declaration of variables 'err'.
bertrand
parents: 1046
diff changeset
255 int err;
50c49c976f23 Added missing declaration of variables 'err'.
bertrand
parents: 1046
diff changeset
256
1046
59fc1f75e486 audio_pause/resume implementacio es kozmetikai valtoztatasok
al3x
parents: 1038
diff changeset
257 if ((err = snd_pcm_playback_drain(alsa_handler)) < 0)
59fc1f75e486 audio_pause/resume implementacio es kozmetikai valtoztatasok
al3x
parents: 1038
diff changeset
258 {
13383
c1955840883d mp_msg transition of unmaintained audio output drivers.
ivo
parents: 12145
diff changeset
259 mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_ALSA5_DrainError, snd_strerror(err));
1046
59fc1f75e486 audio_pause/resume implementacio es kozmetikai valtoztatasok
al3x
parents: 1038
diff changeset
260 return;
59fc1f75e486 audio_pause/resume implementacio es kozmetikai valtoztatasok
al3x
parents: 1038
diff changeset
261 }
59fc1f75e486 audio_pause/resume implementacio es kozmetikai valtoztatasok
al3x
parents: 1038
diff changeset
262
59fc1f75e486 audio_pause/resume implementacio es kozmetikai valtoztatasok
al3x
parents: 1038
diff changeset
263 if ((err = snd_pcm_channel_flush(alsa_handler, SND_PCM_CHANNEL_PLAYBACK)) < 0)
59fc1f75e486 audio_pause/resume implementacio es kozmetikai valtoztatasok
al3x
parents: 1038
diff changeset
264 {
13383
c1955840883d mp_msg transition of unmaintained audio output drivers.
ivo
parents: 12145
diff changeset
265 mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_ALSA5_FlushError, snd_strerror(err));
1046
59fc1f75e486 audio_pause/resume implementacio es kozmetikai valtoztatasok
al3x
parents: 1038
diff changeset
266 return;
59fc1f75e486 audio_pause/resume implementacio es kozmetikai valtoztatasok
al3x
parents: 1038
diff changeset
267 }
59fc1f75e486 audio_pause/resume implementacio es kozmetikai valtoztatasok
al3x
parents: 1038
diff changeset
268
59fc1f75e486 audio_pause/resume implementacio es kozmetikai valtoztatasok
al3x
parents: 1038
diff changeset
269 if ((err = snd_pcm_close(alsa_handler)) < 0)
59fc1f75e486 audio_pause/resume implementacio es kozmetikai valtoztatasok
al3x
parents: 1038
diff changeset
270 {
13383
c1955840883d mp_msg transition of unmaintained audio output drivers.
ivo
parents: 12145
diff changeset
271 mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_ALSA5_PcmCloseError, snd_strerror(err));
1046
59fc1f75e486 audio_pause/resume implementacio es kozmetikai valtoztatasok
al3x
parents: 1038
diff changeset
272 return;
59fc1f75e486 audio_pause/resume implementacio es kozmetikai valtoztatasok
al3x
parents: 1038
diff changeset
273 }
996
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
274 }
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
275
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
276 /* stop playing and empty buffers (for seeking/pause) */
18915
99e20a22d5d0 modifies function declarations without parameters from ()
reynaldo
parents: 14264
diff changeset
277 static void reset(void)
996
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
278 {
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
279 int err;
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
280
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
281 if ((err = snd_pcm_playback_drain(alsa_handler)) < 0)
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
282 {
13383
c1955840883d mp_msg transition of unmaintained audio output drivers.
ivo
parents: 12145
diff changeset
283 mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_ALSA5_ResetDrainError, snd_strerror(err));
996
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
284 return;
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
285 }
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
286
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
287 if ((err = snd_pcm_channel_flush(alsa_handler, SND_PCM_CHANNEL_PLAYBACK)) < 0)
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
288 {
13383
c1955840883d mp_msg transition of unmaintained audio output drivers.
ivo
parents: 12145
diff changeset
289 mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_ALSA5_ResetFlushError, snd_strerror(err));
996
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
290 return;
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
291 }
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
292
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
293 if ((err = snd_pcm_channel_prepare(alsa_handler, SND_PCM_CHANNEL_PLAYBACK)) < 0)
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
294 {
13383
c1955840883d mp_msg transition of unmaintained audio output drivers.
ivo
parents: 12145
diff changeset
295 mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_ALSA5_ResetChanPrepareError, snd_strerror(err));
996
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
296 return;
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
297 }
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
298 }
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
299
1038
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 996
diff changeset
300 /* stop playing, keep buffers (for pause) */
18915
99e20a22d5d0 modifies function declarations without parameters from ()
reynaldo
parents: 14264
diff changeset
301 static void audio_pause(void)
1038
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 996
diff changeset
302 {
1046
59fc1f75e486 audio_pause/resume implementacio es kozmetikai valtoztatasok
al3x
parents: 1038
diff changeset
303 int err;
59fc1f75e486 audio_pause/resume implementacio es kozmetikai valtoztatasok
al3x
parents: 1038
diff changeset
304
59fc1f75e486 audio_pause/resume implementacio es kozmetikai valtoztatasok
al3x
parents: 1038
diff changeset
305 if ((err = snd_pcm_playback_drain(alsa_handler)) < 0)
59fc1f75e486 audio_pause/resume implementacio es kozmetikai valtoztatasok
al3x
parents: 1038
diff changeset
306 {
13383
c1955840883d mp_msg transition of unmaintained audio output drivers.
ivo
parents: 12145
diff changeset
307 mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_ALSA5_PauseDrainError, snd_strerror(err));
1046
59fc1f75e486 audio_pause/resume implementacio es kozmetikai valtoztatasok
al3x
parents: 1038
diff changeset
308 return;
59fc1f75e486 audio_pause/resume implementacio es kozmetikai valtoztatasok
al3x
parents: 1038
diff changeset
309 }
59fc1f75e486 audio_pause/resume implementacio es kozmetikai valtoztatasok
al3x
parents: 1038
diff changeset
310
59fc1f75e486 audio_pause/resume implementacio es kozmetikai valtoztatasok
al3x
parents: 1038
diff changeset
311 if ((err = snd_pcm_channel_flush(alsa_handler, SND_PCM_CHANNEL_PLAYBACK)) < 0)
59fc1f75e486 audio_pause/resume implementacio es kozmetikai valtoztatasok
al3x
parents: 1038
diff changeset
312 {
13383
c1955840883d mp_msg transition of unmaintained audio output drivers.
ivo
parents: 12145
diff changeset
313 mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_ALSA5_PauseFlushError, snd_strerror(err));
1046
59fc1f75e486 audio_pause/resume implementacio es kozmetikai valtoztatasok
al3x
parents: 1038
diff changeset
314 return;
59fc1f75e486 audio_pause/resume implementacio es kozmetikai valtoztatasok
al3x
parents: 1038
diff changeset
315 }
1038
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 996
diff changeset
316 }
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 996
diff changeset
317
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 996
diff changeset
318 /* resume playing, after audio_pause() */
18915
99e20a22d5d0 modifies function declarations without parameters from ()
reynaldo
parents: 14264
diff changeset
319 static void audio_resume(void)
1038
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 996
diff changeset
320 {
1055
50c49c976f23 Added missing declaration of variables 'err'.
bertrand
parents: 1046
diff changeset
321 int err;
1046
59fc1f75e486 audio_pause/resume implementacio es kozmetikai valtoztatasok
al3x
parents: 1038
diff changeset
322 if ((err = snd_pcm_channel_prepare(alsa_handler, SND_PCM_CHANNEL_PLAYBACK)) < 0)
59fc1f75e486 audio_pause/resume implementacio es kozmetikai valtoztatasok
al3x
parents: 1038
diff changeset
323 {
13383
c1955840883d mp_msg transition of unmaintained audio output drivers.
ivo
parents: 12145
diff changeset
324 mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_ALSA5_ResumePrepareError, snd_strerror(err));
1046
59fc1f75e486 audio_pause/resume implementacio es kozmetikai valtoztatasok
al3x
parents: 1038
diff changeset
325 return;
59fc1f75e486 audio_pause/resume implementacio es kozmetikai valtoztatasok
al3x
parents: 1038
diff changeset
326 }
1038
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 996
diff changeset
327 }
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 996
diff changeset
328
996
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
329 /*
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
330 plays 'len' bytes of 'data'
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
331 returns: number of bytes played
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
332 */
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
333 static int play(void* data, int len, int flags)
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
334 {
5902
2639d60fe5c2 play() fix by Jimen Ching <jching@flex.com>, additional printf->mp_msg conversions (for coming i18n support)
alex
parents: 5790
diff changeset
335 int got_len;
2639d60fe5c2 play() fix by Jimen Ching <jching@flex.com>, additional printf->mp_msg conversions (for coming i18n support)
alex
parents: 5790
diff changeset
336
2639d60fe5c2 play() fix by Jimen Ching <jching@flex.com>, additional printf->mp_msg conversions (for coming i18n support)
alex
parents: 5790
diff changeset
337 if (!len)
26757
0fdf04b07ecb cosmetics: Remove pointless parentheses from return statements.
diego
parents: 18915
diff changeset
338 return 0;
5902
2639d60fe5c2 play() fix by Jimen Ching <jching@flex.com>, additional printf->mp_msg conversions (for coming i18n support)
alex
parents: 5790
diff changeset
339
2639d60fe5c2 play() fix by Jimen Ching <jching@flex.com>, additional printf->mp_msg conversions (for coming i18n support)
alex
parents: 5790
diff changeset
340 if ((got_len = snd_pcm_write(alsa_handler, data, len)) < 0)
996
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
341 {
5902
2639d60fe5c2 play() fix by Jimen Ching <jching@flex.com>, additional printf->mp_msg conversions (for coming i18n support)
alex
parents: 5790
diff changeset
342 if (got_len == -EPIPE) /* underrun? */
996
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
343 {
13383
c1955840883d mp_msg transition of unmaintained audio output drivers.
ivo
parents: 12145
diff changeset
344 mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_ALSA5_Underrun);
5902
2639d60fe5c2 play() fix by Jimen Ching <jching@flex.com>, additional printf->mp_msg conversions (for coming i18n support)
alex
parents: 5790
diff changeset
345 if ((got_len = snd_pcm_channel_prepare(alsa_handler, SND_PCM_CHANNEL_PLAYBACK)) < 0)
996
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
346 {
13383
c1955840883d mp_msg transition of unmaintained audio output drivers.
ivo
parents: 12145
diff changeset
347 mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_ALSA5_PlaybackPrepareError, snd_strerror(got_len));
26757
0fdf04b07ecb cosmetics: Remove pointless parentheses from return statements.
diego
parents: 18915
diff changeset
348 return 0;
996
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
349 }
5902
2639d60fe5c2 play() fix by Jimen Ching <jching@flex.com>, additional printf->mp_msg conversions (for coming i18n support)
alex
parents: 5790
diff changeset
350 if ((got_len = snd_pcm_write(alsa_handler, data, len)) < 0)
996
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
351 {
13383
c1955840883d mp_msg transition of unmaintained audio output drivers.
ivo
parents: 12145
diff changeset
352 mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_ALSA5_WriteErrorAfterReset,
5902
2639d60fe5c2 play() fix by Jimen Ching <jching@flex.com>, additional printf->mp_msg conversions (for coming i18n support)
alex
parents: 5790
diff changeset
353 snd_strerror(got_len));
26757
0fdf04b07ecb cosmetics: Remove pointless parentheses from return statements.
diego
parents: 18915
diff changeset
354 return 0;
996
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
355 }
26757
0fdf04b07ecb cosmetics: Remove pointless parentheses from return statements.
diego
parents: 18915
diff changeset
356 return got_len; /* 2nd write was ok */
996
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
357 }
13383
c1955840883d mp_msg transition of unmaintained audio output drivers.
ivo
parents: 12145
diff changeset
358 mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_ALSA5_OutPutError, snd_strerror(got_len));
26757
0fdf04b07ecb cosmetics: Remove pointless parentheses from return statements.
diego
parents: 18915
diff changeset
359 return 0;
996
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
360 }
26757
0fdf04b07ecb cosmetics: Remove pointless parentheses from return statements.
diego
parents: 18915
diff changeset
361 return got_len;
996
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
362 }
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
363
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
364 /* how many byes are free in the buffer */
18915
99e20a22d5d0 modifies function declarations without parameters from ()
reynaldo
parents: 14264
diff changeset
365 static int get_space(void)
996
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
366 {
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
367 snd_pcm_channel_status_t ch_stat;
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
368
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
369 ch_stat.channel = SND_PCM_CHANNEL_PLAYBACK;
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
370
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
371 if (snd_pcm_channel_status(alsa_handler, &ch_stat) < 0)
26757
0fdf04b07ecb cosmetics: Remove pointless parentheses from return statements.
diego
parents: 18915
diff changeset
372 return 0; /* error occurred */
996
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
373 else
26757
0fdf04b07ecb cosmetics: Remove pointless parentheses from return statements.
diego
parents: 18915
diff changeset
374 return ch_stat.free;
996
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
375 }
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
376
3095
981a9e5118ce interface to libao2 changed ao_plugin added
anders
parents: 3087
diff changeset
377 /* delay in seconds between first and last sample in buffer */
18915
99e20a22d5d0 modifies function declarations without parameters from ()
reynaldo
parents: 14264
diff changeset
378 static float get_delay(void)
996
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
379 {
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
380 snd_pcm_channel_status_t ch_stat;
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
381
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
382 ch_stat.channel = SND_PCM_CHANNEL_PLAYBACK;
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
383
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
384 if (snd_pcm_channel_status(alsa_handler, &ch_stat) < 0)
26757
0fdf04b07ecb cosmetics: Remove pointless parentheses from return statements.
diego
parents: 18915
diff changeset
385 return (float)ao_data.buffersize/(float)ao_data.bps; /* error occurred */
996
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
386 else
26757
0fdf04b07ecb cosmetics: Remove pointless parentheses from return statements.
diego
parents: 18915
diff changeset
387 return (float)ch_stat.count/(float)ao_data.bps;
996
a97eb50a2c3b initial alsa support by al3x
pontscho
parents:
diff changeset
388 }