From 6369b287851e7b61c0fd91aa24c79fab11f8db0b Mon Sep 17 00:00:00 2001 From: Tanu Kaskinen Date: Wed, 6 Sep 2017 16:57:42 +0300 Subject: [PATCH] sink: add more logging --- src/pulsecore/sink.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c index a8b4cd3da..7dde113f4 100644 --- a/src/pulsecore/sink.c +++ b/src/pulsecore/sink.c @@ -396,6 +396,18 @@ pa_sink* pa_sink_new( return s; } +static const char *state_to_string(pa_sink_state_t state) { + switch (state) { + 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: return "WTF"; + } +} + /* Called from main context */ static int sink_set_state(pa_sink *s, pa_sink_state_t state) { int ret; @@ -427,6 +439,7 @@ static int sink_set_state(pa_sink *s, pa_sink_state_t state) { return ret; } + pa_log_info("%s: state: %s -> %s", s->name, state_to_string(s->state), 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 */ @@ -1704,7 +1717,10 @@ static void compute_reference_ratios(pa_sink *s) { pa_sink_assert_ref(s); pa_assert_ctl_context(); - pa_assert(PA_SINK_IS_LINKED(s->state)); + if (!PA_SINK_IS_LINKED(s->state)) { + pa_log("%s: bad state: %s", s->name, state_to_string(s->state)); + pa_assert_not_reached(); + } pa_assert(pa_sink_flat_volume_enabled(s)); PA_IDXSET_FOREACH(i, s->inputs, idx) { @@ -1723,7 +1739,10 @@ static void compute_real_ratios(pa_sink *s) { pa_sink_assert_ref(s); pa_assert_ctl_context(); - pa_assert(PA_SINK_IS_LINKED(s->state)); + if (!PA_SINK_IS_LINKED(s->state)) { + pa_log("%s: bad state: %s", s->name, state_to_string(s->state)); + pa_assert_not_reached(); + } pa_assert(pa_sink_flat_volume_enabled(s)); PA_IDXSET_FOREACH(i, s->inputs, idx) { -- 2.14.1