-
Notifications
You must be signed in to change notification settings - Fork 16
/
QOpenALEngine.h
153 lines (121 loc) · 3.45 KB
/
QOpenALEngine.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#ifndef OPENALENGINE_H
#define OPENALENGINE_H
#include "al.h"
#include "alc.h"
#include "efx.h"
#include "alext.h"
#include "efx-creative.h"
#include "efx-presets.h"
#include <QObject>
#include <QThread>
#include <QMutex>
#include <QTimer>
extern "C"{
#include "libavcodec/avcodec.h"
#include "libavdevice/avdevice.h"
#include "libavfilter/avfilter.h"
#include "libavformat/avformat.h"
#include "libavutil/avutil.h"
#include "libswscale/swscale.h"
#include "libswresample/swresample.h"
#include "libavutil/avstring.h"
#include "libavutil/time.h"
}
#define NUMBUFFERS (4)
#define SERVICE_UPDATE_PERIOD (20)
class QOpenALEngine : public QObject
{
Q_OBJECT
public:
Q_ENUMS(State)
enum State
{
INITIAL=0x1011,
PLAYING=0x1012,
PAUSED=0x1013,
STOPPED=0x1014
};
explicit QOpenALEngine(QObject *parent = 0);
~QOpenALEngine();
static bool init();
static bool deinit();
void end();
void write(void *data, unsigned long size,int samplerate);
void replay();
void seek();
void play();
void pause();
void stop();
void rewind();
int getQueuedNum();
int getProcessedNum();
float getOffset();
float getBufferTimeOffset();
void clear();
void openEFX();
State getState();
void setGain(float gain);
float getGain();
signals:
void needData(int );
public slots:
// void timerSlot();
private:
QList<long> bufsize;
QTimer *timer;
bool isend;
bool isBufInit;
QThread *thread;
static ALCdevice *pDevice;
static ALCcontext *pContext;
ALuint uiBuffers[NUMBUFFERS];
ALuint uiSource;
ALuint uiBuffer;
QMutex mutex;
int bb;
EFXEAXREVERBPROPERTIES efxReverb;
ALuint uiEffectSlot, uiEffect;
ALboolean CreateAuxEffectSlot(ALuint *puiAuxEffectSlot);
ALboolean CreateEffect(ALuint *puiEffect, ALenum eEffectType);
ALboolean SetEFXEAXReverbProperties(EFXEAXREVERBPROPERTIES *pEFXEAXReverb, ALuint uiEffect);
ALboolean ALFWIsEFXSupported();
/////////
// Effect objects
LPALGENEFFECTS alGenEffects;
LPALDELETEEFFECTS alDeleteEffects;
LPALISEFFECT alIsEffect;
LPALEFFECTI alEffecti;
LPALEFFECTIV alEffectiv;
LPALEFFECTF alEffectf;
LPALEFFECTFV alEffectfv;
LPALGETEFFECTI alGetEffecti;
LPALGETEFFECTIV alGetEffectiv;
LPALGETEFFECTF alGetEffectf;
LPALGETEFFECTFV alGetEffectfv;
//Filter objects
LPALGENFILTERS alGenFilters;
LPALDELETEFILTERS alDeleteFilters;
LPALISFILTER alIsFilter;
LPALFILTERI alFilteri;
LPALFILTERIV alFilteriv;
LPALFILTERF alFilterf;
LPALFILTERFV alFilterfv;
LPALGETFILTERI alGetFilteri;
LPALGETFILTERIV alGetFilteriv;
LPALGETFILTERF alGetFilterf;
LPALGETFILTERFV alGetFilterfv;
// Auxiliary slot object
LPALGENAUXILIARYEFFECTSLOTS alGenAuxiliaryEffectSlots;
LPALDELETEAUXILIARYEFFECTSLOTS alDeleteAuxiliaryEffectSlots;
LPALISAUXILIARYEFFECTSLOT alIsAuxiliaryEffectSlot;
LPALAUXILIARYEFFECTSLOTI alAuxiliaryEffectSloti;
LPALAUXILIARYEFFECTSLOTIV alAuxiliaryEffectSlotiv;
LPALAUXILIARYEFFECTSLOTF alAuxiliaryEffectSlotf;
LPALAUXILIARYEFFECTSLOTFV alAuxiliaryEffectSlotfv;
LPALGETAUXILIARYEFFECTSLOTI alGetAuxiliaryEffectSloti;
LPALGETAUXILIARYEFFECTSLOTIV alGetAuxiliaryEffectSlotiv;
LPALGETAUXILIARYEFFECTSLOTF alGetAuxiliaryEffectSlotf;
LPALGETAUXILIARYEFFECTSLOTFV alGetAuxiliaryEffectSlotfv;
protected:
};
#endif // OPENALENGINE_H