HephAudio v3.0.6
A cross-platform C++ library for recording, playing, and processing audio on Windows, Android, Linux, iOS, and macOS.
Loading...
Searching...
No Matches
AndroidAudioSLES.h
Go to the documentation of this file.
1#pragma once
2#if defined(__ANDROID__) && __ANDROID_API__ >= HEPHAUDIO_ANDROID_OPENSL_MIN_API_LEVEL
3#include "HephAudioShared.h"
4#include "AndroidAudioBase.h"
6#include <SLES/OpenSLES.h>
7#include <SLES/OpenSLES_Android.h>
8
11namespace HephAudio
12{
13 namespace Native
14 {
20 {
21 public:
22 using NativeAudio::InitializeRender;
23 using NativeAudio::InitializeCapture;
24
25 private:
26 struct CallbackContext
27 {
28 AndroidAudioSLES* pAndroidAudio;
29 SLint8* pData;
30 SLuint32 index;
31 SLuint32 bufferSize_byte;
32 SLuint32 bufferSize_frame;
33 };
34
35 private:
36 OpenSLParams params;
37 SLObjectItf audioEngineObject;
38 SLEngineItf audioEngine;
39 SLObjectItf outputMixObject;
40 SLObjectItf audioPlayerObject;
41 SLPlayItf audioPlayer;
42 SLVolumeItf masterVolumeObject;
43 SLObjectItf audioRecorderObject;
44 SLRecordItf audioRecorder;
45 CallbackContext renderCallbackContext;
46 CallbackContext captureCallbackContext;
47
48 public:
51
52 AndroidAudioSLES(const AndroidAudioSLES&) = delete;
53 AndroidAudioSLES& operator=(const AndroidAudioSLES&) = delete;
54
57
58 void SetMasterVolume(double volume) override;
59 double GetMasterVolume() const override;
60 void InitializeRender(AudioDevice* device, AudioFormatInfo format) override;
61 void StopRendering() override;
62 void InitializeCapture(AudioDevice* device, AudioFormatInfo format) override;
63 void StopCapturing() override;
64 void GetNativeParams(NativeAudioParams& nativeParams) const override;
65 void SetNativeParams(const NativeAudioParams& nativeParams) override;
66
67 private:
68 SLAndroidDataFormat_PCM_EX ToSLFormat(AudioFormatInfo& formatInfo);
69 static void BufferQueueCallback(SLBufferQueueItf bufferQueue, void* pContext);
70 static void RecordEventCallback(SLAndroidSimpleBufferQueueItf simpleBufferQueue, void* pContext);
71 };
72 }
73}
74#endif
#define HEPH_API
Definition HephShared.h:132
base class for classes that interact with the Android audio APIs.
Definition AndroidAudioBase.h:21
uses OpenSL ES
Definition AndroidAudioSLES.h:20
void SetNativeParams(const NativeAudioParams &nativeParams) override
double GetMasterVolume() const override
void InitializeRender(AudioDevice *device, AudioFormatInfo format) override
void SetMasterVolume(double volume) override
void InitializeCapture(AudioDevice *device, AudioFormatInfo format) override
void GetNativeParams(NativeAudioParams &nativeParams) const override
stores information about an audio device.
Definition AudioDevice.h:76
stores the properties of the audio signals
Definition AudioFormatInfo.h:20
base class for storing the native audio API specific parameters.
Definition NativeAudioParams.h:15
struct for storing the OpenSL ES specific parameters.
Definition OpenSLParams.h:18