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

Commit 7a6f79bc authored by Ajender Reddy's avatar Ajender Reddy
Browse files

audio: add setParameters support in IAudioRecord

IAudioRecord::setParameters is restricted for the
DIRECT thread only.

Reason,this is used to send metadata info for the direct
record where the encoding happens with the Audio HAL.


Bug: 245550345

Test: m

Change-Id: I413dadd1f92be110d9e28e0d126eb9cf67b6d67e
parent e2bc76b9
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -50,4 +50,7 @@ interface IAudioRecord {
  void setPreferredMicrophoneFieldDimension(float zoom);

  void shareAudioHistory(@utf8InCpp String sharedAudioPackageName, long sharedAudioStartMs);

  /** Send parameters to the audio hardware. */
  void setParameters(@utf8InCpp String keyValuePairs);
}
+1 −0
Original line number Diff line number Diff line
@@ -528,6 +528,7 @@ public:
    virtual status_t setPreferredMicrophoneFieldDimension(float zoom) = 0;
    virtual status_t shareAudioHistory(
            const std::string& sharedAudioPackageName, int64_t sharedAudioStartMs) = 0;
    virtual status_t setParameters(const String8& keyValuePairs) = 0;
    virtual int32_t startFrames() const = 0;

    static bool checkServerLatencySupported(audio_format_t format, audio_input_flags_t flags) {
+1 −0
Original line number Diff line number Diff line
@@ -83,6 +83,7 @@ public:
    status_t setPreferredMicrophoneFieldDimension(float zoom) final;
    status_t shareAudioHistory(const std::string& sharedAudioPackageName,
            int64_t sharedAudioStartMs) final;
    status_t setParameters(const String8& keyValuePairs) final;
    int32_t startFrames() const final { return mStartFrames; }

    using SinkMetadatas = std::vector<record_track_metadata_v7_t>;
+18 −0
Original line number Diff line number Diff line
@@ -2651,6 +2651,7 @@ public:
    binder::Status setPreferredMicrophoneFieldDimension(float zoom) final;
    binder::Status shareAudioHistory(
            const std::string& sharedAudioPackageName, int64_t sharedAudioStartMs) final;
    binder::Status setParameters(const ::std::string& keyValuePairs) final;

private:
    const sp<IAfRecordTrack> mRecordTrack;
@@ -2720,6 +2721,11 @@ binder::Status RecordHandle::shareAudioHistory(
            mRecordTrack->shareAudioHistory(sharedAudioPackageName, sharedAudioStartMs));
}

binder::Status RecordHandle::setParameters(const ::std::string& keyValuePairs) {
    return binderStatusFromStatusT(mRecordTrack->setParameters(
            String8(keyValuePairs.c_str())));
}

// ----------------------------------------------------------------------------
#undef LOG_TAG
#define LOG_TAG "AF::RecordTrack"
@@ -3116,6 +3122,18 @@ status_t RecordTrack::shareAudioHistory(
    }
}

status_t RecordTrack::setParameters(const String8& keyValuePairs) {
    const sp<IAfThreadBase> thread = mThread.promote();
    if (thread == nullptr) {
        ALOGE("%s(%d): thread is dead", __func__, mId);
        return FAILED_TRANSACTION;
    } else if (thread->type() == IAfThreadBase::DIRECT) {
        return thread->setParameters(keyValuePairs);
    } else {
        return PERMISSION_DENIED;
    }
}

void RecordTrack::copyMetadataTo(MetadataInserter& backInserter) const
{