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;
40 static void sink_input_block(struct userdata *, pa_sink_input *, pa_bool_t);
42 pa_bool_t pa_stream_state_start_corked(struct userdata *u,
43 pa_sink_input_new_data *data,
44 pa_nodeset_resdef *resdef)
47 if (pa_streq(data->driver, scache_driver)) {
48 pa_assert((data->flags & flag_mask) == flag_mask);
51 data->flags &= ~flag_mask;
52 data->flags |= PA_SINK_INPUT_START_CORKED;
60 void pa_stream_state_change(struct userdata *u, mir_node *node, int req)
65 pa_source_output *sout;
71 pa_assert_se((core = u->core));
75 pa_assert((!loop && node->implement == mir_stream) ||
76 ( loop && node->implement == mir_device) );
77 pa_assert(node->direction == mir_input || node->direction == mir_output);
80 if (node->direction == mir_input) {
81 sinp = pa_idxset_get_by_index(core->sink_inputs,
82 loop->sink_input_index);
88 pa_log_debug("mute '%s'", node->amname);
89 pa_sink_input_set_mute(sinp, TRUE, FALSE);
93 pa_log_debug("unmute '%s'", node->amname);
94 pa_sink_input_set_mute(sinp, FALSE, FALSE);
98 pa_assert_not_reached();
103 pa_log_debug("no enforcement for loopback on '%s'", node->amname);
104 sout = pa_idxset_get_by_index(core->source_outputs,
105 loop->source_output_index);
110 if (node->direction == mir_input) {
111 sinp = pa_idxset_get_by_index(core->sink_inputs, node->paidx);
116 pa_log_debug("killing '%s'", node->amname);
120 case PA_STREAM_BLOCK:
121 pa_log_debug("blocking '%s'", node->amname);
122 sink_input_block(u, sinp, TRUE);
126 pa_log_debug("unblock '%s'", node->amname);
127 sink_input_block(u, sinp, FALSE);
131 pa_assert_not_reached();
136 pa_log_debug("no enforcement for stream '%s'", node->amname);
137 sout = pa_idxset_get_by_index(core->source_outputs, node->paidx);
144 static void sink_input_block(struct userdata *u,
156 if (sinp->driver && pa_streq(sinp->driver, scache_driver)) {
158 sinp->flags &= ~flag_mask;
160 sinp->flags |= flag_mask;
163 muted = pa_sink_input_get_mute(sinp);
164 corked = (sinp->flags & PA_SINK_INPUT_START_CORKED);
166 if (corked && !block)
167 sinp->flags &= ~PA_SINK_INPUT_START_CORKED;
169 block_by_mute = !corked;
171 pa_log_debug("%sblock by %s", block ? "":"un",
172 block_by_mute ? "muting":"corking");
175 if ((muted && !block) || (!muted && block)) {
177 oldvol = pa_fader_get_volume(u, sinp);
179 pa_log_debug("fading in to %u", oldvol);
181 pa_fader_set_volume(u, sinp, 0);
182 pa_fader_ramp_volume(u, sinp, oldvol);
185 pa_sink_input_set_mute(sinp, block, FALSE);
189 if ((corked && !block) || (!corked && block)) {
190 pa_sink_input_cork_internal(sinp, block);
192 if (sinp->send_event) {
194 event = PA_STREAM_EVENT_REQUEST_CORK;
196 event = PA_STREAM_EVENT_REQUEST_UNCORK;
198 pl = pa_proplist_new();
200 sinp->send_event(sinp, event, pl);
202 pa_proplist_free(pl);
211 * indent-tabs-mode: nil