6 #include <pulsecore/pulsecore-config.h>
8 #include <pulse/proplist.h>
9 #include <pulsecore/core-util.h>
10 #include <pulsecore/sink.h>
11 #include <pulsecore/sink-input.h>
19 static void set_stream_volume_limit(struct userdata *, pa_sink_input *, double);
21 void pa_fader_apply_volume_limits(struct userdata *u, uint32_t stamp)
32 pa_assert_se((core = u->core));
34 pa_log_debug("applying volume limits ...");
36 PA_IDXSET_FOREACH(sink, core->sinks, i) {
37 if ((node = pa_discover_find_node_by_ptr(u, sink))) {
38 pa_log_debug(" node '%s'", node->amname);
40 PA_IDXSET_FOREACH(sinp, sink->inputs, j) {
41 class = pa_utils_get_stream_class(sinp->proplist);
42 atten = mir_volume_apply_limits(u, node, class, stamp);
44 pa_log_debug(" stream %u attenuation %.2lf dB", sinp->index, atten);
46 set_stream_volume_limit(u, sinp, atten);
53 static void set_stream_volume_limit(struct userdata *u, pa_sink_input *sinp, double limit)
60 pa_assert_se((sink = sinp->sink));
62 vol = pa_sw_volume_from_dB(limit);
63 pa_cvolume_set(&sinp->volume_factor, sinp->volume.channels, vol);
65 if (pa_sink_flat_volume_enabled(sink)) {
66 pa_sink_set_volume(sink, NULL, TRUE, FALSE);
69 pa_sw_cvolume_multiply(&sinp->soft_volume, &sinp->real_ratio, &sinp->volume_factor);
71 pa_asyncmsgq_send(sink->asyncmsgq, PA_MSGOBJECT(sinp),
72 PA_SINK_INPUT_MESSAGE_SET_SOFT_VOLUME, NULL, 0, NULL);
82 * indent-tabs-mode: nil