WSJT-X/soundout.h
Bill Somerville b1378a3a86 Added tuning parameters for audio subsystem.
By adding the following section to the initialisation file the audio buffer
sizes and audio thread priority may be adjusted.

[Tune]
Audio\InputBufferFrames=1200
Audio\OutputBufferMs=1000
Audio\ThreadPriority=4

The values above are the program defaults that will be used if the
initialisation parameters are omitted.

Thread prioritis are the QThread::Priority enumumeration values.



git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@3576 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
2013-09-27 01:06:23 +00:00

63 lines
1.4 KiB
C++

#ifndef SOUNDOUT_H__
#define SOUNDOUT_H__
#include <QObject>
#include <QString>
#include <QAudioOutput>
#include <QAudioDeviceInfo>
class QAudioDeviceInfo;
class QAudioDeviceInfo;
// An instance of this sends audio data to a specified soundcard.
class SoundOutput : public QObject
{
Q_OBJECT;
Q_PROPERTY(bool running READ isRunning);
Q_PROPERTY(unsigned attenuation READ attenuation WRITE setAttenuation RESET resetAttenuation);
private:
Q_DISABLE_COPY (SoundOutput);
public:
SoundOutput (QIODevice * source);
~SoundOutput ();
bool isRunning() const {return m_active;}
qreal attenuation () const;
private Q_SLOTS:
/* private because we expect to run in a thread and don't want direct
C++ calls made, instead they must be invoked via the Qt
signal/slot mechanism which is thread safe */
void startStream (QAudioDeviceInfo const& device, unsigned channels, unsigned msBuffered = 0u);
void suspend ();
void resume ();
void stopStream ();
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;
QIODevice * m_source;
bool volatile m_active;
QAudioDeviceInfo m_currentDevice;
qreal m_volume;
};
#endif