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
HephAudio::Native::WinAudioBase Class Reference

base class for classes that interact with the Windows audio APIs. More...

#include <WinAudioBase.h>

Inheritance diagram for HephAudio::Native::WinAudioBase:
HephAudio::Native::NativeAudio HephAudio::Native::WinAudio HephAudio::Native::WinAudioDS HephAudio::Native::WinAudioMME

Public Member Functions

 WinAudioBase ()
 
 WinAudioBase (const WinAudioBase &)=delete
 
WinAudioBaseoperator= (const WinAudioBase &)=delete
 
virtual ~WinAudioBase ()=default
 
- Public Member Functions inherited from HephAudio::Native::NativeAudio
 NativeAudio ()
 
 NativeAudio (const NativeAudio &)=delete
 
NativeAudiooperator= (const NativeAudio &)=delete
 
virtual ~NativeAudio ()=default
 
std::shared_ptr< IAudioDecoderGetAudioDecoder () const
 
void SetAudioDecoder (std::shared_ptr< IAudioDecoder > pNewDecoder)
 
std::shared_ptr< IAudioEncoderGetAudioEncoder () const
 
void SetAudioEncoder (std::shared_ptr< IAudioEncoder > pNewEncoder)
 
AudioObjectPlay (const std::filesystem::path &filePath)
 
AudioObjectPlay (const std::filesystem::path &filePath, uint32_t playCount)
 
AudioObjectPlay (const std::filesystem::path &filePath, uint32_t playCount, bool isPaused)
 
AudioObjectLoad (const std::filesystem::path &filePath)
 
AudioObjectLoad (const std::filesystem::path &filePath, uint32_t playCount)
 
AudioObjectLoad (const std::filesystem::path &filePath, uint32_t playCount, bool isPaused)
 
AudioObjectCreateAudioObject (const std::string &name, size_t bufferFrameCount, AudioChannelLayout channelLayout, uint16_t sampleRate)
 
bool DestroyAudioObject (AudioObject *pAudioObject)
 
bool DestroyAudioObject (const Heph::Guid &audioObjectId)
 
bool AudioObjectExists (AudioObject *pAudioObject) const
 
bool AudioObjectExists (const Heph::Guid &audioObjectId) const
 
AudioObjectGetAudioObject (size_t index)
 
AudioObjectGetAudioObject (const Heph::Guid &audioObjectId)
 
AudioObjectGetAudioObject (const std::string &audioObjectName)
 
size_t GetAudioObjectCount () const
 
void ResumeCapture ()
 
void PauseCapture ()
 
bool IsCapturePaused () const
 
uint32_t GetDeviceEnumerationPeriod () const
 
void SetDeviceEnumerationPeriod (uint32_t deviceEnumerationPeriod_ms)
 
virtual void SetMasterVolume (double volume)=0
 
virtual double GetMasterVolume () const =0
 
const AudioFormatInfoGetRenderFormat () const
 
const AudioFormatInfoGetCaptureFormat () const
 
void InitializeRender ()
 
void InitializeRender (AudioChannelLayout channelLayout, uint32_t sampleRate)
 
void InitializeRender (AudioFormatInfo format)
 
virtual void InitializeRender (AudioDevice *device, AudioFormatInfo format)=0
 
virtual void StopRendering ()=0
 
void InitializeCapture ()
 
void InitializeCapture (AudioChannelLayout channelLayout, uint32_t sampleRate)
 
void InitializeCapture (AudioFormatInfo format)
 
virtual void InitializeCapture (AudioDevice *device, AudioFormatInfo format)=0
 
virtual void StopCapturing ()=0
 
virtual void GetNativeParams (NativeAudioParams &nativeParams) const =0
 
virtual void SetNativeParams (const NativeAudioParams &nativeParams)=0
 
AudioDevice GetAudioDeviceById (const std::string &deviceId) const
 
AudioDevice GetRenderDevice () const
 
AudioDevice GetCaptureDevice () const
 
AudioDevice GetDefaultAudioDevice (AudioDeviceType deviceType) const
 
std::vector< AudioDeviceGetAudioDevices (AudioDeviceType deviceType) const
 

Protected Member Functions

void InitializeCOM () const
 
- Protected Member Functions inherited from HephAudio::Native::NativeAudio
virtual bool EnumerateAudioDevices ()=0
 
virtual void CheckAudioDevices ()
 
void JoinRenderThread ()
 
void JoinCaptureThread ()
 
void JoinDeviceThread ()
 
EncodedAudioBuffer Mix (uint32_t frameCount)
 
size_t GetAOCountToMix () const
 
virtual double GetFinalAOVolume (AudioObject *pAudioObject) const
 

Static Protected Member Functions

static AudioFormatInfo WFX2AFI (const WAVEFORMATEXTENSIBLE &wfx)
 
static WAVEFORMATEXTENSIBLE AFI2WFX (const AudioFormatInfo &afi)
 
static std::string GetComErrorMessage (HRESULT hr)
 

Additional Inherited Members

- Public Attributes inherited from HephAudio::Native::NativeAudio
Heph::Event OnAudioDeviceAdded
 
Heph::Event OnAudioDeviceRemoved
 
Heph::Event OnCapture
 
- Protected Attributes inherited from HephAudio::Native::NativeAudio
std::shared_ptr< IAudioDecoderpAudioDecoder
 
std::shared_ptr< IAudioEncoderpAudioEncoder
 
std::vector< AudioObjectaudioObjects
 
std::vector< AudioDeviceaudioDevices
 
std::thread::id mainThreadId
 
std::thread renderThread
 
std::thread captureThread
 
std::thread deviceThread
 
std::string renderDeviceId
 
std::string captureDeviceId
 
AudioFormatInfo renderFormat
 
AudioFormatInfo captureFormat
 
bool disposing
 
bool isRenderInitialized
 
bool isCaptureInitialized
 
bool isCapturePaused
 
uint32_t deviceEnumerationPeriod_ms
 
std::mutex audioDevicesMutex
 
std::recursive_mutex audioObjectsMutex
 
- Static Protected Attributes inherited from HephAudio::Native::NativeAudio
static constexpr bool DEVICE_ENUMERATION_FAIL = false
 
static constexpr bool DEVICE_ENUMERATION_SUCCESS = true
 

Detailed Description

base class for classes that interact with the Windows audio APIs.

Constructor & Destructor Documentation

◆ WinAudioBase()

HephAudio::Native::WinAudioBase::WinAudioBase ( )

creates a new instance and initializes it with default values.

◆ ~WinAudioBase()

virtual HephAudio::Native::WinAudioBase::~WinAudioBase ( )
virtualdefault

releases the resources and destroys the instance.

Member Function Documentation

◆ InitializeCOM()

void HephAudio::Native::WinAudioBase::InitializeCOM ( ) const
protected

initializes COM.

◆ WFX2AFI()

static AudioFormatInfo HephAudio::Native::WinAudioBase::WFX2AFI ( const WAVEFORMATEXTENSIBLE & wfx)
staticprotected

converts WAVEFORMATEXTENSIBLE to AudioFormatInfo.

◆ AFI2WFX()

static WAVEFORMATEXTENSIBLE HephAudio::Native::WinAudioBase::AFI2WFX ( const AudioFormatInfo & afi)
staticprotected

converts AudioFormatInfo to WAVEFORMATEXTENSIBLE.

◆ GetComErrorMessage()

static std::string HephAudio::Native::WinAudioBase::GetComErrorMessage ( HRESULT hr)
staticprotected

gets the COM error message that corresponds to the HRESULT.