1e41f4b71Sopenharmony_ci# OpenSL ES 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ci## Introduction 4e41f4b71Sopenharmony_ci 5e41f4b71Sopenharmony_ciOpen 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. 6e41f4b71Sopenharmony_ci 7e41f4b71Sopenharmony_ci## Introducing OpenSL ES 8e41f4b71Sopenharmony_ci 9e41f4b71Sopenharmony_ciTo use OpenSL ES capabilities, include the following header files: 10e41f4b71Sopenharmony_ci 11e41f4b71Sopenharmony_ci``` 12e41f4b71Sopenharmony_ci#include <SLES/OpenSLES.h> 13e41f4b71Sopenharmony_ci#include <SLES/OpenSLES_OpenHarmony.h> 14e41f4b71Sopenharmony_ci#include <SLES/OpenSLES_Platform.h> 15e41f4b71Sopenharmony_ci``` 16e41f4b71Sopenharmony_ci 17e41f4b71Sopenharmony_ciAdd the following dynamic link library to **CMakeLists.txt**: 18e41f4b71Sopenharmony_ci 19e41f4b71Sopenharmony_ci``` 20e41f4b71Sopenharmony_cilibOpenSLES.so 21e41f4b71Sopenharmony_ci``` 22e41f4b71Sopenharmony_ci 23e41f4b71Sopenharmony_ci## Supported APIs 24e41f4b71Sopenharmony_ci 25e41f4b71Sopenharmony_ci|Object |External Interface |Interface Invocation |Supported |Description | 26e41f4b71Sopenharmony_ci| ------------------ | -------------------- | -------------------------------------------------------------------------------------|----------| -------------------- | 27e41f4b71Sopenharmony_ci|SLEngineItf |CreateAudioPlayer |CreateAudioPlayer(SLEngineItf self, SLObjectItf *pPlayer, SLDataSource *pAudioSrc, SLDataSink *pAudioSnk, SLuint32 numInterfaces, const SLInterfaceID *pInterfaceIds, const SLboolean *pInterfaceRequired) |Yes |Creates an audio player. | 28e41f4b71Sopenharmony_ci|SLEngineItf |CreateAudioRecorder |reateAudioRecorder(SLEngineItf self, SLObjectItf *pRecorder, SLDataSource *pAudioSrc, SLDataSink *pAudioSnk, SLuint32 numInterfaces, const SLInterfaceID *pInterfaceIds, const SLboolean *pInterfaceRequired)|Yes |Creates an audio recorder. | 29e41f4b71Sopenharmony_ci|SLEngineItf |CreateAudioOutputMix |CreateOutputMix(SLEngineItf self, SLObjectItf *pMix, SLuint32 numInterfaces, const SLInterfaceID *pInterfaceIds, const SLboolean *pInterfaceRequired)|Yes |Creates an audio output mixer. | 30e41f4b71Sopenharmony_ci|SLObjectItf |Realize |Realize(SLObjectItf self, SLboolean async) |Yes |Realizes an audio player. | 31e41f4b71Sopenharmony_ci|SLObjectItf |getState |GetState(SLObjectItf self, SLuint32 *pState) |Yes |Obtains the state. | 32e41f4b71Sopenharmony_ci|SLObjectItf |getInterface |GetInterface(SLObjectItf self, const SLInterfaceID iid, void *pInterface) |Yes |Obtains the interface. | 33e41f4b71Sopenharmony_ci|SLObjectItf |Destroy |Destroy(SLObjectItf self) |Yes |Destroys an object. | 34e41f4b71Sopenharmony_ci|SLOHBufferQueueItf |Enqueue |Enqueue(SLOHBufferQueueItf self, const void *pBuffer, SLuint32 size) |Yes |Adds a buffer to the queue.| 35e41f4b71Sopenharmony_ci|SLOHBufferQueueItf |clear |Clear(SLOHBufferQueueItf self) |Yes |Releases the buffer queue. | 36e41f4b71Sopenharmony_ci|SLOHBufferQueueItf |getState |GetState(SLOHBufferQueueItf self, SLOHBufferQueueState *pState) |Yes |Obtains the BufferQueue status. | 37e41f4b71Sopenharmony_ci|SLOHBufferQueueItf |getBuffer |GetBuffer(SLOHBufferQueueItf self, SLuint8 **buffer, SLuint32 *size) |Yes |Obtains a buffer. | 38e41f4b71Sopenharmony_ci|SLOHBufferQueueItf |RegisterCallback |RegisterCallback(SLOHBufferQueueItf self, SlOHBufferQueueCallback callback, void *pContext) |Yes |Registers a callback. | 39e41f4b71Sopenharmony_ci|SLPlayItf |SetPlayState |SetPlayState(SLPlayItf self, SLuint32 state) |Yes |Sets the playback state. | 40e41f4b71Sopenharmony_ci|SLPlayItf |GetPlayState |GetPlayState(SLPlayItf self, SLuint32 *pState) |Yes |Obtains the playback state. | 41e41f4b71Sopenharmony_ci|SLRecordItf |SetRecordState |SetRecordState(SLRecordItf self, SLuint32 state) |Yes |Sets the recording state. | 42e41f4b71Sopenharmony_ci|SLRecordItf |GetRecordState |GetRecordState(SLRecordItf self, SLuint32 *pState) |Yes |Obtains the recording state. | 43e41f4b71Sopenharmony_ci|SLVolumeItf |SetVolumeLevel |SetVolumeLevel(SLVolumeItf self, SLmillibel level) |Yes |Sets the volume. | 44e41f4b71Sopenharmony_ci|SLVolumeItf |GetVolumeLevel |GetVolumeLevel(SLVolumeItf self, SLmillibel *pLevel) |Yes |Obtains the volume. | 45e41f4b71Sopenharmony_ci|SLVolumeItf |GetMaxVolumeLevel |GetMaxVolumeLevel(SLVolumeItf self, SLmillibel *pMaxLevel) |Yes |Obtains the maximum volume. | 46