audio/out: always round get_space on period size

Round get_space() results in the same way play() rounds the input size.
Some audio APIs do this for various reasons.

This affects only "push" based AOs. Some of these need no change,
because they either do it already right (like ao_openal), or they seem
not to have any such requirements (like ao_pulse).

Needed for the following commit.
This commit is contained in:
wm4 2014-09-06 12:59:00 +02:00
parent d9941e01cc
commit 769ac6fb7b
4 changed files with 6 additions and 4 deletions

View File

@ -675,7 +675,7 @@ static int get_space(struct ao *ao)
unsigned space = snd_pcm_status_get_avail(status);
if (space > p->buffersize) // Buffer underrun?
space = p->buffersize;
return space;
return space / p->outburst * p->outburst;
alsa_error:
return 0;

View File

@ -585,7 +585,7 @@ static int get_space(struct ao *ao)
int space = check_free_buffer_size(ao);
if (space < p->min_free_space)
return 0;
return (space - p->min_free_space) / ao->sstride;
return (space - p->min_free_space) / p->outburst * p->outburst / ao->sstride;
}
/**

View File

@ -148,7 +148,8 @@ static int get_space(struct ao *ao)
struct priv *priv = ao->priv;
drain(ao);
return priv->buffersize - priv->latency - priv->buffered;
int samples = priv->buffersize - priv->latency - priv->buffered;
return samples / priv->outburst * priv->outburst;
}
static int play(struct ao *ao, void **data, int samples, int flags)

View File

@ -273,7 +273,8 @@ static int get_space(struct ao *ao)
; /* nothing */
sio_revents(p->hdl, p->pfd);
return (p->par.bufsz * p->par.pchan * p->par.bps - p->delay) / ao->sstride;
int samples = (p->par.bufsz * p->par.pchan * p->par.bps - p->delay) / ao->sstride;
return samples / p->par.round * p->par.round;
}
/*