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

Unverified Commit c383d49a authored by Naresh Tanniru's avatar Naresh Tanniru Committed by Rashed Abdel-Tawab
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

Change-Id: Ida7992f6b327491fab1f4ea376e85e8eb34b89ca
parent 8d3bfcbb
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@ static const audio_format_t gDynamicFormat = AUDIO_FORMAT_DEFAULT;

// 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
@@ -78,6 +78,7 @@ public:

    sp<AudioPort>       mPort;
    audio_devices_t mDevice;                   // current device this output is routed to
    audio_io_handle_t mIoHandle;           // output handle
    uint32_t mRefCount[AUDIO_STREAM_CNT]; // number of streams of each type using this output
    nsecs_t mStopTime[AUDIO_STREAM_CNT];
    float mCurVolume[AUDIO_STREAM_CNT];   // current stream volume in dB
@@ -138,7 +139,6 @@ public:
                                     audio_io_handle_t *ioHandle);

    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;   //
    AudioMix *mPolicyMix;             // non NULL when used by a dynamic policy
+2 −2
Original line number Diff line number Diff line
@@ -34,7 +34,7 @@ namespace android {

AudioOutputDescriptor::AudioOutputDescriptor(const sp<AudioPort>& port,
                                             AudioPolicyClientInterface *clientInterface)
    : mPort(port), mDevice(AUDIO_DEVICE_NONE),
    : mPort(port), mDevice(AUDIO_DEVICE_NONE), mIoHandle(AUDIO_IO_HANDLE_NONE),
      mClientInterface(clientInterface), mPatchHandle(AUDIO_PATCH_HANDLE_NONE), mId(0)
{
    // clear usage count for all stream types
@@ -222,7 +222,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), mPolicyMix(NULL),
    mOutput1(0), mOutput2(0), mDirectOpenCount(0),
    mDirectClientSession(AUDIO_SESSION_NONE), mGlobalRefCount(0)
+8 −0
Original line number Diff line number Diff line
@@ -101,6 +101,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.
     *
+19 −0
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ namespace audio_policy
Engine::Engine()
    : mManagerInterface(this),
      mPhoneState(AUDIO_MODE_NORMAL),
      mDpConnAndAllowedForVoice(false),
      mApmObserver(NULL)
{
    for (int i = 0; i < AUDIO_POLICY_FORCE_USE_CNT; i++) {
@@ -62,6 +63,11 @@ status_t Engine::initCheck()
    return (mApmObserver != NULL) ?  NO_ERROR : NO_INIT;
}

void Engine::setDpConnAndAllowedForVoice(bool connAndAllowed)
{
    mDpConnAndAllowedForVoice = connAndAllowed;
}

status_t Engine::setPhoneState(audio_mode_t state)
{
    ALOGV("setPhoneState() state %d", state);
@@ -367,6 +373,10 @@ audio_devices_t Engine::getDeviceForStrategyInt(routing_strategy strategy,
            if (device) break;
            device = availableOutputDevicesType & AUDIO_DEVICE_OUT_USB_DEVICE;
            if (device) break;
            if (getDpConnAndAllowedForVoice() && isInCall()) {
                device = availableOutputDevicesType & AUDIO_DEVICE_OUT_AUX_DIGITAL;
                if (device) break;
            }
            if (!isInCall()) {
                device = availableOutputDevicesType & AUDIO_DEVICE_OUT_USB_ACCESSORY;
                if (device) break;
@@ -465,6 +475,15 @@ audio_devices_t Engine::getDeviceForStrategyInt(routing_strategy strategy,
                }
            }
        }
        // if display-port is connected and being used in voice usecase,
        // play ringtone over speaker and display-port
        if ((strategy == STRATEGY_SONIFICATION) && getDpConnAndAllowedForVoice()) {
             uint32_t device2 = availableOutputDevicesType & AUDIO_DEVICE_OUT_AUX_DIGITAL;
             if (device2 != AUDIO_DEVICE_NONE) {
                 device |= device2;
                 break;
             }
        }
        // The second device used for sonification is the same as the device used by media strategy
        // FALL THROUGH

Loading