Improve GVFG audio playback and event shutdown
- Split PCM acquisition from Qt audio playback in the preview sample. - Copy SDK-owned audio frames into a bounded application queue before release. - Track and display dropped audio queue entries. - Add a dedicated stop event for the SDK event-monitor thread. - Replace periodic event-monitor wakeups with an interruptible infinite wait. - Poll public channel events every 200 ms for responsive format and signal updates. - Preserve finite 200 ms video and audio reads for ownership-safe worker shutdown.
This commit is contained in:
@@ -9,9 +9,12 @@
|
||||
|
||||
#include <array>
|
||||
#include <atomic>
|
||||
#include <condition_variable>
|
||||
#include <cstdint>
|
||||
#include <deque>
|
||||
#include <mutex>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
class QCloseEvent;
|
||||
class PreviewWindow;
|
||||
@@ -45,10 +48,15 @@ private:
|
||||
std::atomic<bool> frameAvailable{false};
|
||||
std::thread captureThread;
|
||||
std::thread audioThread;
|
||||
std::thread audioPlaybackThread;
|
||||
std::mutex audioQueueMutex;
|
||||
std::condition_variable audioQueueReady;
|
||||
std::deque<std::vector<uint8_t>> audioQueue;
|
||||
bool audioEnabled = false;
|
||||
gvfg_audio_format_t audioFormat{};
|
||||
std::atomic<uint64_t> audioFrames{0};
|
||||
std::atomic<uint64_t> audioBytes{0};
|
||||
std::atomic<uint64_t> audioQueueDrops{0};
|
||||
std::atomic<double> getFrameAverageMs{0.0};
|
||||
std::atomic<double> getFrameMaximumMs{0.0};
|
||||
std::atomic<double> getFrameWindowMaximumMs{0.0};
|
||||
@@ -94,6 +102,7 @@ private:
|
||||
void appendLog(const QString &message);
|
||||
void captureReadLoop(int channel);
|
||||
void audioReadLoop(int channel);
|
||||
void audioPlaybackLoop(int channel);
|
||||
void joinCaptureThread(int channel);
|
||||
void joinAudioThread(int channel);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user