Update Qt Sample capture handling

- accept only the supported 48 kHz stereo 16-bit audio format

- preserve the last signal, SDI, preview, and audio information after Stop

- refresh signal and SDI state when channel Start times out

- retain the existing internal diagnostics and timing statistics

Validation: git diff --check passed. The MSVC Release gvfg_qt_preview build completed successfully, and the updated Sample behavior was tested on hardware.
This commit is contained in:
Mark.lin
2026-09-21 14:46:44 +08:00
parent 7fb0028ba6
commit 55dfed73ec
+17 -5
View File
@@ -21,6 +21,8 @@
namespace namespace
{ {
constexpr size_t kMaxQueuedAudioFrames = 10; constexpr size_t kMaxQueuedAudioFrames = 10;
constexpr int kAudioSampleRate = 48000;
constexpr int kAudioChannelCount = 2;
#if GVFG_INTERNAL_DIAGNOSTICS #if GVFG_INTERNAL_DIAGNOSTICS
QString boolText(int value) { return value ? QStringLiteral("yes") : QStringLiteral("no"); } QString boolText(int value) { return value ? QStringLiteral("yes") : QStringLiteral("no"); }
@@ -306,19 +308,24 @@ void CaptureController::closeDeviceSession(bool clearSelection)
appendLog(QStringLiteral("Closed device")); appendLog(QStringLiteral("Closed device"));
} }
if (clearSelection)
{
emit statusChanged(QStringLiteral("Idle")); emit statusChanged(QStringLiteral("Idle"));
lastSignalStatusText_.clear(); lastSignalStatusText_.clear();
emit sdiInfoChanged(QStringLiteral("SDI Info: --")); emit sdiInfoChanged(QStringLiteral("SDI Info: --"));
if (clearSelection)
selectedDeviceIndex_ = -1; selectedDeviceIndex_ = -1;
}
for (ChannelRuntime &channel : channels_) for (ChannelRuntime &channel : channels_)
{ {
channel.opened = false; channel.opened = false;
if (clearSelection)
{
channel.cachedSignalStatus = {}; channel.cachedSignalStatus = {};
channel.haveCachedSignalStatus = false; channel.haveCachedSignalStatus = false;
channel.cachedSdiInfoText.clear(); channel.cachedSdiInfoText.clear();
channel.lastLoggedInputStatus.clear(); channel.lastLoggedInputStatus.clear();
} }
}
closingDevice_ = false; closingDevice_ = false;
emit stateChanged(); emit stateChanged();
} }
@@ -351,10 +358,9 @@ void CaptureController::startCapture(int channelIndex)
closeDeviceIfIdle(); closeDeviceIfIdle();
return; return;
} }
if (channel.audioFormat.channels == 0 || channel.audioFormat.sample_rate == 0 || if (channel.audioFormat.sample_rate != kAudioSampleRate ||
(channel.audioFormat.bits_per_sample != 8 && channel.audioFormat.channels != kAudioChannelCount ||
channel.audioFormat.bits_per_sample != 16 && channel.audioFormat.bits_per_sample != 16)
channel.audioFormat.bits_per_sample != 32))
{ {
appendLog(QStringLiteral("CH%1 [APP] ERROR audio format unsupported | %2 Hz %3 ch %4-bit") appendLog(QStringLiteral("CH%1 [APP] ERROR audio format unsupported | %2 Hz %3 ch %4-bit")
.arg(channelIndex) .arg(channelIndex)
@@ -376,6 +382,11 @@ void CaptureController::startCapture(int channelIndex)
if (st != GVFG_OK) if (st != GVFG_OK)
{ {
reportError(QStringLiteral("gvfg_start_channel"), st, channelIndex); reportError(QStringLiteral("gvfg_start_channel"), st, channelIndex);
if (st == GVFG_ETIMEOUT)
{
updateSignalStatus();
refreshSdiInfo(channelIndex);
}
emit previewCloseRequested(channelIndex); emit previewCloseRequested(channelIndex);
emit stateChanged(); emit stateChanged();
closeDeviceIfIdle(); closeDeviceIfIdle();
@@ -485,6 +496,7 @@ void CaptureController::stopCapture(int channelIndex)
gvfg_stop_channel(handle_, channelIndex); gvfg_stop_channel(handle_, channelIndex);
channel.running.store(false, std::memory_order_release); channel.running.store(false, std::memory_order_release);
channel.frameAvailable.store(false, std::memory_order_release); channel.frameAvailable.store(false, std::memory_order_release);
updateSignalStatus(false);
channel.audioEnabled = false; channel.audioEnabled = false;
emit previewCloseRequested(channelIndex); emit previewCloseRequested(channelIndex);
appendLog(QStringLiteral("CH%1 Stopped capture").arg(channelIndex)); appendLog(QStringLiteral("CH%1 Stopped capture").arg(channelIndex));