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

Commit 4545b923 authored by Steve Kondik's avatar Steve Kondik
Browse files

audio: Add A2DP notification support

 * Forward porting this code.
 * Sends notifications to legacy LPAPlayer for routing A2DP thru LPA.

Change-Id: I53eebda30b2e5cd60eeac5eb2a4cdb53e38381c9
parent a28fc8b9
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -150,6 +150,7 @@ public:
        INPUT_CONFIG_CHANGED,
        STREAM_CONFIG_CHANGED,
#ifdef QCOM_HARDWARE
        A2DP_OUTPUT_STATE,
        EFFECT_CONFIG_CHANGED,
#endif
        NUM_CONFIG_EVENTS
+3 −0
Original line number Diff line number Diff line
@@ -207,6 +207,9 @@ public:
                                    audio_io_handle_t dstOutput) = 0;

    virtual audio_module_handle_t loadHwModule(const char *name) = 0;
#ifdef QCOM_HARDWARE
    virtual status_t deregisterClient(const sp<IAudioFlingerClient>& client) { return false; };
#endif

    // helpers for android.media.AudioManager.getProperty(), see description there for meaning
    // FIXME move these APIs to AudioPolicy to permit a more accurate implementation
+0 −4
Original line number Diff line number Diff line
@@ -117,11 +117,9 @@ LPAPlayer::~LPAPlayer() {
    }

    reset();
#if 0
    if (mAudioFlinger != NULL) {
        mAudioFlinger->deregisterClient(AudioFlingerClient);
    }
#endif
    mObjectsAlive--;
    mLpaInProgress = false;

@@ -166,7 +164,6 @@ void LPAPlayer::AudioFlingerLPAdecodeClient::binderDied(const wp<IBinder>& who)
void LPAPlayer::AudioFlingerLPAdecodeClient::ioConfigChanged(int event, audio_io_handle_t ioHandle, const void *param2) {
    ALOGV("ioConfigChanged() event %d", event);

#if 0
    if (event != AudioSystem::A2DP_OUTPUT_STATE) {
        return;
    }
@@ -197,7 +194,6 @@ void LPAPlayer::AudioFlingerLPAdecodeClient::ioConfigChanged(int event, audio_io
        }
        break;
    }
#endif
    ALOGV("ioConfigChanged Out");

}
+33 −1
Original line number Diff line number Diff line
@@ -177,6 +177,9 @@ AudioFlinger::AudioFlinger()
void AudioFlinger::onFirstRef()
{
    int rc = 0;
#ifdef QCOM_HARDWARE
    mA2DPHandle = -1;
#endif

    Mutex::Autolock _l(mLock);

@@ -752,6 +755,9 @@ status_t AudioFlinger::setMasterVolume(float value)
        return PERMISSION_DENIED;
    }

#ifdef QCOM_HARDWARE
    mA2DPHandle = -1;
#endif
    Mutex::Autolock _l(mLock);
    mMasterVolume = value;

@@ -1290,6 +1296,13 @@ void AudioFlinger::registerClient(const sp<IAudioFlingerClient>& client)
            mRecordThreads.valueAt(i)->sendIoConfigEvent(AudioSystem::INPUT_OPENED);
        }
    }
#ifdef QCOM_HARDWARE
    // Send the notification to the client only once.
    if (mA2DPHandle != -1) {
        ALOGV("A2DP active. Notifying the registered client");
        client->ioConfigChanged(AudioSystem::A2DP_OUTPUT_STATE, mA2DPHandle, &mA2DPHandle);
    }
#endif
}

#ifdef QCOM_HARDWARE
@@ -1796,6 +1809,12 @@ audio_io_handle_t AudioFlinger::openOutput(audio_module_handle_t module,
            thread->mOutputFlags = flags;
#ifdef QCOM_HARDWARE
        }
        // if the device is a A2DP, then this is an A2DP Output
        if (audio_is_a2dp_device((audio_devices_t) *pDevices))
        {
            mA2DPHandle = id;
            ALOGV("A2DP device activated. The handle is set to %d", mA2DPHandle);
        }
#endif

        if (pSamplingRate != NULL) *pSamplingRate = config.sample_rate;
@@ -1905,6 +1924,14 @@ status_t AudioFlinger::closeOutput_nonvirtual(audio_io_handle_t output)
        }
        audioConfigChanged_l(AudioSystem::OUTPUT_CLOSED, output, NULL);
        mPlaybackThreads.removeItem(output);
#ifdef QCOM_HARDWARE
        if (mA2DPHandle == output)
        {
            mA2DPHandle = -1;
            ALOGV("A2DP OutputClosed Notifying Client");
            audioConfigChanged_l(AudioSystem::A2DP_OUTPUT_STATE, mA2DPHandle, &mA2DPHandle);
        }
#endif
    }
    thread->exit();
    // The thread entity (active unit of execution) is no longer running here,
@@ -2152,7 +2179,12 @@ status_t AudioFlinger::setStreamOutput(audio_stream_type_t stream, audio_io_hand
        thread->invalidateTracks(stream);
#endif
    }

#ifdef QCOM_HARDWARE
    if ( mA2DPHandle == output ) {
        ALOGV("A2DP Activated and hence notifying the client");
        audioConfigChanged_l(AudioSystem::A2DP_OUTPUT_STATE, mA2DPHandle, &output);
    }
#endif
    return NO_ERROR;
}

+1 −0
Original line number Diff line number Diff line
@@ -740,6 +740,7 @@ private:
                DefaultKeyedVector<audio_io_handle_t, AudioSessionDescriptor *> mDirectAudioTracks;
                // protected by mLock
                volatile bool                       mIsEffectConfigChanged;
                int                                 mA2DPHandle; // Handle to notify connection status
#endif
                Vector<AudioSessionRef*> mAudioSessionRefs;
#ifdef QCOM_HARDWARE