forked from Elleo/libQtSpotify
-
Notifications
You must be signed in to change notification settings - Fork 3
/
qspotifyaudiothreadworker.h
46 lines (35 loc) · 1.07 KB
/
qspotifyaudiothreadworker.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
#ifndef QSPOTIFYAUDIOTHREADWORKER_H
#define QSPOTIFYAUDIOTHREADWORKER_H
#include <QtCore/QObject>
#include <QtCore/QBuffer>
#include <QtCore/QMutex>
#include <QtCore/QWaitCondition>
#include <QtCore/QHash>
#include <QtGui/QImage>
#include <libspotify/api.h>
#include "qspotifyringbuffer.h"
#define AUDIOSTREAM_UPDATE_INTERVAL 20
extern QSpotifyRingbuffer g_buffer;
extern QMutex g_mutex;
extern QMutex g_imageRequestMutex;
extern QHash<QString, QWaitCondition *> g_imageRequestConditions;
extern QHash<QString, QImage> g_imageRequestImages;
extern QHash<sp_image *, QString> g_imageRequestObject;
class QAudioOutput;
class QIODevice;
class QSpotifyAudioThreadWorker : public QObject
{
public:
QSpotifyAudioThreadWorker(QObject *parent = nullptr);
bool event(QEvent *);
private:
void startStreaming(int channels, int sampleRate);
void updateAudioBuffer();
void startAudioOutput();
QAudioOutput *m_audioOutput{};
QIODevice *m_iodevice{};
int m_audioTimerID{};
int m_timeCounter{};
int m_previousElapsedTime{};
};
#endif // QSPOTIFYAUDIOTHREADWORKER_H