forked from mixxxdj/mixxx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvinylcontrolprocessor.h
86 lines (68 loc) · 2.84 KB
/
vinylcontrolprocessor.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
#ifndef VINYLCONTROLPROCESSOR_H
#define VINYLCONTROLPROCESSOR_H
#include <QObject>
#include <QThread>
#include <QVector>
#include <QMutex>
#include <QWaitCondition>
#include "preferences/usersettings.h"
#include "util/fifo.h"
#include "vinylcontrol/vinylsignalquality.h"
#include "soundio/soundmanagerutil.h"
class VinylControl;
class ControlPushButton;
// VinylControlProcessor is a thread that is in charge of receiving samples from
// the engine callback and feeding those samples to the VinylControl
// classes. The most important thing is that the connection between the engine
// callback and VinylControlProcessor (the receiveBuffer method) is lock-free.
class VinylControlProcessor : public QThread, public AudioDestination {
Q_OBJECT
public:
VinylControlProcessor(QObject* pParent, UserSettingsPointer pConfig);
virtual ~VinylControlProcessor();
// Called from main thread. Must only touch m_bReportSignalQuality.
void setSignalQualityReporting(bool enable);
// Called from the main thread. Must only touch m_bQuit;
void shutdown();
// Called from the main thread. Must only touch m_bReload;
void requestReloadConfig();
bool deckConfigured(int index) const;
FIFO<VinylSignalQualityReport>* getSignalQualityFifo() {
return &m_signalQualityFifo;
}
public slots:
virtual void onInputConfigured(AudioInput input);
virtual void onInputUnconfigured(AudioInput input);
// Called by the engine callback. Must not touch any state in
// VinylControlProcessor except for m_samplePipes. NOTE:
// This is called by SoundManager whenever there are new samples from the
// configured input to be processed. This is run in the callback thread of
// the soundcard this AudioDestination was registered for! Beware, this
// method is re-entrant since the VinylControlProcessor is registered for
// multiple AudioDestinations, however it is not re-entrant for a given
// AudioInput index.
void receiveBuffer(AudioInput input, const CSAMPLE* pBuffer,
unsigned int iNumFrames);
protected:
void run();
private slots:
void toggleDeck(double value);
private:
void reloadConfig();
UserSettingsPointer m_pConfig;
ControlPushButton* m_pToggle;
// A pre-allocated array of FIFOs for writing samples from the engine
// callback to the processor thread. There is a maximum of
// kMaximumVinylControlInputs pipes.
FIFO<CSAMPLE>* m_samplePipes[kMaximumVinylControlInputs];
CSAMPLE* m_pWorkBuffer;
QWaitCondition m_samplesAvailableSignal;
QMutex m_waitForSampleMutex;
QMutex m_processorsLock;
QVector<VinylControl*> m_processors;
FIFO<VinylSignalQualityReport> m_signalQualityFifo;
volatile bool m_bReportSignalQuality;
volatile bool m_bQuit;
volatile bool m_bReloadConfig;
};
#endif /* VINYLCONTROLPROCESSOR_H */