Skip to content

Commit

Permalink
Revert "Bluetooth: A2DP SINK audio focus and state handling changes"
Browse files Browse the repository at this point in the history
This reverts commit 139245f.
  • Loading branch information
Alberto97 committed Dec 31, 2013
1 parent 55a8c42 commit d40a816
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 103 deletions.
1 change: 0 additions & 1 deletion btif/include/btif_av.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ typedef enum {
BTIF_AV_STOP_STREAM_REQ_EVT,
BTIF_AV_SUSPEND_STREAM_REQ_EVT,
BTIF_AV_RECONFIGURE_REQ_EVT,
BTIF_AV_REQUEST_AUDIO_FOCUS_EVT,
} btif_av_sm_event_t;


Expand Down
1 change: 0 additions & 1 deletion btif/include/btif_media.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,5 @@ void btif_a2dp_set_rx_flush(BOOLEAN enable);
void btif_media_check_iop_exceptions(UINT8 *peer_bda);
void btif_reset_decoder(UINT8 *p_av);
BOOLEAN btif_media_task_start_decoding_req(void);
void btif_a2dp_set_audio_focus_state(BOOLEAN is_enable);

#endif
81 changes: 2 additions & 79 deletions btif/src/btif_av.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,38 +192,11 @@ const char *dump_av_sm_event_name(btif_av_sm_event_t event)
CASE_RETURN_STR(BTIF_AV_STOP_STREAM_REQ_EVT)
CASE_RETURN_STR(BTIF_AV_SUSPEND_STREAM_REQ_EVT)
CASE_RETURN_STR(BTIF_AV_RECONFIGURE_REQ_EVT)
CASE_RETURN_STR(BTIF_AV_REQUEST_AUDIO_FOCUS_EVT)

default: return "UNKNOWN_EVENT";
}
}

/*******************************************************************************
**
** Function btif_av_request_audio_focus
**
** Description send request to gain audio focus
**
** Returns void
**
*******************************************************************************/
void btif_av_request_audio_focus( BOOLEAN enable)
{
btif_sm_state_t state;
state= btif_sm_get_state(btif_av_cb.sm_handle);
/* We shld be in started state */
if (state != BTIF_AV_STATE_STARTED)
return;
/* If we are in started state, suspend shld not have been initiated */
if ((btif_av_cb.flags & BTIF_AV_FLAG_REMOTE_SUSPEND )||
(btif_av_cb.flags & BTIF_AV_FLAG_LOCAL_SUSPEND_PENDING))
return;
if(enable)
{
btif_dispatch_sm_event(BTIF_AV_REQUEST_AUDIO_FOCUS_EVT, NULL, 0);
}
}

/****************************************************************************
** Local helper functions
*****************************************************************************/
Expand Down Expand Up @@ -562,12 +535,6 @@ static BOOLEAN btif_av_state_opened_handler(btif_sm_event_t event, void *p_data)
break;

