mirror of
https://gitlab.gnome.org/GNOME/calls.git
synced 2025-01-09 21:35:32 +00:00
ringer: Cancel async libfeedback calls on timeout
If libfeedback has not finished triggering/ending a feedback after one second we give up and set an error state.
This commit is contained in:
parent
01ca267c10
commit
e36f9b4e95
1 changed files with 29 additions and 0 deletions
|
@ -38,6 +38,10 @@
|
|||
#include <libfeedback.h>
|
||||
|
||||
|
||||
/* cancel lfb operations after reaching the timeout */
|
||||
#define LFB_TIMEOUT_MS 1000
|
||||
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_RING_STATE,
|
||||
|
@ -59,6 +63,7 @@ struct _CallsRinger {
|
|||
CallsRingState target_state;
|
||||
|
||||
gboolean freeze_state_notify;
|
||||
guint request_timeout_id;
|
||||
};
|
||||
|
||||
|
||||
|
@ -88,6 +93,8 @@ set_ring_state (CallsRinger *self,
|
|||
g_assert (CALLS_IS_RINGER (self));
|
||||
g_assert (state >= CALLS_RING_STATE_INACTIVE && state <= CALLS_RING_STATE_ERROR);
|
||||
|
||||
g_clear_handle_id (&self->request_timeout_id, g_source_remove);
|
||||
|
||||
if (self->state == state)
|
||||
return;
|
||||
|
||||
|
@ -195,6 +202,23 @@ on_feedback_ended (LfbEvent *event,
|
|||
}
|
||||
|
||||
|
||||
static gboolean
|
||||
request_timed_out (CallsRinger *self)
|
||||
{
|
||||
if (!CALLS_IS_RINGER (self))
|
||||
return G_SOURCE_REMOVE;
|
||||
|
||||
g_debug ("Request '%s' timed out, cancelling..",
|
||||
ring_state_to_string (self->target_state));
|
||||
|
||||
g_cancellable_cancel (self->cancel);
|
||||
|
||||
set_ring_state (self, CALLS_RING_STATE_ERROR);
|
||||
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
|
||||
|
||||
static LfbEvent *
|
||||
get_event_for_state (CallsRinger *self,
|
||||
CallsRingState state)
|
||||
|
@ -246,6 +270,9 @@ target_state_step (CallsRinger *self)
|
|||
(GAsyncReadyCallback) on_event_feedback_ended,
|
||||
self);
|
||||
}
|
||||
|
||||
self->request_timeout_id =
|
||||
g_timeout_add (LFB_TIMEOUT_MS, G_SOURCE_FUNC (request_timed_out), self);
|
||||
}
|
||||
|
||||
|
||||
|
@ -453,6 +480,8 @@ dispose (GObject *object)
|
|||
|
||||
g_signal_handlers_disconnect_by_data (calls_manager_get_default (), self);
|
||||
|
||||
g_clear_handle_id (&self->request_timeout_id, g_source_remove);
|
||||
|
||||
g_cancellable_cancel (self->cancel);
|
||||
g_clear_object (&self->cancel);
|
||||
|
||||
|
|
Loading…
Reference in a new issue