[pulseaudio-discuss] [PATCH] optimization: Take samples from silence cache rather than write zeros.
Jyri Sarha
jyri.sarha at nokia.com
Thu May 7 09:55:57 PDT 2009
If the only stream to render from is muted take samples from the
silence cache. This should shrink memory/cache bandwidth. Again the
gain was not what I hoped for.
---
src/pulsecore/sink.c | 32 ++++++++++++++++++++++----------
1 files changed, 22 insertions(+), 10 deletions(-)
diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c
index d3a6dc9..6cda8c8 100644
--- a/src/pulsecore/sink.c
+++ b/src/pulsecore/sink.c
@@ -788,11 +788,17 @@ void pa_sink_render(pa_sink*s, size_t length, pa_memchunk *result) {
pa_sw_cvolume_multiply(&volume, &s->thread_info.soft_volume, &info[0].volume);
if (s->thread_info.soft_muted || !pa_cvolume_is_norm(&volume)) {
- pa_memchunk_make_writable(result, 0);
- if (s->thread_info.soft_muted || pa_cvolume_is_muted(&volume))
- pa_silence_memchunk(result, &s->sample_spec);
- else
+ if (s->thread_info.soft_muted || pa_cvolume_is_muted(&volume)) {
+ pa_memblock_unref(result->memblock);
+ pa_silence_memchunk_get(&s->core->silence_cache,
+ s->core->mempool,
+ result,
+ &s->sample_spec,
+ result->length);
+ } else {
+ pa_memchunk_make_writable(result, 0);
pa_volume_memchunk(result, &s->sample_spec, &volume);
+ }
}
} else {
void *ptr;
@@ -969,13 +975,19 @@ void pa_sink_render_full(pa_sink *s, size_t length, pa_memchunk *result) {
pa_sw_cvolume_multiply(&volume, &s->thread_info.soft_volume, &info[0].volume);
- if (s->thread_info.soft_muted || !pa_cvolume_is_norm(&volume)) {
- pa_memchunk_make_writable(result, length);
- if (s->thread_info.soft_muted || pa_cvolume_is_muted(&volume))
- pa_silence_memchunk(result, &s->sample_spec);
- else
+ if (s->thread_info.soft_muted || !pa_cvolume_is_norm(&volume)) {
+ if (s->thread_info.soft_muted || pa_cvolume_is_muted(&volume)) {
+ pa_memblock_unref(result->memblock);
+ pa_silence_memchunk_get(&s->core->silence_cache,
+ s->core->mempool,
+ result,
+ &s->sample_spec,
+ result->length);
+ } else {
+ pa_memchunk_make_writable(result, length);
pa_volume_memchunk(result, &s->sample_spec, &volume);
- }
+ }
+ }
} else {
void *ptr;
--
1.5.6.3
More information about the pulseaudio-discuss
mailing list