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
diff --git a/btif/src/btif_media_task.c b/btif/src/btif_media_task.c
index 01d5290..7338946 100644
--- a/btif/src/btif_media_task.c
+++ b/btif/src/btif_media_task.c
@@ -510,8 +510,11 @@
 
                 /* post start event and wait for audio path to open */
                 btif_dispatch_sm_event(BTIF_AV_START_STREAM_REQ_EVT, NULL, 0);
-//FIXME
-                a2dp_cmd_acknowledge(A2DP_CTRL_ACK_SUCCESS);
+
+#if (BTA_AV_SINK_INCLUDED == TRUE)
+                if (btif_media_cb.peer_sep == AVDT_TSEP_SRC)
+                    a2dp_cmd_acknowledge(A2DP_CTRL_ACK_SUCCESS);
+#endif
             }
             else if (btif_av_stream_started_ready())
             {