[pulseaudio-discuss] [PATCH v2 07/12] pulsecore, tests: Use new memexport/memimport API

David Henningsson david.henningsson at canonical.com
Tue Feb 16 14:09:48 UTC 2016


No comments on this one.

Reviewed-by: David Henningsson <david.henningsson at canonical.com>

On 2016-02-12 01:15, Ahmed S. Darwish wrote:
> Signed-off-by: Ahmed S. Darwish <darwish.07 at gmail.com>
> ---
>   src/pulsecore/memblock.c  | 24 ++++--------------------
>   src/pulsecore/memblock.h  |  5 +++--
>   src/pulsecore/pstream.c   |  4 ++++
>   src/tests/memblock-test.c |  9 +++++----
>   4 files changed, 16 insertions(+), 26 deletions(-)
>
> diff --git a/src/pulsecore/memblock.c b/src/pulsecore/memblock.c
> index 959453e..af27ba5 100644
> --- a/src/pulsecore/memblock.c
> +++ b/src/pulsecore/memblock.c
> @@ -1116,8 +1116,8 @@ finish:
>   }
>
>   /* Self-locked */
> -static pa_memblock* NEW_API_pa_memimport_get(pa_memimport *i, pa_mem_type_t type, uint32_t block_id, uint32_t shm_id,
> -                                             size_t offset, size_t size, bool writable) {
> +pa_memblock* pa_memimport_get(pa_memimport *i, pa_mem_type_t type, uint32_t block_id, uint32_t shm_id,
> +                              size_t offset, size_t size, bool writable) {
>       pa_memblock *b = NULL;
>       pa_memimport_segment *seg;
>
> @@ -1177,11 +1177,6 @@ finish:
>       return b;
>   }
>
> -pa_memblock* pa_memimport_get(pa_memimport *i, uint32_t block_id, uint32_t shm_id,
> -                              size_t offset, size_t size, bool writable) {
> -    return NEW_API_pa_memimport_get(i, PA_MEM_TYPE_SHARED_POSIX, block_id, shm_id, offset, size, writable);
> -}
> -
>   int pa_memimport_process_revoke(pa_memimport *i, uint32_t id) {
>       pa_memblock *b;
>       int ret = 0;
> @@ -1338,8 +1333,8 @@ static pa_memblock *memblock_shared_copy(pa_mempool *p, pa_memblock *b) {
>   }
>
>   /* Self-locked */
> -static int NEW_API_pa_memexport_put(pa_memexport *e, pa_memblock *b, pa_mem_type_t *type, uint32_t *block_id,
> -                                    uint32_t *shm_id, size_t *offset, size_t * size) {
> +int pa_memexport_put(pa_memexport *e, pa_memblock *b, pa_mem_type_t *type, uint32_t *block_id,
> +                     uint32_t *shm_id, size_t *offset, size_t * size) {
>       pa_shm  *memory;
>       struct memexport_slot *slot;
>       void *data;
> @@ -1402,14 +1397,3 @@ static int NEW_API_pa_memexport_put(pa_memexport *e, pa_memblock *b, pa_mem_type
>
>       return 0;
>   }
> -
> -int pa_memexport_put(pa_memexport *e, pa_memblock *b, uint32_t *block_id, uint32_t *shm_id,
> -                     size_t *offset, size_t *size) {
> -    pa_mem_type_t type;
> -    int ret;
> -
> -    if (!(ret = NEW_API_pa_memexport_put(e, b, &type, block_id, shm_id, offset, size)))
> -        pa_assert(type == PA_MEM_TYPE_SHARED_POSIX);
> -
> -    return ret;
> -}
> diff --git a/src/pulsecore/memblock.h b/src/pulsecore/memblock.h
> index 776b017..059538f 100644
> --- a/src/pulsecore/memblock.h
> +++ b/src/pulsecore/memblock.h
> @@ -140,14 +140,15 @@ pa_memimport* pa_memimport_new(pa_mempool *p, pa_memimport_release_cb_t cb, void
>   void pa_memimport_free(pa_memimport *i);
>   int pa_memimport_add_permanent_shmid_to_memfd_mapping(pa_memimport *i, uint32_t shm_id, int memfd_fd,
>                                                         bool writable);
> -pa_memblock* pa_memimport_get(pa_memimport *i, uint32_t block_id, uint32_t shm_id,
> +pa_memblock* pa_memimport_get(pa_memimport *i, pa_mem_type_t type, uint32_t block_id, uint32_t shm_id,
>                                 size_t offset, size_t size, bool writable);
>   int pa_memimport_process_revoke(pa_memimport *i, uint32_t block_id);
>
>   /* For sending blocks to other nodes */
>   pa_memexport* pa_memexport_new(pa_mempool *p, pa_memexport_revoke_cb_t cb, void *userdata);
>   void pa_memexport_free(pa_memexport *e);
> -int pa_memexport_put(pa_memexport *e, pa_memblock *b, uint32_t *block_id, uint32_t *shm_id, size_t *offset, size_t *size);
> +int pa_memexport_put(pa_memexport *e, pa_memblock *b, pa_mem_type_t *type, uint32_t *block_id,
> +                     uint32_t *shm_id, size_t *offset, size_t * size);
>   int pa_memexport_process_release(pa_memexport *e, uint32_t id);
>
>   #endif
> diff --git a/src/pulsecore/pstream.c b/src/pulsecore/pstream.c
> index 98a8382..ef2bbf9 100644
> --- a/src/pulsecore/pstream.c
> +++ b/src/pulsecore/pstream.c
> @@ -536,6 +536,7 @@ static void prepare_next_write_item(pa_pstream *p) {
>           flags = (uint32_t) (p->write.current->seek_mode & PA_FLAG_SEEKMASK);
>
>           if (p->use_shm) {
> +            pa_mem_type_t type;
>               uint32_t block_id, shm_id;
>               size_t offset, length;
>               uint32_t *shm_info = (uint32_t *) &p->write.minibuf[PA_PSTREAM_DESCRIPTOR_SIZE];
> @@ -550,10 +551,12 @@ static void prepare_next_write_item(pa_pstream *p) {
>
>               if (pa_memexport_put(current_export,
>                                    p->write.current->chunk.memblock,
> +                                 &type,
>                                    &block_id,
>                                    &shm_id,
>                                    &offset,
>                                    &length) >= 0) {
> +                pa_assert(type == PA_MEM_TYPE_SHARED_POSIX);
>
>                   flags |= PA_FLAG_SHMDATA;
>                   if (pa_mempool_is_remote_writable(current_pool))
> @@ -890,6 +893,7 @@ static int do_read(pa_pstream *p, struct pstream_read *re) {
>               pa_assert(p->import);
>
>               if (!(b = pa_memimport_get(p->import,
> +                                       PA_MEM_TYPE_SHARED_POSIX,
>                                          ntohl(re->shm_info[PA_PSTREAM_SHM_BLOCKID]),
>                                          ntohl(re->shm_info[PA_PSTREAM_SHM_SHMID]),
>                                          ntohl(re->shm_info[PA_PSTREAM_SHM_INDEX]),
> diff --git a/src/tests/memblock-test.c b/src/tests/memblock-test.c
> index 58eae7b..5cd795c 100644
> --- a/src/tests/memblock-test.c
> +++ b/src/tests/memblock-test.c
> @@ -74,6 +74,7 @@ START_TEST (memblock_test) {
>       pa_memblock *mb_a, *mb_b, *mb_c;
>       int r, i;
>       pa_memblock* blocks[5];
> +    pa_mem_type_t mem_type;
>       uint32_t id, shm_id;
>       size_t offset, size;
>       char *x;
> @@ -122,22 +123,22 @@ START_TEST (memblock_test) {
>           import_c = pa_memimport_new(pool_c, release_cb, (void*) "C");
>           fail_unless(import_b != NULL);
>
> -        r = pa_memexport_put(export_a, mb_a, &id, &shm_id, &offset, &size);
> +        r = pa_memexport_put(export_a, mb_a, &mem_type, &id, &shm_id, &offset, &size);
>           fail_unless(r >= 0);
>           fail_unless(shm_id == id_a);
>
>           pa_log("A: Memory block exported as %u", id);
>
> -        mb_b = pa_memimport_get(import_b, id, shm_id, offset, size, false);
> +        mb_b = pa_memimport_get(import_b, PA_MEM_TYPE_SHARED_POSIX, id, shm_id, offset, size, false);
>           fail_unless(mb_b != NULL);
> -        r = pa_memexport_put(export_b, mb_b, &id, &shm_id, &offset, &size);
> +        r = pa_memexport_put(export_b, mb_b, &mem_type, &id, &shm_id, &offset, &size);
>           fail_unless(r >= 0);
>           fail_unless(shm_id == id_a || shm_id == id_b);
>           pa_memblock_unref(mb_b);
>
>           pa_log("B: Memory block exported as %u", id);
>
> -        mb_c = pa_memimport_get(import_c, id, shm_id, offset, size, false);
> +        mb_c = pa_memimport_get(import_c, PA_MEM_TYPE_SHARED_POSIX, id, shm_id, offset, size, false);
>           fail_unless(mb_c != NULL);
>           x = pa_memblock_acquire(mb_c);
>           pa_log_debug("1 data=%s", x);
>
> Regards,
>

-- 
David Henningsson, Canonical Ltd.
https://launchpad.net/~diwic


More information about the pulseaudio-discuss mailing list