This repository has been archived by the owner on Sep 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathConnection.h
50 lines (36 loc) · 1.48 KB
/
Connection.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
/*
This file is part of duckOS.
duckOS is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
duckOS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with duckOS. If not, see <https://www.gnu.org/licenses/>.
Copyright (c) Byteduck 2016-2022. All rights reserved.
*/
#pragma once
#include <libduck/Result.h>
#include <libriver/river.h>
#include "SampleBuffer.h"
#include <libduck/AtomicCircularQueue.h>
#define LIBSOUND_QUEUE_SIZE 4096
namespace Sound {
class Connection {
public:
static Duck::ResultRet<std::shared_ptr<Connection>> create();
void queue_samples(Duck::Ptr<SampleBuffer> buffer);
[[nodiscard]] uint32_t server_sample_rate() const { return m_server_samplerate; }
private:
explicit Connection(std::shared_ptr<River::Endpoint> endpoint);
std::shared_ptr<River::Endpoint> m_endpoint;
uint32_t m_server_samplerate;
Duck::AtomicCircularQueue<Sample, LIBSOUND_QUEUE_SIZE> m_buffer;
//RIVER FUNCTIONS
River::Function<int> server_request_buffer = {"request_buffer"};
River::Function<uint32_t> get_server_sample_rate = {"get_sample_rate"};
};
}