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

Commit ffc2e067 authored by Naresh Tanniru's avatar Naresh Tanniru Committed by Bruno Martins
Browse files

audiopolicy: make audio policy extensible

make function virtual or protected so that
they can be extended in custom audio policy.
Change-Id: Ida7992f6b327491fab1f4ea376e85e8eb34b89ca

audiopolicy: update APM to use custom audio policy configuration
Change-Id: I3161ff4fa41d37d0b761202f0b3a490d9c7e418e

audiopolicy: allow dp device selection for voice usecases
Change-Id: I13f1ddd0fd3655376d28a0ebe028d495fa2c6e5f

audiopolicy: follow-up change to support extended feature
Change-Id: Iddc14a3e2e61bc57f8637eae71e36cc21ce2d3e8

[dianlujitao: Port to R]

Change-Id: Ida7992f6b327491fab1f4ea376e85e8eb34b89ca
parent 3a148056
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -35,7 +35,7 @@ static const uint32_t SONIFICATION_RESPECTFUL_AFTER_MUSIC_DELAY = 5000;

// For mixed output and inputs, the policy will use max mixer sampling rates.
// Do not limit sampling rate otherwise
#define SAMPLE_RATE_HZ_MAX 192000
#define SAMPLE_RATE_HZ_MAX 384000

// Used when a client opens a capture stream, without specifying a desired sample rate.
#define SAMPLE_RATE_HZ_DEFAULT 48000
+1 −1
Original line number Diff line number Diff line
@@ -305,6 +305,7 @@ public:

    DeviceVector mDevices; /**< current devices this output is routed to */
    wp<AudioPolicyMix> mPolicyMix;  // non NULL when used by a dynamic policy
    audio_io_handle_t mIoHandle;           // output handle

protected:
    const sp<PolicyAudioPort> mPolicyAudioPort;
@@ -404,7 +405,6 @@ public:
    DeviceVector filterSupportedDevices(const DeviceVector &devices) const;

    const sp<IOProfile> mProfile;          // I/O profile this output derives from
    audio_io_handle_t mIoHandle;           // output handle
    uint32_t mLatency;                  //
    audio_output_flags_t mFlags;   //
    sp<SwAudioOutputDescriptor> mOutput1;    // used by duplicated outputs: first output
+2 −2
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@ static const DeviceTypeSet& getAllOutRemoteDevices() {

AudioOutputDescriptor::AudioOutputDescriptor(const sp<PolicyAudioPort>& policyAudioPort,
                                             AudioPolicyClientInterface *clientInterface)
    : mPolicyAudioPort(policyAudioPort), mClientInterface(clientInterface)
    : mIoHandle(AUDIO_IO_HANDLE_NONE), mPolicyAudioPort(policyAudioPort), mClientInterface(clientInterface)
{
    if (mPolicyAudioPort.get() != nullptr) {
        mPolicyAudioPort->pickAudioProfile(mSamplingRate, mChannelMask, mFormat);
@@ -278,7 +278,7 @@ void AudioOutputDescriptor::log(const char* indent)
SwAudioOutputDescriptor::SwAudioOutputDescriptor(const sp<IOProfile>& profile,
                                                 AudioPolicyClientInterface *clientInterface)
    : AudioOutputDescriptor(profile, clientInterface),
    mProfile(profile), mIoHandle(AUDIO_IO_HANDLE_NONE), mLatency(0),
    mProfile(profile), mLatency(0),
    mFlags((audio_output_flags_t)0),
    mOutput1(0), mOutput2(0), mDirectOpenCount(0),
    mDirectClientSession(AUDIO_SESSION_NONE)
+12 −0
Original line number Diff line number Diff line
@@ -39,6 +39,11 @@ public:

    audio_mode_t getPhoneState() const override { return mPhoneState; }

    void setDpConnAndAllowedForVoice(bool connAndAllowed) override
    {
        mDpConnAndAllowedForVoice = connAndAllowed;
    }

    status_t setForceUse(audio_policy_force_use_t usage, audio_policy_forced_cfg_t config) override
    {
        mForceUse[usage] = config;
@@ -118,6 +123,11 @@ public:
        return is_state_in_call(getPhoneState());
    }

    inline bool getDpConnAndAllowedForVoice() const
    {
        return mDpConnAndAllowedForVoice;
    }

    VolumeSource toVolumeSource(audio_stream_type_t stream) const
    {
        return static_cast<VolumeSource>(getVolumeGroupForStreamType(stream));
@@ -135,6 +145,8 @@ private:
    VolumeGroupMap mVolumeGroups;
    LastRemovableMediaDevices mLastRemovableMediaDevices;
    audio_mode_t mPhoneState = AUDIO_MODE_NORMAL;  /**< current phone state. */
    /* if display-port is connected and can be used for voip/voice */
    bool mDpConnAndAllowedForVoice;

    /** current forced use configuration. */
    audio_policy_forced_cfg_t mForceUse[AUDIO_POLICY_FORCE_USE_CNT] = {};
+8 −0
Original line number Diff line number Diff line
@@ -72,6 +72,14 @@ public:
     */
    virtual audio_mode_t getPhoneState() const = 0;

    /**
     * Set whether display-port is connected and is allowed to be used
     * for voice usecases
     *
     * @param[in] connAndAllowed: if display-port is connected and can be used
     */
    virtual void setDpConnAndAllowedForVoice(bool connAndAllowed) = 0;

    /**
     * Set Force Use config for a given usage.
     *
Loading