blob: 72904b3a9436485a5d53f0097bbd3678714f2257 (
plain)
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
|
/***************************************************************************
enginesidechain.h
-------------------
copyright : (C) 2008 Albert Santoni
email : gamegod \a\t users.sf.net
***************************************************************************/
/***************************************************************************
* *
* This program 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 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef ENGINESIDECHAIN_H
#define ENGINESIDECHAIN_H
#include <QThread>
#include <QMutex>
#include <QWaitCondition>
#include <QList>
#include "preferences/usersettings.h"
#include "engine/sidechain/sidechainworker.h"
#include "util/fifo.h"
#include "util/mutex.h"
#include "util/types.h"
class EngineSideChain : public QThread {
Q_OBJECT
public:
EngineSideChain(UserSettingsPointer pConfig);
virtual ~EngineSideChain();
// Not thread-safe, wait-free. Submit buffer of samples to the sidechain for
// processing. Should only be called from a single writer thread (typically
// the engine callback).
void writeSamples(const CSAMPLE* buffer, int buffer_size);
// Thread-safe, blocking.
void addSideChainWorker(SideChainWorker* pWorker);
private:
void run();
UserSettingsPointer m_pConfig;
// Indicates that the thread should exit.
volatile bool m_bStopThread;
FIFO<CSAMPLE> m_sampleFifo;
CSAMPLE* m_pWorkBuffer;
// Provides thread safety around the wait condition below.
QMutex m_waitLock;
// Allows sleeping until we have samples to process.
QWaitCondition m_waitForSamples;
// Sidechain workers registered with EngineSideChain.
MMutex m_workerLock;
QList<SideChainWorker*> m_workers GUARDED_BY(m_workerLock);
};
#endif
|