[MPlayer-dev-eng] [PATCH 8/12] ao_alsa: get_space() fixes

Clemens Ladisch cl at cl.domainfactory-kunde.de
Mon Feb 6 09:29:06 CET 2006


Fix get_space(): we don't need to differentiate between the various PCM
device states, and there is no need to avoid returning a positive value
less than 1024.

Index: MPlayer-1.0pre7try2/libao2/ao_alsa.c
===================================================================
--- MPlayer-1.0pre7try2.orig/libao2/ao_alsa.c	2006-02-05 22:52:14.000000000 +0100
+++ MPlayer-1.0pre7try2/libao2/ao_alsa.c	2006-02-05 22:52:15.000000000 +0100
@@ -63,8 +63,6 @@ static int alsa_fragsize = 4096;
 static int alsa_fragcount = 16;
 static snd_pcm_uframes_t chunk_size = 1024;//is alsa_fragsize / 4
 
-#define MIN_CHUNK_SIZE 1024
-
 static size_t bytes_per_sample;
 
 int ao_mmap = 0;
@@ -819,9 +817,6 @@ static int get_space()
 {
     snd_pcm_status_t *status;
     int ret;
-    char *str_status;
-
-    //snd_pcm_sframes_t avail_frames = 0;
     
     snd_pcm_status_alloca(&status);
     
@@ -831,52 +826,9 @@ static int get_space()
 	return(0);
     }
     
-    switch(snd_pcm_status_get_state(status))
-    {
-    case SND_PCM_STATE_OPEN:
-      str_status = "open";
-      ret = snd_pcm_status_get_avail(status) * bytes_per_sample;
-      break;
-    case SND_PCM_STATE_PREPARED:
-	str_status = "prepared";
-	ret = snd_pcm_status_get_avail(status) * bytes_per_sample;
-	break;
-    case SND_PCM_STATE_RUNNING:
-      ret = snd_pcm_status_get_avail(status) * bytes_per_sample;
-      //avail_frames = snd_pcm_avail_update(alsa_handler) * bytes_per_sample;
-      if (str_status != "open" && str_status != "prepared")
-	str_status = "running";
-      break;
-    case SND_PCM_STATE_PAUSED:
-      mp_msg(MSGT_AO,MSGL_V,"alsa-space: paused");
-      str_status = "paused";
-      ret = 0;
-      break;
-    case SND_PCM_STATE_XRUN:
-      xrun("space");
-      str_status = "xrun";
-      ret = 0;
-      break;
-    default:
-      str_status = "undefined";
-      ret = snd_pcm_status_get_avail(status) * bytes_per_sample;
-      if (ret <= 0) {
-	xrun("space");
-      }
-    }
-
-    if (snd_pcm_status_get_state(status) != SND_PCM_STATE_RUNNING)
-      mp_msg(MSGT_AO,MSGL_V,"alsa-space: free space = %i, %s --\n", ret, str_status);
-    
-    if (ret < 0) {
-      mp_msg(MSGT_AO,MSGL_ERR,"negative value!!\n");
-      ret = 0;
-    }
- 
-    // workaround for too small value returned
-    if (ret < MIN_CHUNK_SIZE)
-      ret = 0;
-
+    ret = snd_pcm_status_get_avail(status) * bytes_per_sample;
+    if (ret > MAX_OUTBURST)
+	    ret = MAX_OUTBURST;
     return(ret);
 }
 




More information about the MPlayer-dev-eng mailing list