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

Commit 97ac871c authored by Eric Laurent's avatar Eric Laurent
Browse files

audio policy: refactor preferred route implementation

Remove SessionRoute class and replace by use of
preferredDevice and active state in ClientDescriptor

Also fix the behavior for other clients using same strategy as
client with preferred route: the preferred route is only used if
no other clients using the same strategy are active without a preferred
route.
If all clients have a preferred route, the route of the last active
client is used.

Also fixed getOutputForAttr() to return correct selected device ID when
dynamic policies are used.

Test: CTS RoutingTest, AudioPlayRoutingNative, AudioRecordRoutingNative
Test: Manual: AudioExplicitRouting, UplinkMusicSampleApp

Change-Id: Id342c2241ace3e1a359ea74f4a539a395f793b86
parent dd6f1835
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 −1
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@ LOCAL_SRC_FILES:= \
    src/AudioCollections.cpp \
    src/EffectDescriptor.cpp \
    src/SoundTriggerSession.cpp \
    src/SessionRoute.cpp \
    src/VolumeCurve.cpp \
    src/TypeConverter.cpp \
    src/AudioSession.cpp \
+3 −1
Original line number Diff line number Diff line
@@ -89,8 +89,10 @@ public:
    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:

+3 −1
Original line number Diff line number Diff line
@@ -78,7 +78,9 @@ 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
+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