diff options
author | cladisch <cladisch@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2006-02-10 09:21:17 +0000 |
---|---|---|
committer | cladisch <cladisch@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2006-02-10 09:21:17 +0000 |
commit | 689c7b37a295bbe4e8465733d17217ba28623e25 (patch) | |
tree | c114b7c5e4fe62e86097d06ed79600bd5c7384bc | |
parent | 508d589e216395e82630e166ca7f01deff522984 (diff) | |
download | mpv-689c7b37a295bbe4e8465733d17217ba28623e25.tar.bz2 mpv-689c7b37a295bbe4e8465733d17217ba28623e25.tar.xz |
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.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@17573 b3059339-0415-0410-9bf9-f77b7e298cf2
-rw-r--r-- | libao2/ao_alsa.c | 58 |
1 files changed, 3 insertions, 55 deletions
diff --git a/libao2/ao_alsa.c b/libao2/ao_alsa.c index f4819f9b9a..f03ea55441 100644 --- a/libao2/ao_alsa.c +++ b/libao2/ao_alsa.c @@ -64,8 +64,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 bits_per_sample, bytes_per_sample, bits_per_frame; static size_t chunk_bytes; @@ -1021,9 +1019,6 @@ static int get_space(void) { 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 @@ static int get_space(void) 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); } |