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

Commit ac4e764d authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "aaudio: honor requested device in Legacy mode"

parents ea5523d8 ee995399
Loading
Loading
Loading
Loading
+11 −7
Original line number Diff line number Diff line
@@ -98,12 +98,15 @@ aaudio_result_t AudioStreamRecord::open(const AudioStreamBuilder& builder)

    ALOGD("open(), request notificationFrames = %u, frameCount = %u",
          notificationFrames, (uint)frameCount);

    // Don't call mAudioRecord->setInputDevice() because it will be overwritten by set()!
    audio_port_handle_t selectedDeviceId = (getDeviceId() == AAUDIO_UNSPECIFIED)
                                           ? AUDIO_PORT_HANDLE_NONE
                                           : getDeviceId();

    mAudioRecord = new AudioRecord(
            mOpPackageName // const String16& opPackageName TODO does not compile
            );
    if (getDeviceId() != AAUDIO_UNSPECIFIED) {
        mAudioRecord->setInputDevice(getDeviceId());
    }
    mAudioRecord->set(
            AUDIO_SOURCE_VOICE_RECOGNITION,
            getSampleRate(),
@@ -116,10 +119,11 @@ aaudio_result_t AudioStreamRecord::open(const AudioStreamBuilder& builder)
            false /*threadCanCallJava*/,
            AUDIO_SESSION_ALLOCATE,
            streamTransferType,
            flags
            //   int uid = -1,
            //   pid_t pid = -1,
            //   const audio_attributes_t* pAttributes = nullptr
            flags,
            AUDIO_UID_INVALID, // DEFAULT uid
            -1,                // DEFAULT pid
            NULL,              // DEFAULT audio_attributes_t
            selectedDeviceId
            );

    // Did we get a valid track?
+20 −8
Original line number Diff line number Diff line
@@ -115,10 +115,13 @@ aaudio_result_t AudioStreamTrack::open(const AudioStreamBuilder& builder)

    ALOGD("open(), request notificationFrames = %d, frameCount = %u",
          notificationFrames, (uint)frameCount);
    mAudioTrack = new AudioTrack(); // TODO review
    if (getDeviceId() != AAUDIO_UNSPECIFIED) {
        mAudioTrack->setOutputDevice(getDeviceId());
    }

    // Don't call mAudioTrack->setDeviceId() because it will be overwritten by set()!
    audio_port_handle_t selectedDeviceId = (getDeviceId() == AAUDIO_UNSPECIFIED)
                                           ? AUDIO_PORT_HANDLE_NONE
                                           : getDeviceId();

    mAudioTrack = new AudioTrack();
    mAudioTrack->set(
            (audio_stream_type_t) AUDIO_STREAM_MUSIC,
            getSampleRate(),
@@ -129,10 +132,19 @@ aaudio_result_t AudioStreamTrack::open(const AudioStreamBuilder& builder)
            callback,
            callbackData,
            notificationFrames,
            0 /*sharedBuffer*/,
            false /*threadCanCallJava*/,
            0,       // DEFAULT sharedBuffer*/,
            false,   // DEFAULT threadCanCallJava
            AUDIO_SESSION_ALLOCATE,
            streamTransferType
            streamTransferType,
            NULL,    // DEFAULT audio_offload_info_t
            AUDIO_UID_INVALID, // DEFAULT uid
            -1,      // DEFAULT pid
            NULL,    // DEFAULT audio_attributes_t
            // WARNING - If doNotReconnect set true then audio stops after plugging and unplugging
            // headphones a few times.
            false,   // DEFAULT doNotReconnect,
            1.0f,    // DEFAULT maxRequiredSpeed
            selectedDeviceId
    );

    // Did we get a valid track?