-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsoundoutput.h
105 lines (73 loc) · 2.23 KB
/
soundoutput.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/*
This file is part of Waver
Copyright (C) 2021 Peter Papp
Please visit https://launchpad.net/waver for details
*/
#ifndef SOUNDOUTPUT_H
#define SOUNDOUTPUT_H
#include <QAudioFormat>
#include <QAudioOutput>
#include <QByteArray>
#include <QCoreApplication>
#include <QDateTime>
#include <QFile>
#include <QIODevice>
#include <QMutex>
#include <QObject>
#include <QThread>
#include <QTimer>
#include "decodergeneric.h"
#include "equalizer.h"
#include "globals.h"
#include "outputfeeder.h"
#ifdef QT_DEBUG
#include <QDebug>
#endif
class SoundOutput : public QObject
{
Q_OBJECT
public:
explicit SoundOutput(QAudioFormat format, PeakCallback::PeakCallbackInfo peakCallbackInfo, QObject *parent = nullptr);
~SoundOutput();
void setBufferQueue(TimedChunkQueue *chunkQueue, QMutex *chunkQueueMutex);
void wideStereoDelayChanged(int wideStereoDelayMillisec);
qint64 remainingMilliseconds();
private:
static const int INITIAL_CACHE_BUFFER_COUNT = 5;
static const qint64 NOTIFICATION_INTERVAL_MILLISECONDS = 500;
QAudioFormat format;
PeakCallback::PeakCallbackInfo peakCallbackInfo;
TimedChunkQueue *chunkQueue;
QMutex *chunkQueueMutex;
QAudioOutput *audioOutput;
QIODevice *audioIODevice;
QByteArray *bytesToPlay;
QMutex *bytesToPlayMutex;
QThread feederThread;
OutputFeeder *feeder;
QTimer *feedTimer;
bool wasError;
bool wasUnderrun;
bool initialCachingDone;
bool timerWaits;
qint64 notificationCounter;
qint64 beginningMicroseconds;
double volume;
void fillBytesToPlay();
void clearBuffers();
public slots:
void run();
void chunkAvailable();
void pause();
void resume();
private slots:
void timerTimeout();
void audioOutputNotification();
void audioOutputStateChanged(QAudio::State state);
signals:
void positionChanged(qint64 posMilliseconds);
void needChunk();
void bufferUnderrun();
void error(QString errorMessage);
};
#endif // SOUNDOUTPUT_H