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

Commit 98317214 authored by Phil Burk's avatar Phil Burk Committed by Android (Google) Code Review
Browse files

Merge changes from topic "aaudio_session"

* changes:
  aaudio: implement sessionId for effects
  aaudio test: test sessionID for effects
  aaudio: header for SessionId for effects
parents 5b6921e7 4e1af9fc
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -52,6 +52,9 @@ class MmapStreamInterface : public virtual RefBase
     * \param[in,out] deviceId audio device the stream should preferably be routed to/from
     *                       Requested as input,
     *                       Actual as output
     * \param[in,out] sessionId audio sessionId for the stream
     *                       Requested as input, may be AUDIO_SESSION_ALLOCATE
     *                       Actual as output
     * \param[in] callback the MmapStreamCallback interface used by AudioFlinger to notify
     *                     condition changes affecting the stream operation
     * \param[out] interface the MmapStreamInterface interface controlling the created stream
@@ -66,6 +69,7 @@ class MmapStreamInterface : public virtual RefBase
                                           audio_config_base_t *config,
                                           const AudioClient& client,
                                           audio_port_handle_t *deviceId,
                                           audio_session_t *sessionId,
                                           const sp<MmapStreamCallback>& callback,
                                           sp<MmapStreamInterface>& interface,
                                           audio_port_handle_t *handle);
+70 −3
Original line number Diff line number Diff line
@@ -283,6 +283,25 @@ enum {
};
typedef int32_t aaudio_input_preset_t;

enum {
    /**
     * Do not allocate a session ID.
     * Effects cannot be used with this stream.
     * Default.
     */
    AAUDIO_SESSION_ID_NONE = -1,

    /**
     * Allocate a session ID that can be used to attach and control
     * effects using the Java AudioEffects API.
     * Note that the use of this flag may result in higher latency.
     *
     * Note that this matches the value of AudioManager.AUDIO_SESSION_ID_GENERATE.
     */
    AAUDIO_SESSION_ID_ALLOCATE = 0,
};
typedef int32_t aaudio_session_id_t;

typedef struct AAudioStreamStruct         AAudioStream;
typedef struct AAudioStreamBuilderStruct  AAudioStreamBuilder;

@@ -499,6 +518,32 @@ AAUDIO_API void AAudioStreamBuilder_setContentType(AAudioStreamBuilder* builder,
AAUDIO_API void AAudioStreamBuilder_setInputPreset(AAudioStreamBuilder* builder,
                                                   aaudio_input_preset_t inputPreset);

/** Set the requested session ID.
 *
 * The session ID can be used to associate a stream with effects processors.
 * The effects are controlled using the Android AudioEffect Java API.
 *
 * The default, if you do not call this function, is AAUDIO_SESSION_ID_NONE.
 *
 * If set to AAUDIO_SESSION_ID_ALLOCATE then a session ID will be allocated
 * when the stream is opened.
 *
 * The allocated session ID can be obtained by calling AAudioStream_getSessionId()
 * and then used with this function when opening another stream.
 * This allows effects to be shared between streams.
 *
 * Session IDs from AAudio can be used the Android Java APIs and vice versa.
 * So a session ID from an AAudio stream can be passed to Java
 * and effects applied using the Java AudioEffect API.
 *
 * Allocated session IDs will always be positive and nonzero.
 *
 * @param builder reference provided by AAudio_createStreamBuilder()
 * @param sessionId an allocated sessionID or AAUDIO_SESSION_ID_ALLOCATE
 */
AAUDIO_API void AAudioStreamBuilder_setSessionId(AAudioStreamBuilder* builder,
                                                aaudio_session_id_t sessionId);

/**
 * Return one of these values from the data callback function.
 */
@@ -995,6 +1040,28 @@ AAUDIO_API int64_t AAudioStream_getFramesWritten(AAudioStream* stream);
 */
AAUDIO_API int64_t AAudioStream_getFramesRead(AAudioStream* stream);

/**
 * Passes back the session ID associated with this stream.
 *
 * The session ID can be used to associate a stream with effects processors.
 * The effects are controlled using the Android AudioEffect Java API.
 *
 * If AAudioStreamBuilder_setSessionId() was called with AAUDIO_SESSION_ID_ALLOCATE
 * then a new session ID should be allocated once when the stream is opened.
 *
 * If AAudioStreamBuilder_setSessionId() was called with a previously allocated
 * session ID then that value should be returned.
 *
 * If AAudioStreamBuilder_setSessionId() was not called then this function should
 * return AAUDIO_SESSION_ID_NONE.
 *
 * The sessionID for a stream should not change once the stream has been opened.
 *
 * @param stream reference provided by AAudioStreamBuilder_openStream()
 * @return session ID or AAUDIO_SESSION_ID_NONE
 */
AAUDIO_API aaudio_session_id_t AAudioStream_getSessionId(AAudioStream* stream);

/**
 * Passes back the time at which a particular frame was presented.
 * This can be used to synchronize audio with video or MIDI.
+2 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ LIBAAUDIO {
    AAudioStreamBuilder_setUsage;       # introduced=28
    AAudioStreamBuilder_setContentType; # introduced=28
    AAudioStreamBuilder_setInputPreset; # introduced=28
    AAudioStreamBuilder_setSessionId;   # introduced=28
    AAudioStreamBuilder_openStream;
    AAudioStreamBuilder_delete;
    AAudioStream_close;
@@ -50,6 +51,7 @@ LIBAAUDIO {
    AAudioStream_getInputPreset; # introduced=28
    AAudioStream_getFramesWritten;
    AAudioStream_getFramesRead;
    AAudioStream_getSessionId;   # introduced=28
    AAudioStream_getTimestamp;
    AAudioStream_isMMapUsed;
  local:
+5 −0
Original line number Diff line number Diff line
@@ -56,6 +56,8 @@ status_t AAudioStreamConfiguration::writeToParcel(Parcel* parcel) const {
    if (status != NO_ERROR) goto error;
    status = parcel->writeInt32((int32_t) getInputPreset());
    if (status != NO_ERROR) goto error;
    status = parcel->writeInt32(getSessionId());
    if (status != NO_ERROR) goto error;
    return NO_ERROR;
error:
    ALOGE("AAudioStreamConfiguration.writeToParcel(): write failed = %d", status);
@@ -94,6 +96,9 @@ status_t AAudioStreamConfiguration::readFromParcel(const Parcel* parcel) {
    status = parcel->readInt32(&value);
    if (status != NO_ERROR) goto error;
    setInputPreset((aaudio_input_preset_t) value);
    status = parcel->readInt32(&value);
    if (status != NO_ERROR) goto error;
    setSessionId(value);
    return NO_ERROR;
error:
    ALOGE("AAudioStreamConfiguration.readFromParcel(): read failed = %d", status);
+1 −0
Original line number Diff line number Diff line
@@ -133,6 +133,7 @@ aaudio_result_t AudioStreamInternal::open(const AudioStreamBuilder &builder) {
    setSampleRate(configurationOutput.getSampleRate());
    setSamplesPerFrame(configurationOutput.getSamplesPerFrame());
    setDeviceId(configurationOutput.getDeviceId());
    setSessionId(configurationOutput.getSessionId());
    setSharingMode(configurationOutput.getSharingMode());

    setUsage(configurationOutput.getUsage());
Loading