diff options
author | Pavlin Radoslavov <pavlin@google.com> | 2015-09-16 13:30:26 -0700 |
---|---|---|
committer | Scott James Remnant <keybuk@google.com> | 2015-10-19 10:36:17 -0700 |
commit | 642f233005cdcbbbcb92b77d6297fc080b7f072e (patch) | |
tree | fae3c8a6cd8517dc0b53eb77ed18fe9fc34e3b75 | |
parent | de86bfa27b3ae6a9812788efe2b76fa3e7931d56 (diff) | |
download | bt-642f233005cdcbbbcb92b77d6297fc080b7f072e.tar.gz |
GKI cleanup - Eliminated function GKI_delay
Removed function GKI_delay from the GKI module, and replaced
it with a local static function inside file btif/src/btif_rc.c - the
only place it is (still) used.
Change-Id: Id8f3f700efd22d6e31c70aa8b1724ffa9afbc631
-rw-r--r-- | btif/src/btif_rc.c | 28 | ||||
-rw-r--r-- | gki/common/gki.h | 4 | ||||
-rw-r--r-- | gki/ulinux/gki_ulinux.c | 14 |
3 files changed, 25 insertions, 21 deletions
diff --git a/btif/src/btif_rc.c b/btif/src/btif_rc.c index a2074b383..5b4e49561 100644 --- a/btif/src/btif_rc.c +++ b/btif/src/btif_rc.c @@ -26,9 +26,11 @@ #define LOG_TAG "bt_btif_avrc" +#include <errno.h> #include <fcntl.h> #include <pthread.h> #include <string.h> +#include <time.h> #include <unistd.h> #include <hardware/bluetooth.h> @@ -149,6 +151,7 @@ static int uinput_create(char *name); static int init_uinput (void); static void close_uinput (void); static BOOLEAN dev_blacklisted_for_absolute_volume(BD_ADDR peer_dev); +static void sleep_ms(uint32_t timeout_ms); static const struct { const char *name; @@ -611,7 +614,7 @@ void handle_rc_passthrough_cmd ( tBTA_AV_REMOTE_CMD *p_remote_cmd) send_key(uinput_fd, key_map[i].mapped_id, pressed); if ((key_map[i].release_quirk == 1) && (pressed == 1)) { - GKI_delay(30); // 30ms + sleep_ms(30); BTIF_TRACE_DEBUG("%s: AVRC %s Release quirk enabled, send release now", __FUNCTION__, key_map[i].name); send_key(uinput_fd, key_map[i].mapped_id, 0); @@ -888,12 +891,12 @@ void btif_rc_check_handle_pending_play (BD_ADDR peer_addr, BOOLEAN bSendToApp) ** which causes the audio to be on th device's speaker. Delay between ** OPEN & RC_PLAYs */ - GKI_delay (200); + sleep_ms(200); /* send to app - both PRESSED & RELEASED */ remote_cmd.key_state = AVRC_STATE_PRESS; handle_rc_passthrough_cmd( &remote_cmd ); - GKI_delay (100); + sleep_ms(100); remote_cmd.key_state = AVRC_STATE_RELEASE; handle_rc_passthrough_cmd( &remote_cmd ); @@ -1919,3 +1922,22 @@ static BOOLEAN dev_blacklisted_for_absolute_volume(BD_ADDR peer_dev) peer_dev[0], peer_dev[1], peer_dev[2], dev_name_str); return TRUE; } + +/******************************************************************************* +** Function sleep_ms +** +** Description Sleep the calling thread unconditionally for +** |timeout_ms| milliseconds. +** +** Returns void +*******************************************************************************/ +static void sleep_ms(uint32_t timeout_ms) { + struct timespec delay; + delay.tv_sec = timeout_ms / 1000; + delay.tv_nsec = 1000 * 1000 * (timeout_ms % 1000); + + int err; + do { + err = nanosleep(&delay, &delay); + } while (err == -1 && errno == EINTR); +} diff --git a/gki/common/gki.h b/gki/common/gki.h index f0df9e3ee..e6800620c 100644 --- a/gki/common/gki.h +++ b/gki/common/gki.h @@ -85,10 +85,6 @@ BOOLEAN GKI_queue_is_empty(BUFFER_Q *); void *GKI_remove_from_queue (BUFFER_Q *, void *); UINT16 GKI_get_pool_bufsize (UINT8); -/* Timer management -*/ -void GKI_delay(UINT32); - /* Disable Interrupts, Enable Interrupts */ void GKI_enable(void); diff --git a/gki/ulinux/gki_ulinux.c b/gki/ulinux/gki_ulinux.c index c8e99539e..a13e1700c 100644 --- a/gki/ulinux/gki_ulinux.c +++ b/gki/ulinux/gki_ulinux.c @@ -19,10 +19,8 @@ #define LOG_TAG "bt_gki" #include <assert.h> -#include <errno.h> #include <pthread.h> #include <string.h> -#include <time.h> #include "btcore/include/module.h" #include "gki/ulinux/gki_int.h" @@ -68,18 +66,6 @@ UINT32 GKI_get_os_tick_count(void) { return (timespec.tv_sec * 1000) + (timespec.tv_nsec / 1000000); } -// Sleep the calling thread unconditionally for |timeout_ms| milliseconds. -void GKI_delay(UINT32 timeout_ms) { - struct timespec delay; - delay.tv_sec = timeout_ms / 1000; - delay.tv_nsec = 1000 * 1000 * (timeout_ms % 1000); - - int err; - do { - err = nanosleep(&delay, &delay); - } while (err == -1 && errno == EINTR); -} - void GKI_enable(void) { pthread_mutex_unlock(&gki_cb.lock); } |