[pulseaudio-discuss] [PATCH 19/21] sink-input-node, source-output-node: Introduce sink input and source output nodes
Tanu Kaskinen
tanu.kaskinen at linux.intel.com
Wed Jun 19 08:40:16 PDT 2013
These node types take care of things that are common to all sink input
and source output nodes.
---
src/Makefile.am | 2 ++
src/pulsecore/sink-input-node.c | 70 ++++++++++++++++++++++++++++++++++++++
src/pulsecore/sink-input-node.h | 40 ++++++++++++++++++++++
src/pulsecore/source-output-node.c | 70 ++++++++++++++++++++++++++++++++++++++
src/pulsecore/source-output-node.h | 40 ++++++++++++++++++++++
5 files changed, 222 insertions(+)
create mode 100644 src/pulsecore/sink-input-node.c
create mode 100644 src/pulsecore/sink-input-node.h
create mode 100644 src/pulsecore/source-output-node.c
create mode 100644 src/pulsecore/source-output-node.h
diff --git a/src/Makefile.am b/src/Makefile.am
index 5a7b817..5e6d41e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -892,8 +892,10 @@ libpulsecore_ at PA_MAJORMINOR@_la_SOURCES = \
pulsecore/remap_mmx.c pulsecore/remap_sse.c \
pulsecore/resampler.c pulsecore/resampler.h \
pulsecore/rtpoll.c pulsecore/rtpoll.h \
+ pulsecore/sink-input-node.c pulsecore/sink-input-node.h \
pulsecore/sink-node.c pulsecore/sink-node.h \
pulsecore/source-node.c pulsecore/source-node.h \
+ pulsecore/source-output-node.c pulsecore/source-output-node.h \
pulsecore/mix.c pulsecore/mix.h \
pulsecore/cpu.h \
pulsecore/cpu-arm.c pulsecore/cpu-arm.h \
diff --git a/src/pulsecore/sink-input-node.c b/src/pulsecore/sink-input-node.c
new file mode 100644
index 0000000..2a7ba45
--- /dev/null
+++ b/src/pulsecore/sink-input-node.c
@@ -0,0 +1,70 @@
+/***
+ This file is part of PulseAudio.
+
+ Copyright (c) 2013 Intel Corporation
+ Author: Tanu Kaskinen <tanu.kaskinen at intel.com>
+
+ PulseAudio is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of the License,
+ or (at your option) any later version.
+
+ PulseAudio is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with PulseAudio; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ USA.
+***/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "sink-input-node.h"
+
+pa_sink_input_node *pa_sink_input_node_new(pa_sink_input *input, const char *name) {
+ pa_node_new_data data;
+ pa_node *node;
+ pa_sink_input_node *input_node;
+
+ pa_assert(input);
+ pa_assert(name);
+
+ pa_node_new_data_init(&data);
+ pa_node_new_data_set_name(&data, name);
+ pa_node_new_data_set_description(&data, pa_sink_input_get_description(input));
+ pa_node_new_data_set_direction(&data, PA_DIRECTION_INPUT);
+
+ node = pa_node_new(input->core, &data);
+ pa_node_new_data_done(&data);
+
+ if (!node) {
+ pa_log("Failed to create a node for sink input %" PRIu32 ".", input->index);
+ return NULL;
+ }
+
+ input_node = pa_xnew0(pa_sink_input_node, 1);
+ input_node->core = input->core;
+ input_node->node = node;
+ input_node->sink_input = input;
+
+ node->userdata = input_node;
+
+ /* We may need to move this to pa_sink_input_node_put() at some point. */
+ pa_node_put(node);
+
+ return input_node;
+}
+
+void pa_sink_input_node_free(pa_sink_input_node *input_node) {
+ pa_assert(input_node);
+
+ if (input_node->node)
+ pa_node_free(input_node->node);
+
+ pa_xfree(input_node);
+}
diff --git a/src/pulsecore/sink-input-node.h b/src/pulsecore/sink-input-node.h
new file mode 100644
index 0000000..da154ae
--- /dev/null
+++ b/src/pulsecore/sink-input-node.h
@@ -0,0 +1,40 @@
+#ifndef foosinkinputnodehfoo
+#define foosinkinputnodehfoo
+
+/***
+ This file is part of PulseAudio.
+
+ Copyright (c) 2013 Intel Corporation
+ Author: Tanu Kaskinen <tanu.kaskinen at intel.com>
+
+ PulseAudio is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of the License,
+ or (at your option) any later version.
+
+ PulseAudio is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with PulseAudio; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ USA.
+***/
+
+typedef struct pa_sink_input_node pa_sink_input_node;
+
+#include <pulsecore/core.h>
+#include <pulsecore/node.h>
+
+struct pa_sink_input_node {
+ pa_core *core;
+ pa_node *node;
+ pa_sink_input *sink_input;
+};
+
+pa_sink_input_node *pa_sink_input_node_new(pa_sink_input *input, const char *name);
+void pa_sink_input_node_free(pa_sink_input_node *input_node);
+
+#endif
diff --git a/src/pulsecore/source-output-node.c b/src/pulsecore/source-output-node.c
new file mode 100644
index 0000000..9db35e8
--- /dev/null
+++ b/src/pulsecore/source-output-node.c
@@ -0,0 +1,70 @@
+/***
+ This file is part of PulseAudio.
+
+ Copyright (c) 2013 Intel Corporation
+ Author: Tanu Kaskinen <tanu.kaskinen at intel.com>
+
+ PulseAudio is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of the License,
+ or (at your option) any later version.
+
+ PulseAudio is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with PulseAudio; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ USA.
+***/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "source-output-node.h"
+
+pa_source_output_node *pa_source_output_node_new(pa_source_output *output, const char *name) {
+ pa_node_new_data data;
+ pa_node *node;
+ pa_source_output_node *output_node;
+
+ pa_assert(output);
+ pa_assert(name);
+
+ pa_node_new_data_init(&data);
+ pa_node_new_data_set_name(&data, name);
+ pa_node_new_data_set_description(&data, pa_source_output_get_description(output));
+ pa_node_new_data_set_direction(&data, PA_DIRECTION_OUTPUT);
+
+ node = pa_node_new(output->core, &data);
+ pa_node_new_data_done(&data);
+
+ if (!node) {
+ pa_log("Failed to create a node for source output %" PRIu32 ".", output->index);
+ return NULL;
+ }
+
+ output_node = pa_xnew0(pa_source_output_node, 1);
+ output_node->core = output->core;
+ output_node->node = node;
+ output_node->source_output = output;
+
+ node->userdata = output_node;
+
+ /* We may need to move this to pa_source_output_node_put() at some point. */
+ pa_node_put(node);
+
+ return output_node;
+}
+
+void pa_source_output_node_free(pa_source_output_node *output_node) {
+ pa_assert(output_node);
+
+ if (output_node->node)
+ pa_node_free(output_node->node);
+
+ pa_xfree(output_node);
+}
diff --git a/src/pulsecore/source-output-node.h b/src/pulsecore/source-output-node.h
new file mode 100644
index 0000000..ed906f4
--- /dev/null
+++ b/src/pulsecore/source-output-node.h
@@ -0,0 +1,40 @@
+#ifndef foosourceoutputnodehfoo
+#define foosourceoutputnodehfoo
+
+/***
+ This file is part of PulseAudio.
+
+ Copyright (c) 2013 Intel Corporation
+ Author: Tanu Kaskinen <tanu.kaskinen at intel.com>
+
+ PulseAudio is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of the License,
+ or (at your option) any later version.
+
+ PulseAudio is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with PulseAudio; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ USA.
+***/
+
+typedef struct pa_source_output_node pa_source_output_node;
+
+#include <pulsecore/core.h>
+#include <pulsecore/node.h>
+
+struct pa_source_output_node {
+ pa_core *core;
+ pa_node *node;
+ pa_source_output *source_output;
+};
+
+pa_source_output_node *pa_source_output_node_new(pa_source_output *output, const char *name);
+void pa_source_output_node_free(pa_source_output_node *output_node);
+
+#endif
--
1.8.1.2
More information about the pulseaudio-discuss
mailing list