case BTIF_AV_START_STREAM_REQ_EVT:
if (btif_av_cb.sep == SEP_SRC)
{
BTA_AvStart();
btif_av_cb.flags |= BTIF_AV_FLAG_PENDING_START;
break;
}
status = btif_a2dp_setup_codec();
if (status == BTIF_SUCCESS)
{
Expand Down Expand Up @@ -610,16 +577,12 @@ static BOOLEAN btif_av_state_opened_handler(btif_sm_event_t event, void *p_data)
if (p_av->start.status != BTA_AV_SUCCESS)
return FALSE;

if (btif_av_cb.sep == SEP_SRC)
{
btif_a2dp_set_rx_flush(FALSE); /* remove flush state, ready for streaming*/
btif_media_task_start_decoding_req();
}

/* change state to started, send acknowledgement if start is pending */
if (btif_av_cb.flags & BTIF_AV_FLAG_PENDING_START) {
if (btif_av_cb.sep == SEP_SNK)
btif_a2dp_on_started(NULL, TRUE);
else if (btif_av_cb.sep == SEP_SRC)
btif_a2dp_set_rx_flush(FALSE); /* remove flush state, ready for streaming*/
/* pending start flag will be cleared when exit current state */
}
btif_sm_change_state(btif_av_cb.sm_handle, BTIF_AV_STATE_STARTED);
Expand Down Expand Up @@ -805,11 +768,6 @@ static BOOLEAN btif_av_state_started_handler(btif_sm_event_t event, void *p_data

break;

case BTIF_AV_REQUEST_AUDIO_FOCUS_EVT:
HAL_CBACK(bt_av_callbacks, audio_focus_request_cb,
1, &(btif_av_cb.peer_bda));
break;

case BTA_AV_CLOSE_EVT:

btif_av_cb.flags |= BTIF_AV_FLAG_PENDING_STOP;
Expand Down Expand Up @@ -1042,39 +1000,6 @@ void suspend_sink()
btif_dispatch_sm_event(BTIF_AV_SUSPEND_STREAM_REQ_EVT, NULL, 0);
}

/*******************************************************************************
**
** Function resume_sink
**
** Description Resumes stream in case of A2DP Sink
**
** Returns None
**
*******************************************************************************/
void resume_sink()
{
BTIF_TRACE_DEBUG0(" resume Stream called");
if (btif_av_cb.sep == SEP_SRC)
btif_dispatch_sm_event(BTIF_AV_START_STREAM_REQ_EVT, NULL, 0);
}

/*******************************************************************************
**
** Function audio_focus_status
**
** Description Updates audio focus state
**
** Returns None
**
*******************************************************************************/
static void audio_focus_status(int is_enable)
{
BTIF_TRACE_DEBUG1(" Audio Focus granted %d",is_enable);
if (is_enable == 1)
btif_a2dp_set_audio_focus_state(TRUE);
else
btif_a2dp_set_audio_focus_state(FALSE);
}

static void allow_connection(int is_valid)
{
Expand Down Expand Up @@ -1128,8 +1053,6 @@ static const btav_interface_t bt_av_interface = {
allow_connection,
is_src,
suspend_sink,
resume_sink,
audio_focus_status,
};

/*******************************************************************************
Expand Down
25 changes: 3 additions & 22 deletions btif/src/btif_media_task.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ oi_sbc_decoder_vendor_interface_t *oi_sbc_decode_vnd_if = NULL;
** Constants
*****************************************************************************/


#ifndef AUDIO_CHANNEL_OUT_MONO
#define AUDIO_CHANNEL_OUT_MONO 0x01
#endif
Expand Down Expand Up @@ -229,6 +230,7 @@ static UINT32 a2dp_media_task_stack[(A2DP_MEDIA_TASK_STACK_SIZE + 3) / 4];
#define PACKET_PLAYED_PER_TICK_32 5
#define PACKET_PLAYED_PER_TICK_16 3

#define BTIF_MEDIA_VERBOSE_ENABLED

#ifdef BTIF_MEDIA_VERBOSE_ENABLED
#define VERBOSE(fmt, ...) \
Expand Down Expand Up @@ -288,7 +290,6 @@ typedef struct
BOOLEAN is_edr_supported;
BOOLEAN is_source;
UINT8 frames_to_process;
BOOLEAN rx_audio_focus_gained;
#endif

} tBTIF_MEDIA_CB;
Expand Down Expand Up @@ -353,8 +354,6 @@ static void btif_media_task_aa_handle_decoder_reset(BT_HDR *p_msg);
static void btif_media_task_aa_handle_start_decoding(void );
#endif
extern BOOLEAN btif_hf_is_call_idle();
extern void btif_av_request_audio_focus(BOOLEAN enable);

BOOLEAN btif_media_task_start_decoding_req(void);

/*****************************************************************************
Expand Down Expand Up @@ -939,7 +938,6 @@ void btif_a2dp_on_idle(void)
APPL_TRACE_DEBUG0("Reset to Source role");
btif_media_cb.is_source = TRUE;
btif_media_cb.rx_flush = TRUE;
btif_media_cb.rx_audio_focus_gained = FALSE;
}
#endif
}
Expand Down Expand Up @@ -1211,13 +1209,6 @@ void btif_a2dp_set_tx_flush(BOOLEAN enable)
btif_media_cb.tx_flush = enable;
}

/* when true media task discards any rx frames */
void btif_a2dp_set_audio_focus_state(BOOLEAN is_enable)
{
APPL_TRACE_EVENT1("## Audio_focus_state Rx %d ##", is_enable);
btif_media_cb.rx_audio_focus_gained = is_enable;
}

/*****************************************************************************
**
** Function btif_calc_pcmtime
Expand Down Expand Up @@ -1275,12 +1266,6 @@ static void btif_media_task_avk_handle_timer ( void )
}
else
{
if (btif_media_cb.rx_audio_focus_gained == FALSE)
{
/* Send a Audio Focus Request */
btif_av_request_audio_focus(TRUE);
return;
}
if (btif_media_cb.rx_flush == TRUE)
{
btif_media_flush_q(&(btif_media_cb.RxSbcQ));
Expand Down Expand Up @@ -2221,8 +2206,6 @@ static void btif_media_task_aa_handle_stop_decoding(void )
*******************************************************************************/
static void btif_media_task_aa_handle_start_decoding(void )
{
if(btif_media_cb.is_rx_timer == TRUE)
return;
btif_media_cb.is_rx_timer = TRUE;
GKI_start_timer(BTIF_MEDIA_AVK_TASK_TIMER_ID, GKI_MS_TO_TICKS(BTIF_SINK_MEDIA_TIME_TICK), TRUE);
}
Expand Down Expand Up @@ -2594,9 +2577,7 @@ UINT8 btif_media_sink_enque_buf(BT_HDR *p_pkt)
if(btif_media_cb.rx_flush == TRUE) /* Flush enabled, do not enque*/
return btif_media_cb.RxSbcQ.count;
if(btif_media_cb.RxSbcQ.count == MAX_OUTPUT_A2DP_FRAME_QUEUE_SZ)
{
GKI_freebuf(GKI_dequeue(&(btif_media_cb.RxSbcQ)));
}
return MAX_OUTPUT_A2DP_FRAME_QUEUE_SZ;

BTIF_TRACE_VERBOSE0("btif_media_sink_enque_buf + ");
/* allocate and Queue this buffer */
Expand Down

0 comments on commit d40a816

Please sign in to comment.