summaryrefslogtreecommitdiffstats
path: root/btif
diff options
context:
space:
mode:
authorSreenidhi T <nidhit@broadcom.com>2012-05-21 00:04:56 -0700
committerMatthew Xie <mattx@google.com>2012-07-14 11:19:21 -0700
commitc31ac09a04a4aa3319e0cff85b92f5b2a92b16c9 (patch)
tree48beab2d90dbb2de0b6b84877af964444084b2cc /btif
parent104a50ef31fdf9f378f7fb8d3c6466ff32bb0b72 (diff)
downloadexternal_bluetooth_bluedroid-c31ac09a04a4aa3319e0cff85b92f5b2a92b16c9.zip
external_bluetooth_bluedroid-c31ac09a04a4aa3319e0cff85b92f5b2a92b16c9.tar.gz
external_bluetooth_bluedroid-c31ac09a04a4aa3319e0cff85b92f5b2a92b16c9.tar.bz2
Changes done to queue play if received during the timeout for AV connection initiation and send the pending play after AV open event.
Change-Id: I2bff3a8f5ff3eb85918156a84c855dc8eb990634
Diffstat (limited to 'btif')
-rwxr-xr-x[-rw-r--r--]btif/src/btif_av.c19
-rwxr-xr-xbtif/src/btif_rc.c69
2 files changed, 86 insertions, 2 deletions
diff --git a/btif/src/btif_av.c b/btif/src/btif_av.c
index b350448..b2b1378 100644..100755
--- a/btif/src/btif_av.c
+++ b/btif/src/btif_av.c
@@ -145,6 +145,7 @@ static const btif_sm_handler_t btif_av_state_handlers[] =
extern void btif_rc_init(void);
extern void btif_rc_handler(tBTA_AV_EVT event, tBTA_AV *p_data);
extern BOOLEAN btif_rc_get_connected_peer(BD_ADDR peer_addr);
+extern void btif_rc_check_handle_pending_play (BD_ADDR peer_addr, BOOLEAN bSendToApp);
/*****************************************************************************
** Local helper functions
@@ -374,8 +375,10 @@ static BOOLEAN btif_av_state_opening_handler(btif_sm_event_t event, void *p_data
state, &(btif_av_cb.peer_bda));
/* change state to open/idle based on the status */
btif_sm_change_state(btif_av_cb.sm_handle, av_state);
+ /* if queued PLAY command, send it now */
+ btif_rc_check_handle_pending_play(p_bta_data->open.bd_addr,
+ (p_bta_data->open.status == BTA_AV_SUCCESS));
btif_queue_advance();
-
} break;
CHECK_RC_EVENT(event, p_data);
@@ -927,3 +930,17 @@ const btav_interface_t *btif_av_get_interface(void)
BTIF_TRACE_EVENT1("%s", __FUNCTION__);
return &bt_av_interface;
}
+
+/*******************************************************************************
+**
+** Function btif_av_is_rc_open_without_a2dp
+**
+** Description Checks if GAVDTP Open notification to app is pending (2 second timer)
+**
+** Returns boolean
+**
+*******************************************************************************/
+BOOLEAN btif_av_is_rc_open_without_a2dp(void)
+{
+ return (tle_av_open_on_rc.in_use);
+}
diff --git a/btif/src/btif_rc.c b/btif/src/btif_rc.c
index 24133cc..9a0d0ee 100755
--- a/btif/src/btif_rc.c
+++ b/btif/src/btif_rc.c
@@ -133,7 +133,7 @@ static btif_rc_cb_t btif_rc_cb;
******************************************************************************/
extern BOOLEAN btif_hf_call_terminated_recently();
extern BOOLEAN check_cod(const bt_bdaddr_t *remote_bdaddr, uint32_t cod);
-
+BOOLEAN btif_av_is_rc_open_without_a2dp(void);
/*****************************************************************************
** Functions
@@ -326,6 +326,29 @@ void handle_rc_passthrough_cmd ( tBTA_AV_REMOTE_CMD *p_remote_cmd)
const char *status;
int pressed, i;
+ btif_rc_cb.rc_handle = p_remote_cmd->rc_handle;
+
+ /* If AVRC is open and peer sends PLAY but there is no AVDT, then we queue-up this PLAY */
+ if (p_remote_cmd)
+ {
+ /* queue AVRC PLAY if GAVDTP Open notification to app is pending (2 second timer) */
+ if ((p_remote_cmd->rc_id == BTA_AV_RC_PLAY) && btif_av_is_rc_open_without_a2dp())
+ {
+ if (p_remote_cmd->key_state == AVRC_STATE_PRESS)
+ {
+ APPL_TRACE_WARNING1("%s: AVDT not open, queuing the PLAY command", __FUNCTION__);
+ btif_rc_cb.rc_pending_play = TRUE;
+ }
+ return;
+ }
+
+ if ((p_remote_cmd->rc_id == BTA_AV_RC_PAUSE) && (btif_rc_cb.rc_pending_play))
+ {
+ APPL_TRACE_WARNING1("%s: Clear the pending PLAY on PAUSE received", __FUNCTION__);
+ btif_rc_cb.rc_pending_play = FALSE;
+ return;
+ }
+ }
if (p_remote_cmd->key_state == AVRC_STATE_RELEASE) {
status = "released";
pressed = 0;
@@ -455,3 +478,47 @@ BOOLEAN btif_rc_get_connected_peer(BD_ADDR peer_addr)
}
return FALSE;
}
+
+/***************************************************************************
+ **
+ ** Function btif_rc_check_handle_pending_play
+ **
+ ** Description Clears the queued PLAY command. if bSend is TRUE, forwards to app
+ **
+ ***************************************************************************/
+
+/* clear the queued PLAY command. if bSend is TRUE, forward to app */
+void btif_rc_check_handle_pending_play (BD_ADDR peer_addr, BOOLEAN bSendToApp)
+{
+ LOGV("btapp_rc_check_handle_pending_play: bSendToApp=%d", bSendToApp);
+ if (btif_rc_cb.rc_pending_play)
+ {
+ if (bSendToApp)
+ {
+ tBTA_AV_REMOTE_CMD remote_cmd;
+ APPL_TRACE_DEBUG1("%s: Sending queued PLAYED event to app", __FUNCTION__);
+
+ memset (&remote_cmd, 0, sizeof(tBTA_AV_REMOTE_CMD));
+ remote_cmd.rc_handle = btif_rc_cb.rc_handle;
+ remote_cmd.rc_id = AVRC_ID_PLAY;
+ remote_cmd.hdr.ctype = AVRC_CMD_CTRL;
+ remote_cmd.hdr.opcode = AVRC_OP_PASS_THRU;
+
+ /* delay sending to app, else there is a timing issue in the framework,
+ ** which causes the audio to be on th device's speaker. Delay between
+ ** OPEN & RC_PLAYs
+ */
+ GKI_delay (200);
+ /* send to app - both PRESSED & RELEASED */
+ remote_cmd.key_state = AVRC_STATE_PRESS;
+ handle_rc_passthrough_cmd( &remote_cmd );
+
+ GKI_delay (100);
+
+ remote_cmd.key_state = AVRC_STATE_RELEASE;
+ handle_rc_passthrough_cmd( &remote_cmd );
+ }
+ btif_rc_cb.rc_pending_play = FALSE;
+ }
+}
+