Sound für synchrone Wiedergabe geändert

This commit is contained in:
2026-10-06 19:10:34 +02:00
parent bc564c5371
commit 98f6f1c903
12 changed files with 572 additions and 409 deletions

37
include/audiothread.h Normal file
View 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;
};