1 From: Tanu Kaskinen <tanu.kaskinen@linux.intel.com>
2 Date: Mon, 4 Aug 2014 21:26:17 +0300
3 Subject: sink-input, source-output: Add hooks for reference ratio changes
5 Needed for implementing relative volume controls for streams in
6 module-volume-api. The plan is to create those controls in the core,
7 though, and these hooks won't be needed at that point any more.
9 Change-Id: Id30f38f4adfa9ede7bd0b12b484fe329ca1a3991
11 src/pulsecore/core.h | 2 ++
12 src/pulsecore/sink-input.c | 2 ++
13 src/pulsecore/sink-input.h | 3 ++-
14 src/pulsecore/source-output.c | 2 ++
15 src/pulsecore/source-output.h | 3 ++-
16 5 files changed, 10 insertions(+), 2 deletions(-)
18 diff --git a/src/pulsecore/core.h b/src/pulsecore/core.h
19 index 1f042b9..0e8f709 100644
20 --- a/src/pulsecore/core.h
21 +++ b/src/pulsecore/core.h
22 @@ -100,6 +100,7 @@ typedef enum pa_core_hook {
23 PA_CORE_HOOK_SINK_INPUT_STATE_CHANGED,
24 PA_CORE_HOOK_SINK_INPUT_PROPLIST_CHANGED,
25 PA_CORE_HOOK_SINK_INPUT_VOLUME_CHANGED,
26 + PA_CORE_HOOK_SINK_INPUT_REFERENCE_RATIO_CHANGED,
27 PA_CORE_HOOK_SINK_INPUT_MUTE_CHANGED,
28 PA_CORE_HOOK_SINK_INPUT_SEND_EVENT,
29 PA_CORE_HOOK_SOURCE_OUTPUT_NEW,
30 @@ -113,6 +114,7 @@ typedef enum pa_core_hook {
31 PA_CORE_HOOK_SOURCE_OUTPUT_STATE_CHANGED,
32 PA_CORE_HOOK_SOURCE_OUTPUT_PROPLIST_CHANGED,
33 PA_CORE_HOOK_SOURCE_OUTPUT_VOLUME_CHANGED,
34 + PA_CORE_HOOK_SOURCE_OUTPUT_REFERENCE_RATIO_CHANGED,
35 PA_CORE_HOOK_SOURCE_OUTPUT_MUTE_CHANGED,
36 PA_CORE_HOOK_SOURCE_OUTPUT_SEND_EVENT,
37 PA_CORE_HOOK_CLIENT_NEW,
38 diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c
39 index 57c906d..d62be6f 100644
40 --- a/src/pulsecore/sink-input.c
41 +++ b/src/pulsecore/sink-input.c
42 @@ -2352,4 +2352,6 @@ void pa_sink_input_set_reference_ratio(pa_sink_input *i, const pa_cvolume *ratio
43 pa_log_debug("Sink input %u reference ratio changed from %s to %s.", i->index,
44 pa_cvolume_snprint_verbose(old_ratio_str, sizeof(old_ratio_str), &old_ratio, &i->channel_map, true),
45 pa_cvolume_snprint_verbose(new_ratio_str, sizeof(new_ratio_str), ratio, &i->channel_map, true));
47 + pa_hook_fire(&i->core->hooks[PA_CORE_HOOK_SINK_INPUT_REFERENCE_RATIO_CHANGED], i);
49 diff --git a/src/pulsecore/sink-input.h b/src/pulsecore/sink-input.h
50 index e5b0ae8..c99ce1f 100644
51 --- a/src/pulsecore/sink-input.h
52 +++ b/src/pulsecore/sink-input.h
53 @@ -440,7 +440,8 @@ void pa_sink_input_set_volume_direct(pa_sink_input *i, const pa_cvolume *volume)
54 /* Called from the main thread, from sink.c only. This shouldn't be a public
55 * function, but the flat volume logic in sink.c currently needs a way to
56 * directly set the sink input reference ratio. This function simply sets
57 - * i->reference_ratio and logs a message if the value changes. */
58 + * i->reference_ratio and logs a message and fires a hook if the value
60 void pa_sink_input_set_reference_ratio(pa_sink_input *i, const pa_cvolume *ratio);
62 #define pa_sink_input_assert_io_context(s) \
63 diff --git a/src/pulsecore/source-output.c b/src/pulsecore/source-output.c
64 index 0012be3..ae5a92c 100644
65 --- a/src/pulsecore/source-output.c
66 +++ b/src/pulsecore/source-output.c
67 @@ -1718,4 +1718,6 @@ void pa_source_output_set_reference_ratio(pa_source_output *o, const pa_cvolume
68 pa_log_debug("Source output %u reference ratio changed from %s to %s.", o->index,
69 pa_cvolume_snprint_verbose(old_ratio_str, sizeof(old_ratio_str), &old_ratio, &o->channel_map, true),
70 pa_cvolume_snprint_verbose(new_ratio_str, sizeof(new_ratio_str), ratio, &o->channel_map, true));
72 + pa_hook_fire(&o->core->hooks[PA_CORE_HOOK_SOURCE_OUTPUT_REFERENCE_RATIO_CHANGED], o);
74 diff --git a/src/pulsecore/source-output.h b/src/pulsecore/source-output.h
75 index 3ed950b..60bbda8 100644
76 --- a/src/pulsecore/source-output.h
77 +++ b/src/pulsecore/source-output.h
78 @@ -362,7 +362,8 @@ void pa_source_output_set_volume_direct(pa_source_output *o, const pa_cvolume *v
79 /* Called from the main thread, from source.c only. This shouldn't be a public
80 * function, but the flat volume logic in source.c currently needs a way to
81 * directly set the source output reference ratio. This function simply sets
82 - * o->reference_ratio and logs a message if the value changes. */
83 + * o->reference_ratio and logs a message and fires a hook if the value
85 void pa_source_output_set_reference_ratio(pa_source_output *o, const pa_cvolume *ratio);
87 #define pa_source_output_assert_io_context(s) \