diff options
| author | hibby <d@vehibberd.com> | 2026-10-06 21:24:40 +0100 |
|---|---|---|
| committer | hibby <d@vehibberd.com> | 2026-10-06 21:24:40 +0100 |
| commit | c25cbdf6fb6d946175f4335fab77bfea601b56db (patch) | |
| tree | 6f7a94b7b81f999e434f61b73d47e337dfd26bf2 /Audio/AudioInputSource.hpp | |
| parent | 71f5689252c9f13e70e1c24856904475b2307809 (diff) | |
| parent | 0685fcada9f95fe90f70b387cd7d757da8209624 (diff) | |
Merge tag 'debian/3.2.0_rc1+dfsg-2' into debian/trixie-backportsdebian/trixie-backports
tagging wsjtx 3.2.0~rc1+dfsg-2
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 |
