Previously the audio output manager was a "hybrid device" that acted as a pull device for audio devices and as a push device and device proxy for the rest of the application. This approach turned out to be flawed, particularly in the frequent opening and closing of the audio device (extremely slow). Since we use both pulling (for constant playback) and pushing (audio scrubbing, short bursts of sound), it needed a similar but different approach. This approach will switch the output device from push mode (default) to pull mode (during playback) only when necessary resulting in far less UI lag (basically unnoticeable now) than the previous approach.
32 lines
565 B
C++
32 lines
565 B
C++
#ifndef AUDIOOUTPUTDEVICEPROXY_H
|
|
#define AUDIOOUTPUTDEVICEPROXY_H
|
|
|
|
#include <QIODevice>
|
|
|
|
class AudioOutputDeviceProxy : public QIODevice
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
AudioOutputDeviceProxy();
|
|
|
|
void SetDevice(QIODevice* device);
|
|
|
|
void SetSendAverages(bool send);
|
|
|
|
signals:
|
|
void ProcessedAverages(QVector<double> averages);
|
|
|
|
protected:
|
|
virtual qint64 readData(char *data, qint64 maxlen) override;
|
|
|
|
virtual qint64 writeData(const char *data, qint64 maxSize) override;
|
|
|
|
private:
|
|
QIODevice* device_;
|
|
|
|
bool send_averages_;
|
|
|
|
};
|
|
|
|
#endif // AUDIOOUTPUTDEVICEPROXY_H
|