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

Commit f8c7618b authored by Andy Hung's avatar Andy Hung Committed by Gerrit Code Review
Browse files

Merge "audioflinger: add DirectRecordThread" into main

parents 1c148b8a 32a815a0
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -144,6 +144,7 @@ public:
        MMAP_CAPTURE,   // Thread class for MMAP capture stream
        SPATIALIZER,    //
        BIT_PERFECT,    // Thread class for BitPerfectThread
        DIRECT_RECORD,  // Thread class for DirectRecordThread
        // When adding a value, also update IAfThreadBase::threadTypeToString()
    };

+20 −2
Original line number Diff line number Diff line
@@ -629,6 +629,8 @@ const char* ThreadBase::threadTypeToString(ThreadBase::type_t type)
        return "SPATIALIZER";
    case BIT_PERFECT:
        return "BIT_PERFECT";
    case DIRECT_RECORD:
        return "DIRECT_RECORD";
    default:
        return "unknown";
    }
@@ -8170,15 +8172,19 @@ sp<IAfRecordThread> IAfRecordThread::create(const sp<IAfThreadCallback>& afThrea
        AudioStreamIn* input,
        audio_io_handle_t id,
        bool systemReady) {
    return sp<RecordThread>::make(afThreadCallback, input, id, systemReady);
    if (input->flags & AUDIO_INPUT_FLAG_DIRECT) {
        return sp<DirectRecordThread>::make(afThreadCallback, input, id, systemReady);
    }
    return sp<RecordThread>::make(afThreadCallback, RECORD, input, id, systemReady);
}

RecordThread::RecordThread(const sp<IAfThreadCallback>& afThreadCallback,
                                         ThreadBase::type_t type,
                                         AudioStreamIn *input,
                                         audio_io_handle_t id,
                                         bool systemReady
                                         ) :
    ThreadBase(afThreadCallback, id, RECORD, systemReady, false /* isOut */),
    ThreadBase(afThreadCallback, id, type, systemReady, false /* isOut */),
    mInput(input),
    mSource(mInput),
    mActiveTracks(&this->mLocalLog),
@@ -9589,6 +9595,18 @@ void RecordThread::setRecordSilenced(audio_port_handle_t portId, bool silenced)
    }
}

// --------------------------------------------------------------------------------------
//              DirectRecordThread
// --------------------------------------------------------------------------------------

DirectRecordThread::DirectRecordThread(const sp<IAfThreadCallback>& afThreadCallback,
                                     AudioStreamIn* input, audio_io_handle_t id, bool systemReady)
    : RecordThread(afThreadCallback, DIRECT_RECORD, input, id, systemReady) {
    ALOGD("%s:", __func__);
}

DirectRecordThread::~DirectRecordThread() {}

void ResamplerBufferProvider::reset()
{
    const auto threadBase = mRecordTrack->thread().promote();
+8 −0
Original line number Diff line number Diff line
@@ -1990,6 +1990,7 @@ public:
    }

            RecordThread(const sp<IAfThreadCallback>& afThreadCallback,
                    ThreadBase::type_t type,
                    AudioStreamIn *input,
                    audio_io_handle_t id,
                    bool systemReady
@@ -2221,6 +2222,13 @@ private:
            audio_session_t                     mSharedAudioSessionId = AUDIO_SESSION_NONE;
};

class DirectRecordThread final : public RecordThread {
  public:
    DirectRecordThread(const sp<IAfThreadCallback>& afThreadCallback, AudioStreamIn* input,
                       audio_io_handle_t id, bool systemReady);
    ~DirectRecordThread() override;
};

class MmapThread : public ThreadBase, public virtual IAfMmapThread
{
 public:
+1 −1
Original line number Diff line number Diff line
@@ -3168,7 +3168,7 @@ status_t RecordTrack::setParameters(const String8& keyValuePairs) {
    if (thread == nullptr) {
        ALOGE("%s(%d): thread is dead", __func__, mId);
        return FAILED_TRANSACTION;
    } else if (thread->type() == IAfThreadBase::DIRECT) {
    } else if (thread->type() == IAfThreadBase::DIRECT_RECORD) {
        return thread->setParameters(keyValuePairs);
    } else {
        return PERMISSION_DENIED;