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

Commit 230b188b authored by Wei Jia's avatar Wei Jia
Browse files

mediaplayer: check existence of AudioTrack before trying to access it.

Bug: 19828971
Change-Id: Ib7fdb8bf36e33ef95d21fa5342cd1647fd81ff24
parent 802a568f
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -566,12 +566,22 @@ size_t NuPlayer::Renderer::fillAudioBuffer(void *buffer, size_t size) {
}

bool NuPlayer::Renderer::onDrainAudioQueue() {
#if 0
    // TODO: This call to getPosition checks if AudioTrack has been created
    // in AudioSink before draining audio. If AudioTrack doesn't exist, then
    // CHECKs on getPosition will fail.
    // We still need to figure out why AudioTrack is not created when
    // this function is called. One possible reason could be leftover
    // audio. Another possible place is to check whether decoder
    // has received INFO_FORMAT_CHANGED as the first buffer since
    // AudioSink is opened there, and possible interactions with flush
    // immediately after start. Investigate error message
    // "vorbis_dsp_synthesis returned -135", along with RTSP.
    uint32_t numFramesPlayed;
    if (mAudioSink->getPosition(&numFramesPlayed) != OK) {
        return false;
    }

#if 0
    ssize_t numFramesAvailableToWrite =
        mAudioSink->frameCount() - (mNumFramesWritten - numFramesPlayed);