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

Commit c4b88a8d authored by Glenn Kasten's avatar Glenn Kasten
Browse files

Fix bug for direct track with PCM != 16-bit

The AUDIO_FORMAT_PCM_8_BIT format was being converted to
AUDIO_FORMAT_PCM_16_BIT on client side even for direct tracks.
That conversion was incorrect; it should only be done for mixed tracks.

Also remove checks for specific PCM formats in the generic part of
server side of createTrack.  Those format checks should only be done by
the thread.  This will allow direct tracks for PCM 8-bit, PCM 24-bit, etc.

Change-Id: If5b9fd79f8642ed93e2aeabcaf4809b2ed798978
parent b53fc4ef
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -1005,7 +1005,8 @@ status_t AudioTrack::createTrack_l(size_t epoch)
    sp<IAudioTrack> track = audioFlinger->createTrack(mStreamType,
                                                      mSampleRate,
                                                      // AudioFlinger only sees 16-bit PCM
                                                      mFormat == AUDIO_FORMAT_PCM_8_BIT ?
                                                      mFormat == AUDIO_FORMAT_PCM_8_BIT &&
                                                          !(mFlags & AUDIO_OUTPUT_FLAG_DIRECT) ?
                                                              AUDIO_FORMAT_PCM_16_BIT : mFormat,
                                                      mChannelMask,
                                                      &temp,
+2 −4
Original line number Diff line number Diff line
@@ -541,10 +541,8 @@ sp<IAudioTrack> AudioFlinger::createTrack(
        goto Exit;
    }

    // client is responsible for conversion of 8-bit PCM to 16-bit PCM,
    // and we don't yet support 8.24 or 32-bit PCM
    if (!audio_is_valid_format(format) ||
            (audio_is_linear_pcm(format) && format != AUDIO_FORMAT_PCM_16_BIT)) {
    // further format checks are performed by createTrack_l() depending on the thread type
    if (!audio_is_valid_format(format)) {
        ALOGE("createTrack() invalid format %#x", format);
        lStatus = BAD_VALUE;
        goto Exit;