[MPlayer-cvslog] CVS: main/libao2 ao_alsa.c,1.34,1.35
Ivo
ivop at euronet.nl
Thu Mar 30 11:33:38 CEST 2006
Hi,
On Monday 13 February 2006 12:43, Clemens Ladisch CVS wrote:
> RCS file: /cvsroot/mplayer/main/libao2/ao_alsa.c,v
> retrieving revision 1.34
> retrieving revision 1.35
> diff -u -r1.34 -r1.35
> --- ao_alsa.c 13 Feb 2006 11:38:12 -0000 1.34
> +++ ao_alsa.c 13 Feb 2006 11:43:25 -0000 1.35
> @@ -256,6 +256,7 @@
> int block;
> strarg_t device;
> snd_pcm_uframes_t bufsize;
> + snd_pcm_uframes_t boundary;
> opt_t subopts[] = {
> {"block", OPT_ARG_BOOL, &block, NULL},
> {"device", OPT_ARG_STR, &device, (opt_test_f)str_maxlen},
> @@ -280,7 +281,6 @@
> ao_data.samplerate = rate_hz;
> ao_data.format = format;
> ao_data.channels = channels;
> - ao_data.outburst = OUTBURST;
>
> switch (format)
> {
> @@ -594,6 +594,49 @@
> mp_msg(MSGT_AO,MSGL_V,"alsa-init: got buffersize=%i\n",
> ao_data.buffersize); }
>
> + if ((err = snd_pcm_hw_params_get_period_size(alsa_hwparams,
> &chunk_size, NULL)) < 0) { + mp_msg(MSGT_AO,MSGL_ERR,"alsa-init: unable
> to get period size: %s\n", snd_strerror(err)); + } else {
> + mp_msg(MSGT_AO,MSGL_V,"alsa-init: got period size %li\n", chunk_size);
> + }
> + ao_data.outburst = chunk_size * bytes_per_sample;
> +
> + /* setting software parameters */
> + if ((err = snd_pcm_sw_params_current(alsa_handler, alsa_swparams))
> < 0) { + mp_msg(MSGT_AO,MSGL_ERR,"alsa-init: unable to get sw-parameters:
> %s\n", + snd_strerror(err));
> + return 0;
> + }
> + if ((err = snd_pcm_sw_params_get_boundary(alsa_swparams,
> &boundary)) < 0) { + mp_msg(MSGT_AO,MSGL_ERR,"alsa-init: unable to get
> boundary: %s\n", + snd_strerror(err));
> + return 0;
> + }
> + /* start playing when one period has been written */
> + if ((err = snd_pcm_sw_params_set_start_threshold(alsa_handler,
> alsa_swparams, chunk_size)) < 0) { + mp_msg(MSGT_AO,MSGL_ERR,"alsa-init:
> unable to set start threshold: %s\n", + snd_strerror(err));
> + return 0;
> + }
> + /* disable underrun reporting */
> + if ((err = snd_pcm_sw_params_set_stop_threshold(alsa_handler,
> alsa_swparams, boundary)) < 0) { + mp_msg(MSGT_AO,MSGL_ERR,"alsa-init:
> unable to set stop threshold: %s\n", + snd_strerror(err));
> + return 0;
> + }
> + /* play silence when there is an underrun */
> + if ((err = snd_pcm_sw_params_set_silence_size(alsa_handler,
> alsa_swparams, boundary)) < 0) { + mp_msg(MSGT_AO,MSGL_ERR,"alsa-init:
> unable to set silence size: %s\n", + snd_strerror(err));
> + return 0;
> + }
> + if ((err = snd_pcm_sw_params(alsa_handler, alsa_swparams)) < 0) {
> + mp_msg(MSGT_AO,MSGL_ERR,"alsa-init: unable to set sw-parameters: %s\n",
> + snd_strerror(err));
> + return 0;
> + }
> + /* end setting sw-params */
> +
This breaks linking on my system, because snd_pcm_sw_params_get_boundary()
is missing. I am not sure how to get the boundary value without that
function (I know nothing about alsa), so I put the function calls that use
it under an #if too. I believe that reverts the behaviour partly to before
this patch in case an old alsa-lib is found? Anyway, this fixes linking and
mplayer -ao alsa foobar.mp3 seems to work properly, but it'll probably
report underruns again, like it did before and not play silence in that
case.
Somebody more knowledgeable about alsa should take a look at this :)
"patch" against current CVS.
--Ivo
Index: libao2/ao_alsa.c
===================================================================
RCS file: /cvsroot/mplayer/main/libao2/ao_alsa.c,v
retrieving revision 1.40
diff -u -r1.40 ao_alsa.c
--- libao2/ao_alsa.c 13 Mar 2006 10:50:37 -0000 1.40
+++ libao2/ao_alsa.c 30 Mar 2006 09:21:08 -0000
@@ -275,7 +275,9 @@
int block;
strarg_t device;
snd_pcm_uframes_t bufsize;
+#if SND_LIB_MAJOR >= 1
snd_pcm_uframes_t boundary;
+#endif
opt_t subopts[] = {
{"block", OPT_ARG_BOOL, &block, NULL},
{"device", OPT_ARG_STR, &device, (opt_test_f)str_maxlen},
@@ -638,17 +640,20 @@
snd_strerror(err));
return 0;
}
+#if SND_LIB_MAJOR >= 1
if ((err = snd_pcm_sw_params_get_boundary(alsa_swparams, &boundary))
< 0) {
mp_msg(MSGT_AO,MSGL_ERR,"alsa-init: unable to get boundary: %s\n",
snd_strerror(err));
return 0;
}
+#endif
/* start playing when one period has been written */
if ((err = snd_pcm_sw_params_set_start_threshold(alsa_handler,
alsa_swparams, chunk_size)) < 0) {
mp_msg(MSGT_AO,MSGL_ERR,"alsa-init: unable to set start threshold:
%s\n",
snd_strerror(err));
return 0;
}
+#if SND_LIB_MAJOR >= 1
/* disable underrun reporting */
if ((err = snd_pcm_sw_params_set_stop_threshold(alsa_handler,
alsa_swparams, boundary)) < 0) {
mp_msg(MSGT_AO,MSGL_ERR,"alsa-init: unable to set stop threshold:
%s\n",
@@ -661,6 +666,7 @@
snd_strerror(err));
return 0;
}
+#endif
if ((err = snd_pcm_sw_params(alsa_handler, alsa_swparams)) < 0) {
mp_msg(MSGT_AO,MSGL_ERR,"alsa-init: unable to set sw-parameters:
%s\n",
snd_strerror(err));
More information about the MPlayer-cvslog
mailing list