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

Commit 4b441c1e authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Audio policy: notify system_server of routing change"

parents 75b915ab 9a6b9adb
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -53,6 +53,7 @@ sp<AudioSystem::AudioFlingerClient> AudioSystem::gAudioFlingerClient;
std::set<audio_error_callback> AudioSystem::gAudioErrorCallbacks;
dynamic_policy_callback AudioSystem::gDynPolicyCallback = NULL;
record_config_callback AudioSystem::gRecordConfigCallback = NULL;
routing_callback AudioSystem::gRoutingCallback = NULL;

// Required to be held while calling into gSoundTriggerCaptureStateListener.
class CaptureStateListenerImpl;
@@ -771,6 +772,12 @@ status_t AudioSystem::AudioFlingerClient::removeAudioDeviceCallback(
    gRecordConfigCallback = cb;
}

/*static*/ void AudioSystem::setRoutingCallback(routing_callback cb)
{
    Mutex::Autolock _l(gLock);
    gRoutingCallback = cb;
}

// client singleton for AudioPolicyService binder interface
// protected by gLockAPS
sp<IAudioPolicyService> AudioSystem::gAudioPolicyService;
@@ -1914,6 +1921,19 @@ Status AudioSystem::AudioPolicyServiceClient::onRecordingConfigurationUpdate(
    return Status::ok();
}

Status AudioSystem::AudioPolicyServiceClient::onRoutingUpdated() {
    routing_callback cb = NULL;
    {
        Mutex::Autolock _l(AudioSystem::gLock);
        cb = gRoutingCallback;
    }

    if (cb != NULL) {
        cb();
    }
    return Status::ok();
}

void AudioSystem::AudioPolicyServiceClient::binderDied(const wp<IBinder>& who __unused)
{
    {
+2 −0
Original line number Diff line number Diff line
@@ -44,4 +44,6 @@ oneway interface IAudioPolicyServiceClient {
                                        in EffectDescriptor[] effects,
                                        int /* audio_patch_handle_t */ patchHandle,
                                        AudioSourceType source);
     /** Notifies a change of audio routing */
     void onRoutingUpdated();
}
+4 −0
Original line number Diff line number Diff line
@@ -65,6 +65,7 @@ typedef void (*record_config_callback)(int event,
                                       std::vector<effect_descriptor_t> effects,
                                       audio_patch_handle_t patchHandle,
                                       audio_source_t source);
typedef void (*routing_callback)();

class IAudioFlinger;
class IAudioPolicyService;
@@ -138,6 +139,7 @@ public:

    static void setDynPolicyCallback(dynamic_policy_callback cb);
    static void setRecordConfigCallback(record_config_callback);
    static void setRoutingCallback(routing_callback cb);

    // helper function to obtain AudioFlinger service handle
    static const sp<IAudioFlinger> get_audio_flinger();
@@ -630,6 +632,7 @@ private:
                const std::vector<media::EffectDescriptor>& effects,
                int32_t patchHandle,
                media::AudioSourceType source) override;
        binder::Status onRoutingUpdated();

    private:
        Mutex                               mLock;
@@ -656,6 +659,7 @@ private:
    static std::set<audio_error_callback> gAudioErrorCallbacks;
    static dynamic_policy_callback gDynPolicyCallback;
    static record_config_callback gRecordConfigCallback;
    static routing_callback gRoutingCallback;

    static size_t gInBuffSize;
    // previous parameters for recording buffer size queries
+2 −0
Original line number Diff line number Diff line
@@ -439,6 +439,8 @@ public:
                                                audio_patch_handle_t patchHandle,
                                                audio_source_t source) = 0;

    virtual void onRoutingUpdated() = 0;

    // Used to notify the sound trigger module that an audio capture is about to
    // take place. This should typically result in any active recognition
    // sessions to be preempted on modules that do not support sound trigger
+2 −0
Original line number Diff line number Diff line
@@ -5362,6 +5362,8 @@ void AudioPolicyManager::checkForDeviceAndOutputChanges(std::function<bool()> on
    if (mHwModules.getModuleFromName(AUDIO_HARDWARE_MODULE_ID_MSD) != 0) {
        setMsdPatch();
    }
    // an event that changed routing likely occurred, inform upper layers
    mpClientInterface->onRoutingUpdated();
}

bool AudioPolicyManager::followsSameRouting(const audio_attributes_t &lAttr,
Loading