WSJT-X/Audio/soundout.h
Bill Somerville a0ceace5b4
User configurable audio device buffer sizes
Adjusting these may help with  audio drop-outs, particularly on slower
CPU systems or heavily loaded systems. Smaller buffer sizes leave less
margin for  process interruptions,  larger sizes waste  resources that
could impact other processes.
2020-08-08 16:25:14 +01:00

55 lines
1007 B
C++

// -*- 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_framesBuffered {0}
, m_volume {1.0}
{
}
qreal attenuation () const;
public Q_SLOTS:
void setFormat (QAudioDeviceInfo const& device, unsigned channels, int frames_buffered = 0);
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;
int m_framesBuffered;
qreal m_volume;
};
#endif