[pulseaudio-discuss] pa_mempool_blocksize_max

Tanu Kaskinen tanuk at iki.fi
Tue Nov 9 22:31:02 PST 2010


On Tue, 2010-11-09 at 20:48 +0000, Tarantism wrote:
> Whilst trying to get to grips with memblocks and chunks, I came across
> this in rtp.c:
> 
>     if (ioctl(c->fd, FIONREAD, &size) < 0) {
>         pa_log_warn("FIONREAD failed: %s", pa_cstrerror(errno));
>         goto fail;
>     }
> 
>     if (size <= 0)
>         return 0;
> 
>     if (c->memchunk.length < (unsigned) size) {
>         size_t l;
> 
>         if (c->memchunk.memblock)
>             pa_memblock_unref(c->memchunk.memblock);
> 
>         l = PA_MAX((size_t) size, pa_mempool_block_size_max(pool));
> 
> I'd have expected that last line to use PA_MIN rather than PA_MAX or
> have I misunderstood?

There indeed are many places where we want to limit the memblock size to
the maximum block size of the mempool, but this is not one of those
cases. It seems that the memblock stored by pa_rtp_context.memchunk is
reused for all received rtp packets, and normally its size is kept at
the maximum block size, which allows us to use the mempool. The rtp
packet size can however be almost anything, and I think we must read it
all at once. If the maximum block size of the mempool isn't enough, then
we reallocate the memblock from the heap instead of the preallocated
blocks in the mempool.

-- 
Tanu




More information about the pulseaudio-discuss mailing list