[Mplayer-cvslog] CVS: main/libao2 ao_alsa9.c,1.34,1.35
Alex Beregszaszi
alex at mplayerhq.hu
Sun Aug 3 19:55:00 CEST 2003
Update of /cvsroot/mplayer/main/libao2
In directory mail:/var/tmp.root/cvs-serv2736
Modified Files:
ao_alsa9.c
Log Message:
better pause mechanism and faster uninit support by Vladimir I. Umnov <uvi at ezmail.ru>
Index: ao_alsa9.c
===================================================================
RCS file: /cvsroot/mplayer/main/libao2/ao_alsa9.c,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -r1.34 -r1.35
--- ao_alsa9.c 3 Jul 2003 20:07:54 -0000 1.34
+++ ao_alsa9.c 3 Aug 2003 17:54:35 -0000 1.35
@@ -70,6 +70,7 @@
static int open_mode;
static int set_block_mode;
+static int alsa_can_pause = 0;
#define ALSA_DEVICE_SIZE 48
@@ -683,6 +684,7 @@
snd_pcm_format_description(alsa_format));
} // end switch alsa_handler (spdif)
+ alsa_can_pause = snd_pcm_hw_params_can_pause(alsa_hwparams);
return(1);
} // end init
@@ -695,9 +697,9 @@
int err;
if (!ao_noblock) {
- if ((err = snd_pcm_drain(alsa_handler)) < 0)
+ if ((err = snd_pcm_drop(alsa_handler)) < 0)
{
- printf("alsa-uninit: pcm drain error: %s\n", snd_strerror(err));
+ printf("alsa-uninit: pcm drop error: %s\n", snd_strerror(err));
return;
}
}
@@ -722,19 +724,20 @@
{
int err;
- if (!ao_noblock) {
- //drain causes error in nonblock-mode!
- if ((err = snd_pcm_drain(alsa_handler)) < 0)
- {
- printf("alsa-pause: pcm drain error: %s\n", snd_strerror(err));
- return;
- }
- }
- else {
- if (verbose>0)
- printf("alsa-pause: paused nonblock\n");
-
- return;
+ if (alsa_can_pause) {
+ if ((err = snd_pcm_pause(alsa_handler, 1)) < 0)
+ {
+ printf("alsa-pause: pcm pause error: %s\n", snd_strerror(err));
+ return;
+ }
+ if (verbose)
+ printf("alsa-pause: pause supported by hardware\n");
+ } else {
+ if ((err = snd_pcm_drop(alsa_handler)) < 0)
+ {
+ printf("alsa-pause: pcm drop error: %s\n", snd_strerror(err));
+ return;
+ }
}
}
@@ -742,10 +745,20 @@
{
int err;
- if ((err = snd_pcm_prepare(alsa_handler)) < 0)
- {
- printf("alsa-resume: pcm prepare error: %s\n", snd_strerror(err));
- return;
+ if (alsa_can_pause) {
+ if ((err = snd_pcm_pause(alsa_handler, 0)) < 0)
+ {
+ printf("alsa-resume: pcm resume error: %s\n", snd_strerror(err));
+ return;
+ }
+ if (verbose)
+ printf("alsa-resume: resume supported by hardware\n");
+ } else {
+ if ((err = snd_pcm_prepare(alsa_handler)) < 0)
+ {
+ printf("alsa-resume: pcm prepare error: %s\n", snd_strerror(err));
+ return;
+ }
}
}
More information about the MPlayer-cvslog
mailing list