Add HDMI audio input queries and split OSD into a helper in GVFG SDK 3.2
- Expose HDMI audio input information through the capture API and refresh the bundled Gigabyte library. - Move OSD rendering into gvfg_osd.dll, connect channel OSD through the capture frame processor, and remove the experimental in-place zero-copy OSD path. - Update playback integration, the customer API documentation, and the internal build guide. Validation: git diff --cached --check passed. The MSVC Release SDK build passed. Capture hardware and runtime behavior were not tested.
This commit is contained in:
@@ -145,13 +145,15 @@ GVFG_PLAYBACK_API gvfg_playback_status_t gvfg_playback_submit_video(gvfg_playbac
|
||||
* Requires an attached window and a stopped handle. Caller data stays valid
|
||||
* through return. Used for RAW/DICOM image display; no audio is initialized. */
|
||||
GVFG_PLAYBACK_API gvfg_playback_status_t gvfg_playback_present_image(gvfg_playback p, const gvfg_preview_frame_t *image);
|
||||
/* In A/V mode an audio-output failure disables monitoring for this handle,
|
||||
* preserving video playback. Subsequent audio submissions return EAUDIO.
|
||||
* Keep capture/recording audio independent; do not retry output on this handle.
|
||||
* Recreate the handle to retry monitoring. Stop/reset does not clear EAUDIO.
|
||||
/* In A/V mode an unavailable audio output returns EAUDIO while video continues.
|
||||
* With reconnect enabled, keep submitting new PCM so monitoring can resume
|
||||
* when the default output becomes available. Otherwise recreate the handle
|
||||
* to retry monitoring. Keep capture/recording audio independent.
|
||||
* A/V start may succeed with monitoring disabled; audio-only start still fails
|
||||
* if its output is unavailable. Other errors retain their normal meaning. */
|
||||
GVFG_PLAYBACK_API gvfg_playback_status_t gvfg_playback_submit_audio(gvfg_playback p, const void *pcm, uint32_t bytes, uint64_t timestamp_ns);
|
||||
/* Opt in before start. Retries the default Windows output in A/V mode only. */
|
||||
GVFG_PLAYBACK_API gvfg_playback_status_t gvfg_playback_enable_audio_reconnect(gvfg_playback p);
|
||||
GVFG_PLAYBACK_API gvfg_playback_status_t gvfg_playback_set_volume(gvfg_playback p, float gain);
|
||||
/* Default enabled=1. Set 0 for independent best-effort playback with no
|
||||
* automatic return to synchronization. May be called before start or while
|
||||
|
||||
@@ -12,7 +12,9 @@
|
||||
#include <condition_variable>
|
||||
#include <cstdlib>
|
||||
#include <deque>
|
||||
#include <future>
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <new>
|
||||
#include <thread>
|
||||
@@ -42,6 +44,8 @@ struct gvfg_playback_t {
|
||||
bool stopping = false, active = false;
|
||||
bool sync_enabled = true;
|
||||
bool audio_output_failed = false;
|
||||
bool audio_reconnect_enabled = false;
|
||||
uint64_t audio_retry_at = 0;
|
||||
float gain = 1.0f;
|
||||
void *hwnd = nullptr;
|
||||
SignalCard signal_card;
|
||||
@@ -94,14 +98,14 @@ struct gvfg_playback_t {
|
||||
if (!has_video()) { fail(GVFG_PLAYBACK_EOUTPUT); return; }
|
||||
if (audio_output_failed) return;
|
||||
audio_output_failed = true;
|
||||
audio_retry_at = now_ns() + 1'000'000'000;
|
||||
drop_audio();
|
||||
gvfg_audio_player_destroy(audio); audio = nullptr;
|
||||
audio_source_clock = {}; audio_timeline = {};
|
||||
first_audio = audio_end = 0;
|
||||
stats.audio_timestamp_ns = 0; stats.av_difference_ns = 0;
|
||||
stats.audio_rate_ratio = 1;
|
||||
// Retain video packets and move off a failed audio master. Monitoring
|
||||
// remains disabled across resets; a fresh handle may retry the device.
|
||||
// Retain video packets and move off a failed audio master.
|
||||
degrade(now_ns());
|
||||
}
|
||||
void fail(gvfg_playback_status_t error) {
|
||||
@@ -130,11 +134,46 @@ struct gvfg_playback_t {
|
||||
};
|
||||
|
||||
void gvfg_playback_t::loop() {
|
||||
using AudioPlayer = std::unique_ptr<gvfg_audio_player_t, decltype(&gvfg_audio_player_destroy)>;
|
||||
std::future<AudioPlayer> audio_retry;
|
||||
uint64_t last_control = 0;
|
||||
bool started = false, preview_ready = false;
|
||||
for (;;) {
|
||||
std::unique_lock<std::mutex> lock(mutex);
|
||||
if (stopping) break;
|
||||
if (audio_retry.valid() && audio_retry.wait_for(std::chrono::seconds(0)) == std::future_status::ready) {
|
||||
auto candidate = audio_retry.get();
|
||||
audio_retry_at = now_ns() + 1'000'000'000;
|
||||
if (candidate && audio_output_failed) {
|
||||
gvfg_audio_player_set_volume(candidate.get(), gain);
|
||||
audio = candidate.release();
|
||||
last_audio_delivery = last_audio_arrival = 0;
|
||||
recovery_rate = {};
|
||||
fallback_audio_primed = false;
|
||||
audio_wait_since = stable_since = 0;
|
||||
audio_output_failed = false;
|
||||
}
|
||||
}
|
||||
if (audio_reconnect_enabled && config.mode == GVFG_PLAYBACK_AUDIO_VIDEO &&
|
||||
audio_output_failed && !audio_retry.valid() && now_ns() >= audio_retry_at &&
|
||||
stats.last_error == GVFG_PLAYBACK_OK) {
|
||||
const auto format = config.audio_format;
|
||||
try {
|
||||
audio_retry = std::async(std::launch::async, [format] {
|
||||
AudioPlayer candidate(nullptr, gvfg_audio_player_destroy);
|
||||
try {
|
||||
candidate.reset(audio_output_create_managed());
|
||||
if (candidate && gvfg_audio_player_start(candidate.get(), &format) != GVFG_AUDIO_PLAYBACK_OK)
|
||||
candidate.reset();
|
||||
} catch (...) {
|
||||
candidate.reset();
|
||||
}
|
||||
return candidate;
|
||||
});
|
||||
} catch (...) {
|
||||
audio_retry_at = now_ns() + 1'000'000'000;
|
||||
}
|
||||
}
|
||||
if (stats.last_error != GVFG_PLAYBACK_OK) {
|
||||
changed.wait_for(lock, std::chrono::milliseconds(2)); continue;
|
||||
}
|
||||
@@ -555,6 +594,13 @@ gvfg_playback_status_t gvfg_playback_set_sync_enabled(gvfg_playback p, int enabl
|
||||
if (p->active && !p->sync_enabled) p->degrade(now_ns(), false);
|
||||
return GVFG_PLAYBACK_OK;
|
||||
}
|
||||
gvfg_playback_status_t gvfg_playback_enable_audio_reconnect(gvfg_playback p) {
|
||||
if (!p) return GVFG_PLAYBACK_EINVAL;
|
||||
std::lock_guard<std::mutex> lock(p->mutex);
|
||||
if (p->active) return GVFG_PLAYBACK_ESTATE;
|
||||
p->audio_reconnect_enabled = true;
|
||||
return GVFG_PLAYBACK_OK;
|
||||
}
|
||||
gvfg_playback_status_t gvfg_playback_stop(gvfg_playback p) {
|
||||
if (!p) return GVFG_PLAYBACK_EINVAL;
|
||||
{ std::lock_guard<std::mutex> lock(p->mutex); p->stopping = true; p->changed.notify_all(); }
|
||||
|
||||
Reference in New Issue
Block a user