Sound für synchrone Wiedergabe geändert
This commit is contained in:
37
include/audiothread.h
Normal file
37
include/audiothread.h
Normal file
@@ -0,0 +1,37 @@
|
||||
#pragma once
|
||||
|
||||
#include <QThread>
|
||||
#include <QString>
|
||||
#include <atomic>
|
||||
|
||||
#include <alsa/asoundlib.h>
|
||||
|
||||
// Audio passthrough: captures from the grabber's ALSA device and plays it
|
||||
// straight to the default output with small buffers (low latency, so the
|
||||
// sound stays in sync with the video preview). Same implementation as in
|
||||
// the HDMI viewer.
|
||||
class AudioThread : public QThread
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AudioThread(const QString &device, QObject *parent = nullptr);
|
||||
~AudioThread() override;
|
||||
|
||||
void stop();
|
||||
|
||||
signals:
|
||||
void errorOccurred(const QString &message);
|
||||
|
||||
protected:
|
||||
void run() override;
|
||||
|
||||
private:
|
||||
QString m_device;
|
||||
std::atomic<bool> m_running{false};
|
||||
|
||||
// PCM parameters
|
||||
static constexpr unsigned int k_defaultRate = 48000;
|
||||
static constexpr unsigned int k_defaultChannels = 2;
|
||||
static constexpr snd_pcm_uframes_t k_periodFrames = 1024;
|
||||
};
|
||||
Reference in New Issue
Block a user