-
Notifications
You must be signed in to change notification settings - Fork 3
/
loopedpcmstreamer.hpp
48 lines (40 loc) · 1.05 KB
/
loopedpcmstreamer.hpp
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
#ifndef LOOPEDPCMSTREAMER_HPP
#define LOOPEDPCMSTREAMER_HPP
#include <QIODevice>
// https://bugreports.qt.io/browse/QTBUG-73263
#include <filesystem>
namespace fs = std::filesystem;
class LoopedPCMStreamer : public QIODevice
{
Q_OBJECT
public:
LoopedPCMStreamer(const fs::path &source, uint64_t offset, uint32_t length, uint32_t lppnt, QObject *parent = nullptr);
~LoopedPCMStreamer();
bool open(QIODevice::OpenMode mode);
void close();
bool seek(qint64 pos);
bool atEnd() const;
qint64 bytesAvailable() const;
bool isSequential() const;
qint64 pos() const;
qint64 size() const;
void seek_sample(uint64_t pos);
uint64_t pos_sample() const;
protected:
qint64 readData(char *data, qint64 maxSize);
qint64 writeData(const char *data, qint64 maxSize);
private:
void *mapped;
intptr_t fd;
#ifdef _WIN32
intptr_t maph;
#endif
fs::path srcpath;
uint64_t mapped_offset;
uint64_t mapped_length;
uint64_t offset;
uint64_t position;
uint32_t nsamples;
uint32_t loopsample;
};
#endif