mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-10-29 05:40:25 -04:00
Changed result of mmap_commit callback
(follows description of snd_pcm_mmap_commit function).
This commit is contained in:
parent
8ca451f0e1
commit
0917ba63b0
11 changed files with 57 additions and 53 deletions
|
|
@ -279,7 +279,7 @@ static snd_pcm_sframes_t snd_pcm_file_readn(snd_pcm_t *pcm, void **bufs, snd_pcm
|
|||
return n;
|
||||
}
|
||||
|
||||
static snd_pcm_sframes_t snd_pcm_file_mmap_commit(snd_pcm_t *pcm,
|
||||
static int snd_pcm_file_mmap_commit(snd_pcm_t *pcm,
|
||||
snd_pcm_uframes_t offset,
|
||||
snd_pcm_uframes_t size)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -185,7 +185,7 @@ static snd_pcm_sframes_t snd_pcm_hooks_readn(snd_pcm_t *pcm, void **bufs, snd_pc
|
|||
return snd_pcm_readn(h->slave, bufs, size);
|
||||
}
|
||||
|
||||
static snd_pcm_sframes_t snd_pcm_hooks_mmap_commit(snd_pcm_t *pcm,
|
||||
static int snd_pcm_hooks_mmap_commit(snd_pcm_t *pcm,
|
||||
snd_pcm_uframes_t offset,
|
||||
snd_pcm_uframes_t size)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@ typedef struct {
|
|||
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 {
|
||||
|
|
|
|||
|
|
@ -396,7 +396,7 @@ static int snd_pcm_meter_resume(snd_pcm_t *pcm)
|
|||
return snd_pcm_resume(meter->slave);
|
||||
}
|
||||
|
||||
static snd_pcm_sframes_t snd_pcm_meter_mmap_commit(snd_pcm_t *pcm,
|
||||
static int snd_pcm_meter_mmap_commit(snd_pcm_t *pcm,
|
||||
snd_pcm_uframes_t offset,
|
||||
snd_pcm_uframes_t size)
|
||||
{
|
||||
|
|
@ -406,11 +406,10 @@ static snd_pcm_sframes_t snd_pcm_meter_mmap_commit(snd_pcm_t *pcm,
|
|||
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)
|
||||
|
|
|
|||
|
|
@ -506,26 +506,22 @@ static int snd_pcm_multi_resume(snd_pcm_t *pcm)
|
|||
return err;
|
||||
}
|
||||
|
||||
static snd_pcm_sframes_t snd_pcm_multi_mmap_commit(snd_pcm_t *pcm,
|
||||
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;
|
||||
slave = multi->slaves[i].pcm;
|
||||
err = snd_pcm_mmap_commit(slave, offset, size);
|
||||
if (err < 0)
|
||||
return err;
|
||||
}
|
||||
if ((snd_pcm_uframes_t) frames != size)
|
||||
return -EBADFD;
|
||||
}
|
||||
return size;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int snd_pcm_multi_mmap(snd_pcm_t *pcm ATTRIBUTE_UNUSED)
|
||||
|
|
|
|||
|
|
@ -221,11 +221,17 @@ static snd_pcm_sframes_t snd_pcm_null_readn(snd_pcm_t *pcm, void **bufs ATTRIBUT
|
|||
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,
|
||||
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)
|
||||
|
|
|
|||
|
|
@ -1821,7 +1821,7 @@ static snd_interval_t refine_intervals[SND_PCM_HW_PARAM_LAST_INTERVAL - SND_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)
|
||||
{
|
||||
|
|
@ -1995,7 +1995,7 @@ int snd_pcm_hw_refine_slave(snd_pcm_t *pcm, 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);
|
||||
|
|
|
|||
|
|
@ -286,7 +286,7 @@ snd_pcm_sframes_t snd_pcm_plugin_readn(snd_pcm_t *pcm, void **bufs, snd_pcm_ufra
|
|||
snd_pcm_plugin_read_areas);
|
||||
}
|
||||
|
||||
snd_pcm_sframes_t snd_pcm_plugin_mmap_commit(snd_pcm_t *pcm,
|
||||
int snd_pcm_plugin_mmap_commit(snd_pcm_t *pcm,
|
||||
snd_pcm_uframes_t offset ATTRIBUTE_UNUSED,
|
||||
snd_pcm_uframes_t size)
|
||||
{
|
||||
|
|
@ -294,20 +294,22 @@ snd_pcm_sframes_t snd_pcm_plugin_mmap_commit(snd_pcm_t *pcm,
|
|||
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;
|
||||
|
|
@ -331,7 +333,8 @@ snd_pcm_sframes_t snd_pcm_plugin_mmap_commit(snd_pcm_t *pcm,
|
|||
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)
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ snd_pcm_sframes_t snd_pcm_plugin_writei(snd_pcm_t *pcm, const void *buffer, snd_
|
|||
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);
|
||||
|
|
|
|||
|
|
@ -759,14 +759,14 @@ static snd_pcm_sframes_t snd_pcm_share_avail_update(snd_pcm_t *pcm)
|
|||
}
|
||||
|
||||
/* Call it with mutex held */
|
||||
static snd_pcm_sframes_t _snd_pcm_share_mmap_commit(snd_pcm_t *pcm,
|
||||
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) {
|
||||
|
|
@ -792,10 +792,10 @@ static snd_pcm_sframes_t _snd_pcm_share_mmap_commit(snd_pcm_t *pcm,
|
|||
}
|
||||
_snd_pcm_share_update(pcm);
|
||||
}
|
||||
return size;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static snd_pcm_sframes_t snd_pcm_share_mmap_commit(snd_pcm_t *pcm,
|
||||
static int snd_pcm_share_mmap_commit(snd_pcm_t *pcm,
|
||||
snd_pcm_uframes_t offset,
|
||||
snd_pcm_uframes_t size)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -446,7 +446,7 @@ static int snd_pcm_shm_resume(snd_pcm_t *pcm)
|
|||
return snd_pcm_shm_action(pcm);
|
||||
}
|
||||
|
||||
static snd_pcm_sframes_t snd_pcm_shm_mmap_commit(snd_pcm_t *pcm,
|
||||
static int snd_pcm_shm_mmap_commit(snd_pcm_t *pcm,
|
||||
snd_pcm_uframes_t offset ATTRIBUTE_UNUSED,
|
||||
snd_pcm_uframes_t size)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue