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

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

Merge "Issue 2667801: [Audio Effect Framework] AudioFlinger, AudioMixer...

Merge "Issue 2667801: [Audio Effect Framework] AudioFlinger, AudioMixer AudioTrack modifications." into kraken
parents 5f5df382 65b65459
Loading
Loading
Loading
Loading
+15 −2
Original line number Diff line number Diff line
@@ -142,7 +142,8 @@ public:
                                    uint32_t flags      = 0,
                                    callback_t cbf = 0,
                                    void* user = 0,
                                    int notificationFrames = 0);
                                    int notificationFrames = 0,
                                    int sessionId = 0);


    /* Terminates the AudioRecord and unregisters it from AudioFlinger.
@@ -168,7 +169,8 @@ public:
                            callback_t cbf = 0,
                            void* user = 0,
                            int notificationFrames = 0,
                            bool threadCanCallJava = false);
                            bool threadCanCallJava = false,
                            int sessionId = 0);


    /* Result of constructing the AudioRecord. This must be checked
@@ -270,6 +272,16 @@ public:
     */
            audio_io_handle_t    getInput();

    /* returns the audio session ID associated to this AudioRecord.
     *
     * Parameters:
     *  none.
     *
     * Returned value:
     *  AudioRecord session ID.
     */
            int    getSessionId();

    /* obtains a buffer of "frameCount" frames. The buffer must be
     * filled entirely. If the track is stopped, obtainBuffer() returns
     * STOPPED instead of NO_ERROR as long as there are buffers availlable,
@@ -356,6 +368,7 @@ private:
    uint32_t                mFlags;
    uint32_t                mChannels;
    audio_io_handle_t       mInput;
    int                     mSessionId;
};

}; // namespace android
+2 −0
Original line number Diff line number Diff line
@@ -230,6 +230,8 @@ public:
    static status_t getRenderPosition(uint32_t *halFrames, uint32_t *dspFrames, int stream = DEFAULT);

    static unsigned int  getInputFramesLost(audio_io_handle_t ioHandle);

    static int newAudioSessionId();
    //
    // AudioPolicyService interface
    //
+41 −4
Original line number Diff line number Diff line
@@ -138,7 +138,8 @@ public:
                                    uint32_t flags       = 0,
                                    callback_t cbf       = 0,
                                    void* user           = 0,
                                    int notificationFrames = 0);
                                    int notificationFrames = 0,
                                    int sessionId = 0);

    /* Creates an audio track and registers it with AudioFlinger. With this constructor,
     * The PCM data to be rendered by AudioTrack is passed in a shared memory buffer
@@ -157,7 +158,8 @@ public:
                                    uint32_t flags      = 0,
                                    callback_t cbf      = 0,
                                    void* user          = 0,
                                    int notificationFrames = 0);
                                    int notificationFrames = 0,
                                    int sessionId = 0);

    /* Terminates the AudioTrack and unregisters it from AudioFlinger.
     * Also destroys all resources assotiated with the AudioTrack.
@@ -182,7 +184,8 @@ public:
                            void* user          = 0,
                            int notificationFrames = 0,
                            const sp<IMemory>& sharedBuffer = 0,
                            bool threadCanCallJava = false);
                            bool threadCanCallJava = false,
                            int sessionId = 0);


    /* Result of constructing the AudioTrack. This must be checked
@@ -239,10 +242,17 @@ public:


    /* set volume for this track, mostly used for games' sound effects
     * left and right volumes. Levels must be <= 1.0.
     */
            void        setVolume(float left, float right);
            status_t    setVolume(float left, float right);
            void        getVolume(float* left, float* right);

    /* set the send level for this track. An auxiliary effect should be attached
     * to the track with attachEffect(). Level must be <= 1.0.
     */
            status_t    setSendLevel(float level);
            void        getSendLevel(float* level);

    /* set sample rate for this track, mostly used for games' sound effects
     */
            status_t    setSampleRate(int sampleRate);
