[pulseaudio-commits] [SCM] PulseAudio Sound Server branch, master, updated. v0.9.13-301-g310f433
Lennart Poettering
gitmailer-noreply at 0pointer.de
Mon Jan 19 14:42:13 PST 2009
This is an automated email from the git hooks/post-receive script. It was
generated because of a push to the "PulseAudio Sound Server" repository.
The master branch has been updated
from f83111dd1710d7e0a3240879217e6d0c783c4a4b (commit)
- Log -----------------------------------------------------------------
310f433... pulse: share private enum values with client side
a3762a2... cli: fix broken array access with signed state enums
6374f8e... sink: trigger subscribe event on sink state change
9c4f8e6... pulse: introspect sink state
-----------------------------------------------------------------------
Summary of changes:
src/pulse/def.h | 76 ++++++++++++++++++++++++++++++++++++++-
src/pulse/introspect.c | 20 ++++++++---
src/pulse/introspect.h | 2 +
src/pulsecore/cli-text.c | 52 ++++++++++++++++++--------
src/pulsecore/protocol-native.c | 12 +++++-
src/pulsecore/sink.c | 4 ++-
src/pulsecore/sink.h | 14 +------
src/pulsecore/source.h | 13 +------
8 files changed, 144 insertions(+), 49 deletions(-)
-----------------------------------------------------------------------
commit 9c4f8e627a70fc610a81da2703eeddfde4a7e4fa
Author: Marc-André Lureau <marcandre.lureau at gmail.com>
Date: Thu Jan 15 17:16:31 2009 +0200
pulse: introspect sink state
diff --git a/src/pulse/def.h b/src/pulse/def.h
index d43c070..7dc753f 100644
--- a/src/pulse/def.h
+++ b/src/pulse/def.h
@@ -613,6 +613,35 @@ typedef enum pa_sink_flags {
#define PA_SINK_DECIBEL_VOLUME PA_SINK_DECIBEL_VOLUME
/** \endcond */
+/** Sink state. \since 0.9.15 */
+typedef enum pa_sink_state { /* enum serialized in u8 */
+ PA_SINK_INVALID_STATE = -1,
+ /**< This state is used when the server does not support sink state introspection \since 0.9.15 */
+
+ PA_SINK_RUNNING = 0,
+ /**< Running, sink is playing and used by at least one non-corked sink-input \since 0.9.15 */
+
+ PA_SINK_IDLE = 1,
+ /**< When idle, the sink is playing but there is no non-corked sink-input attached to it \since 0.9.15 */
+
+ PA_SINK_SUSPENDED = 2
+ /**< When suspended, actual sink access can be closed, for instance \since 0.9.15 */
+
+} pa_sink_state_t;
+
+/** Returns non-zero if sink is playing: running or idle. \since 0.9.15 */
+static inline int PA_SINK_IS_OPENED(pa_sink_state_t x) {
+ return x == PA_SINK_RUNNING || x == PA_SINK_IDLE;
+}
+
+/** \cond fulldocs */
+#define PA_SINK_INVALID_STATE PA_SINK_INVALID_STATE
+#define PA_SINK_RUNNING PA_SINK_RUNNING
+#define PA_SINK_IDLE PA_SINK_IDLE
+#define PA_SINK_SUSPENDED PA_SINK_SUSPENDED
+#define PA_SINK_IS_OPENED PA_SINK_IS_OPENED
+/** \endcond */
+
/** Special source flags. */
typedef enum pa_source_flags {
PA_SOURCE_HW_VOLUME_CTRL = 0x0001U,
@@ -626,7 +655,7 @@ typedef enum pa_source_flags {
* "virtual"/software source \since 0.9.3 */
PA_SOURCE_NETWORK = 0x0008U,
- /**< Is a networked sink of some kind. \since 0.9.7 */
+ /**< Is a networked source of some kind. \since 0.9.7 */
PA_SOURCE_HW_MUTE_CTRL = 0x0010U,
/**< Supports hardware mute control \since 0.9.11 */
@@ -645,6 +674,35 @@ typedef enum pa_source_flags {
#define PA_SOURCE_DECIBEL_VOLUME PA_SOURCE_DECIBEL_VOLUME
/** \endcond */
+/** Source state. \since 0.9.15 */
+typedef enum pa_source_state {
+ PA_SOURCE_INVALID_STATE = -1,
+ /**< This state is used when the server does not support source state introspection \since 0.9.15 */
+
+ PA_SOURCE_RUNNING = 0,
+ /**< Running, source is recording and used by at least one non-corked source-output \since 0.9.15 */
+
+ PA_SOURCE_IDLE = 1,
+ /**< When idle, the source is still recording but there is no non-corked source-output \since 0.9.15 */
+
+ PA_SOURCE_SUSPENDED = 2
+ /**< When suspended, actual source access can be closed, for instance \since 0.9.15 */
+
+} pa_source_state_t;
+
+/** Returns non-zero if source is recording: running or idle. \since 0.9.15 */
+static inline int PA_SOURCE_IS_OPENED(pa_source_state_t x) {
+ return x == PA_SOURCE_RUNNING || x == PA_SOURCE_IDLE;
+}
+
+/** \cond fulldocs */
+#define PA_SOURCE_INVALID_STATE PA_SOURCE_INVALID_STATE
+#define PA_SOURCE_RUNNING PA_SOURCE_RUNNING
+#define PA_SOURCE_IDLE PA_SOURCE_IDLE
+#define PA_SOURCE_SUSPENDED PA_SOURCE_SUSPENDED
+#define PA_SOURCE_IS_OPENED PA_SOURCE_IS_OPENED
+/** \endcond */
+
/** A generic free() like callback prototype */
typedef void (*pa_free_cb_t)(void *p);
diff --git a/src/pulse/introspect.c b/src/pulse/introspect.c
index e7fa6d7..a6a228e 100644
--- a/src/pulse/introspect.c
+++ b/src/pulse/introspect.c
@@ -146,15 +146,18 @@ static void context_get_sink_info_callback(pa_pdispatch *pd, uint32_t command, u
eol = -1;
} else {
- uint32_t flags;
while (!pa_tagstruct_eof(t)) {
pa_sink_info i;
- pa_bool_t mute = FALSE;
+ pa_bool_t mute;
+ uint32_t flags;
+ uint32_t state;
memset(&i, 0, sizeof(i));
i.proplist = pa_proplist_new();
i.base_volume = PA_VOLUME_NORM;
+ mute = FALSE;
+ state = PA_SINK_INVALID_STATE;
if (pa_tagstruct_getu32(t, &i.index) < 0 ||
pa_tagstruct_gets(t, &i.name) < 0 ||
@@ -173,7 +176,8 @@ static void context_get_sink_info_callback(pa_pdispatch *pd, uint32_t command, u
(pa_tagstruct_get_proplist(t, i.proplist) < 0 ||
pa_tagstruct_get_usec(t, &i.configured_latency) < 0)) ||
(o->context->version >= 15 &&
- pa_tagstruct_get_volume(t, &i.base_volume) < 0)) {
+ (pa_tagstruct_get_volume(t, &i.base_volume) < 0 ||
+ pa_tagstruct_getu32(t, &state) < 0))) {
pa_context_fail(o->context, PA_ERR_PROTOCOL);
pa_proplist_free(i.proplist);
@@ -182,6 +186,7 @@ static void context_get_sink_info_callback(pa_pdispatch *pd, uint32_t command, u
i.mute = (int) mute;
i.flags = (pa_sink_flags_t) flags;
+ i.state = (pa_sink_state_t) state;
if (o->callback) {
pa_sink_info_cb_t cb = (pa_sink_info_cb_t) o->callback;
@@ -273,12 +278,15 @@ static void context_get_source_info_callback(pa_pdispatch *pd, uint32_t command,
while (!pa_tagstruct_eof(t)) {
pa_source_info i;
+ pa_bool_t mute;
uint32_t flags;
- pa_bool_t mute = FALSE;
+ uint32_t state;
memset(&i, 0, sizeof(i));
i.proplist = pa_proplist_new();
i.base_volume = PA_VOLUME_NORM;
+ mute = FALSE;
+ state = PA_SOURCE_INVALID_STATE;
if (pa_tagstruct_getu32(t, &i.index) < 0 ||
pa_tagstruct_gets(t, &i.name) < 0 ||
@@ -297,7 +305,8 @@ static void context_get_source_info_callback(pa_pdispatch *pd, uint32_t command,
(pa_tagstruct_get_proplist(t, i.proplist) < 0 ||
pa_tagstruct_get_usec(t, &i.configured_latency) < 0)) ||
(o->context->version >= 15 &&
- pa_tagstruct_get_volume(t, &i.base_volume) < 0)) {
+ (pa_tagstruct_get_volume(t, &i.base_volume) < 0 ||
+ pa_tagstruct_getu32(t, &state) < 0))) {
pa_context_fail(o->context, PA_ERR_PROTOCOL);
pa_proplist_free(i.proplist);
@@ -306,6 +315,7 @@ static void context_get_source_info_callback(pa_pdispatch *pd, uint32_t command,
i.mute = (int) mute;
i.flags = (pa_source_flags_t) flags;
+ i.state = (pa_source_state_t) state;
if (o->callback) {
pa_source_info_cb_t cb = (pa_source_info_cb_t) o->callback;
diff --git a/src/pulse/introspect.h b/src/pulse/introspect.h
index a656d1c..07318c7 100644
--- a/src/pulse/introspect.h
+++ b/src/pulse/introspect.h
@@ -212,6 +212,7 @@ typedef struct pa_sink_info {
pa_proplist *proplist; /**< Property list \since 0.9.11 */
pa_usec_t configured_latency; /**< The latency this device has been configured to. \since 0.9.11 */
pa_volume_t base_volume; /**< Some kind of "base" volume that refers to unamplified/unattenuated volume in the context of the output device. \since 0.9.15 */
+ pa_sink_state_t state; /**< State \since 0.9.15 */
} pa_sink_info;
/** Callback prototype for pa_context_get_sink_info_by_name() and friends */
@@ -268,6 +269,7 @@ typedef struct pa_source_info {
pa_proplist *proplist; /**< Property list \since 0.9.11 */
pa_usec_t configured_latency; /**< The latency this device has been configured to. \since 0.9.11 */
pa_volume_t base_volume; /**< Some kind of "base" volume that refers to unamplified/unattenuated volume in the context of the input device. \since 0.9.15 */
+ pa_source_state_t state; /**< State \since 0.9.15 */
} pa_source_info;
/** Callback prototype for pa_context_get_source_info_by_name() and friends */
diff --git a/src/pulsecore/protocol-native.c b/src/pulsecore/protocol-native.c
index eb55505..a49d5df 100644
--- a/src/pulsecore/protocol-native.c
+++ b/src/pulsecore/protocol-native.c
@@ -2679,8 +2679,12 @@ static void sink_fill_tagstruct(pa_native_connection *c, pa_tagstruct *t, pa_sin
pa_tagstruct_put_usec(t, pa_sink_get_requested_latency(sink));
}
- if (c->version >= 15)
+ if (c->version >= 15) {
pa_tagstruct_put_volume(t, sink->base_volume);
+ if (PA_UNLIKELY(pa_sink_get_state(sink) == PA_SINK_INVALID_STATE))
+ pa_log_error("Internal sink state is invalid.");
+ pa_tagstruct_putu32(t, pa_sink_get_state(sink));
+ }
}
static void source_fill_tagstruct(pa_native_connection *c, pa_tagstruct *t, pa_source *source) {
@@ -2713,8 +2717,12 @@ static void source_fill_tagstruct(pa_native_connection *c, pa_tagstruct *t, pa_s
pa_tagstruct_put_usec(t, pa_source_get_requested_latency(source));
}
- if (c->version >= 15)
+ if (c->version >= 15) {
pa_tagstruct_put_volume(t, source->base_volume);
+ if (PA_UNLIKELY(pa_source_get_state(source) == PA_SOURCE_INVALID_STATE))
+ pa_log_error("Internal source state is invalid.");
+ pa_tagstruct_putu32(t, pa_source_get_state(source));
+ }
}
static void client_fill_tagstruct(pa_native_connection *c, pa_tagstruct *t, pa_client *client) {
diff --git a/src/pulsecore/sink.h b/src/pulsecore/sink.h
index 507c160..382b2d0 100644
--- a/src/pulsecore/sink.h
+++ b/src/pulsecore/sink.h
@@ -27,6 +27,7 @@ typedef struct pa_sink pa_sink;
#include <inttypes.h>
+#include <pulse/def.h>
#include <pulse/sample.h>
#include <pulse/channelmap.h>
#include <pulse/volume.h>
@@ -42,18 +43,16 @@ typedef struct pa_sink pa_sink;
#define PA_MAX_INPUTS_PER_SINK 32
-typedef enum pa_sink_state {
- PA_SINK_INIT,
- PA_SINK_RUNNING,
- PA_SINK_SUSPENDED,
- PA_SINK_IDLE,
- PA_SINK_UNLINKED
-} pa_sink_state_t;
+/* anonymous enum extending pa_sink_state_t */
+enum {
+ PA_SINK_INIT = -2,
+ /* Initialization state */
-static inline pa_bool_t PA_SINK_IS_OPENED(pa_sink_state_t x) {
- return x == PA_SINK_RUNNING || x == PA_SINK_IDLE;
-}
+ PA_SINK_UNLINKED = -3
+ /* The state when the sink is getting unregistered and removed from client access */
+};
+/* Returns true if sink is linked: registered and accessible from client side. */
static inline pa_bool_t PA_SINK_IS_LINKED(pa_sink_state_t x) {
return x == PA_SINK_RUNNING || x == PA_SINK_IDLE || x == PA_SINK_SUSPENDED;
}
diff --git a/src/pulsecore/source.h b/src/pulsecore/source.h
index 4824099..369da43 100644
--- a/src/pulsecore/source.h
+++ b/src/pulsecore/source.h
@@ -45,18 +45,16 @@ typedef struct pa_source pa_source;
#define PA_MAX_OUTPUTS_PER_SOURCE 32
-typedef enum pa_source_state {
- PA_SOURCE_INIT,
- PA_SOURCE_RUNNING,
- PA_SOURCE_SUSPENDED,
- PA_SOURCE_IDLE,
- PA_SOURCE_UNLINKED
-} pa_source_state_t;
-
-static inline pa_bool_t PA_SOURCE_IS_OPENED(pa_source_state_t x) {
- return x == PA_SOURCE_RUNNING || x == PA_SOURCE_IDLE;
-}
+/* anonymous enum extending pa_source_state_t */
+enum {
+ PA_SOURCE_INIT = -2,
+ /* Initialization state */
+
+ PA_SOURCE_UNLINKED = -3
+ /* The state when the source is getting unregistered and removed from client access */
+};
+/* Returns true if source is linked: registered and accessible from client side. */
static inline pa_bool_t PA_SOURCE_IS_LINKED(pa_source_state_t x) {
return x == PA_SOURCE_RUNNING || x == PA_SOURCE_IDLE || x == PA_SOURCE_SUSPENDED;
}
commit 6374f8e427269c16afcd9d8a2536eec260d28ef6
Author: Marc-André Lureau <marcandre.lureau at gmail.com>
Date: Thu Jan 15 17:28:33 2009 +0200
sink: trigger subscribe event on sink state change
diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c
index 2abc848..bd90cf5 100644
--- a/src/pulsecore/sink.c
+++ b/src/pulsecore/sink.c
@@ -311,8 +311,10 @@ static int sink_set_state(pa_sink *s, pa_sink_state_t state) {
i->suspend(i, state == PA_SINK_SUSPENDED);
}
- if (state != PA_SINK_UNLINKED) /* if we enter UNLINKED state pa_sink_unlink() will fire the apropriate events */
+ if (state != PA_SINK_UNLINKED) { /* if we enter UNLINKED state pa_sink_unlink() will fire the apropriate events */
pa_hook_fire(&s->core->hooks[PA_CORE_HOOK_SINK_STATE_CHANGED], s);
+ pa_subscription_post(s->core, PA_SUBSCRIPTION_EVENT_SINK | PA_SUBSCRIPTION_EVENT_CHANGE, s->index);
+ }
return 0;
}
commit a3762a2f9836b1a5f94eb0c69b24bd1839cb1205
Author: Marc-André Lureau <marcandre.lureau at gmail.com>
Date: Thu Jan 15 20:58:04 2009 +0200
cli: fix broken array access with signed state enums
I wish I could have merge sink_to_string and source_to_string, but the
enum values are equal, and we cannot assume they will always be.
diff --git a/src/pulsecore/cli-text.c b/src/pulsecore/cli-text.c
index 7962039..b97c870 100644
--- a/src/pulsecore/cli-text.c
+++ b/src/pulsecore/cli-text.c
@@ -150,17 +150,44 @@ char *pa_card_list_to_string(pa_core *c) {
return pa_strbuf_tostring_free(s);
}
+static const char *sink_state_to_string(pa_sink_state_t state) {
+ switch (state) {
+ case PA_SINK_INIT:
+ return "INIT";
+ case PA_SINK_RUNNING:
+ return "RUNNING";
+ case PA_SINK_SUSPENDED:
+ return "SUSPENDED";
+ case PA_SINK_IDLE:
+ return "IDLE";
+ case PA_SINK_UNLINKED:
+ return "UNLINKED";
+ default:
+ return "INVALID";
+ }
+}
+
+static const char *source_state_to_string(pa_source_state_t state) {
+ switch (state) {
+ case PA_SOURCE_INIT:
+ return "INIT";
+ case PA_SOURCE_RUNNING:
+ return "RUNNING";
+ case PA_SOURCE_SUSPENDED:
+ return "SUSPENDED";
+ case PA_SOURCE_IDLE:
+ return "IDLE";
+ case PA_SOURCE_UNLINKED:
+ return "UNLINKED";
+ default:
+ return "INVALID";
+ }
+}
+
char *pa_sink_list_to_string(pa_core *c) {
pa_strbuf *s;
pa_sink *sink;
uint32_t idx = PA_IDXSET_INVALID;
- static const char* const state_table[] = {
- [PA_SINK_INIT] = "INIT",
- [PA_SINK_RUNNING] = "RUNNING",
- [PA_SINK_SUSPENDED] = "SUSPENDED",
- [PA_SINK_IDLE] = "IDLE",
- [PA_SINK_UNLINKED] = "UNLINKED"
- };
pa_assert(c);
s = pa_strbuf_new();
@@ -208,7 +235,7 @@ char *pa_sink_list_to_string(pa_core *c) {
sink->flags & PA_SINK_HW_VOLUME_CTRL ? "HW_VOLUME_CTRL " : "",
sink->flags & PA_SINK_DECIBEL_VOLUME ? "DECIBEL_VOLUME " : "",
sink->flags & PA_SINK_LATENCY ? "LATENCY " : "",
- state_table[pa_sink_get_state(sink)],
+ sink_state_to_string(pa_sink_get_state(sink)),
pa_cvolume_snprint(cv, sizeof(cv), pa_sink_get_volume(sink, FALSE)),
sink->flags & PA_SINK_DECIBEL_VOLUME ? "\n\t " : "",
sink->flags & PA_SINK_DECIBEL_VOLUME ? pa_sw_cvolume_snprint_dB(cvdb, sizeof(cvdb), pa_sink_get_volume(sink, FALSE)) : "",
@@ -246,13 +273,6 @@ char *pa_source_list_to_string(pa_core *c) {
pa_strbuf *s;
pa_source *source;
uint32_t idx = PA_IDXSET_INVALID;
- static const char* const state_table[] = {
- [PA_SOURCE_INIT] = "INIT",
- [PA_SOURCE_RUNNING] = "RUNNING",
- [PA_SOURCE_SUSPENDED] = "SUSPENDED",
- [PA_SOURCE_IDLE] = "IDLE",
- [PA_SOURCE_UNLINKED] = "UNLINKED"
- };
pa_assert(c);
s = pa_strbuf_new();
@@ -298,7 +318,7 @@ char *pa_source_list_to_string(pa_core *c) {
source->flags & PA_SOURCE_HW_VOLUME_CTRL ? "HW_VOLUME_CTRL " : "",
source->flags & PA_SOURCE_DECIBEL_VOLUME ? "DECIBEL_VOLUME " : "",
source->flags & PA_SOURCE_LATENCY ? "LATENCY " : "",
- state_table[pa_source_get_state(source)],
+ source_state_to_string(pa_source_get_state(source)),
pa_cvolume_snprint(cv, sizeof(cv), pa_source_get_volume(source, FALSE)),
source->flags & PA_SOURCE_DECIBEL_VOLUME ? "\n\t " : "",
source->flags & PA_SOURCE_DECIBEL_VOLUME ? pa_sw_cvolume_snprint_dB(cvdb, sizeof(cvdb), pa_source_get_volume(source, FALSE)) : "",
commit 310f433848b21a53def0a5a5ca0b3b2e6a2008ef
Author: Marc-André Lureau <marcandre.lureau at gmail.com>
Date: Fri Jan 16 15:53:27 2009 +0200
pulse: share private enum values with client side
diff --git a/src/pulse/def.h b/src/pulse/def.h
index 7dc753f..8e8857c 100644
--- a/src/pulse/def.h
+++ b/src/pulse/def.h
@@ -624,9 +624,17 @@ typedef enum pa_sink_state { /* enum serialized in u8 */
PA_SINK_IDLE = 1,
/**< When idle, the sink is playing but there is no non-corked sink-input attached to it \since 0.9.15 */
- PA_SINK_SUSPENDED = 2
+ PA_SINK_SUSPENDED = 2,
/**< When suspended, actual sink access can be closed, for instance \since 0.9.15 */
+ /* *** PRIVATE: server-side values *** */
+
+ PA_SINK_INIT = -2,
+ /* Initialization state */
+
+ PA_SINK_UNLINKED = -3
+ /* The state when the sink is getting unregistered and removed from client access */
+
} pa_sink_state_t;
/** Returns non-zero if sink is playing: running or idle. \since 0.9.15 */
@@ -685,9 +693,17 @@ typedef enum pa_source_state {
PA_SOURCE_IDLE = 1,
/**< When idle, the source is still recording but there is no non-corked source-output \since 0.9.15 */
- PA_SOURCE_SUSPENDED = 2
+ PA_SOURCE_SUSPENDED = 2,
/**< When suspended, actual source access can be closed, for instance \since 0.9.15 */
+ /* *** PRIVATE: server-side values *** */
+
+ PA_SOURCE_INIT = -2,
+ /* Initialization state */
+
+ PA_SOURCE_UNLINKED = -3
+ /* The state when the source is getting unregistered and removed from client access */
+
} pa_source_state_t;
/** Returns non-zero if source is recording: running or idle. \since 0.9.15 */
diff --git a/src/pulsecore/sink.h b/src/pulsecore/sink.h
index 382b2d0..89ed6d4 100644
--- a/src/pulsecore/sink.h
+++ b/src/pulsecore/sink.h
@@ -43,15 +43,6 @@ typedef struct pa_sink pa_sink;
#define PA_MAX_INPUTS_PER_SINK 32
-/* anonymous enum extending pa_sink_state_t */
-enum {
- PA_SINK_INIT = -2,
- /* Initialization state */
-
- PA_SINK_UNLINKED = -3
- /* The state when the sink is getting unregistered and removed from client access */
-};
-
/* Returns true if sink is linked: registered and accessible from client side. */
static inline pa_bool_t PA_SINK_IS_LINKED(pa_sink_state_t x) {
return x == PA_SINK_RUNNING || x == PA_SINK_IDLE || x == PA_SINK_SUSPENDED;
diff --git a/src/pulsecore/source.h b/src/pulsecore/source.h
index 369da43..336599d 100644
--- a/src/pulsecore/source.h
+++ b/src/pulsecore/source.h
@@ -45,15 +45,6 @@ typedef struct pa_source pa_source;
#define PA_MAX_OUTPUTS_PER_SOURCE 32
-/* anonymous enum extending pa_source_state_t */
-enum {
- PA_SOURCE_INIT = -2,
- /* Initialization state */
-
- PA_SOURCE_UNLINKED = -3
- /* The state when the source is getting unregistered and removed from client access */
-};
-
/* Returns true if source is linked: registered and accessible from client side. */
static inline pa_bool_t PA_SOURCE_IS_LINKED(pa_source_state_t x) {
return x == PA_SOURCE_RUNNING || x == PA_SOURCE_IDLE || x == PA_SOURCE_SUSPENDED;
--
hooks/post-receive
PulseAudio Sound Server
More information about the pulseaudio-commits
mailing list