-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathaudiodevice.h
56 lines (38 loc) · 1.08 KB
/
audiodevice.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#pragma once
#ifdef HAVE_ALSA
#include <alsa/asoundlib.h>
#endif
#ifdef WIN32
#include <xaudio2.h>
#endif
#include "result.h"
#include "mediaformat.h"
#include <atomic>
namespace audiodevice
{
#ifdef WIN32
class Audio2VoiceCallback;
#endif
static const int64_t ENQUEUE_SAMPLES_US = 10000000;
struct Device
{
#ifdef HAVE_ALSA
snd_pcm_t* playbackHandle = nullptr;
#endif
#ifdef WIN32
IXAudio2* xaudioHandle = nullptr;
IXAudio2MasteringVoice* masterVoice = nullptr;
IXAudio2SourceVoice* sourceVoice = nullptr;
WAVEFORMATEX wfx;
Audio2VoiceCallback* voiceCallbacks = nullptr;
#endif
};
Result Create(Device*& device);
void Destroy(Device*& device);
Result SetInputFormat(Device* device, uint32_t channels, uint32_t sampleRate, SampleFormat sampleFormat);
Result WriteInterleaved(Device* device, void* buf, uint32_t frames, std::atomic<bool>& bufferInUse);
Result StartWhenReady(Device* device);
Result Pause(Device* device);
Result Resume(Device* device);
Result Flush(Device* device);
}