[pulseaudio-discuss] [PATCH 01/11] Introduce "available" concept for ports, and communicate that to clients. Bump protocol version to 24.
David Henningsson
david.henningsson at canonical.com
Tue Aug 30 12:24:54 PDT 2011
Signed-off-by: David Henningsson <david.henningsson at canonical.com>
---
configure.ac | 2 +-
src/pulse/def.h | 17 +++++++++++++++++
src/pulse/introspect.c | 16 ++++++++++++++++
src/pulse/introspect.h | 2 ++
src/pulsecore/protocol-native.c | 4 ++++
src/pulsecore/sink.h | 1 +
6 files changed, 41 insertions(+), 1 deletions(-)
diff --git a/configure.ac b/configure.ac
index b1118c7..9cfc57e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -36,7 +36,7 @@ AC_SUBST(PA_MINOR, pa_minor)
AC_SUBST(PA_MAJORMINOR, pa_major.pa_minor)
AC_SUBST(PA_API_VERSION, 12)
-AC_SUBST(PA_PROTOCOL_VERSION, 23)
+AC_SUBST(PA_PROTOCOL_VERSION, 24)
# The stable ABI for client applications, for the version info x:y:z
# always will hold y=z
diff --git a/src/pulse/def.h b/src/pulse/def.h
index 386ea2b..ef10bc8 100644
--- a/src/pulse/def.h
+++ b/src/pulse/def.h
@@ -962,6 +962,23 @@ typedef void (*pa_free_cb_t)(void *p);
* playback, \since 1.0 */
#define PA_STREAM_EVENT_FORMAT_LOST "format-lost"
+/** Port availability / jack detection status
+ * \since MERGE_OF_JACK_DETECTION */
+typedef enum pa_port_available {
+ PA_PORT_AVAILABLE_UNKNOWN = 0, /**< This port does not support jack detection \since MERGE_OF_JACK_DETECTION */
+ PA_PORT_AVAILABLE_NO = 1, /**< This port is not available, likely because the jack is not plugged in. \since MERGE_OF_JACK_DETECTION */
+ PA_PORT_AVAILABLE_YES = 2, /**< This port is available, likely because the jack is plugged in. \since MERGE_OF_JACK_DETECTION */
+} pa_port_available_t;
+
+/** \cond fulldocs */
+#define PA_PORT_AVAILABLE_UNKNOWN PA_PORT_AVAILABLE_UNKNOWN
+#define PA_PORT_AVAILABLE_NO PA_PORT_AVAILABLE_NO
+#define PA_PORT_AVAILABLE_YES PA_PORT_AVAILABLE_YES
+
+/* FIXME: Remove the line below when this actually gets merged. Protocol version number */
+#define JACK_DETECTION_PROTOCOL_VERSION 24
+/** \endcond */
+
PA_C_DECL_END
#endif
diff --git a/src/pulse/introspect.c b/src/pulse/introspect.c
index 0d1d03f..7a472d3 100644
--- a/src/pulse/introspect.c
+++ b/src/pulse/introspect.c
@@ -211,6 +211,14 @@ static void context_get_sink_info_callback(pa_pdispatch *pd, uint32_t command, u
goto fail;
}
+ i.ports[0][j].available = PA_PORT_AVAILABLE_UNKNOWN;
+ if (o->context->version >= JACK_DETECTION_PROTOCOL_VERSION) {
+ uint32_t av;
+ if (pa_tagstruct_getu32(t, &av) < 0 || av > PA_PORT_AVAILABLE_YES)
+ goto fail;
+ i.ports[0][j].available = av;
+ }
+
i.ports[j] = &i.ports[0][j];
}
@@ -476,6 +484,14 @@ static void context_get_source_info_callback(pa_pdispatch *pd, uint32_t command,
goto fail;
}
+ i.ports[0][j].available = PA_PORT_AVAILABLE_UNKNOWN;
+ if (o->context->version >= JACK_DETECTION_PROTOCOL_VERSION) {
+ uint32_t av;
+ if (pa_tagstruct_getu32(t, &av) < 0 || av > PA_PORT_AVAILABLE_YES)
+ goto fail;
+ i.ports[0][j].available = av;
+ }
+
i.ports[j] = &i.ports[0][j];
}
diff --git a/src/pulse/introspect.h b/src/pulse/introspect.h
index 1d77d45..eba1471 100644
--- a/src/pulse/introspect.h
+++ b/src/pulse/introspect.h
@@ -202,6 +202,7 @@ typedef struct pa_sink_port_info {
const char *name; /**< Name of this port */
const char *description; /**< Description of this port */
uint32_t priority; /**< The higher this value is the more useful this port is as a default */
+ pa_port_available_t available; /**< PA_PORT_AVAILABLE_UNKNOWN, PA_PORT_AVAILABLE_NO or PA_PORT_AVAILABLE_YES \since MERGE_OF_JACK_DETECTION */
} pa_sink_port_info;
/** Stores information about sinks. Please note that this structure
@@ -281,6 +282,7 @@ typedef struct pa_source_port_info {
const char *name; /**< Name of this port */
const char *description; /**< Description of this port */
uint32_t priority; /**< The higher this value is the more useful this port is as a default */
+ pa_port_available_t available; /**< PA_PORT_AVAILABLE_UNKNOWN, PA_PORT_AVAILABLE_NO or PA_PORT_AVAILABLE_YES \since MERGE_OF_JACK_DETECTION */
} pa_source_port_info;
/** Stores information about sources. Please note that this structure
diff --git a/src/pulsecore/protocol-native.c b/src/pulsecore/protocol-native.c
index 3cffecb..efbc1ba 100644
--- a/src/pulsecore/protocol-native.c
+++ b/src/pulsecore/protocol-native.c
@@ -3094,6 +3094,8 @@ static void sink_fill_tagstruct(pa_native_connection *c, pa_tagstruct *t, pa_sin
pa_tagstruct_puts(t, p->name);
pa_tagstruct_puts(t, p->description);
pa_tagstruct_putu32(t, p->priority);
+ if (c->version >= JACK_DETECTION_PROTOCOL_VERSION)
+ pa_tagstruct_putu32(t, p->available);
}
}
@@ -3165,6 +3167,8 @@ static void source_fill_tagstruct(pa_native_connection *c, pa_tagstruct *t, pa_s
pa_tagstruct_puts(t, p->name);
pa_tagstruct_puts(t, p->description);
pa_tagstruct_putu32(t, p->priority);
+ if (c->version >= JACK_DETECTION_PROTOCOL_VERSION)
+ pa_tagstruct_putu32(t, p->available);
}
}
diff --git a/src/pulsecore/sink.h b/src/pulsecore/sink.h
index e5eaab3..39b2806 100644
--- a/src/pulsecore/sink.h
+++ b/src/pulsecore/sink.h
@@ -60,6 +60,7 @@ struct pa_device_port {
char *description;
unsigned priority;
+ pa_port_available_t available; /**< PA_PORT_AVAILABLE_UNKNOWN, PA_PORT_AVAILABLE_NO or PA_PORT_AVAILABLE_YES \since MERGE_OF_JACK_DETECTION */
/* .. followed by some implementation specific data */
};
--
1.7.5.4
More information about the pulseaudio-discuss
mailing list