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,
24 #include <pulsecore/pulsecore-config.h>
26 #include <pulse/def.h>
27 #include <pulsecore/thread.h>
28 #include <pulsecore/strlist.h>
29 #include <pulsecore/time-smoother.h>
30 #include <pulsecore/sink.h>
31 #include <pulsecore/sink-input.h>
39 pa_loopback *pa_loopback_init(void)
41 pa_loopback *loopback = pa_xnew0(pa_loopback, 1);
47 void pa_loopback_done(pa_loopback *loopback, pa_core *core)
49 pa_loopnode *loop, *n;
51 PA_LLIST_FOREACH_SAFE(loop,n, loopback->loopnodes) {
52 pa_module_unload_by_index(core, loop->module_index, FALSE);
58 pa_loopnode *pa_loopback_create(pa_loopback *loopback,
60 uint32_t source_index,
62 const char *media_role)
64 static char *modnam = "module-loopback";
70 pa_sink_input *sink_input;
76 if (!(source = pa_idxset_get_by_index(core->sources, source_index))) {
77 pa_log_debug("can't find source (index %u) for loopback",source_index);
81 if (!(sink = pa_idxset_get_by_index(core->sinks, sink_index))) {
82 pa_log_debug("can't find the primary sink (index %u) for loopback",
90 snprintf(args, sizeof(args), "source=\"%s\" sink=\"%s\" "
91 "sink_input_properties=%s=\"%s\"",
92 source->name, sink->name,
93 PA_PROP_MEDIA_ROLE, media_role);
95 pa_log_debug("loading %s %s", modnam, args);
97 if (!(module = pa_module_load(core, modnam, args))) {
98 pa_log("failed to load module '%s %s'. can't loopback", modnam, args);
102 PA_IDXSET_FOREACH(sink_input, core->sink_inputs, idx) {
103 if (sink_input->module == module)
108 pa_log("can't find output stream of loopback module (index %u)",
110 pa_module_unload(core, module, FALSE);
114 pa_assert(sink_input->index != PA_IDXSET_INVALID);
116 loop = pa_xnew0(pa_loopnode, 1);
117 loop->module_index = module->index;
118 loop->sink_input_index = sink_input->index;
120 PA_LLIST_PREPEND(pa_loopnode, loopback->loopnodes, loop);
122 pa_log_debug("loopback succesfully loaded. Module index %u",module->index);
128 void pa_loopback_destroy(pa_loopback *loopback,
136 PA_LLIST_REMOVE(pa_loopnode, loopback->loopnodes, loop);
137 pa_module_unload_by_index(core, loop->module_index, FALSE);
142 uint32_t pa_loopback_get_sink_index(pa_core *core, pa_loopnode *loop)
144 pa_sink_input *sink_input;
150 sink_input = pa_idxset_get_by_index(core->sink_inputs,
151 loop->sink_input_index);
153 if (sink_input && (sink = sink_input->sink))
156 return PA_IDXSET_INVALID;
159 int pa_loopback_print(pa_loopnode *loop, char *buf, int len)
169 p += snprintf(p, e-p, "<not set>");
171 p += snprintf(p, e-p, "module %u, sink_input %u",
172 loop->module_index, loop->sink_input_index);
182 * indent-tabs-mode: nil