mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-11-21 19:55:20 -05:00
542ffe8311
where possible audio devices that disappear are not forgotten until the user selects another device, this should allow temporarily missing devices or forgetting to switch on devices before starting WSJT-X to be handled more cleanly. If all else fails, visiting the Settings dialog and clicking OK should get things going again. Note that we still do not have a reliable way of detecting failed audio out devices, in that case selecting another device and then returning to the original should work. Enumerating audio devices is expensive and on Linux may take many seconds per device. To avoid lengthy blocking behaviour until it is absolutely necessary, audio devices are not enumerated until one of the "Settings->Audio" device drop-down lists is opened. Elsewhere when devices must be discovered the enumeration stops as soon as the configured device is discovered. A status bar message is posted when audio devices are being enumerated as a reminder that the UI may block while this is happening. The message box warning about unaccounted-for input audio samples now only triggers when >5 seconds of audio appears to be missing or over provided. Hopefully this will make the warning less annoying for those that are using audio sources with high and/or variable latencies. A status bar message is still posted for any amount of audio input samples unaccounted for >1/5 second, this message appearing a lot should be considered as notification that there is a problem with the audio sub-system, system load is too high, or time synchronization is stepping the PC clock rather than adjusting the frequency to maintain monotonic clock ticks.
62 lines
1.1 KiB
C++
62 lines
1.1 KiB
C++
// -*- Mode: C++ -*-
|
|
#ifndef SOUNDOUT_H__
|
|
#define SOUNDOUT_H__
|
|
|
|
#include <QObject>
|
|
#include <QString>
|
|
#include <QAudioOutput>
|
|
#include <QAudioDeviceInfo>
|
|
#include <QPointer>
|
|
|
|
class AudioDevice;
|
|
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}
|
|
, error_ {false}
|
|
{
|
|
}
|
|
|
|
qreal attenuation () const;
|
|
|
|
public Q_SLOTS:
|
|
void setFormat (QAudioDeviceInfo const& device, unsigned channels, int frames_buffered = 0);
|
|
void restart (AudioDevice *);
|
|
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 checkStream () const;
|
|
|
|
private Q_SLOTS:
|
|
void handleStateChanged (QAudio::State);
|
|
|
|
private:
|
|
QAudioDeviceInfo m_device;
|
|
unsigned m_channels;
|
|
QScopedPointer<QAudioOutput> m_stream;
|
|
QPointer<AudioDevice> m_source;
|
|
int m_framesBuffered;
|
|
qreal m_volume;
|
|
bool error_;
|
|
};
|
|
|
|
#endif
|