blob: 5b31cbbe1df926a07eb8222f696f5b935651e8ba (
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
|
// -*- Mode: C++ -*-
#ifndef SOUNDIN_H__
#define SOUNDIN_H__
#include <limits>
#include <QString>
#include <QDateTime>
#include <QScopedPointer>
#include <QPointer>
#include <QAudioInput>
#include "Audio/AudioInputSource.hpp"
class QAudioDeviceInfo;
class QAudioInput;
// Gets audio data from sound sample source and passes it to a sink device
class SoundInput
final : public AudioInputSource
{
Q_OBJECT;
public:
SoundInput (QObject * parent = nullptr)
: AudioInputSource {parent}
, cummulative_lost_usec_ {std::numeric_limits<qint64>::min ()}
{
}
~SoundInput () override;
// sink must exist from the start call until the next start call or
// stop call
Q_SLOT void start(QAudioDeviceInfo const&, int framesPerBuffer, AudioDevice * sink, unsigned downSampleFactor, AudioDevice::Channel = AudioDevice::Mono) override;
Q_SLOT void suspend () override;
Q_SLOT void resume () override;
Q_SLOT void stop () override;
Q_SLOT void reset (bool report_dropped_frames) override;
private:
friend class TestSoundInput;
// used internally
Q_SLOT void handleStateChanged (QAudio::State);
bool checkStream ();
void updateStreamInterruption (QAudio::State, QAudio::Error);
void publishStreamDescriptor ();
QScopedPointer<QAudioInput> m_stream;
QPointer<AudioDevice> m_sink;
qint64 cummulative_lost_usec_;
QAudio::Error m_lastStreamError {QAudio::NoError};
bool m_interruptionReported {false};
bool m_destroying {false};
};
#endif
|