-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathChannel.h
62 lines (46 loc) · 1.49 KB
/
Channel.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
55
56
57
58
59
60
61
62
//
// by Weikton 05.09.23
//
#pragma once
#include "../main.h"
#include "../libbass.h"
#include "Header.h"
class Channel {
Channel() = delete;
Channel(const Channel&) = delete;
Channel(Channel&&) = delete;
Channel& operator=(const Channel&) = delete;
Channel& operator=(Channel&&) = delete;
private:
using PlayCallback = std::function<void(const Channel&)>;
using StopCallback = std::function<void(const Channel&)>;
public:
explicit Channel(uint32_t channelFlags);
~Channel() noexcept;
public:
HSTREAM GetHandle() const noexcept;
void SetSpeaker(uint16_t speaker) noexcept;
bool HasSpeaker() const noexcept;
uint16_t GetSpeaker() const noexcept;
bool IsActive() const noexcept;
void Reset() noexcept;
void Push(uint32_t packetNumber, const uint8_t* dataPtr, uint32_t dataSize) noexcept;
void SetPlayCallback(PlayCallback playCallback) noexcept;
void SetStopCallback(StopCallback stopCallback) noexcept;
public:
bool playing { false };
bool channelplay { false };
bool channelstop { false };
private:
const HSTREAM handle;
uint16_t speaker { SV::kNonePlayer };
PlayCallback playCallback;
StopCallback stopCallback;
OpusDecoder* const decoder;
std::array<opus_int16, SV::kFrameSizeInSamples> decBuffer;
uint32_t expectedPacketNumber { 0 };
bool initialized { false };
int opusErrorCode { -1 };
};
using ChannelPtr = std::unique_ptr<Channel>;
#define MakeChannel std::make_unique<Channel>