1# OpenSL ES 2 3## Introduction 4 5Open Sound Library for Embedded Systems (OpenSL ES) is a set of audio acceleration standards for embedded systems. It provides objects and APIs for developers to implement high-performance, low-latency audio features. OpenHarmony implements some native APIs based on [OpenSL ES](https://www.khronos.org/opensles/) 1.0.1 API specifications. The table [Supported APIs](#supported-apis) list these APIs. 6 7## Introducing OpenSL ES 8 9To use OpenSL ES capabilities, include the following header files: 10 11``` 12#include <SLES/OpenSLES.h> 13#include <SLES/OpenSLES_OpenHarmony.h> 14#include <SLES/OpenSLES_Platform.h> 15``` 16 17Add the following dynamic link library to **CMakeLists.txt**: 18 19``` 20libOpenSLES.so 21``` 22 23## Supported APIs 24 25|Object |External Interface |Interface Invocation |Supported |Description | 26| ------------------ | -------------------- | -------------------------------------------------------------------------------------|----------| -------------------- | 27|SLEngineItf |CreateAudioPlayer |CreateAudioPlayer(SLEngineItf self, SLObjectItf *pPlayer, SLDataSource *pAudioSrc, SLDataSink *pAudioSnk, SLuint32 numInterfaces, const SLInterfaceID *pInterfaceIds, const SLboolean *pInterfaceRequired) |Yes |Creates an audio player. | 28|SLEngineItf |CreateAudioRecorder |reateAudioRecorder(SLEngineItf self, SLObjectItf *pRecorder, SLDataSource *pAudioSrc, SLDataSink *pAudioSnk, SLuint32 numInterfaces, const SLInterfaceID *pInterfaceIds, const SLboolean *pInterfaceRequired)|Yes |Creates an audio recorder. | 29|SLEngineItf |CreateAudioOutputMix |CreateOutputMix(SLEngineItf self, SLObjectItf *pMix, SLuint32 numInterfaces, const SLInterfaceID *pInterfaceIds, const SLboolean *pInterfaceRequired)|Yes |Creates an audio output mixer. | 30|SLObjectItf |Realize |Realize(SLObjectItf self, SLboolean async) |Yes |Realizes an audio player. | 31|SLObjectItf |getState |GetState(SLObjectItf self, SLuint32 *pState) |Yes |Obtains the state. | 32|SLObjectItf |getInterface |GetInterface(SLObjectItf self, const SLInterfaceID iid, void *pInterface) |Yes |Obtains the interface. | 33|SLObjectItf |Destroy |Destroy(SLObjectItf self) |Yes |Destroys an object. | 34|SLOHBufferQueueItf |Enqueue |Enqueue(SLOHBufferQueueItf self, const void *pBuffer, SLuint32 size) |Yes |Adds a buffer to the queue.| 35|SLOHBufferQueueItf |clear |Clear(SLOHBufferQueueItf self) |Yes |Releases the buffer queue. | 36|SLOHBufferQueueItf |getState |GetState(SLOHBufferQueueItf self, SLOHBufferQueueState *pState) |Yes |Obtains the BufferQueue status. | 37|SLOHBufferQueueItf |getBuffer |GetBuffer(SLOHBufferQueueItf self, SLuint8 **buffer, SLuint32 *size) |Yes |Obtains a buffer. | 38|SLOHBufferQueueItf |RegisterCallback |RegisterCallback(SLOHBufferQueueItf self, SlOHBufferQueueCallback callback, void *pContext) |Yes |Registers a callback. | 39|SLPlayItf |SetPlayState |SetPlayState(SLPlayItf self, SLuint32 state) |Yes |Sets the playback state. | 40|SLPlayItf |GetPlayState |GetPlayState(SLPlayItf self, SLuint32 *pState) |Yes |Obtains the playback state. | 41|SLRecordItf |SetRecordState |SetRecordState(SLRecordItf self, SLuint32 state) |Yes |Sets the recording state. | 42|SLRecordItf |GetRecordState |GetRecordState(SLRecordItf self, SLuint32 *pState) |Yes |Obtains the recording state. | 43|SLVolumeItf |SetVolumeLevel |SetVolumeLevel(SLVolumeItf self, SLmillibel level) |Yes |Sets the volume. | 44|SLVolumeItf |GetVolumeLevel |GetVolumeLevel(SLVolumeItf self, SLmillibel *pLevel) |Yes |Obtains the volume. | 45|SLVolumeItf |GetMaxVolumeLevel |GetMaxVolumeLevel(SLVolumeItf self, SLmillibel *pMaxLevel) |Yes |Obtains the maximum volume. | 46