Commit 4f96309c authored by David Reid's avatar David Reid

Add experimental loop detection to the routing system.

parent c5403669
......@@ -1774,6 +1774,7 @@ typedef int ma_result;
#define MA_NO_DEVICE -104
#define MA_API_NOT_FOUND -105
#define MA_INVALID_DEVICE_CONFIG -106
#define MA_LOOP -107
/* State errors. */
#define MA_DEVICE_NOT_INITIALIZED -200
This diff is collapsed.
......@@ -5,6 +5,7 @@
ma_node_graph g_nodeGraph;
ma_data_source_node g_dataSourceNode;
ma_splitter_node g_splitterNode;
ma_splitter_node g_loopNode; /* For testing loop detection. We're going to route one of these endpoints back to g_splitterNode to form a loop. */
void data_callback(ma_device* pDevice, void* pFramesOut, const void* pFramesIn, ma_uint32 frameCount)
{
......@@ -89,18 +90,41 @@ int main(int argc, char** argv)
}
/*
Splitter node. Note that we've already attached the data source node to another, so this section
will test that changing of attachments works as expected.
*/
splitterNodeConfig = ma_splitter_node_config_init(device.playback.channels);
/* Loop detection testing. */
result = ma_splitter_node_init(&g_nodeGraph, &splitterNodeConfig, NULL, &g_loopNode);
if (result != MA_SUCCESS) {
printf("Failed to initialize loop node.");
return -1;
}
/* Connect both outputs of the splitter to the endpoint for now. Later on we'll test effects and whatnot. */
ma_node_attach_to_output_node(&g_loopNode, 0, ma_node_graph_get_endpoint(&g_nodeGraph), 0);
ma_node_attach_to_output_node(&g_loopNode, 1, ma_node_graph_get_endpoint(&g_nodeGraph), 0);
/* Adjust the volume of the splitter node's endpoints. We'll just do it 50/50 so that both of them combine to reproduce the original signal at the endpoint. */
ma_node_set_output_bus_volume(&g_loopNode, 0, 0.5f);
ma_node_set_output_bus_volume(&g_loopNode, 1, 0.5f);
result = ma_splitter_node_init(&g_nodeGraph, &splitterNodeConfig, NULL, &g_splitterNode);
if (result != MA_SUCCESS) {
printf("Failed to initialize splitter node.");
return -1;
}
#if 0
/* Connect both outputs of the splitter to the endpoint for now. Later on we'll test effects and whatnot. */
ma_node_attach_to_output_node(&g_splitterNode, 0, ma_node_graph_get_endpoint(&g_nodeGraph), 0);
ma_node_attach_to_output_node(&g_splitterNode, 1, ma_node_graph_get_endpoint(&g_nodeGraph), 0);
......@@ -108,11 +132,22 @@ int main(int argc, char** argv)
/* Adjust the volume of the splitter node's endpoints. We'll just do it 50/50 so that both of them combine to reproduce the original signal at the endpoint. */
ma_node_set_output_bus_volume(&g_splitterNode, 0, 0.5f);
ma_node_set_output_bus_volume(&g_splitterNode, 1, 0.5f);
#else
/* Connect both outputs of the splitter to the endpoint for now. Later on we'll test effects and whatnot. */
ma_node_attach_to_output_node(&g_splitterNode, 0, &g_loopNode, 0);
ma_node_attach_to_output_node(&g_splitterNode, 1, &g_loopNode, 1);
/* Now loop back to the splitter node to form a loop. */
ma_node_attach_to_output_node(&g_loopNode, 1, &g_splitterNode, 0);
#endif
/* The data source needs to have it's connection changed from the endpoint to the splitter. */
ma_node_attach_to_output_node(&g_dataSourceNode, 0, &g_splitterNode, 0);
/* Stop the splitter node for testing. */
/*ma_node_set_state(&g_splitterNode, ma_node_state_stopped);*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment