profiles: Use timeout_add_seconds
authorFrédéric Danis <frederic.danis@collabora.com>
Tue, 16 Mar 2021 17:18:36 +0000 (18:18 +0100)
committerAyush Garg <ayush.garg@samsung.com>
Fri, 11 Mar 2022 13:38:34 +0000 (19:08 +0530)
Replace calls to g_timeout_add_seconds() by the timeout_add_seconds()
wrapper which takes care of 0 delay.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
profiles/audio/a2dp.c
profiles/audio/avctp.c
profiles/audio/avdtp.c
profiles/audio/avrcp.c
profiles/health/hdp.c
profiles/health/mcap.c
profiles/input/device.c
profiles/network/bnep.c
profiles/sap/server.c

index 8f34135..00c6341 100644 (file)
@@ -39,6 +39,7 @@
 #include "src/log.h"
 #include "src/sdpd.h"
 #include "src/shared/queue.h"
+#include "src/shared/timeout.h"
 #include "src/shared/util.h"
 
 #include "btio/btio.h"
@@ -74,7 +75,7 @@ struct a2dp_sep {
        struct avdtp_local_sep *lsep;
        struct avdtp *session;
        struct avdtp_stream *stream;
-       guint suspend_timer;
+       unsigned int suspend_timer;
 #ifdef TIZEN_FEATURE_BLUEZ_MODIFY
        gboolean remote_suspended;
 #endif
@@ -496,7 +497,7 @@ static void stream_state_changed(struct avdtp_stream *stream,
 
 #ifdef TIZEN_FEATURE_BLUEZ_MODIFY
        if (new_state == AVDTP_STATE_STREAMING && sep->suspend_timer) {
-               g_source_remove(sep->suspend_timer);
+               timeout_remove(sep->suspend_timer);
                sep->suspend_timer = 0;
        }
 #endif
@@ -505,7 +506,7 @@ static void stream_state_changed(struct avdtp_stream *stream,
                return;
 
        if (sep->suspend_timer) {
-               g_source_remove(sep->suspend_timer);
+               timeout_remove(sep->suspend_timer);
                sep->suspend_timer = 0;
        }
 
@@ -1024,7 +1025,7 @@ static void open_cfm(struct avdtp *session, struct avdtp_local_sep *sep,
        return;
 }
 
-static gboolean suspend_timeout(struct a2dp_sep *sep)
+static bool suspend_timeout(struct a2dp_sep *sep)
 {
        if (avdtp_suspend(sep->session, sep->stream) == 0)
                sep->suspending = TRUE;
@@ -1053,9 +1054,9 @@ static gboolean start_ind(struct avdtp *session, struct avdtp_local_sep *sep,
        if (!a2dp_sep->locked) {
                if (a2dp_sep->remote_suspended == FALSE) {
                        a2dp_sep->session = avdtp_ref(session);
-                       a2dp_sep->suspend_timer = g_timeout_add_seconds(SUSPEND_TIMEOUT,
-                                                       (GSourceFunc) suspend_timeout,
-                                                       a2dp_sep);
+                       a2dp_sep->suspend_timer = timeout_add_seconds(SUSPEND_TIMEOUT,
+                                                       (timeout_func_t) suspend_timeout,
+                                                       a2dp_sep, NULL);
                } else
                        a2dp_sep->remote_suspended = FALSE;
        }
@@ -1063,9 +1064,9 @@ static gboolean start_ind(struct avdtp *session, struct avdtp_local_sep *sep,
 
        if (!a2dp_sep->locked) {
                a2dp_sep->session = avdtp_ref(session);
-               a2dp_sep->suspend_timer = g_timeout_add_seconds(SUSPEND_TIMEOUT,
-                                               (GSourceFunc) suspend_timeout,
-                                               a2dp_sep);
+               a2dp_sep->suspend_timer = timeout_add_seconds(SUSPEND_TIMEOUT,
+                                               (timeout_func_t) suspend_timeout,
+                                               a2dp_sep, NULL);
        }
 #endif
 
@@ -1126,7 +1127,7 @@ static gboolean suspend_ind(struct avdtp *session, struct avdtp_local_sep *sep,
 #endif
 
        if (a2dp_sep->suspend_timer) {
-               g_source_remove(a2dp_sep->suspend_timer);
+               timeout_remove(a2dp_sep->suspend_timer);
                a2dp_sep->suspend_timer = 0;
                avdtp_unref(a2dp_sep->session);
                a2dp_sep->session = NULL;
@@ -3196,7 +3197,7 @@ unsigned int a2dp_resume(struct avdtp *session, struct a2dp_sep *sep,
                break;
        case AVDTP_STATE_STREAMING:
                if (!sep->suspending && sep->suspend_timer) {
-                       g_source_remove(sep->suspend_timer);
+                       timeout_remove(sep->suspend_timer);
                        sep->suspend_timer = 0;
                        avdtp_unref(sep->session);
                        sep->session = NULL;
index 94089aa..e8427d0 100644 (file)
@@ -39,6 +39,7 @@
 #include "src/log.h"
 #include "src/error.h"
 #include "src/uinput.h"
+#include "src/shared/timeout.h"
 
 #include "avctp.h"
 #include "avrcp.h"
@@ -151,7 +152,7 @@ typedef int (*avctp_process_cb) (void *data);
 struct avctp_pending_req {
        struct avctp_queue *queue;
        uint8_t transaction;
-       guint timeout;
+       unsigned int timeout;
        bool retry;
        int err;
        avctp_process_cb process;
@@ -182,7 +183,7 @@ struct avctp_channel {
 
 struct key_pressed {
        uint16_t op;
-       guint timer;
+       unsigned int timer;
 #ifndef TIZEN_FEATURE_BLUEZ_MODIFY
        bool hold;
 #endif
@@ -328,7 +329,7 @@ static void send_key(int fd, uint16_t key, int pressed)
        send_event(fd, EV_SYN, SYN_REPORT, 0);
 }
 
-static gboolean auto_release(gpointer user_data)
+static bool auto_release(gpointer user_data)
 {
        struct avctp *session = user_data;
 #ifdef TIZEN_FEATURE_BLUEZ_MODIFY
@@ -374,14 +375,14 @@ static void handle_press(struct avctp *session, uint16_t op)
        send_key(session->uinput, op, 1);
 
 done:
-       session->key.timer = g_timeout_add_seconds(AVC_PRESS_TIMEOUT,
-                                                       auto_release, session);
+       session->key.timer = timeout_add_seconds(AVC_PRESS_TIMEOUT,
+                               auto_release, session, NULL);
 }
 
 static void handle_release(struct avctp *session, uint16_t op)
 {
        if (session->key.timer > 0) {
-               g_source_remove(session->key.timer);
+               timeout_remove(session->key.timer);
                session->key.timer = 0;
        }
 
@@ -538,7 +539,7 @@ static void pending_destroy(gpointer data, gpointer user_data)
                req->destroy(req->data);
 
        if (req->timeout > 0)
-               g_source_remove(req->timeout);
+               timeout_remove(req->timeout);
 
        g_free(req);
 }
@@ -596,7 +597,7 @@ static void avctp_disconnected(struct avctp *session)
        }
 
        if (session->key.timer > 0)
-               g_source_remove(session->key.timer);
+               timeout_remove(session->key.timer);
 
        if (session->uinput >= 0) {
                char address[18];
@@ -809,7 +810,7 @@ done:
        g_free(req);
 }
 
-static gboolean req_timeout(gpointer user_data)
+static bool req_timeout(gpointer user_data)
 {
        struct avctp_queue *queue = user_data;
        struct avctp_pending_req *p = queue->p;
@@ -847,8 +848,8 @@ static int process_passthrough(void *data)
        if (ret < 0)
                return ret;
 
-       p->timeout = g_timeout_add_seconds(AVC_PRESS_TIMEOUT, req_timeout,
-                                                               p->queue);
+       p->timeout = timeout_add_seconds(AVC_PRESS_TIMEOUT, req_timeout,
+                                                       p->queue, NULL);
 
        return 0;
 }
@@ -867,8 +868,8 @@ static int process_control(void *data)
 
        p->retry = !p->retry;
 
-       p->timeout = g_timeout_add_seconds(CONTROL_TIMEOUT, req_timeout,
-                                                               p->queue);
+       p->timeout = timeout_add_seconds(CONTROL_TIMEOUT, req_timeout,
+                                                       p->queue, NULL);
 
        return 0;
 }
@@ -884,8 +885,8 @@ static int process_browsing(void *data)
        if (ret < 0)
                return ret;
 
-       p->timeout = g_timeout_add_seconds(BROWSING_TIMEOUT, req_timeout,
-                                                               p->queue);
+       p->timeout = timeout_add_seconds(BROWSING_TIMEOUT, req_timeout,
+                                                       p->queue, NULL);
 
        return 0;
 }
@@ -975,7 +976,7 @@ static void control_response(struct avctp_channel *control,
                control->processed = g_slist_prepend(control->processed, p);
 
                if (p->timeout > 0) {
-                       g_source_remove(p->timeout);
+                       timeout_remove(p->timeout);
                        p->timeout = 0;
                }
 
@@ -1027,7 +1028,7 @@ static void browsing_response(struct avctp_channel *browsing,
                browsing->processed = g_slist_prepend(browsing->processed, p);
 
                if (p->timeout > 0) {
-                       g_source_remove(p->timeout);
+                       timeout_remove(p->timeout);
                        p->timeout = 0;
                }
 
@@ -1945,7 +1946,7 @@ static int avctp_passthrough_release(struct avctp *session, uint8_t op)
                                NULL, NULL);
 }
 
-static gboolean repeat_timeout(gpointer user_data)
+static bool repeat_timeout(gpointer user_data)
 {
        struct avctp *session = user_data;
 
@@ -1977,7 +1978,7 @@ static int release_pressed(struct avctp *session)
        int ret = avctp_passthrough_release(session, session->key.op);
 #endif
        if (session->key.timer > 0)
-               g_source_remove(session->key.timer);
+               timeout_remove(session->key.timer);
 
        session->key.timer = 0;
 #ifndef TIZEN_FEATURE_BLUEZ_MODIFY
@@ -2009,13 +2010,13 @@ static bool hold_pressed(struct avctp *session, uint8_t op)
 
 #ifdef TIZEN_FEATURE_BLUEZ_MODIFY
        session->key.op = op;
-       session->key.timer = g_timeout_add_seconds(AVC_PRESS_TIMEOUT,
+       session->key.timer = timeout_add_seconds(AVC_PRESS_TIMEOUT,
 #else
        if (session->key.timer == 0)
-               session->key.timer = g_timeout_add_seconds(AVC_HOLD_TIMEOUT,
+               session->key.timer = timeout_add_seconds(AVC_HOLD_TIMEOUT,
 #endif
                                                        repeat_timeout,
-                                                       session);
+                                                       session, NULL);
 
        return TRUE;
 }
index 58f5e5a..9da2f9f 100644 (file)
@@ -36,6 +36,7 @@
 #include "btio/btio.h"
 #include "src/btd.h"
 #include "src/log.h"
+#include "src/shared/timeout.h"
 #include "src/shared/util.h"
 #include "src/shared/queue.h"
 #include "src/adapter.h"
@@ -320,7 +321,7 @@ struct pending_req {
        void *data;
        size_t data_size;
        struct avdtp_stream *stream; /* Set if the request targeted a stream */
-       guint timeout;
+       unsigned int timeout;
        gboolean collided;
 };
 
@@ -379,12 +380,12 @@ struct avdtp_stream {
        GSList *callbacks;
        struct avdtp_service_capability *codec;
        guint io_id;            /* Transport GSource ID */
-       guint timer;            /* Waiting for other side to close or open
+       unsigned int timer;             /* Waiting for other side to close or open
                                 * the transport channel */
        gboolean open_acp;      /* If we are in ACT role for Open */
        gboolean close_int;     /* If we are in INT role for Close */
        gboolean abort_int;     /* If we are in INT role for Abort */
-       guint start_timer;      /* Wait START command timer */
+       unsigned int start_timer;       /* Wait START command timer */
        gboolean delay_reporting;
        uint16_t delay;         /* AVDTP 1.3 Delay Reporting feature */
        gboolean starting;      /* only valid while sep state == OPEN */
@@ -433,7 +434,7 @@ struct avdtp {
        struct discover_callback *discover;
        struct pending_req *req;
 
-       guint dc_timer;
+       unsigned int dc_timer;
        int dc_timeout;
 
        /* Attempt stream setup instead of disconnecting */
@@ -669,7 +670,7 @@ static void pending_req_free(void *data)
        struct pending_req *req = data;
 
        if (req->timeout)
-               g_source_remove(req->timeout);
+               timeout_remove(req->timeout);
        g_free(req->data);
        g_free(req);
 }
@@ -691,7 +692,7 @@ static void close_stream(struct avdtp_stream *stream)
        stream->io = NULL;
 }
 
-static gboolean stream_close_timeout(gpointer user_data)
+static bool stream_close_timeout(gpointer user_data)
 {
        struct avdtp_stream *stream = user_data;
 
@@ -704,7 +705,7 @@ static gboolean stream_close_timeout(gpointer user_data)
        return FALSE;
 }
 
-static gboolean stream_open_timeout(gpointer user_data)
+static bool stream_open_timeout(gpointer user_data)
 {
        struct avdtp_stream *stream = user_data;
 
@@ -725,12 +726,12 @@ static gboolean stream_open_timeout(gpointer user_data)
 }
 
 static void stream_set_timer(struct avdtp_stream *stream, guint timeout,
-                                                       GSourceFunc func)
+                                               timeout_func_t func)
 {
        if (stream->timer)
-               g_source_remove(stream->timer);
+               timeout_remove(stream->timer);
 
-       stream->timer = g_timeout_add_seconds(timeout, func, stream);
+       stream->timer = timeout_add_seconds(timeout, func, stream, NULL);
 }
 
 static void stream_set_pending_open(struct avdtp_stream *stream, GIOChannel *io)
@@ -830,7 +831,7 @@ static void stream_free(void *data)
                rsep->stream = NULL;
 
        if (stream->timer)
-               g_source_remove(stream->timer);
+               timeout_remove(stream->timer);
 
        if (stream->io)
                close_stream(stream);
@@ -910,7 +911,7 @@ static void handle_transport_connect(struct avdtp *session, GIOChannel *io,
        session->pending_open = NULL;
 
        if (stream->timer) {
-               g_source_remove(stream->timer);
+               timeout_remove(stream->timer);
                stream->timer = 0;
        }
 
@@ -1298,7 +1299,7 @@ static void avdtp_sep_set_state(struct avdtp *session,
                break;
        case AVDTP_STATE_STREAMING:
                if (stream->start_timer) {
-                       g_source_remove(stream->start_timer);
+                       timeout_remove(stream->start_timer);
                        stream->start_timer = 0;
                }
 
@@ -1319,13 +1320,13 @@ static void avdtp_sep_set_state(struct avdtp *session,
        case AVDTP_STATE_CLOSING:
        case AVDTP_STATE_ABORTING:
                if (stream->start_timer) {
-                       g_source_remove(stream->start_timer);
+                       timeout_remove(stream->start_timer);
                        stream->start_timer = 0;
                }
                break;
        case AVDTP_STATE_IDLE:
                if (stream->start_timer) {
-                       g_source_remove(stream->start_timer);
+                       timeout_remove(stream->start_timer);
                        stream->start_timer = 0;
                }
                if (session->pending_open == stream)
@@ -1426,7 +1427,7 @@ static void remove_disconnect_timer(struct avdtp *session)
        if (!session->dc_timer)
                return;
 
-       g_source_remove(session->dc_timer);
+       timeout_remove(session->dc_timer);
        session->dc_timer = 0;
        session->stream_setup = FALSE;
 
@@ -1495,7 +1496,7 @@ static void connection_lost(struct avdtp *session, int err)
 }
 
 #ifdef TIZEN_FEATURE_BLUEZ_MODIFY
-static gboolean disconnect_acl_timeout(gpointer user_data)
+static bool disconnect_acl_timeout(gpointer user_data)
 {
        struct btd_device *device = user_data;
 
@@ -1507,7 +1508,7 @@ static gboolean disconnect_acl_timeout(gpointer user_data)
 }
 #endif
 
-static gboolean disconnect_timeout(gpointer user_data)
+static bool disconnect_timeout(gpointer user_data)
 {
        struct avdtp *session = user_data;
        struct btd_service *service;
@@ -1568,9 +1569,9 @@ done:
 
 #ifdef TIZEN_FEATURE_BLUEZ_MODIFY
        if (device)
-               g_timeout_add(100,
+               timeout_add(100,
                        disconnect_acl_timeout,
-                       device);
+                       device, NULL);
 #endif
 
        return FALSE;
@@ -1588,20 +1589,20 @@ static void set_disconnect_timer_for_sink(struct avdtp *session, gboolean discon
        DBG("name : [%s]", name);
        if (g_str_equal(name, "VW BT") || g_str_equal(name, "VW MI") ||
                 g_str_equal(name, "Seat ") || g_str_equal(name, "Galax")) {
-               session->dc_timer = g_timeout_add_seconds(3, disconnect_timeout,
-                               session);
+               session->dc_timer = timeout_add_seconds(3, disconnect_timeout,
+                               session, NULL);
        } else if (g_str_equal(name, "CAR M")) {
-               session->dc_timer = g_timeout_add(200, disconnect_timeout,
-                               session);
+               session->dc_timer = timeout_add(200, disconnect_timeout,
+                               session, NULL);
        } else {
                if (disconn == TRUE)
-                       session->dc_timer = g_timeout_add(100,
+                       session->dc_timer = timeout_add(100,
                                        disconnect_timeout,
-                                       session);
+                                       session, NULL);
                else
-                       session->dc_timer = g_timeout_add_seconds(DISCONNECT_TIMEOUT,
+                       session->dc_timer = timeout_add_seconds(DISCONNECT_TIMEOUT,
                                        disconnect_timeout,
-                                       session);
+                                       session, NULL);
        }
 }
 #endif
@@ -1623,24 +1624,21 @@ static void set_disconnect_timer(struct avdtp *session)
        DBG("name : [%s]", name);
        if (g_str_equal(name, "VW BT") || g_str_equal(name, "VW MI") ||
                 g_str_equal(name, "Seat ") || g_str_equal(name, "Galax")) {
-               session->dc_timer = g_timeout_add_seconds(3, disconnect_timeout,
-                               session);
+               session->dc_timer = timeout_add_seconds(3, disconnect_timeout,
+                               session, NULL);
        } else if (g_str_equal(name, "CAR M")) {
-               session->dc_timer = g_timeout_add(200, disconnect_timeout,
-                               session);
+               session->dc_timer = timeout_add(200, disconnect_timeout,
+                               session, NULL);
        } else {
-               session->dc_timer = g_timeout_add_seconds(DISCONNECT_TIMEOUT,
+               session->dc_timer = timeout_add_seconds(DISCONNECT_TIMEOUT,
                                disconnect_timeout,
-                               session);
+                               session, NULL);
        }
 #else
        DBG("timeout %d", session->dc_timeout);
-       if (!session->dc_timeout)
-               session->dc_timer = g_idle_add(disconnect_timeout, session);
-       else
-               session->dc_timer = g_timeout_add_seconds(session->dc_timeout,
-                                                       disconnect_timeout,
-                                                       session);
+       session->dc_timer = timeout_add_seconds(session->dc_timeout,
+                                       disconnect_timeout,
+                                       session, NULL);
 #endif
 }
 
@@ -2318,9 +2316,9 @@ static gboolean avdtp_close_cmd(struct avdtp *session, uint8_t transaction,
                                                AVDTP_CLOSE, NULL, 0))
                return FALSE;
 
-       stream->timer = g_timeout_add_seconds(REQ_TIMEOUT,
+       stream->timer = timeout_add_seconds(REQ_TIMEOUT,
                                        stream_close_timeout,
-                                       stream);
+                                       stream, NULL);
 
        return TRUE;
 
@@ -2739,7 +2737,7 @@ static gboolean session_cb(GIOChannel *chan, GIOCondition cond,
                return TRUE;
        }
 
-       g_source_remove(session->req->timeout);
+       timeout_remove(session->req->timeout);
        session->req->timeout = 0;
 
        switch (header->message_type) {
@@ -3127,7 +3125,7 @@ done:
        return err;
 }
 
-static gboolean request_timeout(gpointer user_data)
+static bool request_timeout(gpointer user_data)
 {
        struct avdtp *session = user_data;
 
@@ -3188,7 +3186,8 @@ static int send_req(struct avdtp *session, gboolean priority,
                timeout = REQ_TIMEOUT;
        }
 
-       req->timeout = g_timeout_add_seconds(timeout, request_timeout, session);
+       req->timeout = timeout_add_seconds(timeout, request_timeout,
+                       session, NULL);
        return 0;
 
 failed:
@@ -4092,7 +4091,7 @@ int avdtp_open(struct avdtp *session, struct avdtp_stream *stream)
                                                        &req, sizeof(req));
 }
 
-static gboolean start_timeout(gpointer user_data)
+static bool start_timeout(gpointer user_data)
 {
        struct avdtp_stream *stream = user_data;
        struct avdtp *session = stream->session;
@@ -4154,15 +4153,15 @@ int avdtp_start(struct avdtp *session, struct avdtp_stream *stream)
                                return 0;
                        }
 
-                       stream->start_timer = g_timeout_add_seconds(timeout_sec,
+                       stream->start_timer = timeout_add_seconds(timeout_sec,
                                                                        start_timeout,
-                                                                       stream);
+                                                                       stream, NULL);
                        return 0;
                }
 #else
-               stream->start_timer = g_timeout_add_seconds(START_TIMEOUT,
+               stream->start_timer = timeout_add_seconds(START_TIMEOUT,
                                                                start_timeout,
-                                                               stream);
+                                                               stream, NULL);
                return 0;
 #endif
        }
index cc5aad8..e0566a1 100644 (file)
@@ -45,6 +45,7 @@
 #include "src/error.h"
 #include "src/sdpd.h"
 #include "src/dbus-common.h"
+#include "src/shared/timeout.h"
 #include "src/shared/util.h"
 
 #include "avctp.h"
@@ -1721,7 +1722,7 @@ void avrcp_stop_position_timer(void)
                pos_timer_id = 0;
        }
 }
-gboolean send_playback_position_event(gpointer user_data)
+bool send_playback_position_event(gpointer user_data)
 {
        struct avrcp_player *player = user_data;
        uint32_t playback_position;
@@ -1820,9 +1821,9 @@ static uint8_t avrcp_handle_register_notification(struct avrcp *session,
                        DBG("Play Pos Changed Event is skipped(%d)", play_status);
                } else {
                        DBG("Playback interval : %d secs", playback_interval);
-                       pos_timer_id = g_timeout_add_seconds(
+                       pos_timer_id = timeout_add_seconds(
                                        playback_interval,
-                                       send_playback_position_event, player);
+                                       send_playback_position_event, player, NULL);
                }
 
                /* retrieve current playback position for interim response */
@@ -4388,7 +4389,7 @@ static char *avrcp_event_to_string(uint8_t event)
        }
 }
 
-static gboolean avrcp_get_playback_status(gpointer user_data)
+static bool avrcp_get_playback_status(gpointer user_data)
 {
        struct avrcp *session = user_data;
 
@@ -4414,7 +4415,7 @@ static gboolean avrcp_get_capabilities_resp(struct avctp *conn, uint8_t code,
 
        /* Connect browsing if pending */
        if (session->browsing_timer > 0) {
-               g_source_remove(session->browsing_timer);
+               timeout_remove(session->browsing_timer);
                session->browsing_timer = 0;
                avctp_connect_browsing(session->conn);
        }
@@ -4472,8 +4473,8 @@ static gboolean avrcp_get_capabilities_resp(struct avctp *conn, uint8_t code,
 
 #ifdef TIZEN_FEATURE_BLUEZ_MODIFY
        if ((events & (1 << AVRCP_EVENT_STATUS_CHANGED)) == 0) {
-               session->playback_status_id = g_timeout_add_seconds(1,
-                               avrcp_get_playback_status, session);
+               session->playback_status_id = timeout_add_seconds(1,
+                               avrcp_get_playback_status, session, NULL);
        }
 #endif
        return FALSE;
@@ -4523,7 +4524,7 @@ static void destroy_browsing(void *data)
 static void session_init_browsing(struct avrcp *session)
 {
        if (session->browsing_timer > 0) {
-               g_source_remove(session->browsing_timer);
+               timeout_remove(session->browsing_timer);
                session->browsing_timer = 0;
        }
 
@@ -4558,7 +4559,7 @@ static struct avrcp_data *data_init(struct avrcp *session, const char *uuid)
        return data;
 }
 
-static gboolean connect_browsing(gpointer user_data)
+static bool connect_browsing(gpointer user_data)
 {
        struct avrcp *session = user_data;
 
@@ -4582,9 +4583,9 @@ static void avrcp_connect_browsing(struct avrcp *session)
        if (session->browsing_timer > 0)
                return;
 
-       session->browsing_timer = g_timeout_add_seconds(AVRCP_BROWSING_TIMEOUT,
+       session->browsing_timer = timeout_add_seconds(AVRCP_BROWSING_TIMEOUT,
                                                        connect_browsing,
-                                                       session);
+                                                       session, NULL);
 }
 
 #ifdef TIZEN_FEATURE_BLUEZ_AVRCP_TARGET
@@ -4764,7 +4765,7 @@ static void session_destroy(struct avrcp *session, int err)
 #ifdef TIZEN_FEATURE_BLUEZ_MODIFY
        if (session->playback_status_id > 0) {
                DBG("Removing the timer for playback status polling");
-               g_source_remove(session->playback_status_id);
+               timeout_remove(session->playback_status_id);
                session->playback_status_id = 0;
        }
 #endif
@@ -4788,7 +4789,7 @@ static void session_destroy(struct avrcp *session, int err)
        }
 
        if (session->browsing_timer > 0)
-               g_source_remove(session->browsing_timer);
+               timeout_remove(session->browsing_timer);
 
        if (session->controller != NULL)
                controller_destroy(session);
index c6bf3b7..3dcdff8 100755 (executable)
@@ -30,6 +30,7 @@
 #include "src/adapter.h"
 #include "src/device.h"
 #include "src/sdpd.h"
+#include "src/shared/timeout.h"
 #include "btio/btio.h"
 
 #include "hdp_types.h"
@@ -69,7 +70,7 @@ struct hdp_tmp_dc_data {
 struct hdp_echo_data {
        gboolean                echo_done;      /* Is a echo was already done */
        gpointer                buf;            /* echo packet sent */
-       guint                   tid;            /* echo timeout */
+       unsigned int            tid;            /* echo timeout */
 };
 
 static struct hdp_channel *hdp_channel_ref(struct hdp_channel *chan)
@@ -682,7 +683,7 @@ static void free_echo_data(struct hdp_echo_data *edata)
                return;
 
        if (edata->tid > 0)
-               g_source_remove(edata->tid);
+               timeout_remove(edata->tid);
 
        if (edata->buf != NULL)
                g_free(edata->buf);
@@ -1523,7 +1524,7 @@ end:
        reply = g_dbus_create_reply(hdp_conn->msg, DBUS_TYPE_BOOLEAN, &value,
                                                        DBUS_TYPE_INVALID);
        g_dbus_send_message(btd_get_dbus_connection(), reply);
-       g_source_remove(edata->tid);
+       timeout_remove(edata->tid);
        edata->tid = 0;
        g_free(edata->buf);
        edata->buf = NULL;
@@ -1537,7 +1538,7 @@ end:
        return FALSE;
 }
 
-static gboolean echo_timeout(gpointer data)
+static bool echo_timeout(gpointer data)
 {
        struct hdp_channel *chan = data;
        GIOChannel *io;
@@ -1605,10 +1606,9 @@ static void hdp_echo_connect_cb(struct mcap_mdl *mdl, GError *err,
        g_io_add_watch(io, G_IO_ERR | G_IO_HUP | G_IO_NVAL | G_IO_IN,
                        check_echo, hdp_tmp_dc_data_ref(hdp_conn));
 
-       edata->tid = g_timeout_add_seconds_full(G_PRIORITY_DEFAULT,
-                                       ECHO_TIMEOUT, echo_timeout,
-                                       hdp_channel_ref(hdp_conn->hdp_chann),
-                                       (GDestroyNotify) hdp_channel_unref);
+       edata->tid = timeout_add_seconds(ECHO_TIMEOUT, echo_timeout,
+                               hdp_channel_ref(hdp_conn->hdp_chann),
+                               (timeout_destroy_func_t) hdp_channel_unref);
 
        g_io_channel_unref(io);
 }
index f53e215..6e23d4b 100755 (executable)
@@ -24,6 +24,7 @@
 #include "bluetooth/l2cap.h"
 #include "btio/btio.h"
 #include "src/log.h"
+#include "src/shared/timeout.h"
 
 #include "mcap.h"
 
@@ -41,7 +42,7 @@
 
 #define RELEASE_TIMER(__mcl) do {              \
        if (__mcl->tid) {                       \
-               g_source_remove(__mcl->tid);    \
+               timeout_remove(__mcl->tid);     \
                __mcl->tid = 0;                 \
        }                                       \
 } while(0)
@@ -481,7 +482,7 @@ static int compare_mdl(gconstpointer a, gconstpointer b)
                return 1;
 }
 
-static gboolean wait_response_timer(gpointer data)
+static bool wait_response_timer(gpointer data)
 {
        struct mcap_mcl *mcl = data;
 
@@ -547,8 +548,8 @@ gboolean mcap_create_mdl(struct mcap_mcl *mcl,
 
        mcl->mdls = g_slist_insert_sorted(mcl->mdls, mcap_mdl_ref(mdl),
                                                                compare_mdl);
-       mcl->tid = g_timeout_add_seconds(RESPONSE_TIMER, wait_response_timer,
-                                                                       mcl);
+       mcl->tid = timeout_add_seconds(RESPONSE_TIMER, wait_response_timer,
+                                                       mcl, NULL);
        return TRUE;
 }
 
@@ -585,8 +586,8 @@ gboolean mcap_reconnect_mdl(struct mcap_mdl *mdl,
        mcl->state = MCL_ACTIVE;
        mcl->priv_data = con;
 
-       mcl->tid = g_timeout_add_seconds(RESPONSE_TIMER, wait_response_timer,
-                                                                       mcl);
+       mcl->tid = timeout_add_seconds(RESPONSE_TIMER, wait_response_timer,
+                                                               mcl, NULL);
        return TRUE;
 }
 
@@ -605,8 +606,8 @@ static gboolean send_delete_req(struct mcap_mcl *mcl,
 
        mcl->priv_data = con;
 
-       mcl->tid = g_timeout_add_seconds(RESPONSE_TIMER, wait_response_timer,
-                                                                       mcl);
+       mcl->tid = timeout_add_seconds(RESPONSE_TIMER, wait_response_timer,
+                                                       mcl, NULL);
        return TRUE;
 }
 
@@ -716,8 +717,8 @@ gboolean mcap_mdl_abort(struct mcap_mdl *mdl, mcap_mdl_notify_cb abort_cb,
        con->user_data = user_data;
 
        mcl->priv_data = con;
-       mcl->tid = g_timeout_add_seconds(RESPONSE_TIMER, wait_response_timer,
-                                                                       mcl);
+       mcl->tid = timeout_add_seconds(RESPONSE_TIMER, wait_response_timer,
+                                                               mcl, NULL);
        return TRUE;
 }
 
index 94c1da1..9a6f803 100644 (file)
@@ -38,6 +38,7 @@
 #include "src/dbus-common.h"
 #include "src/error.h"
 #include "src/sdp-client.h"
+#include "src/shared/timeout.h"
 #include "src/shared/uhid.h"
 
 #include "device.h"
@@ -67,12 +68,12 @@ struct input_device {
        struct hidp_connadd_req *req;
        bool                    disable_sdp;
        enum reconnect_mode_t   reconnect_mode;
-       guint                   reconnect_timer;
+       unsigned int            reconnect_timer;
        uint32_t                reconnect_attempt;
        struct bt_uhid          *uhid;
        bool                    uhid_created;
        uint8_t                 report_req_pending;
-       guint                   report_req_timer;
+       unsigned int            report_req_timer;
        uint32_t                report_rsp_id;
        bool                    virtual_cable_unplug;
 #ifdef TIZEN_BT_HID_DEVICE_ENABLE
@@ -142,10 +143,10 @@ static void input_device_free(struct input_device *idev)
        }
 
        if (idev->reconnect_timer > 0)
-               g_source_remove(idev->reconnect_timer);
+               timeout_remove(idev->reconnect_timer);
 
        if (idev->report_req_timer > 0)
-               g_source_remove(idev->report_req_timer);
+               timeout_remove(idev->report_req_timer);
 
        g_free(idev);
 }
@@ -446,7 +447,7 @@ static void hidp_recv_ctrl_handshake(struct input_device *idev, uint8_t param)
        if (pending_req_complete) {
                idev->report_req_pending = 0;
                if (idev->report_req_timer > 0) {
-                       g_source_remove(idev->report_req_timer);
+                       timeout_remove(idev->report_req_timer);
                        idev->report_req_timer = 0;
                }
                idev->report_rsp_id = 0;
@@ -506,7 +507,7 @@ static void hidp_recv_ctrl_data(struct input_device *idev, uint8_t param,
 
        idev->report_req_pending = 0;
        if (idev->report_req_timer > 0) {
-               g_source_remove(idev->report_req_timer);
+               timeout_remove(idev->report_req_timer);
                idev->report_req_timer = 0;
        }
        idev->report_rsp_id = 0;
@@ -595,7 +596,7 @@ static gboolean ctrl_watch_cb(GIOChannel *chan, GIOCondition cond, gpointer data
 
 #define REPORT_REQ_TIMEOUT  3
 
-static gboolean hidp_report_req_timeout(gpointer data)
+static bool hidp_report_req_timeout(gpointer data)
 {
        struct input_device *idev = data;
        uint8_t pending_req_type;
@@ -676,8 +677,8 @@ static void hidp_send_set_report(struct uhid_event *ev, void *user_data)
        if (sent) {
                idev->report_req_pending = hdr;
                idev->report_req_timer =
-                       g_timeout_add_seconds(REPORT_REQ_TIMEOUT,
-                                       hidp_report_req_timeout, idev);
+                       timeout_add_seconds(REPORT_REQ_TIMEOUT,
+                                       hidp_report_req_timeout, idev, NULL);
                idev->report_rsp_id = ev->u.set_report.id;
        } else
                uhid_send_set_report_reply(idev, ev->u.set_report.id, EIO);
@@ -719,8 +720,8 @@ static void hidp_send_get_report(struct uhid_event *ev, void *user_data)
        if (sent) {
                idev->report_req_pending = hdr;
                idev->report_req_timer =
-                       g_timeout_add_seconds(REPORT_REQ_TIMEOUT,
-                                               hidp_report_req_timeout, idev);
+                       timeout_add_seconds(REPORT_REQ_TIMEOUT,
+                                       hidp_report_req_timeout, idev, NULL);
                idev->report_rsp_id = ev->u.get_report.id;
        } else
                uhid_send_get_report_reply(idev, NULL, 0, ev->u.get_report.id,
@@ -1320,7 +1321,7 @@ static int dev_connect(struct input_device *idev)
        return -EIO;
 }
 
-static gboolean input_device_auto_reconnect(gpointer user_data)
+static bool input_device_auto_reconnect(gpointer user_data)
 {
        struct input_device *idev = user_data;
 
@@ -1390,12 +1391,12 @@ static void input_device_enter_reconnect_mode(struct input_device *idev)
                return;
 
        if (idev->reconnect_timer > 0)
-               g_source_remove(idev->reconnect_timer);
+               timeout_remove(idev->reconnect_timer);
 
        DBG("registering auto-reconnect");
        idev->reconnect_attempt = 0;
-       idev->reconnect_timer = g_timeout_add_seconds(30,
-                                       input_device_auto_reconnect, idev);
+       idev->reconnect_timer = timeout_add_seconds(30,
+                               input_device_auto_reconnect, idev, NULL);
 
 }
 
index 914b342..5a83fc8 100755 (executable)
@@ -31,6 +31,7 @@
 #include "lib/uuid.h"
 
 #include "src/log.h"
+#include "src/shared/timeout.h"
 #include "src/shared/util.h"
 #include "btio/btio.h"
 
@@ -66,7 +67,7 @@ struct bnep {
        bdaddr_t        dst_addr;
        char    iface[16];
        guint   attempts;
-       guint   setup_to;
+       unsigned int    setup_to;
        guint   watch;
        bnep_connect_cb conn_cb;
        void    *conn_data;
@@ -249,7 +250,7 @@ static gboolean bnep_setup_cb(GIOChannel *chan, GIOCondition cond,
                return FALSE;
 
        if (session->setup_to > 0) {
-               g_source_remove(session->setup_to);
+               timeout_remove(session->setup_to);
                session->setup_to = 0;
        }
 
@@ -353,7 +354,7 @@ static int bnep_setup_conn_req(struct bnep *session)
        return 0;
 }
 
-static gboolean bnep_conn_req_to(gpointer user_data)
+static bool bnep_conn_req_to(gpointer user_data)
 {
        struct bnep *session = user_data;
 
@@ -442,8 +443,8 @@ int bnep_connect(struct bnep *session, bnep_connect_cb conn_cb,
        if (err < 0)
                return err;
 
-       session->setup_to = g_timeout_add_seconds(CON_SETUP_TO,
-                                               bnep_conn_req_to, session);
+       session->setup_to = timeout_add_seconds(CON_SETUP_TO,
+                                       bnep_conn_req_to, session, NULL);
        return 0;
 }
 
index b0a454c..fa13a20 100755 (executable)
@@ -31,6 +31,7 @@
 #include "src/log.h"
 #include "src/error.h"
 #include "src/dbus-common.h"
+#include "src/shared/timeout.h"
 #include "src/shared/util.h"
 
 #include "sap.h"
@@ -62,7 +63,7 @@ struct sap_connection {
        GIOChannel *io;
        uint32_t state;
        uint8_t processing_req;
-       guint timer_id;
+       unsigned int timer_id;
 };
 
 struct sap_server {
@@ -74,7 +75,7 @@ struct sap_server {
 
 static void start_guard_timer(struct sap_server *server, guint interval);
 static void stop_guard_timer(struct sap_server *server);
-static gboolean guard_timeout(gpointer data);
+static bool guard_timeout(gpointer data);
 
 static size_t add_result_parameter(uint8_t result,
                                        struct sap_parameter *param)
@@ -554,8 +555,8 @@ static void start_guard_timer(struct sap_server *server, guint interval)
                return;
 
        if (!conn->timer_id)
-               conn->timer_id = g_timeout_add_seconds(interval, guard_timeout,
-                                                               server);
+               conn->timer_id = timeout_add_seconds(interval, guard_timeout,
+                                                       server, NULL);
        else
                error("Timer is already active.");
 }
@@ -565,12 +566,12 @@ static void stop_guard_timer(struct sap_server *server)
        struct sap_connection *conn = server->conn;
 
        if (conn  && conn->timer_id) {
-               g_source_remove(conn->timer_id);
+               timeout_remove(conn->timer_id);
                conn->timer_id = 0;
        }
 }
 
-static gboolean guard_timeout(gpointer data)
+static bool guard_timeout(gpointer data)
 {
        struct sap_server *server = data;
        struct sap_connection *conn = server->conn;