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

Commit 0f5e339e authored by Jaideep Sharma's avatar Jaideep Sharma Committed by Cherrypicker Worker
Browse files

libaudiohal: Modify calculation of buffer duration for mmap streams

To calculate to buffer duration of mmap streams, use burst size.
Burst size gives proper timings about consumption of mmap buffers,
eventually adjusting the mLastReplyLifeTimeNs, which impacts query of
position from HAL.

Bug: 342529498
Test: run mmap usecase and check timestamp query interval.
(cherry picked from https://android-review.googlesource.com/q/commit:0cb1387ee606c06e0e2270344bfb36039f4be0a1)
Merged-In: Ibb88765da62e019bbb677fe0b1980bbf64e82073
Change-Id: Ibb88765da62e019bbb677fe0b1980bbf64e82073
parent 7e7dfe64
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -95,7 +95,8 @@ class StreamContextAidl {
    size_t getBufferSizeBytes() const { return mFrameSizeBytes * mBufferSizeFrames; }
    size_t getBufferSizeFrames() const { return mBufferSizeFrames; }
    size_t getBufferDurationMs(int32_t sampleRate) const {
        return sampleRate != 0 ? mBufferSizeFrames * MILLIS_PER_SECOND / sampleRate : 0;
        auto bufferSize = mIsMmapped ? getMmapBurstSize() : mBufferSizeFrames;
        return sampleRate != 0 ? bufferSize * MILLIS_PER_SECOND / sampleRate : 0;
    }
    CommandMQ* getCommandMQ() const { return mCommandMQ.get(); }
    DataMQ* getDataMQ() const { return mDataMQ.get(); }
@@ -104,7 +105,7 @@ class StreamContextAidl {
    bool isAsynchronous() const { return mIsAsynchronous; }
    bool isMmapped() const { return mIsMmapped; }
    const MmapBufferDescriptor& getMmapBufferDescriptor() const { return mMmapBufferDescriptor; }

    size_t getMmapBurstSize() const { return mMmapBufferDescriptor.burstSizeFrames;}
  private:
    static std::unique_ptr<DataMQ> maybeCreateDataMQ(
            const ::aidl::android::hardware::audio::core::StreamDescriptor& descriptor) {