pcm: add mmap_begin callback to snd_pcm_fast_ops_t api
PATCH 3/4 pcm: add mmap_begin callback to snd_pcm_fast_ops_t api
main motivation for adding the callback is to use it to enable operation on mmaped buffer before user access for pcm_file plugin
support for MMAP read access with masking by data from input file is not implemented for pcm_file plugin, by adding this callback implementing such feature can be done by rewriting next continuous portion of buffer on each mmap_begin call
plugins like softvol use pcm_plugin interface and overwrite the buffer by looping around it in avail_update callback, this patch hopes to simplify the task by adding new api callback, removing the need for rewriting pcm_file (to use pcm_plugin callbacks) and careful checking when looping around whole mmaped buffer
Signed-off-by Adam Miartus <[email protected]>
Reviewed-by Timo Wischer <[email protected]>
src/pcm/pcm.c +6 -0
@@ -7129,7 +7129,13 @@ int __snd_pcm_mmap_begin(snd_pcm_t *pcm, const snd_pcm_channel_area_t **areas,snd_pcm_uframes_t f;snd_pcm_uframes_t avail;const snd_pcm_channel_area_t *xareas; +assert (pcm && areas && offset && frames); + +if (pcm->fast_ops->mmap_begin) +return pcm->fast_ops->mmap_begin (pcm->fast_op_arg, areas, offset, frames); + +/* fallback for plugins that do not specify new callback */ xareas =snd_pcm_mmap_areas (pcm);if (xareas ==NULL )return -EBADFD ;
src/pcm/pcm_dmix.c +1 -0
@@ -990,6 +990,7 @@ static const snd_pcm_fast_ops_t snd_pcm_dmix_fast_ops = { .poll_descriptors = snd_pcm_direct_poll_descriptors, .poll_descriptors_count = NULL, .poll_revents = snd_pcm_dmix_poll_revents, + .mmap_begin = NULL, };/**
src/pcm/pcm_dshare.c +1 -0
@@ -667,6 +667,7 @@ static const snd_pcm_fast_ops_t snd_pcm_dshare_fast_ops = { .poll_descriptors = snd_pcm_direct_poll_descriptors, .poll_descriptors_count = NULL, .poll_revents = snd_pcm_direct_poll_revents, + .mmap_begin = NULL, };/**
src/pcm/pcm_dsnoop.c +1 -0
@@ -544,6 +544,7 @@ static const snd_pcm_fast_ops_t snd_pcm_dsnoop_fast_ops = { .poll_descriptors = snd_pcm_direct_poll_descriptors, .poll_descriptors_count = NULL, .poll_revents = snd_pcm_direct_poll_revents, + .mmap_begin = NULL, };/**
src/pcm/pcm_file.c +1 -0
@@ -773,6 +773,7 @@ static const snd_pcm_fast_ops_t snd_pcm_file_fast_ops = { .poll_descriptors = snd_pcm_generic_poll_descriptors, .poll_revents = snd_pcm_generic_poll_revents, .htimestamp = snd_pcm_generic_htimestamp, + .mmap_begin = NULL, };/**
src/pcm/pcm_generic.h +0 -1
@@ -161,4 +161,3 @@ snd_pcm_chmap_query_t **snd_pcm_generic_query_chmaps(snd_pcm_t *pcm);snd_pcm_chmap_t *snd_pcm_generic_get_chmap (snd_pcm_t *pcm);int snd_pcm_generic_set_chmap (snd_pcm_t *pcm,const snd_pcm_chmap_t *map);int snd_pcm_generic_may_wait_for_avail_min (snd_pcm_t *pcm,snd_pcm_uframes_t avail); -
src/pcm/pcm_hooks.c +1 -0
@@ -200,6 +200,7 @@ static const snd_pcm_fast_ops_t snd_pcm_hooks_fast_ops = { .poll_descriptors = snd_pcm_generic_poll_descriptors, .poll_revents = snd_pcm_generic_poll_revents, .may_wait_for_avail_min = snd_pcm_generic_may_wait_for_avail_min, + .mmap_begin = NULL, };/**
src/pcm/pcm_hw.c +2 -0
@@ -1481,6 +1481,7 @@ static const snd_pcm_fast_ops_t snd_pcm_hw_fast_ops = { .poll_descriptors = NULL, .poll_descriptors_count = NULL, .poll_revents = NULL, + .mmap_begin = NULL, };static const snd_pcm_fast_ops_t snd_pcm_hw_fast_ops_timer = {
@@ -1512,6 +1513,7 @@ static const snd_pcm_fast_ops_t snd_pcm_hw_fast_ops_timer = { .poll_descriptors = snd_pcm_hw_poll_descriptors, .poll_descriptors_count = snd_pcm_hw_poll_descriptors_count, .poll_revents = snd_pcm_hw_poll_revents, + .mmap_begin = NULL, };/**
src/pcm/pcm_ioplug.c +1 -0
@@ -940,6 +940,7 @@ static const snd_pcm_fast_ops_t snd_pcm_ioplug_fast_ops = { .poll_descriptors_count = snd_pcm_ioplug_poll_descriptors_count, .poll_descriptors = snd_pcm_ioplug_poll_descriptors, .poll_revents = snd_pcm_ioplug_poll_revents, + .mmap_begin = NULL, };#endif /* !DOC_HIDDEN */
src/pcm/pcm_local.h +1 -0
@@ -184,6 +184,7 @@ typedef struct {int (*poll_descriptors)(snd_pcm_t *pcm,struct pollfd *pfds,unsigned int space);/* locked */ int (*poll_revents)(snd_pcm_t *pcm,struct pollfd *pfds,unsigned int nfds,unsigned short *revents);/* locked */ int (*may_wait_for_avail_min)(snd_pcm_t *pcm,snd_pcm_uframes_t avail); +int (*mmap_begin)(snd_pcm_t *pcm,const snd_pcm_channel_area_t **areas,snd_pcm_uframes_t *offset,snd_pcm_uframes_t *frames);/* locked */ } snd_pcm_fast_ops_t;struct _snd_pcm {
src/pcm/pcm_meter.c +1 -0
@@ -548,6 +548,7 @@ static const snd_pcm_fast_ops_t snd_pcm_meter_fast_ops = { .poll_descriptors = snd_pcm_generic_poll_descriptors, .poll_revents = snd_pcm_generic_poll_revents, .may_wait_for_avail_min = snd_pcm_generic_may_wait_for_avail_min, + .mmap_begin = NULL, };/**
src/pcm/pcm_mmap_emul.c +1 -0
@@ -401,6 +401,7 @@ static const snd_pcm_fast_ops_t snd_pcm_mmap_emul_fast_ops = { .poll_descriptors_count = snd_pcm_generic_poll_descriptors_count, .poll_revents = snd_pcm_generic_poll_revents, .may_wait_for_avail_min = snd_pcm_generic_may_wait_for_avail_min, + .mmap_begin = NULL, };#ifndef DOC_HIDDEN
src/pcm/pcm_multi.c +1 -0
@@ -1042,6 +1042,7 @@ static const snd_pcm_fast_ops_t snd_pcm_multi_fast_ops = { .poll_descriptors = snd_pcm_multi_poll_descriptors, .poll_revents = snd_pcm_multi_poll_revents, .may_wait_for_avail_min = snd_pcm_multi_may_wait_for_avail_min, + .mmap_begin = NULL, };/**
src/pcm/pcm_null.c +1 -0
@@ -361,6 +361,7 @@ static const snd_pcm_fast_ops_t snd_pcm_null_fast_ops = { .avail_update = snd_pcm_null_avail_update, .mmap_commit = snd_pcm_null_mmap_commit, .htimestamp = snd_pcm_generic_real_htimestamp, + .mmap_begin = NULL, };/**
src/pcm/pcm_plugin.c +1 -0
@@ -646,6 +646,7 @@ const snd_pcm_fast_ops_t snd_pcm_plugin_fast_ops = { .poll_descriptors = snd_pcm_generic_poll_descriptors, .poll_revents = snd_pcm_generic_poll_revents, .may_wait_for_avail_min = snd_pcm_plugin_may_wait_for_avail_min, + .mmap_begin = NULL, };#endif
src/pcm/pcm_rate.c +1 -0
@@ -1217,6 +1217,7 @@ static const snd_pcm_fast_ops_t snd_pcm_rate_fast_ops = { .poll_descriptors = snd_pcm_generic_poll_descriptors, .poll_revents = snd_pcm_rate_poll_revents, .may_wait_for_avail_min = snd_pcm_plugin_may_wait_for_avail_min, + .mmap_begin = NULL, };static const snd_pcm_ops_t snd_pcm_rate_ops = {
src/pcm/pcm_share.c +1 -0
@@ -1346,6 +1346,7 @@ static const snd_pcm_fast_ops_t snd_pcm_share_fast_ops = { .avail_update = snd_pcm_share_avail_update, .htimestamp = snd_pcm_share_htimestamp, .mmap_commit = snd_pcm_share_mmap_commit, + .mmap_begin = NULL, };/**
src/pcm/pcm_shm.c +1 -0
@@ -629,6 +629,7 @@ static const snd_pcm_fast_ops_t snd_pcm_shm_fast_ops = { .avail_update = snd_pcm_shm_avail_update, .mmap_commit = snd_pcm_shm_mmap_commit, .htimestamp = snd_pcm_shm_htimestamp, + .mmap_begin = NULL, };static int make_local_socket (const char *filename)
Signature · 1 line
2.7.4