[pulseaudio-discuss] [PATCH 04/11] Fire a hook when port available status is changed
David Henningsson
david.henningsson at canonical.com
Tue Aug 30 12:24:57 PDT 2011
Signed-off-by: David Henningsson <david.henningsson at canonical.com>
---
src/pulsecore/core.h | 1 +
src/pulsecore/device-port.c | 17 +++++++++++++++--
src/pulsecore/device-port.h | 5 +++++
3 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/src/pulsecore/core.h b/src/pulsecore/core.h
index d4639e0..72f39c5 100644
--- a/src/pulsecore/core.h
+++ b/src/pulsecore/core.h
@@ -113,6 +113,7 @@ typedef enum pa_core_hook {
PA_CORE_HOOK_CARD_PUT,
PA_CORE_HOOK_CARD_UNLINK,
PA_CORE_HOOK_CARD_PROFILE_CHANGED,
+ PA_CORE_HOOK_PORT_AVAILABLE_CHANGED,
PA_CORE_HOOK_MAX
} pa_core_hook_t;
diff --git a/src/pulsecore/device-port.c b/src/pulsecore/device-port.c
index 9e6ad43..5e6a492 100644
--- a/src/pulsecore/device-port.c
+++ b/src/pulsecore/device-port.c
@@ -20,11 +20,24 @@
USA.
***/
-
-#include "device-port.h"
+#include <pulsecore/device-port.h>
PA_DEFINE_PUBLIC_CLASS(pa_device_port, pa_object);
+void pa_device_port_set_available(pa_device_port *p, pa_port_available_t status, pa_core *core)
+{
+ pa_assert(p);
+
+ if (p->available == status)
+ return;
+
+ pa_assert(status != PA_PORT_AVAILABLE_UNKNOWN);
+ p->available = status;
+ pa_log_debug("Setting port %s to status %s", p->name, status == PA_PORT_AVAILABLE_YES ? "yes" : "no");
+ pa_hook_fire(&core->hooks[PA_CORE_HOOK_PORT_AVAILABLE_CHANGED], p);
+}
+
+
static void device_port_free(pa_object *o) {
pa_device_port *p = PA_DEVICE_PORT(o);
pa_assert(p);
diff --git a/src/pulsecore/device-port.h b/src/pulsecore/device-port.h
index 23f6444..355a4a1 100644
--- a/src/pulsecore/device-port.h
+++ b/src/pulsecore/device-port.h
@@ -57,4 +57,9 @@ pa_device_port *pa_device_port_new(const char *name, const char *description, si
void pa_device_port_hashmap_free(pa_hashmap *h);
+#include <pulsecore/core.h>
+
+/* The port's available status has changed */
+void pa_device_port_set_available(pa_device_port *p, pa_port_available_t available, pa_core *core);
+
#endif
--
1.7.5.4
More information about the pulseaudio-discuss
mailing list