meta-agl-profile-telematics: recipes-core: systemd: change canbus systemd match regex
[AGL/meta-agl.git] / meta-agl-profile-core / recipes-multimedia / pulseaudio / pulseaudio-10.0 / 0003-volume-ramp-adding-volume-ramping-to-sink-input.patch
1 From e4469df7c69316b49cad93dd288badc98fa1cad5 Mon Sep 17 00:00:00 2001
2 From: Sangchul Lee <sangchul1011@gmail.com>
3 Date: Sat, 27 Aug 2016 21:33:17 +0900
4 Subject: [PATCH 3/6] volume ramp: adding volume ramping to sink-input
5
6 The original patch is
7  - https://review.tizen.org/git/?p=platform/upstream/pulseaudio.git;a=commit;h=98042248fd67ce0ab3807c5c472c0d5d8b0f99d3
8  - by Jaska Uimonen <jaska.uimonen <at> helsinki.fi>
9
10 Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
11 ---
12  src/pulsecore/sink-input.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++
13  src/pulsecore/sink-input.h | 11 ++++++++-
14  2 files changed, 71 insertions(+), 1 deletion(-)
15
16 diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c
17 index 8ec63b5..cc8953f 100644
18 --- a/src/pulsecore/sink-input.c
19 +++ b/src/pulsecore/sink-input.c
20 @@ -526,6 +526,11 @@ int pa_sink_input_new(
21      reset_callbacks(i);
22      i->userdata = NULL;
23  
24 +    if (data->flags & PA_SINK_INPUT_START_RAMP_MUTED)
25 +        pa_cvolume_ramp_int_init(&i->ramp, PA_VOLUME_MUTED, data->sample_spec.channels);
26 +    else
27 +        pa_cvolume_ramp_int_init(&i->ramp, PA_VOLUME_NORM, data->sample_spec.channels);
28 +
29      i->thread_info.state = i->state;
30      i->thread_info.attached = false;
31      pa_atomic_store(&i->thread_info.drained, 1);
32 @@ -542,6 +547,8 @@ int pa_sink_input_new(
33      i->thread_info.playing_for = 0;
34      i->thread_info.direct_outputs = pa_hashmap_new(pa_idxset_trivial_hash_func, pa_idxset_trivial_compare_func);
35  
36 +    i->thread_info.ramp = i->ramp;
37 +
38      pa_assert_se(pa_idxset_put(core->sink_inputs, i, &i->index) == 0);
39      pa_assert_se(pa_idxset_put(i->sink->inputs, pa_sink_input_ref(i), NULL) == 0);
40  
41 @@ -923,6 +930,8 @@ void pa_sink_input_peek(pa_sink_input *i, size_t slength /* in sink bytes */, pa
42          while (tchunk.length > 0) {
43              pa_memchunk wchunk;
44              bool nvfs = need_volume_factor_sink;
45 +            pa_cvolume target;
46 +            pa_bool_t tmp;
47  
48              wchunk = tchunk;
49              pa_memblock_ref(wchunk.memblock);
50 @@ -959,6 +968,16 @@ void pa_sink_input_peek(pa_sink_input *i, size_t slength /* in sink bytes */, pa
51                      pa_volume_memchunk(&wchunk, &i->sink->sample_spec, &i->volume_factor_sink);
52                  }
53  
54 +                /* check for possible volume ramp */
55 +                if (pa_cvolume_ramp_active(&i->thread_info.ramp)) {
56 +                    pa_memchunk_make_writable(&wchunk, 0);
57 +                    pa_volume_ramp_memchunk(&wchunk, &i->sink->sample_spec, &(i->thread_info.ramp));
58 +                } else if ((tmp = pa_cvolume_ramp_target_active(&(i->thread_info.ramp)))) {
59 +                    pa_memchunk_make_writable(&wchunk, 0);
60 +                    pa_cvolume_ramp_get_targets(&i->thread_info.ramp, &target);
61 +                    pa_volume_memchunk(&wchunk, &i->sink->sample_spec, &target);
62 +                }
63 +
64                  pa_memblockq_push_align(i->thread_info.render_memblockq, &wchunk);
65              } else {
66                  pa_memchunk rchunk;
67 @@ -975,6 +994,16 @@ void pa_sink_input_peek(pa_sink_input *i, size_t slength /* in sink bytes */, pa
68                          pa_volume_memchunk(&rchunk, &i->sink->sample_spec, &i->volume_factor_sink);
69                      }
70  
71 +                    /* check for possible volume ramp */
72 +                    if (pa_cvolume_ramp_active(&(i->thread_info.ramp))) {
73 +                        pa_memchunk_make_writable(&rchunk, 0);
74 +                        pa_volume_ramp_memchunk(&rchunk, &i->sink->sample_spec, &(i->thread_info.ramp));
75 +                    } else if (pa_cvolume_ramp_target_active(&(i->thread_info.ramp))) {
76 +                        pa_memchunk_make_writable(&rchunk, 0);
77 +                        pa_cvolume_ramp_get_targets(&i->thread_info.ramp, &target);
78 +                        pa_volume_memchunk(&rchunk, &i->sink->sample_spec, &target);
79 +                    }
80 +
81                      pa_memblockq_push_align(i->thread_info.render_memblockq, &rchunk);
82                      pa_memblock_unref(rchunk.memblock);
83                  }
84 @@ -1339,6 +1368,31 @@ int pa_sink_input_remove_volume_factor(pa_sink_input *i, const char *key) {
85      return 0;
86  }
87  
88 +/* Called from main thread */
89 +void pa_sink_input_set_volume_ramp(
90 +        pa_sink_input *i,
91 +        const pa_cvolume_ramp *ramp,
92 +        pa_bool_t send_msg,
93 +        pa_bool_t save) {
94 +
95 +    pa_sink_input_assert_ref(i);
96 +    pa_assert_ctl_context();
97 +    pa_assert(PA_SINK_INPUT_IS_LINKED(i->state));
98 +    pa_assert(ramp);
99 +
100 +    pa_cvolume_ramp_convert(ramp, &i->ramp, i->sample_spec.rate);
101 +
102 +    pa_log_debug("setting volume ramp with target vol:%d and length:%ld",
103 +                i->ramp.ramps[0].target,
104 +                i->ramp.ramps[0].length);
105 +
106 +
107 +    /* This tells the sink that volume ramp changed */
108 +    if (send_msg)
109 +        pa_assert_se(pa_asyncmsgq_send(i->sink->asyncmsgq, PA_MSGOBJECT(i), PA_SINK_INPUT_MESSAGE_SET_VOLUME_RAMP,
110 +                                       NULL, 0, NULL) == 0);
111 +}
112 +
113  /* Called from main context */
114  static void set_real_ratio(pa_sink_input *i, const pa_cvolume *v) {
115      pa_sink_input_assert_ref(i);
116 @@ -1932,6 +1986,13 @@ int pa_sink_input_process_msg(pa_msgobject *o, int code, void *userdata, int64_t
117              }
118              return 0;
119  
120 +        case PA_SINK_INPUT_MESSAGE_SET_VOLUME_RAMP:
121 +            /* we have ongoing ramp where we take current start values */
122 +            pa_cvolume_ramp_start_from(&i->thread_info.ramp, &i->ramp);
123 +            i->thread_info.ramp = i->ramp;
124 +            pa_sink_input_request_rewind(i, 0, true, false, false);
125 +            return 0;
126 +
127          case PA_SINK_INPUT_MESSAGE_SET_SOFT_MUTE:
128              if (i->thread_info.muted != i->muted) {
129                  i->thread_info.muted = i->muted;
130 diff --git a/src/pulsecore/sink-input.h b/src/pulsecore/sink-input.h
131 index 86deab2..6e1b211 100644
132 --- a/src/pulsecore/sink-input.h
133 +++ b/src/pulsecore/sink-input.h
134 @@ -32,6 +32,7 @@
135  #include <pulsecore/client.h>
136  #include <pulsecore/sink.h>
137  #include <pulsecore/core.h>
138 +#include <pulsecore/mix.h>
139  
140  typedef enum pa_sink_input_state {
141      PA_SINK_INPUT_INIT,         /*< The stream is not active yet, because pa_sink_input_put() has not been called yet */
142 @@ -58,7 +59,8 @@ typedef enum pa_sink_input_flags {
143      PA_SINK_INPUT_DONT_INHIBIT_AUTO_SUSPEND = 256,
144      PA_SINK_INPUT_NO_CREATE_ON_SUSPEND = 512,
145      PA_SINK_INPUT_KILL_ON_SUSPEND = 1024,
146 -    PA_SINK_INPUT_PASSTHROUGH = 2048
147 +    PA_SINK_INPUT_PASSTHROUGH = 2048,
148 +    PA_SINK_INPUT_START_RAMP_MUTED = 4096,
149  } pa_sink_input_flags_t;
150  
151  struct pa_sink_input {
152 @@ -121,6 +123,9 @@ struct pa_sink_input {
153       * this.*/
154      bool save_sink:1, save_volume:1, save_muted:1;
155  
156 +    /* for volume ramps */
157 +    pa_cvolume_ramp_int ramp;
158 +
159      pa_resample_method_t requested_resample_method, actual_resample_method;
160  
161      /* Returns the chunk of audio data and drops it from the
162 @@ -249,6 +254,8 @@ struct pa_sink_input {
163          pa_usec_t requested_sink_latency;
164  
165          pa_hashmap *direct_outputs;
166 +
167 +        pa_cvolume_ramp_int ramp;
168      } thread_info;
169  
170      void *userdata;
171 @@ -265,6 +272,7 @@ enum {
172      PA_SINK_INPUT_MESSAGE_SET_STATE,
173      PA_SINK_INPUT_MESSAGE_SET_REQUESTED_LATENCY,
174      PA_SINK_INPUT_MESSAGE_GET_REQUESTED_LATENCY,
175 +    PA_SINK_INPUT_MESSAGE_SET_VOLUME_RAMP,
176      PA_SINK_INPUT_MESSAGE_MAX
177  };
178  
179 @@ -370,6 +378,7 @@ void pa_sink_input_set_volume(pa_sink_input *i, const pa_cvolume *volume, bool s
180  void pa_sink_input_add_volume_factor(pa_sink_input *i, const char *key, const pa_cvolume *volume_factor);
181  int pa_sink_input_remove_volume_factor(pa_sink_input *i, const char *key);
182  pa_cvolume *pa_sink_input_get_volume(pa_sink_input *i, pa_cvolume *volume, bool absolute);
183 +void pa_sink_input_set_volume_ramp(pa_sink_input *i, const pa_cvolume_ramp *ramp, pa_bool_t send_msg, pa_bool_t save);
184  
185  void pa_sink_input_set_mute(pa_sink_input *i, bool mute, bool save);
186  
187 -- 
188 1.9.1
189