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

Commit 464d5b3d authored by Eric Laurent's avatar Eric Laurent
Browse files

Audio framework: support for audio pre processing

Audio effect framework is extended to suport effects on
output and input audio path.

AudioFlinger: Support for audio effects and effect chains is
moved from PlaybackThread class to ThreadBase class so that
RecordThread can manage effects.
Effects of type pre processing are allowed on record thread
only. When a pre processing is enabled, the effect interface handle is
passed down to the input stream so that the audio HAL can call the
process function. The record thread loop calls the effect chain process
function that will only manage the effect state and commands and skip the
process function.

AudioRecord: The audio session is allocated before calling getInput() into
audio policy serice so that the session is known before the input theead is
created and pre processings can be created on the correct session.

AudioPolicyService: default pre processing for a given input source are
loaded from audio_effects.conf file.
When an input is created, corresponding effects are created and enabled.

Change-Id: Id17119e0979b4dcf189b5c7957fec30dc3478790
parent 919511a6
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -188,7 +188,7 @@ public:
     * sessionID:   audio session this effect is associated to. If 0, the effect will be global to
     *      the output mix. If not 0, the effect will be applied to all players
     *      (AudioTrack or MediaPLayer) within the same audio session.
     * output:  HAL audio output stream to which this effect must be attached. Leave at 0 for
     * io:  HAL audio output or input stream to which this effect must be attached. Leave at 0 for
     *      automatic output selection by AudioFlinger.
     */

@@ -198,7 +198,7 @@ public:
                  effect_callback_t cbf = 0,
                  void* user = 0,
                  int sessionId = 0,
                  audio_io_handle_t output = 0
                  audio_io_handle_t io = 0
                  );

    /* Constructor.
@@ -210,7 +210,7 @@ public:
                    effect_callback_t cbf = 0,
                    void* user = 0,
                    int sessionId = 0,
                    audio_io_handle_t output = 0
                    audio_io_handle_t io = 0
                    );

    /* Terminates the AudioEffect and unregisters it from AudioFlinger.
@@ -232,7 +232,7 @@ public:
                            effect_callback_t cbf = 0,
                            void* user = 0,
                            int sessionId = 0,
                            audio_io_handle_t output = 0
                            audio_io_handle_t io = 0
                            );

    /* Result of constructing the AudioEffect. This must be checked
+3 −2
Original line number Diff line number Diff line
@@ -160,7 +160,8 @@ public:
                                    uint32_t samplingRate = 0,
                                    uint32_t format = AUDIO_FORMAT_DEFAULT,
                                    uint32_t channels = AUDIO_CHANNEL_IN_MONO,
                                    audio_in_acoustics_t acoustics = (audio_in_acoustics_t)0);
                                    audio_in_acoustics_t acoustics = (audio_in_acoustics_t)0,
                                    int sessionId = 0);
    static status_t startInput(audio_io_handle_t input);
    static status_t stopInput(audio_io_handle_t input);
    static void releaseInput(audio_io_handle_t input);
@@ -175,7 +176,7 @@ public:

    static audio_io_handle_t getOutputForEffect(effect_descriptor_t *desc);
    static status_t registerEffect(effect_descriptor_t *desc,
                                    audio_io_handle_t output,
                                    audio_io_handle_t io,
                                    uint32_t strategy,
                                    int session,
                                    int id);
+3 −2
Original line number Diff line number Diff line
@@ -65,7 +65,8 @@ public:
                                    uint32_t samplingRate = 0,
                                    uint32_t format = AUDIO_FORMAT_DEFAULT,
                                    uint32_t channels = 0,
                                    audio_in_acoustics_t acoustics = (audio_in_acoustics_t)0) = 0;
                                    audio_in_acoustics_t acoustics = (audio_in_acoustics_t)0,
                                    int audioSession = 0) = 0;
    virtual status_t startInput(audio_io_handle_t input) = 0;
    virtual status_t stopInput(audio_io_handle_t input) = 0;
    virtual void releaseInput(audio_io_handle_t input) = 0;
@@ -78,7 +79,7 @@ public:
    virtual uint32_t getDevicesForStream(audio_stream_type_t 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,
                                    audio_io_handle_t io,
                                    uint32_t strategy,
                                    int session,
                                    int id) = 0;
+69 −0
Original line number Diff line number Diff line
# List of effect libraries to load. Each library element must contain a "path" element
# giving the full path of the library .so file.
#    libraries {
#        <lib name> {
#          path <lib path>
#        }
#    }
libraries {
  bundle {
    path /system/lib/soundfx/libbundlewrapper.so
@@ -10,6 +15,9 @@ libraries {
  visualizer {
    path /system/lib/soundfx/libvisualizer.so
  }
  pre_processing {
    path /system/lib/soundfx/libaudiopreprocessing.so
  }
}

# list of effects to load. Each effect element must contain a "library" and a "uuid" element.
@@ -17,6 +25,16 @@ libraries {
# "libraries" element.
# The name of the effect element is indicative, only the value of the "uuid" element
# designates the effect.
# The uuid is the implementation specific UUID as specified by the effect vendor. This is not the
# generic effect type UUID.
#    effects {
#        <fx name> {
#            library <lib name>
#            uuid <effect uuid>
#        }
#        ...
#    }

effects {
  bassboost {
    library bundle
@@ -54,4 +72,55 @@ effects {
    library visualizer
    uuid d069d9e0-8329-11df-9168-0002a5d5c51b
  }
  agc {
    library pre_processing
    uuid aa8130e0-66fc-11e0-bad0-0002a5d5c51b
  }
  aec {
    library pre_processing
    uuid bb392ec0-8d4d-11e0-a896-0002a5d5c51b
  }
  ns {
    library pre_processing
    uuid c06c8400-8e06-11e0-9cb6-0002a5d5c51b
  }
}
# Audio preprocessor configurations.
# The pre processor configuration consists in a list of elements each describing
# pre processor settings for a given input source. Valid input source names are:
# "mic", "camcorder", "voice_recognition", "voice_communication"
# Each input source element contains a list of effects elements. The name of the effect
# element must be the name of one of the effects in the "effects" list of the file.
# Each effect element may optionally contain a list of parameters and their
# default value to apply when the pre processor effect is created.
# A parameter is defined by a "param" element and a "value" element. Each of these elements
# consists in one or more elements specifying a type followed by a value.
# The types defined are: "int", "short", "float", "bool" and "string"
# When both "param" and "value" are a single int, a simple form is allowed where just
# the param and value pair is present in the parameter description
#    pre_processing {
#        <input source name> {
#            <fx name> {
#                <param 1 name> {
#                    param {
#                        int|short|float|bool|string <value>
#                        [ int|short|float|bool|string <value> ]
#                        ...
#                    }
#                    value {
#                        int|short|float|bool|string <value>
#                        [ int|short|float|bool|string <value> ]
#                        ...
#                    }
#                }
#                <param 2 name > {<param> <value>}
#                ...
#            }
#            ...
#        }
#        ...
#    }

#
# TODO: add default audio pre processor configurations after debug and tuning phase
#
+3 −0
Original line number Diff line number Diff line
@@ -14,4 +14,7 @@ LOCAL_MODULE:= libeffects

LOCAL_SHARED_LIBRARIES += libdl

LOCAL_C_INCLUDES := \
    system/media/audio_effects/include

include $(BUILD_SHARED_LIBRARY)
Loading