[pulseaudio-discuss] RFC: Adding an enum to identify device types (sink vs. source)

Colin Guthrie gmane at colin.guthr.ie
Thu Aug 18 03:38:34 PDT 2011


Hi,

Due to a protocol thinko on the device restore API extension, I forgot
to identify whether the index give was a sink index or a source index.

I therefore need to add a field to differentiate this.

Sadly there does not appear to be an enum for this (unless I cannot find
it) in which case, does anyone have any objections against adding one:


diff --git a/src/pulse/def.h b/src/pulse/def.h
index d14ebca..32176af 100644
--- a/src/pulse/def.h
+++ b/src/pulse/def.h
@@ -124,6 +124,17 @@ typedef enum pa_context_flags {
 #define PA_CONTEXT_NOFAIL PA_CONTEXT_NOFAIL
 /** \endcond */

+/** The type of device we are dealing with */
+typedef enum pa_device_type {
+    PA_DEVICE_SINK,          /**< Playback device */
+    PA_DEVICE_SOURCE         /**< Recording device */
+} pa_device_type_t;
+
+/** \cond fulldocs */
+#define PA_DEVICE_SINK PA_DEVICE_SINK
+#define PA_DEVICE_SOURCE PA_DEVICE_SOURCE
+/** \endcond */
+
 /** The direction of a pa_stream object */
 typedef enum pa_stream_direction {
     PA_STREAM_NODIRECTION,   /**< Invalid direction */



I figure this will be quite useful generally after a 1.0 code cleanup
which will reduce the duplication between sink and source code and
abstracting a lot of it into generic "device" code (while "device" as a
term is not ideal - not all sinks and source are h/w - I'm not sure
there is a better "base" name for sinks/source... suggestions
welcomed!), so this could be useful there too.


Please feel free to point out that this is actually already implemented
in some capacity too :D

Col



-- 

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
  Mageia Contributor [http://www.mageia.org/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]



More information about the pulseaudio-discuss mailing list