mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2026-02-05 04:06:34 -05:00
pcm: plugin - avoid 32-bit to 64-bit return value conversions
Several functions were affected. Simplify code without any functionality change. Signed-off-by: Jaroslav Kysela <jkysela@redhat.com>
This commit is contained in:
parent
a9465869a7
commit
122d362265
1 changed files with 31 additions and 58 deletions
|
|
@ -238,8 +238,7 @@ static snd_pcm_sframes_t snd_pcm_plugin_write_areas(snd_pcm_t *pcm,
|
|||
snd_pcm_plugin_t *plugin = pcm->private_data;
|
||||
snd_pcm_t *slave = plugin->gen.slave;
|
||||
snd_pcm_uframes_t xfer = 0;
|
||||
snd_pcm_sframes_t result;
|
||||
int err;
|
||||
snd_pcm_sframes_t result, err;
|
||||
|
||||
while (size > 0) {
|
||||
snd_pcm_uframes_t frames = size;
|
||||
|
|
@ -296,8 +295,7 @@ static snd_pcm_sframes_t snd_pcm_plugin_read_areas(snd_pcm_t *pcm,
|
|||
snd_pcm_plugin_t *plugin = pcm->private_data;
|
||||
snd_pcm_t *slave = plugin->gen.slave;
|
||||
snd_pcm_uframes_t xfer = 0;
|
||||
snd_pcm_sframes_t result;
|
||||
int err;
|
||||
snd_pcm_sframes_t err;
|
||||
|
||||
while (size > 0) {
|
||||
snd_pcm_uframes_t frames = size;
|
||||
|
|
@ -305,11 +303,9 @@ static snd_pcm_sframes_t snd_pcm_plugin_read_areas(snd_pcm_t *pcm,
|
|||
snd_pcm_uframes_t slave_offset;
|
||||
snd_pcm_uframes_t slave_frames = ULONG_MAX;
|
||||
|
||||
result = snd_pcm_mmap_begin(slave, &slave_areas, &slave_offset, &slave_frames);
|
||||
if (result < 0) {
|
||||
err = result;
|
||||
err = snd_pcm_mmap_begin(slave, &slave_areas, &slave_offset, &slave_frames);
|
||||
if (err < 0)
|
||||
goto error;
|
||||
}
|
||||
if (slave_frames == 0)
|
||||
break;
|
||||
frames = (plugin->read)(pcm, areas, offset, frames,
|
||||
|
|
@ -321,20 +317,14 @@ static snd_pcm_sframes_t snd_pcm_plugin_read_areas(snd_pcm_t *pcm,
|
|||
err = -EPIPE;
|
||||
goto error;
|
||||
}
|
||||
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, offset, frames, slave_frames - result);
|
||||
if (res < 0) {
|
||||
err = res;
|
||||
goto error;
|
||||
}
|
||||
frames -= res;
|
||||
}
|
||||
if (result <= 0) {
|
||||
err = result;
|
||||
err = snd_pcm_mmap_commit(slave, slave_offset, slave_frames);
|
||||
if (err <= 0)
|
||||
goto error;
|
||||
if ((snd_pcm_uframes_t)err != slave_frames) {
|
||||
err = plugin->undo_read(slave, areas, offset, frames, slave_frames - err);
|
||||
if (err < 0)
|
||||
goto error;
|
||||
frames -= err;
|
||||
}
|
||||
snd_pcm_mmap_appl_forward(pcm, frames);
|
||||
offset += frames;
|
||||
|
|
@ -394,8 +384,7 @@ snd_pcm_plugin_mmap_commit(snd_pcm_t *pcm,
|
|||
const snd_pcm_channel_area_t *areas;
|
||||
snd_pcm_uframes_t appl_offset;
|
||||
snd_pcm_sframes_t slave_size;
|
||||
snd_pcm_sframes_t xfer;
|
||||
int err;
|
||||
snd_pcm_sframes_t xfer, err;
|
||||
|
||||
if (pcm->stream == SND_PCM_STREAM_CAPTURE) {
|
||||
snd_pcm_mmap_appl_forward(pcm, size);
|
||||
|
|
@ -415,29 +404,21 @@ snd_pcm_plugin_mmap_commit(snd_pcm_t *pcm,
|
|||
snd_pcm_uframes_t slave_frames = ULONG_MAX;
|
||||
snd_pcm_sframes_t result;
|
||||
|
||||
result = snd_pcm_mmap_begin(slave, &slave_areas, &slave_offset, &slave_frames);
|
||||
if (result < 0) {
|
||||
err = result;
|
||||
err = snd_pcm_mmap_begin(slave, &slave_areas, &slave_offset, &slave_frames);
|
||||
if (err < 0)
|
||||
goto error;
|
||||
}
|
||||
if (frames > cont)
|
||||
frames = cont;
|
||||
frames = plugin->write(pcm, areas, appl_offset, frames,
|
||||
slave_areas, slave_offset, &slave_frames);
|
||||
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_write(pcm, slave_areas, slave_offset + result, slave_frames, slave_frames - result);
|
||||
if (res < 0) {
|
||||
err = res;
|
||||
goto error;
|
||||
}
|
||||
frames -= res;
|
||||
}
|
||||
if (result <= 0) {
|
||||
err = result;
|
||||
err = result = snd_pcm_mmap_commit(slave, slave_offset, slave_frames);
|
||||
if (err <= 0)
|
||||
goto error;
|
||||
if ((snd_pcm_uframes_t)result != slave_frames) {
|
||||
err = plugin->undo_write(pcm, slave_areas, slave_offset + result, slave_frames, slave_frames - result);
|
||||
if (err < 0)
|
||||
goto error;
|
||||
frames -= err;
|
||||
}
|
||||
snd_pcm_mmap_appl_forward(pcm, frames);
|
||||
if (frames == cont)
|
||||
|
|
@ -466,7 +447,7 @@ snd_pcm_plugin_sync_hw_ptr_capture(snd_pcm_t *pcm,
|
|||
snd_pcm_t *slave = plugin->gen.slave;
|
||||
const snd_pcm_channel_area_t *areas;
|
||||
snd_pcm_uframes_t xfer, hw_offset, size;
|
||||
int err;
|
||||
snd_pcm_sframes_t err;
|
||||
|
||||
xfer = snd_pcm_mmap_capture_avail(pcm);
|
||||
size = pcm->buffer_size - xfer;
|
||||
|
|
@ -478,7 +459,6 @@ snd_pcm_plugin_sync_hw_ptr_capture(snd_pcm_t *pcm,
|
|||
const snd_pcm_channel_area_t *slave_areas;
|
||||
snd_pcm_uframes_t slave_offset;
|
||||
snd_pcm_uframes_t slave_frames = ULONG_MAX;
|
||||
snd_pcm_sframes_t result;
|
||||
/* As mentioned in the ALSA API (see pcm/pcm.c:942):
|
||||
* The function #snd_pcm_avail_update()
|
||||
* have to be called before any mmap begin+commit operation.
|
||||
|
|
@ -487,28 +467,21 @@ snd_pcm_plugin_sync_hw_ptr_capture(snd_pcm_t *pcm,
|
|||
* there is more data available.
|
||||
*/
|
||||
slave_size = snd_pcm_avail_update(slave);
|
||||
result = snd_pcm_mmap_begin(slave, &slave_areas, &slave_offset, &slave_frames);
|
||||
if (result < 0) {
|
||||
err = result;
|
||||
err = snd_pcm_mmap_begin(slave, &slave_areas, &slave_offset, &slave_frames);
|
||||
if (err < 0)
|
||||
goto error;
|
||||
}
|
||||
if (frames > cont)
|
||||
frames = cont;
|
||||
frames = (plugin->read)(pcm, areas, hw_offset, frames,
|
||||
slave_areas, slave_offset, &slave_frames);
|
||||
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;
|
||||
goto error;
|
||||
}
|
||||
frames -= res;
|
||||
}
|
||||
if (result <= 0) {
|
||||
err = result;
|
||||
err = snd_pcm_mmap_commit(slave, slave_offset, slave_frames);
|
||||
if (err < 0)
|
||||
goto error;
|
||||
if ((snd_pcm_uframes_t)err != slave_frames) {
|
||||
err = plugin->undo_read(slave, areas, hw_offset, frames, slave_frames - err);
|
||||
if (err < 0)
|
||||
goto error;
|
||||
frames -= err;
|
||||
}
|
||||
snd_pcm_mmap_hw_forward(pcm, frames);
|
||||
if (frames == cont)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue