[PATCH 1/2] core: Add functions that return the logical name of the state of sinks and sink inputs.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 src/pulsecore/sink-input.h |   12 ++++++++++++
 src/pulsecore/sink.h       |   13 +++++++++++++
 2 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/src/pulsecore/sink-input.h b/src/pulsecore/sink-input.h
index af2177a..e46c77c 100644
--- a/src/pulsecore/sink-input.h
+++ b/src/pulsecore/sink-input.h
@@ -42,9 +42,21 @@ typedef enum pa_sink_input_state {
     PA_SINK_INPUT_RUNNING,      /*< The stream is alive and kicking */
     PA_SINK_INPUT_CORKED,       /*< The stream was corked on user request */
     PA_SINK_INPUT_UNLINKED      /*< The stream is dead */
+    /* NOTE: if new states are added, remember to update pa_sink_input_state_to_string function as well */
     /* FIXME: we need a state for MOVING here */
 } pa_sink_input_state_t;
 
+static inline const char* pa_sink_input_state_to_string(pa_sink_input_state_t x) {
+    switch(x) {
+        case PA_SINK_INPUT_INIT:      return "INIT";
+        case PA_SINK_INPUT_DRAINED:   return "DRAINED";
+        case PA_SINK_INPUT_RUNNING:   return "RUNNING";
+        case PA_SINK_INPUT_CORKED:    return "CORKED";
+        case PA_SINK_INPUT_UNLINKED:  return "UNLINKED";
+        default:                      pa_assert_not_reached();
+    }
+}
+
 static inline pa_bool_t PA_SINK_INPUT_IS_LINKED(pa_sink_input_state_t x) {
     return x == PA_SINK_INPUT_DRAINED || x == PA_SINK_INPUT_RUNNING || x == PA_SINK_INPUT_CORKED;
 }
diff --git a/src/pulsecore/sink.h b/src/pulsecore/sink.h
index 0b5048a..466e84e 100644
--- a/src/pulsecore/sink.h
+++ b/src/pulsecore/sink.h
@@ -55,6 +55,19 @@ 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;
 }
 
+/* Returns the logical name of pa_sink_state_t */
+static inline const char* pa_sink_state_to_string(pa_sink_state_t x) {
+    switch(x) {
+        case PA_SINK_INVALID_STATE:  return "INVALID";
+        case PA_SINK_RUNNING:        return "RUNNING";
+        case PA_SINK_IDLE:           return "IDLE";
+        case PA_SINK_SUSPENDED:      return "SUSPENDED";
+        case PA_SINK_INIT:           return "INIT";
+        case PA_SINK_UNLINKED:       return "UNLINKED";
+        default:                     pa_assert_not_reached();
+    }
+}
+
 /* A generic definition for void callback functions */
 typedef void(*pa_sink_cb_t)(pa_sink *s);
 
-- 
1.7.0.4



[Index of Archives]     [Linux Audio Users]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux