-
Notifications
You must be signed in to change notification settings - Fork 1
/
player.h
73 lines (59 loc) · 1.39 KB
/
player.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
#ifndef PLAYER_H
#define PLAYER_H
#include <QObject>
#include <QFuture>
#include <QFutureWatcher>
#include "avobject.h"
#include "memring.h"
class PlayListItem;
class AVFile;
class QSemaphore;
class QCoreAudio;
class QTimer;
class Player : public QObject, public AVObject
{
Q_OBJECT
public:
enum State {
STOP,
PLAY,
PAUSE
};
explicit Player(QObject *parent = 0);
virtual ~Player();
virtual const char * getName();
virtual size_t pull(float *buffer_ptr, size_t buffer_size);
virtual size_t push(float *buffer_ptr, size_t buffer_size);
private:
QCoreAudio *ca;
AVFile *file;
QFuture<void> file_future;
QFuture<void> eject_future;
MemRing<av_sample_t> *ring;
QSemaphore *ring_semaphor;
size_t ring_size;
size_t samples_elapsed;
State state;
bool quiet;
// Stream and DAC
bool startStream();
bool stopStream();
// Player state
void updateState(Player::State);
void ejectFile();
signals:
void trackEnded();
void stateUpdated(Player::State);
void timeComboUpdated(QString);
void progressUpdated(float);
public slots:
void updateItem(PlayListItem *);
void seekToPercent(float p);
void seekForward(float seconds=10.f);
void seekBackward(float seconds=10.f);
void playPause();
void stop();
private slots:
void onProgressTimer();
};
#endif // PLAYER_H