#include <pulse/fork-detect.h>
#include <pulsecore/pstream-util.h>
+#include <pulsecore/sample-util.h>
#include <pulsecore/log.h>
#include <pulsecore/hashmap.h>
#include <pulsecore/macro.h>
chunk.length = t_length;
} else {
void *d;
+ size_t blk_size_max;
- chunk.length = PA_MIN(t_length, pa_mempool_block_size_max(s->context->mempool));
+ /* Break large audio streams into _aligned_ blocks or the
+ * other endpoint will happily discard them upon arrival. */
+ blk_size_max = pa_frame_align(pa_mempool_block_size_max(s->context->mempool), &s->sample_spec);
+ chunk.length = PA_MIN(t_length, blk_size_max);
chunk.memblock = pa_memblock_new(s->context->mempool, chunk.length);
d = pa_memblock_acquire(chunk.memblock);