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

Commit b3e06a75 authored by Jean-Michel Trivi's avatar Jean-Michel Trivi Committed by Android (Google) Code Review
Browse files

Merge "AudioPolicy: AudioOutputDescriptor set/get for patch handle" into nyc-dev

parents 0d035b60 ff155c64
Loading
Loading
Loading
Loading
+4 −1
Original line number Original line Diff line number Diff line
@@ -71,9 +71,11 @@ public:


    audio_module_handle_t getModuleHandle() const;
    audio_module_handle_t getModuleHandle() const;


    audio_patch_handle_t getPatchHandle() const { return mPatchHandle; };
    void setPatchHandle(audio_patch_handle_t handle) { mPatchHandle = handle; };

    sp<AudioPort>       mPort;
    sp<AudioPort>       mPort;
    audio_devices_t mDevice;                   // current device this output is routed to
    audio_devices_t mDevice;                   // current device this output is routed to
    audio_patch_handle_t mPatchHandle;
    uint32_t mRefCount[AUDIO_STREAM_CNT]; // number of streams of each type using this output
    uint32_t mRefCount[AUDIO_STREAM_CNT]; // number of streams of each type using this output
    nsecs_t mStopTime[AUDIO_STREAM_CNT];
    nsecs_t mStopTime[AUDIO_STREAM_CNT];
    float mCurVolume[AUDIO_STREAM_CNT];   // current stream volume in dB
    float mCurVolume[AUDIO_STREAM_CNT];   // current stream volume in dB
@@ -83,6 +85,7 @@ public:
    AudioPolicyClientInterface *mClientInterface;
    AudioPolicyClientInterface *mClientInterface;


protected:
protected:
    audio_patch_handle_t mPatchHandle;
    audio_port_handle_t mId;
    audio_port_handle_t mId;
};
};


