changeset 17572:580dc69d69bf

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.
author cladisch
date Fri, 10 Feb 2006 09:21:17 +0000
parents e476a1d38087
children 8921544f4114
files libao2/ao_alsa.c
diffstat 1 files changed, 3 insertions(+), 55 deletions(-) [+]
line wrap: on
line diff
--- a/libao2/ao_alsa.c	Fri Feb 10 09:20:08 2006 +0000
+++ b/libao2/ao_alsa.c	Fri Feb 10 09:21:17 2006 +0000
@@ -64,8 +64,6 @@
 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 bits_per_sample, bytes_per_sample, bits_per_frame;
 static size_t chunk_bytes;
 
@@ -1021,9 +1019,6 @@
 {
     snd_pcm_status_t *status;
     int ret;
-    char *str_status;
-
-    //snd_pcm_sframes_t avail_frames = 0;
     
     snd_pcm_status_alloca(&status);
     
@@ -1033,56 +1028,9 @@
 	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";
-	first = 1;
-	ret = snd_pcm_status_get_avail(status) * bytes_per_sample;
-	if (ret == 0) //ugly workaround for hang in mmap-mode
-	  ret = 10;
-	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";
-      first = 1;
-      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);
 }