• Andre Eisenbach's avatar
    Avoid race condition in SBC encoder initialization · ae13ec98
    Andre Eisenbach authored
    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
    ae13ec98
btif_av.c 42.8 KB