@@ -340,6 +350,31 @@ public:
     */
            audio_io_handle_t    getOutput();

    /* returns the unique ID associated to this track.
     *
     * Parameters:
     *  none.
     *
     * Returned value:
     *  AudioTrack ID.
     */
            int    getSessionId();


    /* Attach track auxiliary output to specified effect. Used effectId = 0
     * to detach track from effect.
     *
     * Parameters:
     *
     * effectId:  effectId obtained from AudioEffect::id().
     *
     * Returned status (from utils/Errors.h) can be:
     *  - NO_ERROR: successful operation
     *  - INVALID_OPERATION: the effect is not an auxiliary effect.
     *  - BAD_VALUE: The specified effect ID is invalid
     */
            status_t    attachAuxEffect(int effectId);

    /* obtains a buffer of "frameCount" frames. The buffer must be
     * filled entirely. If the track is stopped, obtainBuffer() returns
     * STOPPED instead of NO_ERROR as long as there are buffers availlable,
@@ -406,6 +441,7 @@ private:
    sp<AudioTrackThread>    mAudioTrackThread;

    float                   mVolume[2];
    float                   mSendLevel;
    uint32_t                mFrameCount;

    audio_track_cblk_t*     mCblk;
@@ -431,6 +467,7 @@ private:
    uint32_t                mNewPosition;
    uint32_t                mUpdatePeriod;
    uint32_t                mFlags;
    int                     mSessionId;
};


+13 −9
Original line number Diff line number Diff line
@@ -114,7 +114,8 @@ typedef struct effect_descriptor_s {
//  +---------------------------+-----------+-----------------------------------
//  | Volume management         | 5..6      | 0 none
//  |                           |           | 1 implements volume control
//  |                           |           | 2..3 reserved
//  |                           |           | 2 requires volume indication
//  |                           |           | 3 reserved
//  +---------------------------+-----------+-----------------------------------
//  | Device management         | 7..8      | 0 none
//  |                           |           | 1 requires device updates
@@ -154,6 +155,7 @@ typedef struct effect_descriptor_s {
// volume control
#define EFFECT_FLAG_VOLUME_MASK         0x00000060
#define EFFECT_FLAG_VOLUME_CTRL         0x00000020
#define EFFECT_FLAG_VOLUME_IND          0x00000040
#define EFFECT_FLAG_VOLUME_NONE         0x00000000

// device control
@@ -296,10 +298,12 @@ struct effect_interface_s {
//  | Set and get volume. Used by    | EFFECT_CMD_SET_VOLUME         | size: n * sizeof(uint32_t)    | size: n * sizeof(uint32_t)
//  | audio framework to delegate    |                               | data: volume for each channel | data: volume for each channel
//  | volume control to effect engine|                               | defined in effect_config_t in | defined in effect_config_t in
//  | The engine must return the     |                               | 8.24 fixed point format       | 8.24 fixed point format
//  | volume that should be applied  |                               |                               |
//  | before the effect is processed |                               |                               |
//  | The overall volume (the volume |                               |                               |
//  | If volume control flag is set  |                               | 8.24 fixed point format       | 8.24 fixed point format
//  | in the effect descriptor, the  |                               |                               | It is legal to receive a null
//  | effect engine must return the  |                               |                               | pointer as pReplyData in which
//  | volume that should be applied  |                               |                               | case the effect framework has
//  | before the effect is processed |                               |                               | delegated volume control to
//  | The overall volume (the volume |                               |                               | another effect.
//  | actually applied by the effect |                               |                               |
//  | multiplied by the returned     |                               |                               |
//  | value) should match the        |                               |                               |
@@ -370,7 +374,7 @@ typedef struct buffer_provider_s {
// structure that defines both input and output buffer configurations and is
// passed by the EFFECT_CMD_CONFIGURE command.
typedef struct buffer_config_s {
    audio_buffer_t  buffer;     // buffer for use by process() function is not passed explicitly
    audio_buffer_t  buffer;     // buffer for use by process() function if not passed explicitly
    uint32_t   samplingRate;    // sampling rate
    uint32_t   channels;        // channel mask (see audio_channels_e in AudioCommon.h)
    buffer_provider_t bufferProvider;   // buffer provider
@@ -457,7 +461,7 @@ typedef struct effect_param_s {
//
//    Function:       EffectQueryNumberEffects
//
//    Description:    Returns the number of different effect exposed by the
//    Description:    Returns the number of different effects exposed by the
//          library. Each effect must have a unique effect uuid (see
//          effect_descriptor_t). This function together with EffectQueryNext()
//          is used to enumerate all effects present in the library.
@@ -475,7 +479,7 @@ typedef struct effect_param_s {
//        *pNumEffects:     updated with number of effects in library
//
////////////////////////////////////////////////////////////////////////////////
typedef int32_t (*effect_QueryNumberEffects_t)(int32_t *pNumEffects);
typedef int32_t (*effect_QueryNumberEffects_t)(uint32_t *pNumEffects);

////////////////////////////////////////////////////////////////////////////////
//
@@ -521,7 +525,7 @@ typedef int32_t (*effect_QueryNextEffect_t)(effect_descriptor_t *pDescriptor);
//        returned value:    0          successful operation.
//                          -ENODEV     library failed to initialize
//                          -EINVAL     invalid pEffectUuid or pInterface
//                          -ENOENT     No effect with this uuid found
//                          -ENOENT     no effect with this uuid found
//        *pInterface:     updated with the effect interface handle.
//
////////////////////////////////////////////////////////////////////////////////
+6 −6
Original line number Diff line number Diff line
@@ -34,7 +34,7 @@ extern "C" {
//
//    Function:       EffectQueryNumberEffects
//
//    Description:    Returns the number of different effect in all loaded libraries.
//    Description:    Returns the number of different effects in all loaded libraries.
//          Each effect must have a different effect uuid (see
//          effect_descriptor_t). This function together with EffectQueryNext()
//          is used to enumerate all effects present in all loaded libraries.
@@ -52,7 +52,7 @@ extern "C" {
//        *pNumEffects:     updated with number of effects in factory
//
////////////////////////////////////////////////////////////////////////////////
int EffectQueryNumberEffects(int *pNumEffects);
int EffectQueryNumberEffects(uint32_t *pNumEffects);

////////////////////////////////////////////////////////////////////////////////
//
@@ -98,7 +98,7 @@ int EffectQueryNext(effect_descriptor_t *pDescriptor);
//        returned value:    0          successful operation.
//                          -ENODEV     factory failed to initialize
//                          -EINVAL     invalid pEffectUuid or pInterface
//                          -ENOENT     No effect with this uuid found
//                          -ENOENT     no effect with this uuid found
//        *pInterface:     updated with the effect interface.
//
////////////////////////////////////////////////////////////////////////////////
@@ -140,7 +140,7 @@ int EffectRelease(effect_interface_t interface);
//
//    Output:
//        returned value:    0          successful operation.
//                          -ENODEV     Effect factory not initialized or
//                          -ENODEV     effect factory not initialized or
//                                      library could not be loaded or
//                                      library does not implement required functions
//                          -EINVAL     invalid libPath string or handle
@@ -159,7 +159,7 @@ int EffectLoadLibrary(const char *libPath, int *handle);
//
//    Output:
//        returned value:    0          successful operation.
//                          -ENODEV     Effect factory not initialized
//                          -ENODEV     effect factory not initialized
//                          -ENOENT     invalid handle
//
////////////////////////////////////////////////////////////////////////////////
@@ -184,7 +184,7 @@ int EffectUnloadLibrary(int handle);
//        returned value:    0          successful operation.
//                          -ENODEV     factory failed to initialize
//                          -EINVAL     invalid pEffectUuid or pDescriptor
//                          -ENOENT     No effect with this uuid found
//                          -ENOENT     no effect with this uuid found
//        *pDescriptor:     updated with the effect descriptor.
//
////////////////////////////////////////////////////////////////////////////////
Loading