2 * module-murphy-ivi -- PulseAudio module for providing audio routing support
3 * Copyright (c) 2012, Intel Corporation.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU Lesser General Public License,
7 * version 2.1, as published by the Free Software Foundation.
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE.
12 * See the GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this program; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin St - Fifth Floor, Boston,
25 #include <pulsecore/pulsecore-config.h>
26 #include <pulsecore/sink-input.h>
27 #include <pulsecore/source-output.h>
28 #include <pulsecore/core-util.h>
30 #include "stream-state.h"
35 static const char *scache_driver = "play-memblockq.c";
36 static pa_sink_input_flags_t flag_mask = PA_SINK_INPUT_NO_CREATE_ON_SUSPEND |
37 PA_SINK_INPUT_KILL_ON_SUSPEND;
39 static void sink_input_block(struct userdata *, pa_sink_input *, bool);
41 bool pa_stream_state_start_corked(struct userdata *u,
42 pa_sink_input_new_data *data,
43 pa_nodeset_resdef *resdef)
46 if (pa_streq(data->driver, scache_driver)) {
47 pa_assert((data->flags & flag_mask) == flag_mask);
50 data->flags &= ~flag_mask;
51 data->flags |= PA_SINK_INPUT_START_CORKED;
59 void pa_stream_state_change(struct userdata *u, mir_node *node, int req)
64 pa_source_output *sout;
70 pa_assert_se((core = u->core));
74 pa_assert((!loop && node->implement == mir_stream) ||
75 ( loop && node->implement == mir_device) );
76 pa_assert(node->direction == mir_input || node->direction == mir_output);
79 if (node->direction == mir_input) {
80 sinp = pa_idxset_get_by_index(core->sink_inputs,
81 loop->sink_input_index);
87 pa_log_debug("mute '%s'", node->amname);
88 pa_sink_input_set_mute(sinp, true, false);
92 pa_log_debug("unmute '%s'", node->amname);
93 pa_sink_input_set_mute(sinp, false, false);
97 pa_assert_not_reached();
102 pa_log_debug("no enforcement for loopback on '%s'", node->amname);
103 sout = pa_idxset_get_by_index(core->source_outputs,
104 loop->source_output_index);
109 if (node->direction == mir_input) {
110 sinp = pa_idxset_get_by_index(core->sink_inputs, node->paidx);
115 pa_log_debug("killing '%s'", node->amname);
119 case PA_STREAM_BLOCK:
120 pa_log_debug("blocking '%s'", node->amname);
121 sink_input_block(u, sinp, true);
125 pa_log_debug("unblock '%s'", node->amname);
126 sink_input_block(u, sinp, false);
130 pa_assert_not_reached();
135 pa_log_debug("no enforcement for stream '%s'", node->amname);
136 sout = pa_idxset_get_by_index(core->source_outputs, node->paidx);
143 static void sink_input_block(struct userdata *u,
155 if (sinp->driver && pa_streq(sinp->driver, scache_driver)) {
157 sinp->flags &= ~flag_mask;
159 sinp->flags |= flag_mask;
162 muted = pa_sink_input_get_mute(sinp);
163 corked = (sinp->flags & PA_SINK_INPUT_START_CORKED);
165 if (corked && !block)
166 sinp->flags &= ~PA_SINK_INPUT_START_CORKED;
168 block_by_mute = !corked;
170 pa_log_debug("%sblock by %s", block ? "":"un",
171 block_by_mute ? "muting":"corking");
174 if ((muted && !block) || (!muted && block)) {
176 oldvol = pa_fader_get_volume(u, sinp);
178 pa_log_debug("fading in to %u", oldvol);
180 pa_fader_set_volume(u, sinp, 0);
181 pa_fader_ramp_volume(u, sinp, oldvol);
184 pa_sink_input_set_mute(sinp, block, FALSE);
188 if ((corked && !block) || (!corked && block)) {
189 pa_sink_input_cork_internal(sinp, block);
191 if (sinp->send_event) {
193 event = PA_STREAM_EVENT_REQUEST_CORK;
195 event = PA_STREAM_EVENT_REQUEST_UNCORK;
197 pl = pa_proplist_new();
199 sinp->send_event(sinp, event, pl);
201 pa_proplist_free(pl);
210 * indent-tabs-mode: nil