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>
33 #include <combine/userdata.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,
63 static char *modnam = "module-loopback";
69 pa_sink_input *sink_input;
75 if (!(source = pa_idxset_get_by_index(core->sources, source_index))) {
76 pa_log_debug("can't find source (index %u) for loopback",source_index);
80 if (!(sink = pa_idxset_get_by_index(core->sinks, sink_index))) {
81 pa_log_debug("can't find the primary sink (index %u) for loopback",
86 snprintf(args, sizeof(args), "source=\"%s\" sink=\"%s\"",
87 source->name, sink->name);
89 if (!(module = pa_module_load(core, modnam, args))) {
90 pa_log("failed to load module '%s %s'. can't loopback", modnam, args);
94 PA_IDXSET_FOREACH(sink_input, core->sink_inputs, idx) {
95 if (sink_input->module == module)
100 pa_log("can't find output stream of loopback module (index %u)",
102 pa_module_unload(core, module, FALSE);
106 pa_assert(sink_input->index != PA_IDXSET_INVALID);
108 loop = pa_xnew0(pa_loopnode, 1);
109 loop->module_index = module->index;
110 loop->sink_input_index = sink_input->index;
112 PA_LLIST_PREPEND(pa_loopnode, loopback->loopnodes, loop);
114 pa_log_debug("loopback succesfully loaded. Module index %u",module->index);
120 void pa_loopback_destroy(pa_loopback *loopback,
128 PA_LLIST_REMOVE(pa_loopnode, loopback->loopnodes, loop);
129 pa_module_unload_by_index(core, loop->module_index, FALSE);
136 int pa_loopback_print(pa_loopnode *loop, char *buf, int len)
146 p += snprintf(p, e-p, "<not set>");
148 p += snprintf(p, e-p, "module %u, sink_input %u",
149 loop->module_index, loop->sink_input_index);
159 * indent-tabs-mode: nil