mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-11-02 09:01:48 -05:00
pcm: plugin - tidy snd_pcm_plugin_avail_update()
No functional changes - move the code to snd_pcm_plugin_sync_hw_ptr() and put the mmap capture updates to separate function for readability. Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
parent
49eea5d7bc
commit
fa1895aa2b
1 changed files with 79 additions and 69 deletions
|
|
@ -460,24 +460,15 @@ snd_pcm_plugin_mmap_commit(snd_pcm_t *pcm,
|
|||
return xfer > 0 ? xfer : err;
|
||||
}
|
||||
|
||||
static snd_pcm_sframes_t snd_pcm_plugin_avail_update(snd_pcm_t *pcm)
|
||||
static snd_pcm_sframes_t
|
||||
snd_pcm_plugin_sync_hw_ptr_capture(snd_pcm_t *pcm,
|
||||
snd_pcm_sframes_t slave_size)
|
||||
{
|
||||
snd_pcm_plugin_t *plugin = pcm->private_data;
|
||||
snd_pcm_t *slave = plugin->gen.slave;
|
||||
snd_pcm_sframes_t slave_size;
|
||||
int err;
|
||||
|
||||
slave_size = snd_pcm_avail_update(slave);
|
||||
if (pcm->stream == SND_PCM_STREAM_CAPTURE &&
|
||||
pcm->access != SND_PCM_ACCESS_RW_INTERLEAVED &&
|
||||
pcm->access != SND_PCM_ACCESS_RW_NONINTERLEAVED)
|
||||
goto _capture;
|
||||
*pcm->hw.ptr = *slave->hw.ptr;
|
||||
return slave_size;
|
||||
_capture:
|
||||
{
|
||||
const snd_pcm_channel_area_t *areas;
|
||||
snd_pcm_uframes_t xfer, hw_offset, size;
|
||||
int err;
|
||||
|
||||
xfer = snd_pcm_mmap_capture_avail(pcm);
|
||||
size = pcm->buffer_size - xfer;
|
||||
|
|
@ -510,7 +501,6 @@ static snd_pcm_sframes_t snd_pcm_plugin_avail_update(snd_pcm_t *pcm)
|
|||
result = snd_pcm_mmap_commit(slave, slave_offset, slave_frames);
|
||||
if (result > 0 && (snd_pcm_uframes_t)result != slave_frames) {
|
||||
snd_pcm_sframes_t res;
|
||||
|
||||
res = plugin->undo_read(slave, areas, hw_offset, frames, slave_frames - result);
|
||||
if (res < 0) {
|
||||
err = res;
|
||||
|
|
@ -532,10 +522,30 @@ static snd_pcm_sframes_t snd_pcm_plugin_avail_update(snd_pcm_t *pcm)
|
|||
xfer += frames;
|
||||
}
|
||||
return (snd_pcm_sframes_t)xfer;
|
||||
|
||||
error:
|
||||
error:
|
||||
return xfer > 0 ? (snd_pcm_sframes_t)xfer : err;
|
||||
}
|
||||
}
|
||||
|
||||
static snd_pcm_sframes_t snd_pcm_plugin_sync_hw_ptr(snd_pcm_t *pcm,
|
||||
snd_pcm_uframes_t slave_hw_ptr,
|
||||
snd_pcm_sframes_t slave_size)
|
||||
{
|
||||
if (pcm->stream == SND_PCM_STREAM_CAPTURE &&
|
||||
pcm->access != SND_PCM_ACCESS_RW_INTERLEAVED &&
|
||||
pcm->access != SND_PCM_ACCESS_RW_NONINTERLEAVED)
|
||||
return snd_pcm_plugin_sync_hw_ptr_capture(pcm, slave_size);
|
||||
*pcm->hw.ptr = slave_hw_ptr;
|
||||
return slave_size;
|
||||
}
|
||||
|
||||
static snd_pcm_sframes_t snd_pcm_plugin_avail_update(snd_pcm_t *pcm)
|
||||
{
|
||||
snd_pcm_plugin_t *plugin = pcm->private_data;
|
||||
snd_pcm_t *slave = plugin->gen.slave;
|
||||
snd_pcm_sframes_t slave_size;
|
||||
|
||||
slave_size = snd_pcm_avail_update(slave);
|
||||
return snd_pcm_plugin_sync_hw_ptr(pcm, *slave->hw.ptr, slave_size);
|
||||
}
|
||||
|
||||
static int snd_pcm_plugin_status(snd_pcm_t *pcm, snd_pcm_status_t * status)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue