History log of /system/bt/btif/src/btif_media_task.c
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
caaa00f5ede96461e11de866ac15f5224442d1eb 04-Aug-2015 Pavlin Radoslavov <pavlin@google.com> Fix a crash for a race condition during Bluetooth shutdown

This is same race condition observed in btif_media_task_aa_tx_flush_req()
because btif_media_task_aa_tx_flush_req() and btif_media_task_stop_aa_req()
are called back-to-bach.

This race condition is triggered when A2DP audio is streaming on shutdown:
"btif_a2dp_on_stopped() -> btif_media_task_stop_aa_req()" is called
to stop the particular audio stream, and this happens right after
the "cleanup() -> btif_a2dp_stop_media_task()" processing during
the shutdown of the Bluetooth stack.

Bug: 22700411
Change-Id: Ia0c98d44a108cf0f57731ac8129e4d76c9934542
/system/bt/btif/src/btif_media_task.c
196413f5ca088ef97866092f02bb7571d2a44390 22-Jul-2015 Andre Eisenbach <eisenbach@google.com> Fix TX queue overflow detection

- Prevent possible endless loop if |nb_frame| is too high
- Remove off-by-one calculation before sending frames
- Remove log spam and add better debug info

Bug: 22658329
Change-Id: I374ee980aec48763beb49b4f6f8b076124cadf40
/system/bt/btif/src/btif_media_task.c
197ee6856b43d8eea137a7f37798ee2a012ce518 22-Jul-2015 Pavlin Radoslavov <pavlin@google.com> Fix a crash for a race condition during Bluetooth shutdown

This race condition is triggered when A2DP audio is streaming on shutdown:
"btif_a2dp_on_stopped() -> btif_media_task_aa_tx_flush_req()" is called
to stop the particular audio stream, and this happens right after
the "cleanup() -> btif_a2dp_stop_media_task()" processing during
the shutdown of the Bluetooth stack.

Bug: 22602117
Change-Id: I5de6a8f15b6a2771dde2e299a5b60554063696a2
/system/bt/btif/src/btif_media_task.c
9c5d0727dd4cd09e44c032506c28ab4120ad3b88 27-Jul-2013 Anubhav Gupta <anubhavg@codeaurora.org> Override remote suspend flag on local play state changes

- Remote device may initiate AVDTP Suspend within 3s of AVRCP pause,
which sets remote suspend flag. Later on resumption of local playback
A2DP packets can not be processed further as Remote suspend flag
remains set. current change overrides remote suspend flag if local
suspend is triggered later.
- This change covers the usecase where play is pressed from DUT UI
before local suspend triggers in such scenarios current change takes
care of resetitng remote suspend flag on AVRCP play state change event.
- Moreover this change will drop A2DP packets when the setparameter
is called with A2dpSuspended=true and resumes when the mentioned parameter
is reset.

This change along with corresponding app change helps mitigating
issues reported due to A2Dp, HFP synchronizations and local and remote
device initiated AVDTP suspend handling.

Bug: 22028876
Change-Id: I3bb334373414170254744d9233cbd2e66219bfa0
/system/bt/btif/src/btif_media_task.c
1f293a50abf0bd37d149604c674ae5a6dbab7750 01-May-2015 Nitin Arora <niarora@codeaurora.org> Stop media task alarm when task is exiting

Bug: 20717705
Change-Id: I76e76cf33d7c9f4366f921daf2230e4f681098f7
/system/bt/btif/src/btif_media_task.c
aea27ef29bd0be1d9faa5dcf94588107e9b6a51d 03-Apr-2015 Rakesh Iyer <rni@google.com> Fix build in BT AV_SINK.

Change-Id: Ie20165ee69597e3287283322d14773ac3699c323
/system/bt/btif/src/btif_media_task.c
e1a9e52ff59d36bd1bb5b7b3a02fafba6394edfe 31-Mar-2015 Etan Cohen <etancohen@google.com> Merge commit 'f7f839985b3931682363d2ef3b7c5cae55a842ee' into merge

Change-Id: Iaaec1ea0bf3009b7e32a9a60f697631a3f56e889
f8027005333c88a2f097cfd70d15c3d54c7764ae 12-Mar-2015 Chris Manton <cmanton@google.com> Demote, cleanup and extend observed logging
/system/bt/btif/src/btif_media_task.c
0f9b91e150e153229235c163861198e23600e636 12-Mar-2015 Sharvil Nanavati <sharvil@google.com> Use fully qualified path for OSI includes.
/system/bt/btif/src/btif_media_task.c
71864f490d4dc31857df0b31924cd62a337e9f1a 11-Mar-2015 Zach Johnson <zachoverflow@google.com> Add ability to set periodic alarms

Adds alarm_set_periodic so the alarm code can have more
contextual information when rescheduling alarms.

Problem: A2DP would stream for a few seconds and then
stop working.

Cause: The Java garbage collector. Bluedroid reaches out
to javaland to acquire and release the wake lock. Alarm was
always reaching out to get the wake lock when it scheduled a
short timeout. If GC kicked in during that call out to make
sure we have the wake lock, it could take more than 100ms to
get back us. That would screw over the alarm implementation
particularly for small 20ms timers.

So now if the wake lock was already acquired, we don't try to
reacquire it.

Cool. But we still have thrashing. Why? Because the alarm code
doesn't know the alarm is actually being used in a periodic way.

Here's what used to happen:

alarm expires
alarm is removed
reschedule
alarm callback is called
alarm callback sets the alarm again
alarm is added
reschedule

The problem is the first reschedule will get rid of the wake lock
if the next alarm is too far out or doesn't exist, meaning the next
reschedule needs to get the wake lock again.

With the extra periodicity information we can eliminate the
unnecessary intermediate reschedule, meaning no thrashing on the
wake lock. yay!
/system/bt/btif/src/btif_media_task.c
e13fbfafe2105d264357ac41133f0ac0e054429c 28-Dec-2014 Sharvil Nanavati <sharvil@google.com> Remove more GKI code.

This change removes all remaining GKI task remnants as well as
a few timer and buffer bits.
/system/bt/btif/src/btif_media_task.c
23e561a1f374557d6030b497337a1c96e9bb6aa4 03-Mar-2015 Sharvil Nanavati <sharvil@google.com> Remove dependency on GKI tasks from BTIF media task.

The previous code started a thread and posted a long-running function
to the thread's event loop. In essence, it created a thread and ran
a custom thread main that did its own event handling using GKI_wait.

The new code doesn't use GKI_wait or GKI_send_event at all. Instead,
it uses thread_post and the thread's reactor to enqueue and dispatch
events.
/system/bt/btif/src/btif_media_task.c
c0a87fe60f79ddf41595a30e75a77f43c19cd323 02-Mar-2015 Sharvil Nanavati <sharvil@google.com> Remove GKI timers
/system/bt/btif/src/btif_media_task.c
753173dee0b92efdbdc0eb4d44338cd1a84dbdb2 26-Sep-2014 Chris Manton <cmanton@google.com> Replace bt media GKI task with thread_t
/system/bt/btif/src/btif_media_task.c
8d9d02862b1e00d27681846e3de9c4cf4f6634fc 07-Sep-2014 Sharvil Nanavati <sharvil@google.com> GKI task entry points should have a consistent signature.

Previously, GKI task entry points had inconsistent signatures. For
example, we had:

int btif_media_task(void *p)
void btif_task(UINT32 params)
void btu_task (UINT32 param)

The single argument was universally ignored and the caller always
set it to 0. This change consolidates all of that and defines the
entry point as having 0 arity and no return value.
/system/bt/btif/src/btif_media_task.c
0d5de78354b5f7c819950fc5680a6cfd0052f78a 07-Sep-2014 Sharvil Nanavati <sharvil@google.com> Eliminate unused 'stack' concept for GKI tasks.

This change also fixes the type for task names: should be a const
string, not a mutable INT8*.
/system/bt/btif/src/btif_media_task.c
860a9af89f8dbf8ef65785d5db960c1fa488d2ba 27-Aug-2014 Chris Manton <cmanton@google.com> Replace mailboxes with fixed queues.

Also refactored btu_task a bit.
/system/bt/btif/src/btif_media_task.c
fe7216ca12f91baae733e7c93063db73121af308 06-May-2014 Chris Manton <cmanton@google.com> Enforce GKI API buffer usage

Also add another API GKI_queue_length(BUFFER_Q *)
/system/bt/btif/src/btif_media_task.c
fb17c122b09171492d99b208c1fdd6b76d2c431c 16-Jan-2015 Andre Eisenbach <eisenbach@google.com> am 335bc32b: Merge "Relax max PCM frames per tick a bit" into lmp-mr1-dev

* commit '335bc32bc7dae893358bde20557927e6ed6ad58c':
Relax max PCM frames per tick a bit
26e80aad86fae4e468a330d64ee02291f3a1980e 07-Jan-2015 Andre Eisenbach <eisenbach@google.com> Relax max PCM frames per tick a bit

Also made the value overwrite-able in bt_target.h.

Bug: 18913091
Change-Id: I64bbe453b35fdce6f127b3c23c0552b14d4ac49b
/system/bt/btif/src/btif_media_task.c
11cf5ccd5cd6dd1568bf69e4b6cbc27c95f5026d 11-Dec-2014 Chih-Hung Hsieh <chh@google.com> resolved conflicts for merge of ed0bdd42 to lmp-mr1-dev-plus-aosp

Change-Id: Ife8b72d3688ed78a95ccb8d5e0b60f40e7fec9e9
104e3f238f500cacdb8afaccdc672dfc34eae7ee 12-Nov-2014 Bernhard Rosenkränzer <Bernhard.Rosenkranzer@linaro.org> Cleanups needed to make clang happy

This patch removes a slew of unused variables and some unused functions,
fixes some incomplete initializations of structs and an sprintf
parameter mismatching the format string.

Change-Id: I35f22fdccc8350f885cd357d3685b869224fa433
Signed-off-by: Bernhard Rosenkränzer <Bernhard.Rosenkranzer@linaro.org>
/system/bt/btif/src/btif_media_task.c
c5916e97384f07ec5a2e061e6af24f70107c74a2 08-Nov-2014 Andre Eisenbach <eisenbach@google.com> Remove overflow rate limiting when reading A2DP frames

A2DP now supports adjusting the number of A2DP frames sent per timer
tick to adjust for timer drift and missed media task ticks. When the
signal to the headset/speakers becomes interrupted, the number of
packets to be read can queue up and rate limiting will not allow for the
queue to be cleared.

The overflow mechanism introduced in commit 4aebca4 will cause the media
task to stop sending packets completely, which can underflow the jutter
buffer on the remote device and lead to audio drop-outs.

This patch removes the overflow mechanism and also adds code do discard
audio frames that could not be sent to the remote device (weak signal
etc) to allow the device to stay in sync and not build up audio delays.

Also added additional debug logging and changed the UIPC flush mechanism
to address an issue where reading byte by byte causes an endless flush
loop if remote UIPC producer writes data faster than the flush loop
consumes it.

Bug: 18326405
Change-Id: I9a424984806bb2a464877399804b3355b2c439c3
/system/bt/btif/src/btif_media_task.c
01d102b3b187ab0d24050c1e12f96e6ee1ce50be 17-Oct-2014 Andre Eisenbach <eisenbach@google.com> A2DP: Lowering maximum PCM frame limit to avoid audio breaks

Some car kits (notably Renesas car kits used in Nissan/Infiniti models)
will throttle incoming A2DP frames if too many frames are sent at once.
This patch lowers the maximum number of frames sent per tick to not
overwhelm the remote device.

Bug: 17880920
Change-Id: I7bfbba625405c96159d1c94eebd8dc498f100daa
/system/bt/btif/src/btif_media_task.c
f061e74b81863771b174d1717a6165034dbad8e5 09-Oct-2014 Mattias Agren <magren@broadcom.com> Added missing A2DP priority on java alarm service

Running GKI timer engine via JAVA alarm service was causing severe
timer preemption at times which affects A2DP media task timer. This in
turn was stressing the compensation logic towards UIPC resulting in
very bursty reads of up to 40 UIPC frames at a time. This led to
instabilities on the UIPC pipe and trickled upwards in audio framework.
Inclusion of java alarm thread in A2DP high priority thread list results
in a much smoother data flow for entire A2DP data path and improved
audio quality.

Bug: 17520043
Change-Id: I7cea6ec64aa5b973b5fff767389a8827e681619e
/system/bt/btif/src/btif_media_task.c
ae13ec986e188d66eaad3c69bb916ea18c142fef 03-Sep-2014 Andre Eisenbach <eisenbach@google.com> Avoid race condition in SBC encoder initialization

In the A2DP media task, btif_a2dp_encoder_update() relies on the fact
that btif_a2dp_encoder_init() is called beforehand. Otherwise division
by zero errors will occur.

Since _init() called after the audio stream is opened, and _update() is
called in resonse the the audio stream being opened, a race condition
could ensue where _update() was called before open.

This patch changes the A2DP stream start sequence to ensure the SBC
encoder is initialized before the updated parameters are calculated.

Bug: 17339248
Change-Id: I6ed36a7fff0e4aa672a8866727030681eb4b3dfc
/system/bt/btif/src/btif_media_task.c
a391bf1d4f4250e27b6f157a1a8d2493c36934dc 09-Aug-2014 Andre Eisenbach <eisenbach@google.com> A2DP: Protect against division-by-zero error in bitpool calculation

If the encoder parameters have not been configured correctly before the
SBC encoder is initialized, a division-by-zero can occur resulting in a
SIGFPE.

Bug: 16902125
Change-Id: Ie4c6715b6b374a2d62fcfa0a1a99d40c689d0e2a
/system/bt/btif/src/btif_media_task.c
25067c0afc4d3ed95181b91801d3d638d9aa3f8f 22-Jul-2014 Andre Eisenbach <eisenbach@google.com> Fix integer overflow in GKI timer calculation

Fix an integer overflow in the GKI timer elapsed time calculation that
would cause Bluetooth Stereo Audio (A2DP) playback to stop suddenly
after a period of INT32_MAX microseconds (about 35 minutes) of
continuous uptime of the phone/tablet.

Bug: 16412377
Change-Id: I28cd3155a23444e41b26b3f3b8424cc2a3c5bf91
/system/bt/btif/src/btif_media_task.c
f13db8a534adf5281ee915c4b73b3141957ed17b 12-Jul-2014 Andre Eisenbach <eisenbach@google.com> Calculate A2DP frames to send based on elapsed time

This patch is aimed at improving A2DP audio quality by sending the
correct number of frames based on the actual time elapes between "ticks"
in order to account for timer drift.

Change-Id: If5b7cde90f5eb10b926ad247f51cff0eb60bbff7
/system/bt/btif/src/btif_media_task.c
0317a401142e927be82a0259f54cfa10a686e0fe 09-Jul-2014 Andre Eisenbach <eisenbach@google.com> Merge "Prevent A2DP bit pool calculation endless loops."
4e3593a9a1c596904a844286fbe704e969e7230e 08-Jul-2014 Andre Eisenbach <eisenbach@google.com> Prevent A2DP bit pool calculation endless loops.

This prevents log spam and endless loops in the A2DP bit pool
calculation. Protecting against the endless loop with prevent battery
draining issues and phone unresponsiveness.

This patch addresses the symptom. A separate patch will be submitted
once root cause is determined to address the problem.

Change-Id: I045b724c1c1638551b9333249f39eee109fa9ba1
/system/bt/btif/src/btif_media_task.c
6718c6d9fcfe373a679a529aca003d32062f81dc 02-Jul-2014 lungtsai_lin <lungtsai_lin@htc.com> Bluetooth: Rename BTA_AVK_INCLUDED flag to BTA_AV_SINK_INCLUDED (bt_target.h)

Now OEM could enable/disable A2DP SINK role

Change-Id: I62cf17b0397a86c5f886a2c1ca724ca77a7f9bd4
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
/system/bt/btif/src/btif_media_task.c
afa6e1abbedaad8fe854b0f43999b8aeb801af91 28-Jun-2014 Matthew Xie <mattx@google.com> resolved conflicts for merge of e8c3d75b to master

