Overte C++ Documentation
AudioInjectorLocalBuffer.h
1 //
2 // AudioInjectorLocalBuffer.h
3 // libraries/audio/src
4 //
5 // Created by Stephen Birarda on 2014-11-11.
6 // Copyright 2014 High Fidelity, Inc.
7 //
8 // Distributed under the Apache License, Version 2.0.
9 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
10 //
11 
12 #ifndef hifi_AudioInjectorLocalBuffer_h
13 #define hifi_AudioInjectorLocalBuffer_h
14 
15 #include <QtCore/qiodevice.h>
16 
17 #include <glm/common.hpp>
18 
19 #include "Sound.h"
20 
21 class AudioInjectorLocalBuffer : public QIODevice {
22  Q_OBJECT
23 public:
24  AudioInjectorLocalBuffer(AudioDataPointer audioData);
25  ~AudioInjectorLocalBuffer();
26 
27  void stop();
28 
29  bool seek(qint64 pos) override;
30 
31  qint64 readData(char* data, qint64 maxSize) override;
32  qint64 writeData(const char* data, qint64 maxSize) override { return 0; }
33 
34  void setShouldLoop(bool shouldLoop) { _shouldLoop = shouldLoop; }
35  void setCurrentOffset(int currentOffset) { _currentOffset = currentOffset; }
36 
37 private:
38  qint64 recursiveReadFromFront(char* data, qint64 maxSize);
39 
40  AudioDataPointer _audioData;
41  bool _shouldLoop { false };
42  bool _isStopped { false };
43  int _currentOffset { 0 };
44 };
45 
46 #endif // hifi_AudioInjectorLocalBuffer_h