summaryrefslogtreecommitdiff
path: root/Audio/soundout.h
diff options
context:
space:
mode:
authorChristoph Berg <myon@debian.org>2020-05-11 22:17:58 +0200
committerChristoph Berg <myon@debian.org>2020-05-11 22:17:58 +0200
commit32a41b1abe1a4aab0892c9c2051be6ba5b379f1e (patch)
treec6e107c1ee4d70610e43a7912e57c720334a08c7 /Audio/soundout.h
parent08299e8b2bf50ba90daf570f57def529dd29d6e7 (diff)
New upstream version 2.2.0~rc1+repackupstream/2.2.0_rc1+repack
Diffstat (limited to 'Audio/soundout.h')
-rw-r--r--Audio/soundout.h54
1 files changed, 54 insertions, 0 deletions
diff --git a/Audio/soundout.h b/Audio/soundout.h
new file mode 100644
index 00000000..1e4b3a94
--- /dev/null
+++ b/Audio/soundout.h
@@ -0,0 +1,54 @@
+// -*- Mode: C++ -*-
+#ifndef SOUNDOUT_H__
+#define SOUNDOUT_H__
+
+#include <QObject>
+#include <QString>
+#include <QAudioOutput>
+#include <QAudioDeviceInfo>
+
+class QAudioDeviceInfo;
+
+// An instance of this sends audio data to a specified soundcard.
+
+class SoundOutput
+ : public QObject
+{
+ Q_OBJECT;
+
+public:
+ SoundOutput ()
+ : m_msBuffered {0u}
+ , m_volume {1.0}
+ {
+ }
+
+ qreal attenuation () const;
+
+public Q_SLOTS:
+ void setFormat (QAudioDeviceInfo const& device, unsigned channels, unsigned msBuffered = 0u);
+ void restart (QIODevice *);
+ void suspend ();
+ void resume ();
+ void reset ();
+ void stop ();
+ void setAttenuation (qreal); /* unsigned */
+ void resetAttenuation (); /* to zero */
+
+Q_SIGNALS:
+ void error (QString message) const;
+ void status (QString message) const;
+
+private:
+ bool audioError () const;
+
+private Q_SLOTS:
+ void handleStateChanged (QAudio::State);
+
+private:
+ QScopedPointer<QAudioOutput> m_stream;
+ unsigned m_msBuffered;
+ qreal m_volume;
+};
+
+#endif