#include "switch.h"
#include "node.h"
-bool agl_switch_setup_link (struct userdata *u, agl_node *from, agl_node *to, bool explicit)
+bool agl_switch_setup_link (struct userdata *u, agl_node *from, agl_node *to)
{
pa_core *core;
pa_sink *sink;
/* EXPLICIT ROUTES/DEFAULT ROUTES */
/* 1) EXPLICIT ROUTES : "FROM" AND "TO" ARE DEFINED */
- if (explicit) {
+ if (from && to) {
pa_assert (from);
pa_assert (to);
case agl_device:
//if (!setup_explicit_stream2dev_link (u, from, to))
// return false;
+ sink = agl_utils_get_alsa_sink (u, to->paname);
+ if (!sink) {
+ pa_log("sink output not found!!!!");
+ sink = agl_utils_get_primary_alsa_sink (u);
+ //break;
+ }
+ source = agl_utils_get_null_source (u, from->nullsink);
+ from->loopnode = agl_loopnode_create (u, AGL_LOOPNODE_SINK, from->index, source->index, sink->index);
break;
/* DEFAULT */
default:
/* DEVICE DESTINATION */
case agl_device:
- /* IF THERE IS NO SOURCE : DEFAULT OUTPUT PREROUTE */
- /* if (!from)
- return setup_device_output(u, to) != NULL;
- else { */
switch (from->implement) {
/* STREAM TO DEVICE : OK */
case agl_stream:
- //if (!setup_default_stream2dev_link (u, from, to))
- // return false;
+ sink = agl_utils_get_alsa_sink (u, to->paname);
+ if (!sink) break;
+ source = agl_utils_get_null_source (u, from->nullsink);
+
+ from->loopnode = agl_loopnode_create (u, AGL_LOOPNODE_SINK, from->index, source->index, sink->index);
break;
/* DEVICE TO DEVICE : OK */
case agl_device:
/* ONLY "FROM" IS DEFINED */
else {
- /* only works with a device, use default input prerouting - TODO */
+ /* only works with a stream, use default input prerouting */
if (from->implement == agl_device) {
pa_log_debug ("default routing for a device input is not supported yet");
return false;
return false;
}
- sink = pa_utils_get_primary_alsa_sink (u);
- source = pa_utils_get_null_source (u, from->nullsink);
-
- from->loopnode = pa_loopnode_create (u, PA_LOOPNODE_SINK, from->index, source->index, sink->index);
+ sink = agl_utils_get_primary_alsa_sink (u);
+ source = agl_utils_get_null_source (u, from->nullsink);
+ from->loopnode = agl_loopnode_create (u, AGL_LOOPNODE_SINK, from->index, source->index, sink->index);
}
}
pa_assert (u);
pa_assert_se (core = u->core);
- pa_assert (from || from->direction == agl_input);
- pa_assert (to || to->direction == agl_output);
- switch (from->implement) {
- case agl_stream:
- switch (to->implement) {
- /* STREAM TO STREAM : NOT IMPLEMENTED */
- case agl_stream:
- pa_log_debug ("routing to streams is not implemented yet");
- break;
- /* STREAM TO DEVICE : NOT OK */
- case agl_device:
- //if (!teardown_explicit_stream2dev_link (u, from, to))
- // return false;
- break;
- default:
- pa_log ("can't teardown link: invalid sink node");
- return false;
- }
- break;
+ pa_assert (from || to);
- case agl_device:
- /* DEVICE TO STREAM OR DEVICE TO DEVICE : NOT HANDLED */
- pa_log_debug ("input device routing is not implemented yet");
- break;
+ /* "TO" IS DEFINED */
+ if (to) {
- default:
- pa_log ("can't teardown link: invalid source node");
+ }
+ /* ONLY "FROM" IS DEFINED */
+ else {
+ /* only works with a stream */
+ if (from->implement == agl_device) {
+ pa_log_debug ("default routing for a device input is not supported");
return false;
+ }
+ /* (the rest supposes "from->implement == agl_stream") */
+ if (from->loopnode)
+ agl_loopnode_destroy (u, from->loopnode);
+ if (from->nullsink)
+ agl_utils_destroy_null_sink (u, from->nullsink);
}
- pa_log_debug("link %s => %s is torn down", from->amname, to->amname);
+ //pa_log_debug("link %s => %s is torn down", from->amname, to->amname);
return true;
}