From ed9fa0ed014c3bbd286a54b1de851d88fce4d790 Mon Sep 17 00:00:00 2001 From: Eric Laurent Date: Thu, 15 Dec 2016 09:33:53 -0800 Subject: [PATCH] audio: add methods and structures for streamin MMAP mode Bug: 33398120 Test: make marlin-eng with ENABLE_TREBLE true Change-Id: I65c5c7ba0a94ba47dca78ace38ef3ae75ea7e3bf --- audio/2.0/IStream.hal | 52 +++++++++++++++++++++++++++++++++++++++++++ audio/2.0/types.hal | 19 ++++++++++++++++ 2 files changed, 71 insertions(+) diff --git a/audio/2.0/IStream.hal b/audio/2.0/IStream.hal index dc43346ed2..5c88a6938c 100644 --- a/audio/2.0/IStream.hal +++ b/audio/2.0/IStream.hal @@ -227,4 +227,56 @@ interface IStream { * @param fd dump file descriptor. */ debugDump(handle fd); + + /* + * Called by the framework to start a stream operating in mmap mode. + * createMmapBuffer() must be called before calling start(). + * Function only implemented by streams operating in mmap mode. + * + * @return retval OK in case the success. + * NOT_SUPPORTED on non mmap mode streams + * INVALID_STATE if called out of sequence + */ + start() generates (Result retval); + + /** + * Called by the framework to stop a stream operating in mmap mode. + * Function only implemented by streams operating in mmap mode. + * + * @return retval OK in case the succes. + * NOT_SUPPORTED on non mmap mode streams + * INVALID_STATE if called out of sequence + */ + stop() generates (Result retval) ; + + /* + * Called by the framework to retrieve information on the mmap buffer used for audio + * samples transfer. + * Function only implemented by streams operating in mmap mode. + * + * @param minSizeFrames minimum buffer size requested. The actual buffer + * size returned in struct MmapBufferInfo can be larger. + * @return retval OK in case the success. + * NOT_SUPPORTED on non mmap mode streams + * NOT_INITIALIZED in case of memory allocation error + * INVALID_ARGUMENTS if the requested buffer size is too large + * INVALID_STATE if called out of sequence + * @return info a MmapBufferInfo struct containing information on the MMMAP buffer created. + */ + createMmapBuffer(int32_t minSizeFrames) + generates (Result retval, MmapBufferInfo info); + + /* + * Called by the framework to read current read/write position in the mmap buffer + * with associated time stamp. + * Function only implemented by streams operating in mmap mode. + * + * @return retval OK in case the success. + * NOT_SUPPORTED on non mmap mode streams + * INVALID_STATE if called out of sequence + * @return position a MmapPosition struct containing current HW read/write position in frames + * with associated time stamp. + */ + getMmapPosition() + generates (Result retval, MmapPosition position); }; diff --git a/audio/2.0/types.hal b/audio/2.0/types.hal index 7002f38640..37c39e4df0 100644 --- a/audio/2.0/types.hal +++ b/audio/2.0/types.hal @@ -70,3 +70,22 @@ struct DeviceAddress { string busAddress; // used for BUS string rSubmixAddress; // used for REMOTE_SUBMIX }; + +/* + * Mmap buffer descriptor returned by IStream.createMmapBuffer(). + * Used by streams opened in mmap mode. + */ +struct MmapBufferInfo { + memory sharedMemory; // mmap memory buffer + int32_t bufferSizeFrames; // total buffer size in frames + int32_t burstSizeFrames; // transfer size granularity in frames +}; + +/* + * Mmap buffer read/write position returned by IStream.getMmapPosition(). + * Used by streams opened in mmap mode. + */ +struct MmapPosition { + int64_t timeNanoseconds; // time stamp in ns, CLOCK_MONOTONIC + int32_t positionFrames; // increasing 32 bit frame count reset when IStream.stop() is called +};