Change-Id: I78ef69c4d54a36243620ae14296d3507e3339567
8e50f047de2999e89b6a19ec9bf513017fcde3f9 28-Jun-2014 Matthew Xie <mattx@google.com> resolved conflicts for merge of 6449e497 to master

Change-Id: I01ef7ea6c4ce49c9d775b355fb5b082b25ffbc39
e8c3d75b75493911ebf0f99c83676359657178f7 04-May-2014 Sharvil Nanavati <sharvil@google.com> Logging cleanup: BTIF and APPL.

Change-Id: I5b1214642bbb4b9aecc0fd2c899a6ec2c9793286
/system/bt/btif/src/btif_media_task.c
3e8a242fcbeebea2857fa964ca48624d8433333e 23-May-2014 Mike Lockwood <lockwood@google.com> More work on A2DP Sink:

Output audio data through A2DP audio HAL rather than playing directly
to native AudioTrack API.

Add separate HAL interface for A2DP sink

Change-Id: I6c6cb6088c350e104b4a7354f328b29c7178e295
/system/bt/btif/src/btif_media_task.c
ce24765fe7620c34e8d88ed4f826c8a6917582b2 20-Mar-2014 Hemant Gupta <hemantg@codeaurora.org> SBC Decoder for A2DP SINK

Change-Id: Ic8d1dd81d1788324ec140fe0d1379dfff33deb54
/system/bt/btif/src/btif_media_task.c
f7dd9f5779680da37dc89e5df2b26d436487818c 24-Oct-2013 Hemant Gupta <hemantg@codeaurora.org> Add A2DP Sink Support

Change-Id: I9affefdd2d00597545e49c593ef3bddb110d4c9c
/system/bt/btif/src/btif_media_task.c
1a3006f317b1b493dde1b80c4debbcf1bf5f6727 04-May-2014 Sharvil Nanavati <sharvil@google.com> Eliminate dead code (helped by compiler warnings).

I've removed all functions that the compiler decided were unused.

Change-Id: I0cbddf874ebd1586abe29b80e8d6390680679542
/system/bt/btif/src/btif_media_task.c
e7c4f99f1ca3da0ac46aa7425a37b383177c699f 05-Sep-2013 Hemant Gupta <hemantg@codeaurora.org> Bluetooth: On Suspend ignore media task timer event

On Recieving Suspend confirmation from remote device,
Media task timer reload and tx_timer is made false,
hence media task will not be stopped at that instant.
Media task timer expires causing buffer to be allocated.
Changes done to ensure buffer is allocated only if tx_timer
is true.

Change-Id: I971a82cccc64ba033475ad532b096862968de942
/system/bt/btif/src/btif_media_task.c
309243751678f395e6f7323e45433e5476dc17ef 23-May-2014 Mike Lockwood <lockwood@google.com> More work on A2DP Sink:

Output audio data through A2DP audio HAL rather than playing directly
to native AudioTrack API.

Add separate HAL interface for A2DP sink

Change-Id: I6c6cb6088c350e104b4a7354f328b29c7178e295
/system/bt/btif/src/btif_media_task.c
8e08ad12eae66877f9725ca2d66fc69fe6762340 20-Mar-2014 Hemant Gupta <hemantg@codeaurora.org> SBC Decoder for A2DP SINK

Change-Id: Ic8d1dd81d1788324ec140fe0d1379dfff33deb54
/system/bt/btif/src/btif_media_task.c
cc35559160745c60b42ae182002a59337d844d09 24-Oct-2013 Hemant Gupta <hemantg@codeaurora.org> Add A2DP Sink Support

Change-Id: I9affefdd2d00597545e49c593ef3bddb110d4c9c
/system/bt/btif/src/btif_media_task.c
6449e497dfe4d500810c3e7b4d7d056027c33a0e 06-Jun-2014 Sharvil Nanavati <sharvil@google.com> Eliminate more dead code in GKI.

