Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9a11fb48 authored by Sidipotu Ashok's avatar Sidipotu Ashok Committed by Giulio Cervera
Browse files

libstagefright: LPAPlayer: Fix choppy playback on BT.

-Music playback on BT A2DP device is choppy/glitchy
-Decoder thread hogs the CPU this starves A2DP thread from data.
-Fix is to use small buffer(64k) only in the case of A2DP playback.

CRs-Fixed: 33353851
(cherry picked from commit e64bb36f81b22c93d3af156451b1236966c99ea4)

Conflicts:

	media/libstagefright/LPAPlayer.cpp

Change-Id: I2e9450a2be6f9e79e68d525d2119d33154d132b7
parent 6077d33a
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -45,6 +45,8 @@
namespace android {
int LPAPlayer::objectsAlive = 0;

#define BT_A2DP_BUFFER_SIZE 65536

LPAPlayer::LPAPlayer(
                    const sp<MediaPlayerBase::AudioSink> &audioSink, bool &initCheck,
                    AwesomePlayer *observer)
@@ -774,9 +776,15 @@ void LPAPlayer::decoderThreadEntry() {
        //Queue up the buffers for writing either for A2DP or LPA Driver
        else {
            struct msm_audio_aio_buf aio_buf_local;
            int numOfBytes = 0;

            if (bIsA2DPEnabled)
                numOfBytes = BT_A2DP_BUFFER_SIZE;
            else
                numOfBytes = MEM_BUFFER_SIZE;

            LOGV("Calling fillBuffer for size %d",MEM_BUFFER_SIZE);
            buf.bytesToWrite = fillBuffer(buf.localBuf, MEM_BUFFER_SIZE);
            LOGV("Calling fillBuffer for size %d",numOfBytes);
            buf.bytesToWrite = fillBuffer(buf.localBuf, numOfBytes);
            LOGV("fillBuffer returned size %d",buf.bytesToWrite);

            /* TODO: Check if we have to notify the app if an error occurs */