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

Commit 23aea977 authored by Android (Google) Code Review's avatar Android (Google) Code Review
Browse files

Merge change 9674

* changes:
  Fix problem in AudioTrack with 8 bit PCM and direct output.
parents fa2877b9 3302526f
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -744,7 +744,7 @@ ssize_t AudioTrack::write(const void* buffer, size_t userSize)

        size_t toWrite;

        if (mFormat == AudioSystem::PCM_8_BIT) {
        if (mFormat == AudioSystem::PCM_8_BIT && !(mFlags & AudioSystem::OUTPUT_FLAG_DIRECT)) {
            // Divide capacity by 2 to take expansion into account
            toWrite = audioBuffer.size>>1;
            // 8 to 16 bit conversion
@@ -840,7 +840,7 @@ bool AudioTrack::processAudioBuffer(const sp<AudioTrackThread>& thread)
        // Divide buffer size by 2 to take into account the expansion
        // due to 8 to 16 bit conversion: the callback must fill only half
        // of the destination buffer
        if (mFormat == AudioSystem::PCM_8_BIT) {
        if (mFormat == AudioSystem::PCM_8_BIT && !(mFlags & AudioSystem::OUTPUT_FLAG_DIRECT)) {
            audioBuffer.size >>= 1;
        }

@@ -859,7 +859,7 @@ bool AudioTrack::processAudioBuffer(const sp<AudioTrackThread>& thread)
        }
        if (writtenSize > reqSize) writtenSize = reqSize;

        if (mFormat == AudioSystem::PCM_8_BIT) {
        if (mFormat == AudioSystem::PCM_8_BIT && !(mFlags & AudioSystem::OUTPUT_FLAG_DIRECT)) {
            // 8 to 16 bit conversion
            const int8_t *src = audioBuffer.i8 + writtenSize-1;
            int count = writtenSize;