Signed-off-by: Peter Meerwald <pmeerw at pmeerw.net> --- src/pulsecore/mix.c | 35 +++++++++++++++++++++++------------ src/pulsecore/mix.h | 5 +++++ src/pulsecore/sink-input.c | 2 +- src/pulsecore/sink.c | 4 ++-- src/pulsecore/source.c | 4 ++-- 5 files changed, 33 insertions(+), 17 deletions(-) diff --git a/src/pulsecore/mix.c b/src/pulsecore/mix.c index 4a839ec..436e46f 100644 --- a/src/pulsecore/mix.c +++ b/src/pulsecore/mix.c @@ -689,7 +689,7 @@ static const pa_calc_volume_func_t calc_volume_table[] = { [PA_SAMPLE_S24_32BE] = (pa_calc_volume_func_t) calc_linear_integer_volume }; -void pa_volume_memchunk( +void pa_volume_memchunk_unchecked( pa_memchunk*c, const pa_sample_spec *spec, const pa_cvolume *volume) { @@ -699,21 +699,11 @@ void pa_volume_memchunk( pa_do_volume_func_t do_volume; pa_assert(c); - pa_assert(spec); - pa_assert(pa_sample_spec_valid(spec)); - pa_assert(pa_frame_aligned(c->length, spec)); - pa_assert(volume); if (pa_memblock_is_silence(c->memblock)) return; - if (pa_cvolume_is_norm(volume)) - return; - - if (pa_cvolume_is_muted(volume)) { - pa_silence_memchunk(c, spec); - return; - } + pa_assert(pa_frame_aligned(c->length, spec)); do_volume = pa_get_volume_func(spec->format); pa_assert(do_volume); @@ -726,3 +716,24 @@ void pa_volume_memchunk( pa_memblock_release(c->memblock); } + +void pa_volume_memchunk( + pa_memchunk*c, + const pa_sample_spec *spec, + const pa_cvolume *volume) { + + pa_assert(c); + pa_assert(spec); + pa_assert(pa_sample_spec_valid(spec)); + pa_assert(volume); + + if (pa_cvolume_is_muted(volume)) { + pa_silence_memchunk(c, spec); + return; + } + + if (pa_cvolume_is_norm(volume)) + return; + + pa_volume_memchunk_unchecked(c, spec, volume); +} diff --git a/src/pulsecore/mix.h b/src/pulsecore/mix.h index a4cde01..df774b8 100644 --- a/src/pulsecore/mix.h +++ b/src/pulsecore/mix.h @@ -56,6 +56,11 @@ typedef void (*pa_do_mix_func_t) (pa_mix_info streams[], unsigned nstreams, unsi pa_do_mix_func_t pa_get_mix_func(pa_sample_format_t f); void pa_set_mix_func(pa_sample_format_t f, pa_do_mix_func_t func); +void pa_volume_memchunk_unchecked( + pa_memchunk*c, + const pa_sample_spec *spec, + const pa_cvolume *volume); + void pa_volume_memchunk( pa_memchunk*c, const pa_sample_spec *spec, diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c index 5d755ea..1e909f3 100644 --- a/src/pulsecore/sink-input.c +++ b/src/pulsecore/sink-input.c @@ -946,7 +946,7 @@ void pa_sink_input_peek(pa_sink_input *i, size_t slength /* in sink bytes */, pa * post and the pre volume adjustment into one */ pa_sw_cvolume_multiply(&v, &i->thread_info.soft_volume, &i->volume_factor_sink); - pa_volume_memchunk(&wchunk, &i->thread_info.sample_spec, &v); + pa_volume_memchunk(&wchunk, &i->thread_info.sample_spec, &v); // is_silence nvfs = false; } else diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c index d034b54..62a68e1 100644 --- a/src/pulsecore/sink.c +++ b/src/pulsecore/sink.c @@ -1202,7 +1202,7 @@ void pa_sink_render(pa_sink*s, size_t length, pa_memchunk *result) { result->length); } else if (!pa_cvolume_is_norm(&volume)) { pa_memchunk_make_writable(result, 0); - pa_volume_memchunk(result, &s->sample_spec, &volume); + pa_volume_memchunk_unchecked(result, &s->sample_spec, &volume); } } else { void *ptr; @@ -1283,7 +1283,7 @@ void pa_sink_render_into(pa_sink*s, pa_memchunk *target) { if (!pa_cvolume_is_norm(&volume)) { pa_memchunk_make_writable(&vchunk, 0); - pa_volume_memchunk(&vchunk, &s->sample_spec, &volume); + pa_volume_memchunk_unchecked(&vchunk, &s->sample_spec, &volume); } pa_memchunk_memcpy(target, &vchunk); diff --git a/src/pulsecore/source.c b/src/pulsecore/source.c index 77fa510..23bb061 100644 --- a/src/pulsecore/source.c +++ b/src/pulsecore/source.c @@ -920,7 +920,7 @@ void pa_source_post(pa_source*s, const pa_memchunk *chunk) { if (s->thread_info.soft_muted || pa_cvolume_is_muted(&s->thread_info.soft_volume)) pa_silence_memchunk(&vchunk, &s->sample_spec); else - pa_volume_memchunk(&vchunk, &s->sample_spec, &s->thread_info.soft_volume); + pa_volume_memchunk_unchecked(&vchunk, &s->sample_spec, &s->thread_info.soft_volume); while ((o = pa_hashmap_iterate(s->thread_info.outputs, &state, NULL))) { pa_source_output_assert_ref(o); @@ -962,7 +962,7 @@ void pa_source_post_direct(pa_source*s, pa_source_output *o, const pa_memchunk * if (s->thread_info.soft_muted || pa_cvolume_is_muted(&s->thread_info.soft_volume)) pa_silence_memchunk(&vchunk, &s->sample_spec); else - pa_volume_memchunk(&vchunk, &s->sample_spec, &s->thread_info.soft_volume); + pa_volume_memchunk_unchecked(&vchunk, &s->sample_spec, &s->thread_info.soft_volume); pa_source_output_push(o, &vchunk); -- 1.9.1