Change-Id: I4c0000445535e5300b83a18f5f6ca45f1ef797da
/system/bt/btif/src/btif_media_task.c
740def526e757f5ea8f30d9d28d1e7a668dadc42 04-May-2014 Sharvil Nanavati <sharvil@google.com> Eliminate dead code (helped by compiler warnings).

I've removed all functions that the compiler decided were unused.

Change-Id: I0cbddf874ebd1586abe29b80e8d6390680679542
/system/bt/btif/src/btif_media_task.c
7e4c60ce7757d935901f53d1f21ecc696aa89979 05-Sep-2013 Hemant Gupta <hemantg@codeaurora.org> Bluetooth: On Suspend ignore media task timer event

On Recieving Suspend confirmation from remote device,
Media task timer reload and tx_timer is made false,
hence media task will not be stopped at that instant.
Media task timer expires causing buffer to be allocated.
Changes done to ensure buffer is allocated only if tx_timer
is true.

Change-Id: I971a82cccc64ba033475ad532b096862968de942
/system/bt/btif/src/btif_media_task.c
54db2c249efa91082c5a167a924a527ec73ff38d 13-Apr-2014 Sharvil Nanavati <sharvil@google.com> Remove executable bit on source files.

Change-Id: Id456478aea626f57fed3479346e8fb4dbd0fafa6
/system/bt/btif/src/btif_media_task.c
d2ccbbb73c7851d2fa28dc212d2fffc0ad4e5d50 13-Apr-2014 Sharvil Nanavati <sharvil@google.com> Remove executable bit on source files.

Change-Id: Id456478aea626f57fed3479346e8fb4dbd0fafa6
/system/bt/btif/src/btif_media_task.c
5cd8bff2dd0337cb52bf48f312e3d2d55a8882fb 01-Feb-2014 Mike J. Chen <mjchen@google.com> Major warnings cleanup

Mostly fixing unused parameter warnings.
A few other warnings also fixed like possible use of
unitialized variables (no real issue found, just compiler couldn't
follow the path), signed vs unsigned warning.

Also fixed some typos, indent issues, removal of dead code, etc.

Change-Id: I95eb887aefc4d559d7921f71a0af5f3bfb01ac01
Signed-off-by: Mike J. Chen <mjchen@google.com>
/system/bt/btif/src/btif_media_task.c
4aebca4662c280fdc32e0ad3705cae064bfa068d 19-Sep-2013 Zhihai Xu <zhihaixu@google.com> implement flow control to avoid dropping packets in btif_media_task.

implment flow conrol to save CPU usage and avoid dropping
packet in btif_media_task when overflow and cpu preemption happen.
when the packet count in the queue is above high watermark, we will
stopping adding packets, when the packet count in the queue is below
low watermark, we will start adding packets again.

bug:8252054
Change-Id: I3b7795dffbe5f2ae455e239a0234533f6cbb4403
/system/bt/btif/src/btif_media_task.c
01c686ce0051433d75605ff9ca4c3b7388ce3b6b 16-Sep-2013 Zhihai Xu <zhihaixu@google.com> should return correct length and use shorter poll time for ad2p data

the default poll timeout(100ms) is too long for a2dp data read,
because the a2dp timer pertiod to read data is 20ms. The poll timeout
should be far less than a2dp timer pertiod. also when poll timeout happen
for read, we should return the data length which we already read instead of 0.

bug:8252054
Change-Id: Ifa8587c6b7d127cbbbff76d9e20b630303b6379f
/system/bt/btif/src/btif_media_task.c
379743beded881127703334e1dda2cd327ec651d 29-Sep-2013 Zhihai Xu <zhihaixu@google.com> Failure to start playback on A2DP sink after connection

