[MPlayer-dev-eng] Re: [Fwd: Re: mplayer alsa9 patch]
joy
joy at pingfm.org
Mon Jun 24 18:40:25 CEST 2002
On Sun, Jun 23, 2002 at 02:44:01AM +0300, Marius David wrote:
> Hi,
>
> Here is the new patch, did few improvements and mplayer.c is left
> intact. I hope it works for other people too.
>
> Marius David
>
ok i tested your modifications, it seems to work, but i don't see any needs to set alsa_fragsize to 4096, which kind of improvements did it gave to you?
i think the problem is MAX_OUTBURST in config.h its set by default to 65536 which seems to be ok for alsa-0.5.x but for alsa-0.9.x it should be set at least to the half. its similar to that what you did by modifiying mplayer.c. i changed configure to set MAX_OUTBURST dynamically depending on which alsa-version is installed if no alsa is installed it will be set to 16384.
maybe someone who is responsible for configure take a look at it.
i added warning message for a buffer underrun as it was before.
the patches should applied directly to the files as:
patch ao_alsa9.c patchfile
please choose the mplayer-dev mailinglist for further communication, cause maybe more people are interested in this.
--
regards
____-
joy
________/\---------%%%___________-----------
webcast every sunday 2000 cest at pingfm.org
pgp key at: x-hkp://wwwkeys.de.pgp.net
-------------- next part --------------
--- ao_alsa9.c.orig Sun Jun 23 21:01:34 2002
+++ ao_alsa9.c Sun Jun 23 21:07:45 2002
@@ -597,30 +597,31 @@
static int play(void* data, int len, int flags)
{
- int got_len;
-
- got_len = snd_pcm_writei(alsa_handler, data, len / 4);
-
- //if ((got_len = snd_pcm_writei(alsa_handler, data, (len/ao_data.bps))) != (len/ao_data.bps)) {
- //SHOULD BE FIXED
- if (got_len == -EPIPE) /* underrun? */
- {
- printf("alsa-play: alsa underrun, resetting stream\n");
- if ((got_len = snd_pcm_prepare(alsa_handler)) < 0)
- {
- printf("alsa-play: playback prepare error: %s\n", snd_strerror(got_len));
- return(0);
- }
- if ((got_len = snd_pcm_writei(alsa_handler, data, (len/ao_data.bps))) != (len/ao_data.bps))
- {
- printf("alsa-play: write error after reset: %s - giving up\n",
- snd_strerror(got_len));
- return(0);
- }
- return(len); /* 2nd write was ok */
- }
- return(len);
- //}
+ int num_frames=len/ao_data.bps;
+ signed short *output_samples=data;
+ snd_pcm_sframes_t res = 0;
+
+ do {
+ if (res == -EPIPE) /* underrun */
+ {
+ printf("alsa-play: alsa underrun, resetting stream\n");
+ res = snd_pcm_prepare(alsa_handler);
+ }
+ else if (res == -ESTRPIPE) { /* suspend */
+ while ((res = snd_pcm_resume(alsa_handler)) == -EAGAIN)
+ sleep(1);
+ if (res < 0)
+ res = snd_pcm_prepare(alsa_handler);
+ }
+ res = res < 0 ? res : snd_pcm_writei(alsa_handler, (void *)output_samples, num_frames);
+ if (res > 0) {
+ output_samples += ao_data.channels * res;
+ num_frames -= res;
+ }
+ } while (res == -EPIPE || num_frames > 0);
+ if (res < 0)
+ fprintf(stderr, "writei returned error: %s\n", snd_strerror(res));
+ return res < 0 ? (int)res : len;
}
/* how many byes are free in the buffer */
-------------- next part --------------
--- /usr/local2/cvs_work2/mplayer/mplayer_26_06_02/configure Sun Jun 16 16:03:53 2002
+++ ./configure Mon Jun 24 17:34:01 2002
@@ -2779,6 +2779,7 @@
# AUDIO #
#########
+_def_max_outburst='#define MAX_OUTBURST 16384'
echocheck "OSS Audio"
if test "$_ossaudio" = auto ; then
@@ -2870,18 +2871,21 @@
_aomodules="alsa5 $_aomodules"
_def_alsa5='#define HAVE_ALSA5 1'
_def_sys_asoundlib_h='#define HAVE_SYS_ASOUNDLIB_H 1'
+ _def_max_outburst='#define MAX_OUTBURST 65536'
echores "yes (using alsa 0.5.x and sys/asoundlib.h)"
elif test "$_alsaver" = '0.9.x-sys' ; then
_aosrc="$_aosrc ao_alsa9.c"
_aomodules="alsa9 $_aomodules"
_def_alsa9='#define HAVE_ALSA9 1'
_def_sys_asoundlib_h='#define HAVE_SYS_ASOUNDLIB_H 1'
+ _def_max_outburst='#define MAX_OUTBURST 32768'
echores "yes (using alsa 0.9.x and sys/asoundlib.h)"
elif test "$_alsaver" = '0.9.x-alsa' ; then
_aosrc="$_aosrc ao_alsa9.c"
_aomodules="alsa9 $_aomodules"
_def_alsa9='#define HAVE_ALSA9 1'
_def_alsa_asoundlib_h='#define HAVE_ALSA_ASOUNDLIB_H 1'
+ _def_max_outburst='#define MAX_OUTBURST 32768'
echores "yes (using alsa 0.9.x and alsa/asoundlib.h)"
fi
_ld_alsa="-lasound $_ld_dl $_ld_pthread"
@@ -4214,7 +4218,7 @@
$_def_rtc
/* set up max. outburst. use 65536 for ALSA 0.5, for others 16384 is enough */
-#define MAX_OUTBURST 65536
+$_def_max_outburst
/* set up audio OUTBURST. Do not change this! */
#define OUTBURST 512
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 234 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20020624/46e00bd4/attachment.pgp>
More information about the MPlayer-dev-eng
mailing list