#ifndef __RKAUDIO_H__ #define __RKAUDIO_H__ #include #include namespace RkAudio { // constexpr auto ParamFilePath="/data/sdcard/rw_3a.bin"; constexpr auto ParamFilePath = "/data/sdcard/RKAP_3A_Para.bin"; class Format { public: enum Endian { BigEndian, LittleEndian, }; enum SampleType { Unknown, SignedInt16, SignedInt, Float, }; SampleType sampleType = SignedInt16; Endian byteOrder = LittleEndian; uint32_t sampleRate = 48000; uint32_t channels = 2; uint32_t period = 60; }; class Frame { public: uint8_t *data = nullptr; int32_t byteSize = 0; int32_t frameSize = 0; std::chrono::system_clock::time_point timestamp; }; class Input { public: using ReadCallback = std::function; Input(); ~Input(); void setDataCallback(const ReadCallback &callback); bool open(const Format &format); void stop(); protected: void run(); private: int32_t m_channel = -1; bool m_exit = false; std::thread m_thread; ReadCallback m_callback; Format m_format; }; class Output { public: Output(); ~Output(); bool open(uint32_t sampleSize, uint32_t sampleRate, uint32_t channels); void close(); void write(const uint8_t *data, uint32_t byteSize); private: int32_t m_channel = -1; }; } // namespace RkAudio #endif // __RKAUDIO_H__