summaryrefslogtreecommitdiff
path: root/debian/patches/0010-core-Take-samples-from-silence-cache-rather-than-wr.patch
blob: 289a28b7e33a2bee3c309548cf02a98be261370a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
From 0d6d6d3d9a45a2ed9686c3e03bb2d2aa2c2c0278 Mon Sep 17 00:00:00 2001
From: Jyri Sarha <jyri.sarha@nokia.com>
Date: Thu, 7 May 2009 19:55:57 +0300
Subject: [PATCH] core: Take samples from silence cache rather than write zeros

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 63752d9..c9bf5ef 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