[pulseaudio-discuss] [PATCH 06/11] Introduce pa_device_prototype
Tanu Kaskinen
tanu.kaskinen at linux.intel.com
Sat Nov 23 21:58:03 PST 2013
A "device prototype" is an object that allows referencing potential
devices, i.e. sinks and sources that don't exist. A card usually has
profiles that don't contain all devices that the card can create. The
card knows about all potential sinks and sources, and it would be
useful to make this information available also outside the card.
In my case I need it for implementing a "rescue policy" for profile
switch cases in module-skoa-router. The module shouldn't rescue
streams that are connected to devices that are not actually going to
be removed, because this causes glitches in the audio. Therefore, the
module needs to know before the profile switch happens whether a
device is going to be removed as a part of the profile switch.
The prototype has pointers to a sink and source. The prototype has
an implicit direction, and if it's an output device prototype, then
the source pointer must always be NULL (likewise for the sink pointer
for input device prototypes). The sink/source pointer is non-NULL
when a sink/source exists that is represented by the device prototype.
This patch only adds the device prototype implementation, the
prototypes aren't used yet.
---
src/Makefile.am | 1 +
src/pulsecore/device-prototype.c | 52 ++++++++++++++++++++++++++++++++++++++++
src/pulsecore/device-prototype.h | 40 +++++++++++++++++++++++++++++++
3 files changed, 93 insertions(+)
create mode 100644 src/pulsecore/device-prototype.c
create mode 100644 src/pulsecore/device-prototype.h
diff --git a/src/Makefile.am b/src/Makefile.am
index e024d9a..b92b613 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -875,6 +875,7 @@ libpulsecore_ at PA_MAJORMINOR@_la_SOURCES = \
pulsecore/core-scache.c pulsecore/core-scache.h \
pulsecore/core-subscribe.c pulsecore/core-subscribe.h \
pulsecore/core.c pulsecore/core.h \
+ pulsecore/device-prototype.c pulsecore/device-prototype.h \
pulsecore/fdsem.c pulsecore/fdsem.h \
pulsecore/hook-list.c pulsecore/hook-list.h \
pulsecore/ltdl-helper.c pulsecore/ltdl-helper.h \
diff --git a/src/pulsecore/device-prototype.c b/src/pulsecore/device-prototype.c
new file mode 100644
index 0000000..20cce8f
--- /dev/null
+++ b/src/pulsecore/device-prototype.c
@@ -0,0 +1,52 @@
+/***
+ This file is part of PulseAudio.
+
+ Copyright 2013 Intel Corporation
+
+ 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 "device-prototype.h"
+
+pa_device_prototype *pa_device_prototype_new(void) {
+ pa_device_prototype *prototype;
+
+ prototype = pa_xnew0(pa_device_prototype, 1);
+
+ return prototype;
+}
+
+void pa_device_prototype_free(pa_device_prototype *prototype) {
+ pa_assert(prototype);
+
+ pa_xfree(prototype);
+}
+
+void pa_device_prototype_set_sink(pa_device_prototype *prototype, pa_sink *sink) {
+ pa_assert(prototype);
+
+ prototype->sink = sink;
+}
+
+void pa_device_prototype_set_source(pa_device_prototype *prototype, pa_source *source) {
+ pa_assert(prototype);
+
+ prototype->source = source;
+}
diff --git a/src/pulsecore/device-prototype.h b/src/pulsecore/device-prototype.h
new file mode 100644
index 0000000..2087152
--- /dev/null
+++ b/src/pulsecore/device-prototype.h
@@ -0,0 +1,40 @@
+#ifndef foodeviceprototypehfoo
+#define foodeviceprototypehfoo
+
+/***
+ This file is part of PulseAudio.
+
+ Copyright 2013 Intel Corporation
+
+ 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.
+***/
+
+#include <pulsecore/source.h>
+
+typedef struct pa_device_prototype pa_device_prototype;
+
+struct pa_device_prototype {
+ pa_sink *sink;
+ pa_source *source;
+};
+
+pa_device_prototype *pa_device_prototype_new(void);
+void pa_device_prototype_free(pa_device_prototype *prototype);
+
+void pa_device_prototype_set_sink(pa_device_prototype *prototype, pa_sink *sink);
+void pa_device_prototype_set_source(pa_device_prototype *prototype, pa_source *source);
+
+#endif
--
1.8.3.1
More information about the pulseaudio-discuss
mailing list