[PATCH] memblock: Fix more block ID collisions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



08.01.2015 17:14, David Henningsson wrote:
> Since the srb memblock and the audio data were coming from separate
> pools, and the base index was per pool, they could actually still
> collide.
>
> This patch changes the base index to be global and atomically
> incremented.
>
> Reported-by: Arun Raghavan <arun at accosted.net>
> Signed-off-by: David Henningsson <david.henningsson at canonical.com>

I confirm that the patch fixes the "junk in the recorded stream" bug. 
Looks good.

> ---
>   src/pulsecore/memblock.c | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/src/pulsecore/memblock.c b/src/pulsecore/memblock.c
> index b781312..d071a5f 100644
> --- a/src/pulsecore/memblock.c
> +++ b/src/pulsecore/memblock.c
> @@ -151,7 +151,6 @@ struct pa_mempool {
>       size_t block_size;
>       unsigned n_blocks;
>       bool is_remote_writable;
> -    unsigned export_baseidx;
>
>       pa_atomic_t n_init;
>
> @@ -1088,6 +1087,8 @@ finish:
>   pa_memexport* pa_memexport_new(pa_mempool *p, pa_memexport_revoke_cb_t cb, void *userdata) {
>       pa_memexport *e;
>
> +    static pa_atomic_t export_baseidx = PA_ATOMIC_INIT(0);
> +
>       pa_assert(p);
>       pa_assert(cb);
>
> @@ -1106,8 +1107,7 @@ pa_memexport* pa_memexport_new(pa_mempool *p, pa_memexport_revoke_cb_t cb, void
>       pa_mutex_lock(p->mutex);
>
>       PA_LLIST_PREPEND(pa_memexport, p->exports, e);
> -    e->baseidx = p->export_baseidx;
> -    p->export_baseidx += PA_MEMEXPORT_SLOTS_MAX;
> +    e->baseidx = (uint32_t) pa_atomic_add(&export_baseidx, PA_MEMEXPORT_SLOTS_MAX);
>
>       pa_mutex_unlock(p->mutex);
>       return e;
>

-- 
Alexander E. Patrakov


[Index of Archives]     [Linux Audio Users]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux