diff options
author | Ben Brewer <ben.brewer@codethink.co.uk> | 2014-01-15 10:30:36 +0000 |
---|---|---|
committer | Tanu Kaskinen <tanu.kaskinen@linux.intel.com> | 2014-01-15 12:34:13 +0200 |
commit | dbe66b0b5e6b6e24df45bda8bf656836f18e7f4b (patch) | |
tree | 69ffcff62b3e7d0441f178b258de05e94ca76aaa | |
parent | 4e5051db7297d8171d148ef7d15c2e06ebeff0ce (diff) |
ladspa-sink: Handle empty chunks in sink_input_pop_cb
-rw-r--r-- | src/modules/module-ladspa-sink.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/modules/module-ladspa-sink.c b/src/modules/module-ladspa-sink.c index 7c4c274e2..8e35b1b6d 100644 --- a/src/modules/module-ladspa-sink.c +++ b/src/modules/module-ladspa-sink.c @@ -474,21 +474,28 @@ static int sink_input_pop_cb(pa_sink_input *i, size_t nbytes, pa_memchunk *chunk pa_memblockq_drop(u->memblockq, chunk->length); - src = pa_memblock_acquire_chunk(&tchunk); + src = (tchunk.memblock ? pa_memblock_acquire_chunk(&tchunk) : NULL); dst = pa_memblock_acquire(chunk->memblock); for (h = 0; h < (u->channels / u->max_ladspaport_count); h++) { - for (c = 0; c < u->input_count; c++) - pa_sample_clamp(PA_SAMPLE_FLOAT32NE, u->input[c], sizeof(float), src+ h*u->max_ladspaport_count + c, u->channels*sizeof(float), n); + if (src) { + for (c = 0; c < u->input_count; c++) + pa_sample_clamp(PA_SAMPLE_FLOAT32NE, u->input[c], sizeof(float), src+ h*u->max_ladspaport_count + c, u->channels*sizeof(float), n); + } else { + for (c = 0; c < u->input_count; c++) + memset(u->input[c], 0, (n * sizeof(float))); + } u->descriptor->run(u->handle[h], n); for (c = 0; c < u->output_count; c++) pa_sample_clamp(PA_SAMPLE_FLOAT32NE, dst + h*u->max_ladspaport_count + c, u->channels*sizeof(float), u->output[c], sizeof(float), n); } - pa_memblock_release(tchunk.memblock); - pa_memblock_release(chunk->memblock); + if (tchunk.memblock) { + pa_memblock_release(tchunk.memblock); + pa_memblock_unref(tchunk.memblock); + } - pa_memblock_unref(tchunk.memblock); + pa_memblock_release(chunk->memblock); return 0; } |