+1 −1
Original line number Original line Diff line number Diff line
@@ -34,7 +34,7 @@ namespace android {
AudioOutputDescriptor::AudioOutputDescriptor(const sp<AudioPort>& port,
AudioOutputDescriptor::AudioOutputDescriptor(const sp<AudioPort>& port,
                                             AudioPolicyClientInterface *clientInterface)
                                             AudioPolicyClientInterface *clientInterface)
    : mPort(port), mDevice(AUDIO_DEVICE_NONE),
    : mPort(port), mDevice(AUDIO_DEVICE_NONE),
      mPatchHandle(0), mClientInterface(clientInterface), mId(0)
      mClientInterface(clientInterface), mPatchHandle(0), mId(0)
{
{
    // clear usage count for all stream types
    // clear usage count for all stream types
    for (int i = 0; i < AUDIO_STREAM_CNT; i++) {
    for (int i = 0; i < AUDIO_STREAM_CNT; i++) {
+8 −8
Original line number Original line Diff line number Diff line
@@ -3939,7 +3939,7 @@ void AudioPolicyManager::closeOutput(audio_io_handle_t output)


    nextAudioPortGeneration();
    nextAudioPortGeneration();


    ssize_t index = mAudioPatches.indexOfKey(outputDesc->mPatchHandle);
    ssize_t index = mAudioPatches.indexOfKey(outputDesc->getPatchHandle());
    if (index >= 0) {
    if (index >= 0) {
        sp<AudioPatch> patchDesc = mAudioPatches.valueAt(index);
        sp<AudioPatch> patchDesc = mAudioPatches.valueAt(index);
        status_t status = mpClientInterface->releaseAudioPatch(patchDesc->mAfPatchHandle, 0);
        status_t status = mpClientInterface->releaseAudioPatch(patchDesc->mAfPatchHandle, 0);
@@ -4153,12 +4153,12 @@ audio_devices_t AudioPolicyManager::getNewOutputDevice(const sp<AudioOutputDescr
{
{
    audio_devices_t device = AUDIO_DEVICE_NONE;
    audio_devices_t device = AUDIO_DEVICE_NONE;


    ssize_t index = mAudioPatches.indexOfKey(outputDesc->mPatchHandle);
    ssize_t index = mAudioPatches.indexOfKey(outputDesc->getPatchHandle());
    if (index >= 0) {
    if (index >= 0) {
        sp<AudioPatch> patchDesc = mAudioPatches.valueAt(index);
        sp<AudioPatch> patchDesc = mAudioPatches.valueAt(index);
        if (patchDesc->mUid != mUidCached) {
        if (patchDesc->mUid != mUidCached) {
            ALOGV("getNewOutputDevice() device %08x forced by patch %d",
            ALOGV("getNewOutputDevice() device %08x forced by patch %d",
                  outputDesc->device(), outputDesc->mPatchHandle);
                  outputDesc->device(), outputDesc->getPatchHandle());
            return outputDesc->device();
            return outputDesc->device();
        }
        }
    }
    }
@@ -4513,7 +4513,7 @@ uint32_t AudioPolicyManager::setOutputDevice(const sp<AudioOutputDescriptor>& ou
    // Doing this check here allows the caller to call setOutputDevice() without conditions
    // Doing this check here allows the caller to call setOutputDevice() without conditions
    if ((device == AUDIO_DEVICE_NONE || device == prevDevice) &&
    if ((device == AUDIO_DEVICE_NONE || device == prevDevice) &&
        !force &&
        !force &&
        outputDesc->mPatchHandle != 0) {
        outputDesc->getPatchHandle() != 0) {
        ALOGV("setOutputDevice() setting same device 0x%04x or null device", device);
        ALOGV("setOutputDevice() setting same device 0x%04x or null device", device);
        return muteWaitMs;
        return muteWaitMs;
    }
    }
@@ -4540,7 +4540,7 @@ uint32_t AudioPolicyManager::setOutputDevice(const sp<AudioOutputDescriptor>& ou
            if (patchHandle && *patchHandle != AUDIO_PATCH_HANDLE_NONE) {
            if (patchHandle && *patchHandle != AUDIO_PATCH_HANDLE_NONE) {
                index = mAudioPatches.indexOfKey(*patchHandle);
                index = mAudioPatches.indexOfKey(*patchHandle);
            } else {
            } else {
                index = mAudioPatches.indexOfKey(outputDesc->mPatchHandle);
                index = mAudioPatches.indexOfKey(outputDesc->getPatchHandle());
            }
            }
            sp< AudioPatch> patchDesc;
            sp< AudioPatch> patchDesc;
            audio_patch_handle_t afPatchHandle = AUDIO_PATCH_HANDLE_NONE;
            audio_patch_handle_t afPatchHandle = AUDIO_PATCH_HANDLE_NONE;
@@ -4566,7 +4566,7 @@ uint32_t AudioPolicyManager::setOutputDevice(const sp<AudioOutputDescriptor>& ou
                if (patchHandle) {
                if (patchHandle) {
                    *patchHandle = patchDesc->mHandle;
                    *patchHandle = patchDesc->mHandle;
                }
                }
                outputDesc->mPatchHandle = patchDesc->mHandle;
                outputDesc->setPatchHandle(patchDesc->mHandle);
                nextAudioPortGeneration();
                nextAudioPortGeneration();
                mpClientInterface->onAudioPatchListUpdate();
                mpClientInterface->onAudioPatchListUpdate();
            }
            }
@@ -4601,7 +4601,7 @@ status_t AudioPolicyManager::resetOutputDevice(const sp<AudioOutputDescriptor>&
    if (patchHandle) {
    if (patchHandle) {
        index = mAudioPatches.indexOfKey(*patchHandle);
        index = mAudioPatches.indexOfKey(*patchHandle);
    } else {
    } else {
        index = mAudioPatches.indexOfKey(outputDesc->mPatchHandle);
        index = mAudioPatches.indexOfKey(outputDesc->getPatchHandle());
    }
    }
    if (index < 0) {
    if (index < 0) {
        return INVALID_OPERATION;
        return INVALID_OPERATION;
@@ -4609,7 +4609,7 @@ status_t AudioPolicyManager::resetOutputDevice(const sp<AudioOutputDescriptor>&
    sp< AudioPatch> patchDesc = mAudioPatches.valueAt(index);
    sp< AudioPatch> patchDesc = mAudioPatches.valueAt(index);
    status_t status = mpClientInterface->releaseAudioPatch(patchDesc->mAfPatchHandle, delayMs);
    status_t status = mpClientInterface->releaseAudioPatch(patchDesc->mAfPatchHandle, delayMs);
    ALOGV("resetOutputDevice() releaseAudioPatch returned %d", status);
    ALOGV("resetOutputDevice() releaseAudioPatch returned %d", status);
    outputDesc->mPatchHandle = 0;
    outputDesc->setPatchHandle(0);
    removeAudioPatch(patchDesc->mHandle);
    removeAudioPatch(patchDesc->mHandle);
    nextAudioPortGeneration();
    nextAudioPortGeneration();
    mpClientInterface->onAudioPatchListUpdate();
    mpClientInterface->onAudioPatchListUpdate();