diff options
| author | Christoph Berg <myon@debian.org> | 2026-09-26 23:24:28 +0200 |
|---|---|---|
| committer | Christoph Berg <myon@debian.org> | 2026-09-26 23:24:28 +0200 |
| commit | 69344560ea394c06ca94acac46a2e4c3e8b7b229 (patch) | |
| tree | ebc98370a697a9bbd6b973a14fa5113c475c6db7 /Audio/AudioInputSource.hpp | |
| parent | 3e9d10a67671d0bd5c7b8c3ca8088f1818322eff (diff) | |
| parent | 059831534c7e884f0a607ed86b582fd00d821731 (diff) | |
Update upstream source from tag 'upstream/3.2.0_rc1+dfsg'
Update to upstream version '3.2.0~rc1+dfsg'
with Debian dir dbff457fd2c3616d5c77b863c7bfb2186ed86047
Diffstat (limited to 'Audio/AudioInputSource.hpp')
| -rw-r--r-- | Audio/AudioInputSource.hpp | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/Audio/AudioInputSource.hpp b/Audio/AudioInputSource.hpp new file mode 100644 index 00000000..220e1309 --- /dev/null +++ b/Audio/AudioInputSource.hpp @@ -0,0 +1,71 @@ +// -*- Mode: C++ -*- +#ifndef AUDIO_INPUT_SOURCE_HPP__ +#define AUDIO_INPUT_SOURCE_HPP__ + +#include <QObject> +#include <QMutex> +#include <QMutexLocker> +#include <QString> + +#include "Audio/AudioDevice.hpp" +#include "Audio/AudioStreamDescriptor.hpp" + +class QAudioDeviceInfo; + +class AudioInputSource + : public QObject +{ + Q_OBJECT + +public: + explicit AudioInputSource (QObject * parent = nullptr) + : QObject {parent} + { + } + + ~AudioInputSource () override = default; + + // Return a consistent snapshot that is safe to read from another thread. + AudioStreamDescriptor streamDescriptor () const + { + QMutexLocker locker {&stream_descriptor_mutex_}; + return stream_descriptor_; + } + + Q_SLOT virtual void start (QAudioDeviceInfo const&, int framesPerBuffer, + AudioDevice * sink, unsigned downSampleFactor, + AudioDevice::Channel = AudioDevice::Mono) = 0; + Q_SLOT virtual void suspend () = 0; + Q_SLOT virtual void resume () = 0; + Q_SLOT virtual void stop () = 0; + Q_SLOT virtual void reset (bool reportDroppedFrames) = 0; + + Q_SIGNAL void error (QString message) const; + Q_SIGNAL void status (QString message) const; + Q_SIGNAL void streamDescriptorChanged (AudioStreamDescriptor descriptor) const; + +protected: + void setStreamDescriptor (AudioStreamDescriptor descriptor) + { + { + QMutexLocker locker {&stream_descriptor_mutex_}; + if (descriptor == stream_descriptor_) + { + return; + } + stream_descriptor_ = descriptor; + } + Q_EMIT streamDescriptorChanged (descriptor); + } + + void clearStreamDescriptor () + { + setStreamDescriptor ({}); + } + +private: + mutable QMutex stream_descriptor_mutex_; + AudioStreamDescriptor stream_descriptor_; +}; + +#endif |
