mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2026-03-18 05:33:44 -04: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_plugin_t *plugin = pcm->private_data;
|
||||||
snd_pcm_t *slave = plugin->gen.slave;
|
snd_pcm_t *slave = plugin->gen.slave;
|
||||||
snd_pcm_uframes_t xfer = 0;
|
snd_pcm_uframes_t xfer = 0;
|
||||||
snd_pcm_sframes_t result;
|
snd_pcm_sframes_t result, err;
|
||||||
int err;
|
|
||||||
|
|
||||||
while (size > 0) {
|
while (size > 0) {
|
||||||
snd_pcm_uframes_t frames = size;
|
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_plugin_t *plugin = pcm->private_data;
|
||||||
snd_pcm_t *slave = plugin->gen.slave;
|
snd_pcm_t *slave = plugin->gen.slave;
|
||||||
snd_pcm_uframes_t xfer = 0;
|
snd_pcm_uframes_t xfer = 0;
|
||||||
snd_pcm_sframes_t result;
|
snd_pcm_sframes_t err;
|
||||||
int err;
|
|
||||||
|
|
||||||
while (size > 0) {
|
while (size > 0) {
|
||||||
snd_pcm_uframes_t frames = size;
|
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_offset;
|
||||||
snd_pcm_uframes_t slave_frames = ULONG_MAX;
|
snd_pcm_uframes_t slave_frames = ULONG_MAX;
|
||||||
|
|
||||||
result = snd_pcm_mmap_begin(slave, &slave_areas, &slave_offset, &slave_frames);
|
err = snd_pcm_mmap_begin(slave, &slave_areas, &slave_offset, &slave_frames);
|
||||||
if (result < 0) {
|
if (err < 0)
|
||||||
err = result;
|
|
||||||
goto error;
|
goto error;
|
||||||
}
|
|
||||||
if (slave_frames == 0)
|
if (slave_frames == 0)
|
||||||
break;
|
break;
|
||||||
frames = (plugin->read)(pcm, areas, offset, frames,
|
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;
|
err = -EPIPE;
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
result = snd_pcm_mmap_commit(slave, slave_offset, slave_frames);
|
err = snd_pcm_mmap_commit(slave, slave_offset, slave_frames);
|
||||||
if (result > 0 && (snd_pcm_uframes_t)result != slave_frames) {
|
if (err <= 0)
|
||||||
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;
|
|
||||||
goto error;
|
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);
|
snd_pcm_mmap_appl_forward(pcm, frames);
|
||||||
offset += frames;
|
offset += frames;
|
||||||
|
|
@ -394,8 +384,7 @@ snd_pcm_plugin_mmap_commit(snd_pcm_t *pcm,
|
||||||
const snd_pcm_channel_area_t *areas;
|
const snd_pcm_channel_area_t *areas;
|
||||||
snd_pcm_uframes_t appl_offset;
|
snd_pcm_uframes_t appl_offset;
|
||||||
snd_pcm_sframes_t slave_size;
|
snd_pcm_sframes_t slave_size;
|
||||||
snd_pcm_sframes_t xfer;
|
snd_pcm_sframes_t xfer, err;
|
||||||
int err;
|
|
||||||
|
|
||||||
if (pcm->stream == SND_PCM_STREAM_CAPTURE) {
|
if (pcm->stream == SND_PCM_STREAM_CAPTURE) {
|
||||||
snd_pcm_mmap_appl_forward(pcm, size);
|
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_uframes_t slave_frames = ULONG_MAX;
|
||||||
snd_pcm_sframes_t result;
|
snd_pcm_sframes_t result;
|
||||||
|
|
||||||
result = snd_pcm_mmap_begin(slave, &slave_areas, &slave_offset, &slave_frames);
|
err = snd_pcm_mmap_begin(slave, &slave_areas, &slave_offset, &slave_frames);
|
||||||
if (result < 0) {
|
if (err < 0)
|
||||||
err = result;
|
|
||||||
goto error;
|
goto error;
|
||||||
}
|
|
||||||
if (frames > cont)
|
if (frames > cont)
|
||||||
frames = cont;
|
frames = cont;
|
||||||
frames = plugin->write(pcm, areas, appl_offset, frames,
|
frames = plugin->write(pcm, areas, appl_offset, frames,
|
||||||
slave_areas, slave_offset, &slave_frames);
|
slave_areas, slave_offset, &slave_frames);
|
||||||
result = snd_pcm_mmap_commit(slave, slave_offset, slave_frames);
|
err = result = snd_pcm_mmap_commit(slave, slave_offset, slave_frames);
|
||||||
if (result > 0 && (snd_pcm_uframes_t)result != slave_frames) {
|
if (err <= 0)
|
||||||
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;
|
|
||||||
goto error;
|
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);
|
snd_pcm_mmap_appl_forward(pcm, frames);
|
||||||
if (frames == cont)
|
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;
|
snd_pcm_t *slave = plugin->gen.slave;
|
||||||
const snd_pcm_channel_area_t *areas;
|
const snd_pcm_channel_area_t *areas;
|
||||||
snd_pcm_uframes_t xfer, hw_offset, size;
|
snd_pcm_uframes_t xfer, hw_offset, size;
|
||||||
int err;
|
snd_pcm_sframes_t err;
|
||||||
|
|
||||||
xfer = snd_pcm_mmap_capture_avail(pcm);
|
xfer = snd_pcm_mmap_capture_avail(pcm);
|
||||||
size = pcm->buffer_size - xfer;
|
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;
|
const snd_pcm_channel_area_t *slave_areas;
|
||||||
snd_pcm_uframes_t slave_offset;
|
snd_pcm_uframes_t slave_offset;
|
||||||
snd_pcm_uframes_t slave_frames = ULONG_MAX;
|
snd_pcm_uframes_t slave_frames = ULONG_MAX;
|
||||||
snd_pcm_sframes_t result;
|
|
||||||
/* As mentioned in the ALSA API (see pcm/pcm.c:942):
|
/* As mentioned in the ALSA API (see pcm/pcm.c:942):
|
||||||
* The function #snd_pcm_avail_update()
|
* The function #snd_pcm_avail_update()
|
||||||
* have to be called before any mmap begin+commit operation.
|
* 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.
|
* there is more data available.
|
||||||
*/
|
*/
|
||||||
slave_size = snd_pcm_avail_update(slave);
|
slave_size = snd_pcm_avail_update(slave);
|
||||||
result = snd_pcm_mmap_begin(slave, &slave_areas, &slave_offset, &slave_frames);
|
err = snd_pcm_mmap_begin(slave, &slave_areas, &slave_offset, &slave_frames);
|
||||||
if (result < 0) {
|
if (err < 0)
|
||||||
err = result;
|
|
||||||
goto error;
|
goto error;
|
||||||
}
|
|
||||||
if (frames > cont)
|
if (frames > cont)
|
||||||
frames = cont;
|
frames = cont;
|
||||||
frames = (plugin->read)(pcm, areas, hw_offset, frames,
|
frames = (plugin->read)(pcm, areas, hw_offset, frames,
|
||||||
slave_areas, slave_offset, &slave_frames);
|
slave_areas, slave_offset, &slave_frames);
|
||||||
result = snd_pcm_mmap_commit(slave, slave_offset, slave_frames);
|
err = snd_pcm_mmap_commit(slave, slave_offset, slave_frames);
|
||||||
if (result > 0 && (snd_pcm_uframes_t)result != slave_frames) {
|
if (err < 0)
|
||||||
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;
|
|
||||||
goto error;
|
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);
|
snd_pcm_mmap_hw_forward(pcm, frames);
|
||||||
if (frames == cont)
|
if (frames == cont)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue