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

Commit 8ed6ed0b authored by Eric Laurent's avatar Eric Laurent
Browse files

Audio policy manager changes for audio effects

Added methods for audio effects management by audio policy manager.
- control of total CPU load and memory used by effect engines
- selection of output stream for global effects
- added audio session id in parameter list for startOutput() and stopOutput().
this is not used in default audio policy manager implementation.

Modifications of audio effect framework in AudioFlinger to allow moving and reconfiguring
effect engines from one output mixer thread to another when audio tracks in the same session
are moved or when requested by audio policy manager.
Also fixed mutex deadlock problem with effect chains locks.

Change-Id: Ida43484b06e9b890d6b9e53c13958d042720ebdb
parent ff7049ab
Loading
Loading
Loading
Loading
+25 −2
Original line number Diff line number Diff line
@@ -168,6 +168,15 @@ public:
        TX_DISABLE    = 0
    };

    // special audio session values
    enum audio_sessions {
        SESSION_OUTPUT_STAGE = -1, // session for effects attached to a particular output stream
                                   // (value must be less than 0)
        SESSION_OUTPUT_MIX = 0,    // session for effects applied to output mix. These effects can
                                   // be moved by audio policy manager to another output stream
                                   // (value must be 0)
    };

    /* These are static methods to control the system-wide AudioFlinger
     * only privileged processes can have access to them
     */
@@ -353,8 +362,12 @@ public:
                                        uint32_t format = FORMAT_DEFAULT,
                                        uint32_t channels = CHANNEL_OUT_STEREO,
                                        output_flags flags = OUTPUT_FLAG_INDIRECT);
    static status_t startOutput(audio_io_handle_t output, AudioSystem::stream_type stream);
    static status_t stopOutput(audio_io_handle_t output, AudioSystem::stream_type stream);
    static status_t startOutput(audio_io_handle_t output,
                                AudioSystem::stream_type stream,
                                int session = 0);
    static status_t stopOutput(audio_io_handle_t output,
                               AudioSystem::stream_type stream,
                               int session = 0);
    static void releaseOutput(audio_io_handle_t output);
    static audio_io_handle_t getInput(int inputSource,
                                    uint32_t samplingRate = 0,
@@ -370,6 +383,16 @@ public:
    static status_t setStreamVolumeIndex(stream_type stream, int index);
    static status_t getStreamVolumeIndex(stream_type stream, int *index);

    static uint32_t getStrategyForStream(stream_type stream);

    static audio_io_handle_t getOutputForEffect(effect_descriptor_t *desc);
    static status_t registerEffect(effect_descriptor_t *desc,
                                    audio_io_handle_t output,
                                    uint32_t strategy,
                                    int session,
                                    int id);
    static status_t unregisterEffect(int id);

    static const sp<IAudioPolicyService>& get_audio_policy_service();

    // ----------------------------------------------------------------------------
+2 −0
Original line number Diff line number Diff line
@@ -161,6 +161,8 @@ public:
                                    status_t *status,
                                    int *id,
                                    int *enabled) = 0;

    virtual status_t moveEffects(int session, int srcOutput, int dstOutput) = 0;
};


+14 −2
Original line number Diff line number Diff line
@@ -53,8 +53,12 @@ public:
                                        uint32_t format = AudioSystem::FORMAT_DEFAULT,
                                        uint32_t channels = 0,
                                        AudioSystem::output_flags flags = AudioSystem::OUTPUT_FLAG_INDIRECT) = 0;
    virtual status_t startOutput(audio_io_handle_t output, AudioSystem::stream_type stream) = 0;
    virtual status_t stopOutput(audio_io_handle_t output, AudioSystem::stream_type stream) = 0;
    virtual status_t startOutput(audio_io_handle_t output,
                                 AudioSystem::stream_type stream,
                                 int session = 0) = 0;
    virtual status_t stopOutput(audio_io_handle_t output,
                                AudioSystem::stream_type stream,
                                int session = 0) = 0;
    virtual void releaseOutput(audio_io_handle_t output) = 0;
    virtual audio_io_handle_t getInput(int inputSource,
                                    uint32_t samplingRate = 0,
@@ -69,6 +73,14 @@ public:
                                      int indexMax) = 0;
    virtual status_t setStreamVolumeIndex(AudioSystem::stream_type stream, int index) = 0;
    virtual status_t getStreamVolumeIndex(AudioSystem::stream_type stream, int *index) = 0;
    virtual uint32_t getStrategyForStream(AudioSystem::stream_type stream) = 0;
    virtual audio_io_handle_t getOutputForEffect(effect_descriptor_t *desc) = 0;
    virtual status_t registerEffect(effect_descriptor_t *desc,
                                    audio_io_handle_t output,
                                    uint32_t strategy,
                                    int session,
                                    int id) = 0;
    virtual status_t unregisterEffect(int id) = 0;
};


+1 −1
Original line number Diff line number Diff line
@@ -31,7 +31,7 @@ static list_elem_t *gCurLib; // current library in enumeration process
static list_elem_t *gCurEffect; // current effect in enumeration process
static uint32_t gCurEffectIdx;       // current effect index in enumeration process

static const char * const gEffectLibPath = "/system/lib/soundfx"; // path to built-in effect libraries
const char * const gEffectLibPath = "/system/lib/soundfx"; // path to built-in effect libraries
static int gInitDone; // true is global initialization has been preformed
static int gNextLibId; // used by loadLibrary() to allocate unique library handles
static int gCanQueryEffect; // indicates that call to EffectQueryEffect() is valid, i.e. that the list of effects
+1 −1
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@
#define LOG_TAG "Bundle"
#define ARRAY_SIZE(array) (sizeof array / sizeof array[0])
#define LVM_BUNDLE                // Include all the bundle code
#define LOG_NDEBUG 0
//#define LOG_NDEBUG 0

#include <cutils/log.h>
#include <assert.h>
Loading