1# OpenSL ES
2
3> **NOTE**
4>
5> OpenHarmony provides the OpenSL ES APIs for audio development at the native layer since SDK 8. As the version evolves, these APIs fail to meet the capability expansion requirements of the audio system and therefore are no longer recommended. [Switch from OpenSL ES to OHAudio](../../media/audio/replace-opensles-by-ohaudio.md).
6
7## Introduction
8
9Open 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.
10
11## Introducing OpenSL ES
12
13To use OpenSL ES capabilities, include the following header files:
14
15```
16#include <SLES/OpenSLES.h>
17#include <SLES/OpenSLES_OpenHarmony.h>
18#include <SLES/OpenSLES_Platform.h>
19```
20
21Add the following dynamic link library to **CMakeLists.txt**:
22
23```
24libOpenSLES.so
25```
26
27## Supported APIs
28
29|Object               |External Interface              |Interface Invocation                                                                          |Supported  |Description                 |
30| ------------------ | -------------------- | -------------------------------------------------------------------------------------|----------| -------------------- |
31|SLEngineItf         |CreateAudioPlayer     |CreateAudioPlayer(SLEngineItf self, SLObjectItf *pPlayer, SLDataSource *pAudioSrc, SLDataSink *pAudioSnk, SLuint32 numInterfaces, const SLInterfaceID *pInterfaceIds, const SLboolean *pInterfaceRequired) |Yes       |Creates an audio player.       |
32|SLEngineItf         |CreateAudioRecorder   |reateAudioRecorder(SLEngineItf self, SLObjectItf *pRecorder, SLDataSource *pAudioSrc, SLDataSink *pAudioSnk, SLuint32 numInterfaces, const SLInterfaceID *pInterfaceIds, const SLboolean *pInterfaceRequired)|Yes       |Creates an audio recorder.       |
33|SLEngineItf         |CreateAudioOutputMix  |CreateOutputMix(SLEngineItf self, SLObjectItf *pMix, SLuint32 numInterfaces, const SLInterfaceID *pInterfaceIds, const SLboolean *pInterfaceRequired)|Yes       |Creates an audio output mixer.           |
34|SLObjectItf         |Realize               |Realize(SLObjectItf self, SLboolean async)                                            |Yes       |Realizes an audio player.       |
35|SLObjectItf         |getState              |GetState(SLObjectItf self, SLuint32 *pState)                                           |Yes       |Obtains the state.            |
36|SLObjectItf         |getInterface          |GetInterface(SLObjectItf self, const SLInterfaceID iid, void *pInterface)              |Yes       |Obtains the interface.            |
37|SLObjectItf         |Destroy               |Destroy(SLObjectItf self)                                                             |Yes       |Destroys an object.            |
38|SLOHBufferQueueItf  |Enqueue               |Enqueue(SLOHBufferQueueItf self, const void *pBuffer, SLuint32 size)                   |Yes       |Adds a buffer to the queue.|
39|SLOHBufferQueueItf  |clear                 |Clear(SLOHBufferQueueItf self)                                                        |Yes       |Releases the buffer queue.        |
40|SLOHBufferQueueItf  |getState              |GetState(SLOHBufferQueueItf self, SLOHBufferQueueState *pState)                        |Yes       |Obtains the BufferQueue status. |
41|SLOHBufferQueueItf  |getBuffer             |GetBuffer(SLOHBufferQueueItf self, SLuint8 **buffer, SLuint32 *size)                  |Yes       |Obtains a buffer.          |
42|SLOHBufferQueueItf  |RegisterCallback      |RegisterCallback(SLOHBufferQueueItf self, SlOHBufferQueueCallback callback, void *pContext) |Yes |Registers a callback.         |
43|SLPlayItf           |SetPlayState          |SetPlayState(SLPlayItf self, SLuint32 state)                                          |Yes       |Sets the playback state.         |
44|SLPlayItf           |GetPlayState          |GetPlayState(SLPlayItf self, SLuint32 *pState)                                         |Yes       |Obtains the playback state.         |
45|SLRecordItf         |SetRecordState        |SetRecordState(SLRecordItf self, SLuint32 state)                                      |Yes       |Sets the recording state.         |
46|SLRecordItf         |GetRecordState        |GetRecordState(SLRecordItf self, SLuint32 *pState)                                   |Yes       |Obtains the recording state.         |
47|SLVolumeItf         |SetVolumeLevel        |SetVolumeLevel(SLVolumeItf self, SLmillibel level)                                   |Yes       |Sets the volume.             |
48|SLVolumeItf         |GetVolumeLevel        |GetVolumeLevel(SLVolumeItf self, SLmillibel *pLevel)                                    |Yes       |Obtains the volume.             |
49|SLVolumeItf         |GetMaxVolumeLevel     |GetMaxVolumeLevel(SLVolumeItf self, SLmillibel *pMaxLevel)                             |Yes       |Obtains the maximum volume.         |
50