(follows description of snd_pcm_mmap_commit function).
return n;
}
-static snd_pcm_sframes_t snd_pcm_file_mmap_commit(snd_pcm_t *pcm,
- snd_pcm_uframes_t offset,
- snd_pcm_uframes_t size)
+static int snd_pcm_file_mmap_commit(snd_pcm_t *pcm,
+ snd_pcm_uframes_t offset,
+ snd_pcm_uframes_t size)
{
snd_pcm_file_t *file = pcm->private_data;
snd_pcm_uframes_t ofs;
return snd_pcm_readn(h->slave, bufs, size);
}
-static snd_pcm_sframes_t snd_pcm_hooks_mmap_commit(snd_pcm_t *pcm,
- snd_pcm_uframes_t offset,
- snd_pcm_uframes_t size)
+static int snd_pcm_hooks_mmap_commit(snd_pcm_t *pcm,
+ snd_pcm_uframes_t offset,
+ snd_pcm_uframes_t size)
{
snd_pcm_hooks_t *h = pcm->private_data;
return snd_pcm_mmap_commit(h->slave, offset, size);
snd_pcm_sframes_t (*readi)(snd_pcm_t *pcm, void *buffer, snd_pcm_uframes_t size);
snd_pcm_sframes_t (*readn)(snd_pcm_t *pcm, void **bufs, snd_pcm_uframes_t size);
snd_pcm_sframes_t (*avail_update)(snd_pcm_t *pcm);
- snd_pcm_sframes_t (*mmap_commit)(snd_pcm_t *pcm, snd_pcm_uframes_t offset, snd_pcm_uframes_t size);
+ int (*mmap_commit)(snd_pcm_t *pcm, snd_pcm_uframes_t offset, snd_pcm_uframes_t size);
} snd_pcm_fast_ops_t;
struct _snd_pcm {
return snd_pcm_resume(meter->slave);
}
-static snd_pcm_sframes_t snd_pcm_meter_mmap_commit(snd_pcm_t *pcm,
- snd_pcm_uframes_t offset,
- snd_pcm_uframes_t size)
+static int snd_pcm_meter_mmap_commit(snd_pcm_t *pcm,
+ snd_pcm_uframes_t offset,
+ snd_pcm_uframes_t size)
{
snd_pcm_meter_t *meter = pcm->private_data;
snd_pcm_uframes_t old_rptr = *pcm->appl_ptr;
if (result <= 0)
return result;
if (pcm->stream == SND_PCM_STREAM_PLAYBACK) {
- snd_pcm_meter_add_frames(pcm, snd_pcm_mmap_areas(pcm), old_rptr,
- (snd_pcm_uframes_t) result);
+ snd_pcm_meter_add_frames(pcm, snd_pcm_mmap_areas(pcm), old_rptr, size);
meter->rptr = *pcm->appl_ptr;
}
- return result;
+ return 0;
}
static snd_pcm_sframes_t snd_pcm_meter_avail_update(snd_pcm_t *pcm)
return err;
}
-static snd_pcm_sframes_t snd_pcm_multi_mmap_commit(snd_pcm_t *pcm,
- snd_pcm_uframes_t offset,
- snd_pcm_uframes_t size)
+static int snd_pcm_multi_mmap_commit(snd_pcm_t *pcm,
+ snd_pcm_uframes_t offset,
+ snd_pcm_uframes_t size)
{
snd_pcm_multi_t *multi = pcm->private_data;
+ snd_pcm_t *slave;
unsigned int i;
+ int err;
for (i = 0; i < multi->slaves_count; ++i) {
- snd_pcm_t *slave = multi->slaves[i].pcm;
- snd_pcm_sframes_t frames = snd_pcm_mmap_commit(slave, offset, size);
- if (frames < 0)
- return frames;
- if (i == 0) {
- size = frames;
- continue;
- }
- if ((snd_pcm_uframes_t) frames != size)
- return -EBADFD;
+ slave = multi->slaves[i].pcm;
+ err = snd_pcm_mmap_commit(slave, offset, size);
+ if (err < 0)
+ return err;
}
- return size;
+ return 0;
}
static int snd_pcm_multi_mmap(snd_pcm_t *pcm ATTRIBUTE_UNUSED)
return snd_pcm_read_areas(pcm, NULL, 0, size, snd_pcm_null_xfer_areas);
}
-static snd_pcm_sframes_t snd_pcm_null_mmap_commit(snd_pcm_t *pcm,
- snd_pcm_uframes_t offset ATTRIBUTE_UNUSED,
- snd_pcm_uframes_t size)
+static int snd_pcm_null_mmap_commit(snd_pcm_t *pcm,
+ snd_pcm_uframes_t offset ATTRIBUTE_UNUSED,
+ snd_pcm_uframes_t size)
{
- return snd_pcm_null_fwd(pcm, size);
+ snd_pcm_sframes_t res;
+
+ res = snd_pcm_null_fwd(pcm, size);
+ if (res < 0)
+ return res;
+ assert((snd_pcm_uframes_t)res == size);
+ return 0;
}
static snd_pcm_sframes_t snd_pcm_null_avail_update(snd_pcm_t *pcm)
},
};
-#undef RULES_DEBUG
+#define RULES_DEBUG
int snd_pcm_hw_refine_soft(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_hw_params_t *params)
{
}
if (err < 0) {
#ifdef RULES_DEBUG
- snd_output_printf(log, "cchange '%s', schange < 0\n", pcm->name);
+ snd_output_printf(log, "cchange '%s', (schange || srefine) < 0\n", pcm->name);
snd_pcm_hw_params_dump(params, log);
#endif
cchange(pcm, params, &sparams);
snd_pcm_plugin_read_areas);
}
-snd_pcm_sframes_t snd_pcm_plugin_mmap_commit(snd_pcm_t *pcm,
- snd_pcm_uframes_t offset ATTRIBUTE_UNUSED,
- snd_pcm_uframes_t size)
+int snd_pcm_plugin_mmap_commit(snd_pcm_t *pcm,
+ snd_pcm_uframes_t offset ATTRIBUTE_UNUSED,
+ snd_pcm_uframes_t size)
{
snd_pcm_plugin_t *plugin = pcm->private_data;
snd_pcm_t *slave = plugin->slave;
const snd_pcm_channel_area_t *areas;
snd_pcm_uframes_t xfer, hw_offset;
- snd_pcm_uframes_t slave_size;
+ snd_pcm_sframes_t slave_size;
if (pcm->stream == SND_PCM_STREAM_CAPTURE) {
snd_atomic_write_begin(&plugin->watom);
snd_pcm_mmap_appl_forward(pcm, size);
snd_atomic_write_end(&plugin->watom);
- return size;
+ return 0;
}
slave_size = snd_pcm_avail_update(slave);
- if (slave_size <= 0)
+ if (slave_size < 0)
return slave_size;
+ if (slave_size == 0)
+ return -EIO;
areas = snd_pcm_mmap_areas(pcm);
hw_offset = snd_pcm_mmap_hw_offset(pcm);
xfer = 0;
- while (size && slave_size) {
+ while (size > 0 && slave_size > 0) {
snd_pcm_uframes_t frames = size;
snd_pcm_uframes_t cont = pcm->buffer_size - hw_offset;
const snd_pcm_channel_area_t *slave_areas;
size -= frames;
slave_size -= slave_frames;
}
- return xfer;
+ assert(size == 0);
+ return 0;
}
snd_pcm_sframes_t snd_pcm_plugin_avail_update(snd_pcm_t *pcm)
snd_pcm_sframes_t snd_pcm_plugin_writen(snd_pcm_t *pcm, void **bufs, snd_pcm_uframes_t size);
snd_pcm_sframes_t snd_pcm_plugin_readi(snd_pcm_t *pcm, void *buffer, snd_pcm_uframes_t size);
snd_pcm_sframes_t snd_pcm_plugin_readn(snd_pcm_t *pcm, void **bufs, snd_pcm_uframes_t size);
-snd_pcm_sframes_t snd_pcm_plugin_mmap_commit(snd_pcm_t *pcm, snd_pcm_uframes_t offset, snd_pcm_uframes_t size);
+int snd_pcm_plugin_mmap_commit(snd_pcm_t *pcm, snd_pcm_uframes_t offset, snd_pcm_uframes_t size);
snd_pcm_sframes_t snd_pcm_plugin_avail_update(snd_pcm_t *pcm);
int snd_pcm_plugin_mmap_status(snd_pcm_t *pcm);
int snd_pcm_plugin_mmap_control(snd_pcm_t *pcm);
}
/* Call it with mutex held */
-static snd_pcm_sframes_t _snd_pcm_share_mmap_commit(snd_pcm_t *pcm,
- snd_pcm_uframes_t offset ATTRIBUTE_UNUSED,
- snd_pcm_uframes_t size)
+static int _snd_pcm_share_mmap_commit(snd_pcm_t *pcm,
+ snd_pcm_uframes_t offset ATTRIBUTE_UNUSED,
+ snd_pcm_uframes_t size)
{
snd_pcm_share_t *share = pcm->private_data;
snd_pcm_share_slave_t *slave = share->slave;
snd_pcm_t *spcm = slave->pcm;
- snd_pcm_sframes_t ret = 0;
+ snd_pcm_sframes_t ret;
snd_pcm_sframes_t frames;
if (pcm->stream == SND_PCM_STREAM_PLAYBACK &&
share->state == SND_PCM_STATE_RUNNING) {
}
_snd_pcm_share_update(pcm);
}
- return size;
+ return 0;
}
-static snd_pcm_sframes_t snd_pcm_share_mmap_commit(snd_pcm_t *pcm,
- snd_pcm_uframes_t offset,
- snd_pcm_uframes_t size)
+static int snd_pcm_share_mmap_commit(snd_pcm_t *pcm,
+ snd_pcm_uframes_t offset,
+ snd_pcm_uframes_t size)
{
snd_pcm_share_t *share = pcm->private_data;
snd_pcm_share_slave_t *slave = share->slave;
return snd_pcm_shm_action(pcm);
}
-static snd_pcm_sframes_t snd_pcm_shm_mmap_commit(snd_pcm_t *pcm,
- snd_pcm_uframes_t offset ATTRIBUTE_UNUSED,
- snd_pcm_uframes_t size)
+static int snd_pcm_shm_mmap_commit(snd_pcm_t *pcm,
+ snd_pcm_uframes_t offset ATTRIBUTE_UNUSED,
+ snd_pcm_uframes_t size)
{
snd_pcm_shm_t *shm = pcm->private_data;
volatile snd_pcm_shm_ctrl_t *ctrl = shm->ctrl;