Simplify Qt sample controller boundaries

Compared with 57ad00c:

- Remove the redundant GvfgClient and gvfg_api forwarding layer so the sample calls the public GVFG capture and preview C APIs directly from CaptureController.

- Keep MainWindow limited to widget state, user actions, preview-window presentation, and option synchronization while CaptureController continues to own device, channel, worker, delivery, and logging state.

- Restore the f612cfd customer-visible behavior for hidden CH1 status, Y210 option tooltips, startup log-path reporting, contextual preview errors, timestamped error logging, and zero-copy option status synchronization.

- Preserve the requested device-name number suffixes, MinGW consumer support, video frame release handling, audio read-copy-release queue, QAudioSink playback-thread ownership, delivery accounting, and diagnostic output.

- Destroy and disconnect CaptureController while MainWindow and its UI are still valid, preventing destructor-time callbacks from reaching an object whose derived destructor has completed.

- Use supported QString multi-argument formatting to satisfy clazy without mixing numeric arguments into QString-only overloads.

Validation: git diff --cached --check and focused source/API parity inspection against f612cfd passed. No configure, build, runtime launch, capture, audio playback, device-event, shutdown, or hardware validation was run.
This commit is contained in:
Mark.lin
2026-09-11 16:32:58 +08:00
parent 57ad00c40e
commit 8282724e47
8 changed files with 126 additions and 190 deletions
+7 -4
View File
@@ -1,7 +1,7 @@
#pragma once
#include "gvfg_api.h"
#include <gvfg_capture.h>
#include <gvfg_debug.h>
#include <gvfg_preview.h>
#include <QFile>
@@ -30,15 +30,18 @@ public:
void setSelectedDeviceIndex(int index) { selectedDeviceIndex_ = index; }
void setChannelOptions(int channel, bool zeroCopy, gvfg_pixel_format_t format, bool audioEnabled);
void setChannelStatusVisible(int channel, bool visible);
void setPreviewTarget(int channel, void *nativeWindow);
void setPreviewVisible(int channel, bool visible);
bool deviceOpen() const { return client_.valid(); }
bool deviceOpen() const { return handle_ != nullptr; }
bool channelOpened(int channel) const;
bool channelRunning(int channel) const;
bool frameAvailable(int channel) const;
bool cachedSignalStatus(int channel, gvfg_signal_status_t *status) const;
QString sdkVersion() const;
void logStartupInfo();
void logUiMessage(const QString &message);
public slots:
void refreshDevices();
@@ -57,7 +60,6 @@ signals:
void stateChanged();
void statusChanged(const QString &text);
void logMessage(const QString &message);
void errorOccurred(const QString &apiName, gvfg_status_t status, int channel, const QString &detail);
void previewSourceSizeChanged(int channel, int width, int height);
void previewShowRequested(int channel);
void previewCloseRequested(int channel);
@@ -124,9 +126,10 @@ private:
static constexpr qint64 kMaxLogFileBytes = 20ll * 1024ll * 1024ll;
std::array<gvfg_device_info_t, GVFG_MAX_DEVICES> devices_{};
int deviceCount_ = 0;
GvfgClient client_;
gvfg_handle handle_ = nullptr;
int selectedDeviceIndex_ = -1;
std::array<ChannelRuntime, 2> channels_{};
std::array<bool, 2> channelStatusVisible_{{true, true}};
QTimer *runtimeStatusTimer_ = nullptr;
QString lastSignalStatusText_;
QFile logFile_;