summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTanu Kaskinen <tanuk@iki.fi>2017-12-28 12:09:18 +0200
committerTanu Kaskinen <tanuk@iki.fi>2018-01-03 16:27:16 +0200
commiteeee5664fad6d08c2757bc741db0955b0387b3b7 (patch)
treeecf6a1d68c7128ef44b77af10f9d9f138fa75bfe
parent94fc586c011537536cfb434376354699357af785 (diff)
downloadpulseaudio-eeee5664fad6d08c2757bc741db0955b0387b3b7.tar.gz
sink, source: improve state change logging
Now the old and new state is logged every time when the sink or source state changes.
-rw-r--r--src/pulsecore/cli-text.c38
-rw-r--r--src/pulsecore/sink.c14
-rw-r--r--src/pulsecore/sink.h2
-rw-r--r--src/pulsecore/source.c14
-rw-r--r--src/pulsecore/source.h2
5 files changed, 34 insertions, 36 deletions
diff --git a/src/pulsecore/cli-text.c b/src/pulsecore/cli-text.c
index ded82f6e4..794f51c13 100644
--- a/src/pulsecore/cli-text.c
+++ b/src/pulsecore/cli-text.c
@@ -196,40 +196,6 @@ char *pa_card_list_to_string(pa_core *c) {
return pa_strbuf_to_string_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;
@@ -283,7 +249,7 @@ char *pa_sink_list_to_string(pa_core *c) {
sink->flags & PA_SINK_LATENCY ? "LATENCY " : "",
sink->flags & PA_SINK_FLAT_VOLUME ? "FLAT_VOLUME " : "",
sink->flags & PA_SINK_DYNAMIC_LATENCY ? "DYNAMIC_LATENCY" : "",
- sink_state_to_string(pa_sink_get_state(sink)),
+ pa_sink_state_to_string(pa_sink_get_state(sink)),
sink->suspend_cause & PA_SUSPEND_USER ? "USER " : "",
sink->suspend_cause & PA_SUSPEND_APPLICATION ? "APPLICATION " : "",
sink->suspend_cause & PA_SUSPEND_IDLE ? "IDLE " : "",
@@ -396,7 +362,7 @@ char *pa_source_list_to_string(pa_core *c) {
source->flags & PA_SOURCE_DECIBEL_VOLUME ? "DECIBEL_VOLUME " : "",
source->flags & PA_SOURCE_LATENCY ? "LATENCY " : "",
source->flags & PA_SOURCE_DYNAMIC_LATENCY ? "DYNAMIC_LATENCY" : "",
- source_state_to_string(pa_source_get_state(source)),
+ pa_source_state_to_string(pa_source_get_state(source)),
source->suspend_cause & PA_SUSPEND_USER ? "USER " : "",
source->suspend_cause & PA_SUSPEND_APPLICATION ? "APPLICATION " : "",
source->suspend_cause & PA_SUSPEND_IDLE ? "IDLE " : "",
diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c
index 39bf18f10..35f189ba9 100644
--- a/src/pulsecore/sink.c
+++ b/src/pulsecore/sink.c
@@ -427,6 +427,7 @@ static int sink_set_state(pa_sink *s, pa_sink_state_t state) {
return ret;
}
+ pa_log_debug("%s: state: %s -> %s", s->name, pa_sink_state_to_string(s->state), pa_sink_state_to_string(state));
s->state = state;
if (state != PA_SINK_UNLINKED) { /* if we enter UNLINKED state pa_sink_unlink() will fire the appropriate events */
@@ -2462,6 +2463,19 @@ unsigned pa_sink_check_suspend(pa_sink *s, pa_sink_input *ignore_input, pa_sourc
return ret;
}
+const char *pa_sink_state_to_string(pa_sink_state_t state) {
+ switch (state) {
+ case PA_SINK_INIT: return "INIT";
+ case PA_SINK_IDLE: return "IDLE";
+ case PA_SINK_RUNNING: return "RUNNING";
+ case PA_SINK_SUSPENDED: return "SUSPENDED";
+ case PA_SINK_UNLINKED: return "UNLINKED";
+ case PA_SINK_INVALID_STATE: return "INVALID_STATE";
+ }
+
+ pa_assert_not_reached();
+}
+
/* Called from the IO thread */
static void sync_input_volumes_within_thread(pa_sink *s) {
pa_sink_input *i;
diff --git a/src/pulsecore/sink.h b/src/pulsecore/sink.h
index cae5e517b..3fb230123 100644
--- a/src/pulsecore/sink.h
+++ b/src/pulsecore/sink.h
@@ -476,6 +476,8 @@ unsigned pa_sink_check_suspend(pa_sink *s, pa_sink_input *ignore_input, pa_sourc
#define pa_sink_get_state(s) ((s)->state)
+const char *pa_sink_state_to_string(pa_sink_state_t state);
+
/* Moves all inputs away, and stores them in pa_queue */
pa_queue *pa_sink_move_all_start(pa_sink *s, pa_queue *q);
void pa_sink_move_all_finish(pa_sink *s, pa_queue *q, bool save);
diff --git a/src/pulsecore/source.c b/src/pulsecore/source.c
index 6099c10d5..a0ab8e964 100644
--- a/src/pulsecore/source.c
+++ b/src/pulsecore/source.c
@@ -381,6 +381,7 @@ static int source_set_state(pa_source *s, pa_source_state_t state) {
return ret;
}
+ pa_log_debug("%s: state: %s -> %s", s->name, pa_source_state_to_string(s->state), pa_source_state_to_string(state));
s->state = state;
if (state != PA_SOURCE_UNLINKED) { /* if we enter UNLINKED state pa_source_unlink() will fire the appropriate events */
@@ -2014,6 +2015,19 @@ unsigned pa_source_check_suspend(pa_source *s, pa_source_output *ignore) {
return ret;
}
+const char *pa_source_state_to_string(pa_source_state_t state) {
+ switch (state) {
+ case PA_SOURCE_INIT: return "INIT";
+ case PA_SOURCE_IDLE: return "IDLE";
+ case PA_SOURCE_RUNNING: return "RUNNING";
+ case PA_SOURCE_SUSPENDED: return "SUSPENDED";
+ case PA_SOURCE_UNLINKED: return "UNLINKED";
+ case PA_SOURCE_INVALID_STATE: return "INVALID_STATE";
+ }
+
+ pa_assert_not_reached();
+}
+
/* Called from the IO thread */
static void sync_output_volumes_within_thread(pa_source *s) {
pa_source_output *o;
diff --git a/src/pulsecore/source.h b/src/pulsecore/source.h
index 7fb4a79ea..75ce241f1 100644
--- a/src/pulsecore/source.h
+++ b/src/pulsecore/source.h
@@ -407,6 +407,8 @@ unsigned pa_source_check_suspend(pa_source *s, pa_source_output *ignore);
#define pa_source_get_state(s) ((pa_source_state_t) (s)->state)
+const char *pa_source_state_to_string(pa_source_state_t state);
+
/* Moves all inputs away, and stores them in pa_queue */
pa_queue *pa_source_move_all_start(pa_source *s, pa_queue *q);
void pa_source_move_all_finish(pa_source *s, pa_queue *q, bool save);