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

Commit bffd540a authored by Andy Hung's avatar Andy Hung Committed by Automerger Merge Worker
Browse files

Merge "AudioTrack: Obtain stream type from AudioFlinger" into sc-dev am: 1b5a6da8

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/av/+/15340983

Change-Id: I458136f4c3144c24fd6bdb44e062239eee4f5331
parents 99fafb71 1b5a6da8
Loading
Loading
Loading
Loading
+6 −9
Original line number Diff line number Diff line
@@ -472,7 +472,7 @@ status_t AudioTrack::set(
            status = BAD_VALUE;
            goto exit;
        }
        mStreamType = streamType;
        mOriginalStreamType = streamType;

    } else {
        // stream type shouldn't be looked at, this track has audio attributes
@@ -481,7 +481,7 @@ status_t AudioTrack::set(
                " usage=%d content=%d flags=0x%x tags=[%s]",
                __func__,
                 mAttributes.usage, mAttributes.content_type, mAttributes.flags, mAttributes.tags);
        mStreamType = AUDIO_STREAM_DEFAULT;
        mOriginalStreamType = AUDIO_STREAM_DEFAULT;
        audio_flags_to_audio_output_flags(mAttributes.flags, &flags);
    }

@@ -1605,9 +1605,6 @@ status_t AudioTrack::attachAuxEffect(int effectId)

audio_stream_type_t AudioTrack::streamType() const
{
    if (mStreamType == AUDIO_STREAM_DEFAULT) {
        return AudioSystem::attributesToStreamType(mAttributes);
    }
    return mStreamType;
}

@@ -1688,8 +1685,9 @@ status_t AudioTrack::createTrack_l()
    }

    IAudioFlinger::CreateTrackInput input;
    if (mStreamType != AUDIO_STREAM_DEFAULT) {
        input.attr = AudioSystem::streamTypeToAttributes(mStreamType);
    if (mOriginalStreamType != AUDIO_STREAM_DEFAULT) {
        // Legacy: This is based on original parameters even if the track is recreated.
        input.attr = AudioSystem::streamTypeToAttributes(mOriginalStreamType);
    } else {
        input.attr = mAttributes;
    }
@@ -1745,6 +1743,7 @@ status_t AudioTrack::createTrack_l()
    mNotificationFramesAct = (uint32_t)output.notificationFrameCount;
    mRoutedDeviceId = output.selectedDeviceId;
    mSessionId = output.sessionId;
    mStreamType = output.streamType;

    mSampleRate = output.sampleRate;
    if (mOriginalSampleRate == 0) {
@@ -3284,8 +3283,6 @@ status_t AudioTrack::dump(int fd, const Vector<String16>& args __unused) const
    result.appendFormat("  id(%d) status(%d), state(%d), session Id(%d), flags(%#x)\n",
                        mPortId, mStatus, mState, mSessionId, mFlags);
    result.appendFormat("  stream type(%d), left - right volume(%f, %f)\n",
                        (mStreamType == AUDIO_STREAM_DEFAULT) ?
                            AudioSystem::attributesToStreamType(mAttributes) :
                            mStreamType,
                        mVolume[AUDIO_INTERLEAVE_LEFT], mVolume[AUDIO_INTERLEAVE_RIGHT]);
    result.appendFormat("  format(%#x), channel mask(%#x), channel count(%u)\n",
+4 −0
Original line number Diff line number Diff line
@@ -101,6 +101,8 @@ IAudioFlinger::CreateTrackOutput::toAidl() const {
            legacy2aidl_audio_port_handle_t_int32_t(selectedDeviceId));
    aidl.sessionId = VALUE_OR_RETURN(legacy2aidl_audio_session_t_int32_t(sessionId));
    aidl.sampleRate = VALUE_OR_RETURN(convertIntegral<int32_t>(sampleRate));
    aidl.streamType =  VALUE_OR_RETURN(
            legacy2aidl_audio_stream_type_t_AudioStreamType(streamType));
    aidl.afFrameCount = VALUE_OR_RETURN(convertIntegral<int64_t>(afFrameCount));
    aidl.afSampleRate = VALUE_OR_RETURN(convertIntegral<int32_t>(afSampleRate));
    aidl.afLatencyMs = VALUE_OR_RETURN(convertIntegral<int32_t>(afLatencyMs));
@@ -122,6 +124,8 @@ IAudioFlinger::CreateTrackOutput::fromAidl(
            aidl2legacy_int32_t_audio_port_handle_t(aidl.selectedDeviceId));
    legacy.sessionId = VALUE_OR_RETURN(aidl2legacy_int32_t_audio_session_t(aidl.sessionId));
    legacy.sampleRate = VALUE_OR_RETURN(convertIntegral<uint32_t>(aidl.sampleRate));
    legacy.streamType = VALUE_OR_RETURN(
            aidl2legacy_AudioStreamType_audio_stream_type_t(aidl.streamType));
    legacy.afFrameCount = VALUE_OR_RETURN(convertIntegral<size_t>(aidl.afFrameCount));
    legacy.afSampleRate = VALUE_OR_RETURN(convertIntegral<uint32_t>(aidl.afSampleRate));
    legacy.afLatencyMs = VALUE_OR_RETURN(convertIntegral<uint32_t>(aidl.afLatencyMs));
+2 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package android.media;

import android.media.AudioStreamType;
import android.media.IAudioTrack;

/**
@@ -34,6 +35,7 @@ parcelable CreateTrackResponse {
    int selectedDeviceId;
    int sessionId;
    int sampleRate;
    AudioStreamType streamType;
    long afFrameCount;
    int afSampleRate;
    int afLatencyMs;
+3 −2
Original line number Diff line number Diff line
@@ -1164,8 +1164,9 @@ public:

    // constant after constructor or set()
    audio_format_t          mFormat;                // as requested by client, not forced to 16-bit
    audio_stream_type_t     mStreamType;            // mStreamType == AUDIO_STREAM_DEFAULT implies
                                                    // this AudioTrack has valid attributes
    // mOriginalStreamType == AUDIO_STREAM_DEFAULT implies this AudioTrack has valid attributes
    audio_stream_type_t     mOriginalStreamType = AUDIO_STREAM_DEFAULT;
    audio_stream_type_t     mStreamType = AUDIO_STREAM_DEFAULT;
    uint32_t                mChannelCount;
    audio_channel_mask_t    mChannelMask;
    sp<IMemory>             mSharedBuffer;
+1 −0
Original line number Diff line number Diff line
@@ -110,6 +110,7 @@ public:

        /* output */
        uint32_t sampleRate;
        audio_stream_type_t streamType;
        size_t   afFrameCount;
        uint32_t afSampleRate;
        uint32_t afLatencyMs;
Loading