This is what happen:
after Headset is connected, we call start_audio_datapath which will send AVDTP_Start command to Headset,
Headset reject it with bad state. Bluedroid stack will ack failure to start_audio_datapath.
The next time we write audio data to bluetooth, we will call start_audio_datapath again to send AVDTP_Start command to Headset
Headset reject it with bad state again. Bluedroid stack will ack failure to start_audio_datapath.
When the third time we call start_audio_datapath, right at that time we receive AVDTP_Start command from Headset.
Handle AVDTP_Start command and Handle start_audio_datapath are in two different threads.
Handle AVDTP_Start command is in btu_task thread.
Handle start_audio_datapath() is in btif_task thread.
We have race condition in this case
Because when btif_task processed BTIF_AV_START_STREAM_REQ_EVT(triggered by start_audio_datapath),
it don't know we receive AVDTP_Start command which is processed in btu_task.
btif_task will send a message BTA_AV_API_START_EVT to btu_task, which will be handled by bta_av_do_start.
AVDTP_start command from headset is handled by bta_av_start_ok.
bta_av_start_ok will send BTA_AV_START_EVT with suspending true to btif_task and send AVDTP_Suspend command
to headset to suspend the AVDTP for reconfiguration purpose.

in bta_av_do_start, we will check whether the AVDTP is already started, we will know the AVDTP is already start at this time because
bta_av_do_start is also running in btu_task. We will send BTA_AV_START_EVT with success to btif_task.

In the btif_task, BTA_AV_START_EVT will be processed by btif_av_state_opened_handler:
For the first BTA_AV_START_EVT with suspending true sent by bta_av_start_ok, it will ignore it:
if ((p_av->start.status == BTA_SUCCESS) && (p_av->start.suspending == TRUE))
return TRUE;
For the second BTA_AV_START_EVT with success sent by bta_av_do_start , it will ack success to start_audio_datapath, and change to
BTIF_AV_STATE_STARTED/BTAV_AUDIO_STATE_STARTED, after receive success ack from bluedroid stack, we will start send Audio data to bluetooth.

At last we received AVDTP_Suspend response accept from Headset, we will send BTA_AV_SUSPEND_EVT to btif_task, which will be
handled by btif_av_state_started_handler. It will call btif_a2dp_on_suspended and call audio_state_cb with new audio state
BTAV_AUDIO_STATE_STOPPED.
so The state between bluedroid stack and audio data path is out of sync.
The fix is to send failure message if we know we suspend AVDTP in bta_av_do_start,
also make sure we won't miss acknowledgement for pending start if we exit opened state,
to avoid audio data path dead lock.

bug:10953908
Change-Id: I1704839977324b7c4e234eb843cddf3719e10d2c
/system/bt/btif/src/btif_media_task.c
b8ceaa484a09be14263d5f10d022a272f9602378 05-Apr-2013 Mattias Agren <magren@broadcom.com> Set default a2dp sbc encoding quality to high

* Increased bitpool to high quality setting (53). * Added rate quality
reduction to medium quality for basic rate connections * Enhanced
a2dp frame calculation ratio to smooth out frame distrubution * Removed
iop scaling patch.

Bug 8252054

Change-Id: I20725d0decfe5f820e1c03407889b6272e830aca
/system/bt/btif/src/btif_media_task.c
5fd74f06caab4324d0ba69df86ad5170c072ec64 05-Apr-2013 Mattias Agren <magren@broadcom.com> Stability fixes for a2dp hal control path

Ensure av statemachine is preventing a2dp hal to restart the stream
when not ready. This prevents ending up in a scenario where a2dp hal
locks up. Code cleanup.
bug 7002859

Change-Id: I3f3eeaab4ca185733b8b0042ed2cfa701f76a203
/system/bt/btif/src/btif_media_task.c
45f5f9077c773b9d4533fef13045b5ff77e32e46 08-Feb-2013 Ganesh Ganapathi Batta <ganeshg@broadcom.com> Resolved partial uipc channel read issue

When partial data is read the previously read size wasn't
compensated for. Ensure we don't transmit empty a2dp frames in case
of underrun
Bug 8026551

Change-Id: I4195ed798008378b93343bf7cd266c6e2f11b094
/system/bt/btif/src/btif_media_task.c
5738f83aeb59361a0a2eda2460113f6dc9194271 13-Dec-2012 The Android Open Source Project <initial-contribution@android.com> Snapshot cdeccf6fdd8c2d494ea2867cb37a025bf8879baf

Change-Id: Ia2de32ccb97a9641462c72363b0a8c4288f4f36d
/system/bt/btif/src/btif_media_task.c