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

Commit 4e1af9fc authored by Phil Burk's avatar Phil Burk
Browse files

aaudio: implement sessionId for effects

If a sessionID other than AAUDIO_SESSION_ID_NONE is requested
then legacy data path will be forced.

SessionID is implemented for MMAP data path but not used.
It is easier to implement it now then try to figure
it out later.

Bug: 33268927
Test: test_session_id.cpp will be moved to CTS when stable
Change-Id: I3ea67f57c1cbe24a512980f1352b917ab3cb6387
parent a11f9357
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);
+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());
+14 −1
Original line number Diff line number Diff line
@@ -202,6 +202,13 @@ AAUDIO_API void AAudioStreamBuilder_setBufferCapacityInFrames(AAudioStreamBuilde
    streamBuilder->setBufferCapacity(frames);
}

AAUDIO_API void AAudioStreamBuilder_setSessionId(AAudioStreamBuilder* builder,
                                                 aaudio_session_id_t sessionId)
{
    AudioStreamBuilder *streamBuilder = convertAAudioBuilderToStreamBuilder(builder);
    streamBuilder->setSessionId(sessionId);
}

AAUDIO_API void AAudioStreamBuilder_setDataCallback(AAudioStreamBuilder* builder,
                                                    AAudioStream_dataCallback callback,
                                                    void *userData)
@@ -483,6 +490,12 @@ AAUDIO_API aaudio_input_preset_t AAudioStream_getInputPreset(AAudioStream* strea
    return audioStream->getInputPreset();
}

AAUDIO_API int32_t AAudioStream_getSessionId(AAudioStream* stream)
{
    AudioStream *audioStream = convertAAudioStreamToAudioStream(stream);
    return audioStream->getSessionId();
}

AAUDIO_API int64_t AAudioStream_getFramesWritten(AAudioStream* stream)
{
    AudioStream *audioStream = convertAAudioStreamToAudioStream(stream);
+11 −1
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ void AAudioStreamParameters::copyFrom(const AAudioStreamParameters &other) {
    mSamplesPerFrame = other.mSamplesPerFrame;
    mSampleRate      = other.mSampleRate;
    mDeviceId        = other.mDeviceId;
    mSessionId       = other.mSessionId;
    mSharingMode     = other.mSharingMode;
    mAudioFormat     = other.mAudioFormat;
    mDirection       = other.mDirection;
@@ -59,6 +60,15 @@ aaudio_result_t AAudioStreamParameters::validate() const {
        return AAUDIO_ERROR_OUT_OF_RANGE;
    }

    // All Session ID values are legal.
    switch (mSessionId) {
        case AAUDIO_SESSION_ID_NONE:
        case AAUDIO_SESSION_ID_ALLOCATE:
            break;
        default:
            break;
    }

    switch (mSharingMode) {
        case AAUDIO_SHARING_MODE_EXCLUSIVE:
        case AAUDIO_SHARING_MODE_SHARED:
@@ -154,6 +164,7 @@ aaudio_result_t AAudioStreamParameters::validate() const {

void AAudioStreamParameters::dump() const {
    ALOGD("mDeviceId        = %6d", mDeviceId);
    ALOGD("mSessionId       = %6d", mSessionId);
    ALOGD("mSampleRate      = %6d", mSampleRate);
    ALOGD("mSamplesPerFrame = %6d", mSamplesPerFrame);
    ALOGD("mSharingMode     = %6d", (int)mSharingMode);
@@ -164,4 +175,3 @@ void AAudioStreamParameters::dump() const {
    ALOGD("mContentType     = %6d", mContentType);
    ALOGD("mInputPreset     = %6d", mInputPreset);
}
Loading