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

Commit 6b5aebe6 authored by Eric Laurent's avatar Eric Laurent Committed by Android (Google) Code Review
Browse files

Merge changes I3f135b98,Ifadb1d24,Ieef3e05d,Id342c224

* changes:
  audio policy: fix getDevicesForStream() with preferred route
  audiopolicy: refactor playback activity ref counting
  audio policy: remove AudioSession class
  audio policy: refactor preferred route implementation
parents 4622878b b0688d69
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ namespace android {
#define SONIFICATION_RESPECTFUL_AFTER_MUSIC_DELAY 5000

enum routing_strategy {
    STRATEGY_NONE = -1,
    STRATEGY_MEDIA,
    STRATEGY_PHONE,
    STRATEGY_SONIFICATION,
+0 −2
Original line number Diff line number Diff line
@@ -17,10 +17,8 @@ LOCAL_SRC_FILES:= \
    src/AudioCollections.cpp \
    src/EffectDescriptor.cpp \
    src/SoundTriggerSession.cpp \
    src/SessionRoute.cpp \
    src/VolumeCurve.cpp \
    src/TypeConverter.cpp \
    src/AudioSession.cpp \
    src/ClientDescriptor.cpp

LOCAL_SHARED_LIBRARIES := \
+15 −22
Original line number Diff line number Diff line
@@ -16,19 +16,19 @@

#pragma once

#include "AudioIODescriptorInterface.h"
#include "AudioPort.h"
#include "AudioSession.h"
#include "ClientDescriptor.h"
#include <utils/Errors.h>
#include <system/audio.h>
#include <utils/Errors.h>
#include <utils/SortedVector.h>
#include <utils/KeyedVector.h>
#include "AudioIODescriptorInterface.h"
#include "AudioPort.h"
#include "ClientDescriptor.h"

namespace android {

class IOProfile;
class AudioMix;
class AudioPolicyClientInterface;

// descriptor for audio inputs. Used to maintain current configuration of each opened audio input
// and keep track of the usage of this input.
@@ -39,7 +39,6 @@ public:
                                  AudioPolicyClientInterface *clientInterface);
    audio_port_handle_t getId() const;
    audio_module_handle_t getModuleHandle() const;
    uint32_t getOpenRefCount() const;

    status_t    dump(int fd);

@@ -56,19 +55,13 @@ public:
    SortedVector<audio_session_t> getPreemptedSessions() const;
    bool hasPreemptedSession(audio_session_t session) const;
    void clearPreemptedSessions();
    bool isActive() const;
    bool isActive() const { return mGlobalActiveCount > 0; }
    bool isSourceActive(audio_source_t source) const;
    audio_source_t inputSource(bool activeOnly = false) const;
    bool isSoundTrigger() const;
    status_t addAudioSession(audio_session_t session,
                             const sp<AudioSession>& audioSession);
    status_t removeAudioSession(audio_session_t session);
    sp<AudioSession> getAudioSession(audio_session_t session) const;
    AudioSessionCollection getAudioSessions(bool activeOnly) const;
    size_t getAudioSessionCount(bool activeOnly) const;
    audio_source_t getHighestPrioritySource(bool activeOnly) const;
    void changeRefCount(audio_session_t session, int delta);

    void setClientActive(const sp<RecordClientDescriptor>& client, bool active);
    int32_t activeCount() { return mGlobalActiveCount; }

    // implementation of AudioIODescriptorInterface
    audio_config_base_t getConfig() const override;
@@ -82,24 +75,24 @@ public:
                  audio_input_flags_t flags,
                  audio_io_handle_t *input);
    // Called when a stream is about to be started.
    // Note: called after changeRefCount(session, 1)
    // Note: called after setClientActive(client, true)
    status_t start();
    // Called after a stream is stopped
    // Note: called after changeRefCount(session, -1)
    // Note: called after setClientActive(client, false)
    void stop();
    void close();

    RecordClientMap& clients() { return mClients; }
    RecordClientMap& clientsMap() { return mClients; }
    RecordClientVector getClientsForSession(audio_session_t session);
    RecordClientVector clientsList(bool activeOnly = false,
        audio_source_t source = AUDIO_SOURCE_DEFAULT, bool preferredDeviceOnly = false) const;

 private:

    void updateSessionRecordingConfiguration(int event, const sp<AudioSession>& audioSession);
    void updateClientRecordingConfiguration(int event, const sp<RecordClientDescriptor>& client);

    audio_patch_handle_t          mPatchHandle;
    audio_port_handle_t           mId;
    // audio sessions attached to this input
    AudioSessionCollection        mSessions;
    // Because a preemptible capture session can preempt another one, we end up in an endless loop
    // situation were each session is allowed to restart after being preempted,
    // thus preempting the other one which restarts and so on.
@@ -108,7 +101,7 @@ public:
    // We also inherit sessions from the preempted input to avoid a 3 way preemption loop etc...
    SortedVector<audio_session_t> mPreemptedSessions;
    AudioPolicyClientInterface *mClientInterface;
    uint32_t mGlobalRefCount;  // non-session-specific ref count
    int32_t mGlobalActiveCount;  // non-client-specific activity ref count

    RecordClientMap mClients;
};
+13 −8
Original line number Diff line number Diff line
@@ -59,7 +59,10 @@ public:
                           audio_devices_t device,
                           uint32_t delayMs,
                           bool force);
    virtual void changeRefCount(audio_stream_type_t stream, int delta);
    virtual void changeStreamActiveCount(audio_stream_type_t stream, int delta);
            uint32_t streamActiveCount(audio_stream_type_t stream) const
                            { return mActiveCount[stream]; }
            void setClientActive(const sp<TrackClientDescriptor>& client, bool active);

    bool isActive(uint32_t inPastMs = 0) const;
    bool isStreamActive(audio_stream_type_t stream,
@@ -78,19 +81,23 @@ public:
    audio_patch_handle_t getPatchHandle() const override;
    void setPatchHandle(audio_patch_handle_t handle) override;

    TrackClientMap& clients() { return mClients; }
    TrackClientMap& clientsMap() { return mClients; }
    TrackClientVector clientsList(bool activeOnly = false,
        routing_strategy strategy = STRATEGY_NONE, bool preferredDeviceOnly = false) const;

    sp<AudioPort> mPort;
    audio_devices_t mDevice;                   // current device this output is routed to
    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
    int mMuteCount[AUDIO_STREAM_CNT];     // mute request counter
    bool mStrategyMutedByDevice[NUM_STRATEGIES]; // strategies muted because of incompatible
                                        // device selection. See checkDeviceMuteStrategies()
    AudioPolicyClientInterface *mClientInterface;
    AudioMix *mPolicyMix;             // non NULL when used by a dynamic policy

protected:
    uint32_t mActiveCount[AUDIO_STREAM_CNT]; // number of streams of each type active on this output
    uint32_t mGlobalActiveCount;  // non-client-specific active count
    audio_patch_handle_t mPatchHandle;
    audio_port_handle_t mId;
    TrackClientMap mClients;
@@ -114,7 +121,7 @@ public:
    virtual bool isFixedVolume(audio_devices_t device);
    virtual sp<AudioOutputDescriptor> subOutput1() { return mOutput1; }
    virtual sp<AudioOutputDescriptor> subOutput2() { return mOutput2; }
    virtual void changeRefCount(audio_stream_type_t stream, int delta);
    virtual void changeStreamActiveCount(audio_stream_type_t stream, int delta);
    virtual bool setVolume(float volume,
                           audio_stream_type_t stream,
                           audio_devices_t device,
@@ -132,10 +139,10 @@ public:
                          audio_output_flags_t flags,
                          audio_io_handle_t *output);
            // Called when a stream is about to be started
            // Note: called before changeRefCount(1);
            // Note: called before setClientActive(true);
            status_t start();
            // Called after a stream is stopped.
            // Note: called after changeRefCount(-1);
            // Note: called after setClientActive(false);
            void stop();
            void close();
            status_t openDuplicating(const sp<SwAudioOutputDescriptor>& output1,
@@ -146,12 +153,10 @@ public:
    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
    sp<SwAudioOutputDescriptor> mOutput1;    // used by duplicated outputs: first output
    sp<SwAudioOutputDescriptor> mOutput2;    // used by duplicated outputs: second output
    uint32_t mDirectOpenCount; // number of clients using this output (direct outputs only)
    audio_session_t mDirectClientSession; // session id of the direct output client
    uint32_t mGlobalRefCount;  // non-stream-specific ref count
};

// Audio output driven by an input device directly.
+0 −1
Original line number Diff line number Diff line
@@ -28,7 +28,6 @@
#include <AudioPolicyMix.h>
#include <EffectDescriptor.h>
#include <SoundTriggerSession.h>
#include <SessionRoute.h>

namespace android {

Loading