From f02d22150eb652b83c62cdcc62b1eb84e4859ecf Mon Sep 17 00:00:00 2001 From: Evangelos Ribeiro Tzaras Date: Wed, 27 Oct 2021 00:14:10 +0200 Subject: [PATCH] ringer: Add debugging --- src/calls-ringer.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/calls-ringer.c b/src/calls-ringer.c index 0628b1e..85aaae5 100644 --- a/src/calls-ringer.c +++ b/src/calls-ringer.c @@ -60,11 +60,29 @@ struct _CallsRinger { G_DEFINE_TYPE (CallsRinger, calls_ringer, G_TYPE_OBJECT); +static const char * +ring_state_to_string (CallsRingState state) +{ + switch (state) { + case CALLS_RING_STATE_INACTIVE: + return "inactive"; + case CALLS_RING_STATE_REQUEST_PLAY: + return "request-play"; + case CALLS_RING_STATE_PLAYING: + return "playing"; + case CALLS_RING_STATE_REQUEST_STOP: + return "request-stop"; + default: + return "unknown"; + } +} static void change_ring_state (CallsRinger *self, CallsRingState state) { + g_debug ("%s: old: %s; new: %s", + __func__, ring_state_to_string (self->state), ring_state_to_string (state)); if (self->state == state) return; @@ -75,6 +93,8 @@ change_ring_state (CallsRinger *self, state == CALLS_RING_STATE_REQUEST_STOP) return; + g_debug ("%s: notify ring", __func__); + g_object_notify_by_pspec (G_OBJECT (self), props[PROP_IS_RINGING]); } @@ -88,6 +108,7 @@ on_event_triggered (LfbEvent *event, g_return_if_fail (LFB_IS_EVENT (event)); g_return_if_fail (CALLS_IS_RINGER (self)); + g_debug ("%s", __func__); if (lfb_event_trigger_feedback_finish (event, res, &err)) { change_ring_state (self, CALLS_RING_STATE_PLAYING); } else { @@ -104,6 +125,7 @@ static void start (CallsRinger *self, gboolean quiet) { + g_debug ("%s: state: %s", __func__, ring_state_to_string (self->state)); if (self->event) lfb_event_set_feedback_profile (self->event, quiet ? "quiet" : NULL); @@ -135,6 +157,8 @@ on_event_feedback_ended (LfbEvent *event, g_return_if_fail (LFB_IS_EVENT (event)); g_return_if_fail (CALLS_IS_RINGER (self)); + g_debug ("%s: state: %s", __func__, ring_state_to_string (self->state)); + if (self->state == CALLS_RING_STATE_REQUEST_PLAY || self->state == CALLS_RING_STATE_PLAYING) g_warning ("Feedback ended although it should be playing"); @@ -152,6 +176,7 @@ on_feedback_ended (LfbEvent *event, CallsRinger *self) { g_debug ("Feedback ended"); + g_debug ("%s: state: %s", __func__, ring_state_to_string (self->state)); change_ring_state (self, CALLS_RING_STATE_INACTIVE); } @@ -159,18 +184,21 @@ on_feedback_ended (LfbEvent *event, static void stop (CallsRinger *self) { + g_debug ("%s: state: %s", __func__, ring_state_to_string (self->state)); if (self->state == CALLS_RING_STATE_INACTIVE || self->state == CALLS_RING_STATE_REQUEST_STOP) return; g_debug ("Stopping ringtone"); if (self->state == CALLS_RING_STATE_PLAYING) { + g_debug ("ending event feedback"); lfb_event_end_feedback_async (self->event, NULL, (GAsyncReadyCallback) on_event_feedback_ended, self); change_ring_state (self, CALLS_RING_STATE_REQUEST_STOP); } else if (self->state == CALLS_RING_STATE_REQUEST_PLAY) { + g_debug ("cancelling event feedback"); g_cancellable_cancel (self->cancel_ring); } }