diff options
author | Michał Sułek <maldiran@maldiran.com> | 2025-02-22 11:12:40 +0100 |
---|---|---|
committer | Michał Sułek <maldiran@maldiran.com> | 2025-02-24 16:18:55 +0000 |
commit | 9477469db40efa5f180fa058b2651b302aaa4e26 (patch) | |
tree | 911e1dfccbce92083a6e42fa7d269b0ac2490ab7 /src/plugins/simtech/mm-shared-simtech.c | |
parent | 31e486d672e7fef16066b5fda7566c734c0f6ce5 (diff) |
Dan Williams changed g_usleep to g_timeout_add
Diffstat (limited to 'src/plugins/simtech/mm-shared-simtech.c')
-rw-r--r-- | src/plugins/simtech/mm-shared-simtech.c | 40 |
1 files changed, 29 insertions, 11 deletions
diff --git a/src/plugins/simtech/mm-shared-simtech.c b/src/plugins/simtech/mm-shared-simtech.c index 673fdd62..42b4e346 100644 --- a/src/plugins/simtech/mm-shared-simtech.c +++ b/src/plugins/simtech/mm-shared-simtech.c @@ -1086,18 +1086,43 @@ cpcmreg_set_ready (MMBaseModem *self, g_object_unref (task); } +static gboolean +call_audio_channel_set (gpointer user_data) +{ + GTask *task; + MMBaseModem *modem; + + task = G_TASK (user_data); + if (g_task_return_error_if_cancelled (task)) { + g_object_unref (task); + return G_SOURCE_REMOVE; + } + + modem = g_task_get_source_object (task); + mm_base_modem_at_command (modem, + setup ? "+CPCMREG=1" : "+CPCMREG=0", + 3, + FALSE, + (GAsyncReadyCallback) cpcmreg_set_ready, + task); + return G_SOURCE_REMOVE; +} + + static void common_setup_cleanup_in_call_audio_channel (MMSharedSimtech *self, gboolean setup, GAsyncReadyCallback callback, gpointer user_data) { - GTask *task; - Private *priv; + GTask *task; + Private *priv; + GCancellable *cancellable; priv = get_private (MM_SHARED_SIMTECH (self)); - task = g_task_new (self, NULL, callback, user_data); + cancellable = mm_base_modem_peek_cancellable (MM_BASE_MODEM (self)); + task = g_task_new (self, cancellable, callback, user_data); /* Do nothing if CPCMREG isn't supported */ if (priv->cpcmreg_support != FEATURE_SUPPORTED) { @@ -1107,14 +1132,7 @@ common_setup_cleanup_in_call_audio_channel (MMSharedSimtech *self, } /* Some models (like SIM7600) need to wait a bit before they can accept +CPCMREG */ - g_usleep(100000); - - mm_base_modem_at_command (MM_BASE_MODEM (self), - setup ? "+CPCMREG=1" : "+CPCMREG=0", - 3, - FALSE, - (GAsyncReadyCallback) cpcmreg_set_ready, - task); + g_timeout_add (100, (GSourceFunc)call_audio_channel_set, task); } void |