mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-11-22 20:28:42 -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.
57 lines
1.3 KiB
C++
57 lines
1.3 KiB
C++
// -*- Mode: C++ -*-
|
|
#ifndef SOUNDIN_H__
|
|
#define SOUNDIN_H__
|
|
|
|
#include <limits>
|
|
#include <QObject>
|
|
#include <QString>
|
|
#include <QDateTime>
|
|
#include <QScopedPointer>
|
|
#include <QPointer>
|
|
#include <QAudioInput>
|
|
|
|
#include "Audio/AudioDevice.hpp"
|
|
|
|
class QAudioDeviceInfo;
|
|
class QAudioInput;
|
|
|
|
// Gets audio data from sound sample source and passes it to a sink device
|
|
class SoundInput
|
|
: public QObject
|
|
{
|
|
Q_OBJECT;
|
|
|
|
public:
|
|
SoundInput (QObject * parent = nullptr)
|
|
: QObject {parent}
|
|
, cummulative_lost_usec_ {std::numeric_limits<qint64>::min ()}
|
|
{
|
|
}
|
|
|
|
~SoundInput ();
|
|
|
|
// sink must exist from the start call until the next start call or
|
|
// stop call
|
|
Q_SLOT void start(QAudioDeviceInfo const&, int framesPerBuffer, AudioDevice * sink, unsigned downSampleFactor, AudioDevice::Channel = AudioDevice::Mono);
|
|
Q_SLOT void suspend ();
|
|
Q_SLOT void resume ();
|
|
Q_SLOT void stop ();
|
|
Q_SLOT void reset (bool report_dropped_frames);
|
|
|
|
Q_SIGNAL void error (QString message) const;
|
|
Q_SIGNAL void status (QString message) const;
|
|
Q_SIGNAL void dropped_frames (qint32 dropped, qint64 usec);
|
|
|
|
private:
|
|
// used internally
|
|
Q_SLOT void handleStateChanged (QAudio::State);
|
|
|
|
bool checkStream ();
|
|
|
|
QScopedPointer<QAudioInput> m_stream;
|
|
QPointer<AudioDevice> m_sink;
|
|
qint64 cummulative_lost_usec_;
|
|
};
|
|
|
|
#endif
|