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
WinAudioMME.h
Go to the documentation of this file.
1#pragma once
2#if defined(_WIN32)
3#include "HephAudioShared.h"
4#include "NativeAudio.h"
5#include "WinAudioBase.h"
6#include <mmeapi.h>
7
10namespace HephAudio
11{
12 namespace Native
13 {
18 class HEPH_API WinAudioMME final : public WinAudioBase
19 {
20 public:
21 using NativeAudio::InitializeRender;
22 using NativeAudio::InitializeCapture;
23
24 private:
25 static constexpr uint32_t HDR_COUNT = 2;
26
27 private:
28 HWAVEOUT hwo;
29 HWAVEIN hwi;
30 WAVEHDR renderHdrs[HDR_COUNT];
31 WAVEHDR captureHdrs[HDR_COUNT];
32
33 public:
36
37 WinAudioMME(const WinAudioMME&) = delete;
38 WinAudioMME& operator=(const WinAudioMME&) = delete;
39
42
43 void SetMasterVolume(double volume) override;
44 double GetMasterVolume() const override;
46 void StopRendering() override;
47 void InitializeCapture(AudioDevice* device, AudioFormatInfo format) override;
48 void StopCapturing() override;
49 void GetNativeParams(NativeAudioParams& nativeParams) const override;
50 void SetNativeParams(const NativeAudioParams& nativeParams) override;
51 private:
52 bool EnumerateAudioDevices() override;
53 AudioFormatInfo GetClosestFormat(DWORD dwFormats, const AudioFormatInfo& format) const;
54 static size_t CalculateBufferSize(uint32_t byteRate, uint32_t sampleRate);
55 static void CALLBACK RenderCallback(HWAVEOUT hwo, UINT uMsg, DWORD_PTR dwInstance, DWORD_PTR dwParam1, DWORD_PTR dwParam2);
56 static void CALLBACK CaptureCallback(HWAVEIN hwi, UINT uMsg, DWORD_PTR dwInstance, DWORD_PTR dwParam1, DWORD_PTR dwParam2);
57 static std::string GetErrorString(MMRESULT mmResult);
58 };
59 }
60}
61#endif
#define HEPH_API
Definition HephShared.h:132
base class for classes that interact with the Windows audio APIs.
Definition WinAudioBase.h:24
uses MMEAPI (waveIn and waveOut)
Definition WinAudioMME.h:19
void GetNativeParams(NativeAudioParams &nativeParams) const override
void InitializeCapture(AudioDevice *device, AudioFormatInfo format) override
double GetMasterVolume() const override
void InitializeRender(AudioDevice *device, AudioFormatInfo format)
void SetMasterVolume(double volume) override
void SetNativeParams(const NativeAudioParams &nativeParams) 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