Fixed longstanding avail compute bug. Cosmetic fixes

This commit is contained in:
Abramo Bagnara 2001-02-14 09:36:00 +00:00
parent 31fcb58e9d
commit c71b72ee27
2 changed files with 10 additions and 4 deletions

View file

@ -496,9 +496,10 @@ static void snd_pcm_hw_dump(snd_pcm_t *pcm, snd_output_t *out)
{
snd_pcm_hw_t *hw = pcm->private_data;
char *name = "Unknown";
snd_card_get_name(hw->card, &name);
int err = snd_card_get_name(hw->card, &name);
assert(err >= 0);
snd_output_printf(out, "Hardware PCM card %d '%s' device %d subdevice %d\n",
hw->card, name, hw->device, hw->subdevice);
hw->card, name, hw->device, hw->subdevice);
free(name);
if (pcm->setup) {
snd_output_printf(out, "\nIts setup is:\n");

View file

@ -208,7 +208,9 @@ static inline snd_pcm_uframes_t snd_pcm_mmap_playback_avail(snd_pcm_t *pcm)
{
snd_pcm_sframes_t avail;
avail = *pcm->hw_ptr + pcm->buffer_size - *pcm->appl_ptr;
if (avail < 0)
if (avail >= pcm->boundary)
avail -= pcm->boundary;
else if (avail < 0)
avail += pcm->boundary;
return avail;
}
@ -226,8 +228,11 @@ static inline snd_pcm_uframes_t snd_pcm_mmap_avail(snd_pcm_t *pcm)
{
snd_pcm_sframes_t avail;
avail = *pcm->hw_ptr - *pcm->appl_ptr;
if (pcm->stream == SND_PCM_STREAM_PLAYBACK)
if (pcm->stream == SND_PCM_STREAM_PLAYBACK) {
avail += pcm->buffer_size;
if (avail >= pcm->boundary)
avail -= pcm->boundary;
}
if (avail < 0)
avail += pcm->boundary;
return avail;