Skip to content

Bring PS5 GTA6 to 120FPS with DLSS 5. An advanced Windows video player and capture enhancement tool featuring real-time preview for videos, images, and capture card sources. Combine AI-powered Super Resolution, DLSS5 image enhancement, and Frame Generation to deliver a next-generation visual experience.

C++

Fix standalone FG controls and harden playback recovery

Veyra Goal Agent0b492795dd4c
diff --git a/apps/veyra/SettingsWindow.cpp b/apps/veyra/SettingsWindow.cpp
index 9274ab6c..a58edd67 100644
--- a/apps/veyra/SettingsWindow.cpp
+++ b/apps/veyra/SettingsWindow.cpp
@@ -97,6 +97,12 @@ bool read(engine::EnhancementSettings& s,bool allPages=false){s=enhancementEnabl
// Each notification changes one field on the latest desired settings. Hidden
// controls and incomplete numeric text can never overwrite another field.
bool liveField(int id){
+ if(id==202){
+ const auto index=send(id,CB_GETCURSEL);if(index==CB_ERR)return false;
+ const bool accepted=SendMessageW(GetParent(window),WM_APP+44,202,index+1)!=0;
+ populate(enhancementEnabled?controller->snapshot().desired:configuredSettings);
+ message(accepted?L"已请求补帧;无需先开启NR。":L"总增强正在切换,请待当前事务完成。");return accepted;
+ }
auto s=enhancementEnabled?controller->snapshot().desired:configuredSettings;
if(id>=100&&id<=111){
wchar_t b[64]{};GetWindowTextW(item(id),b,64);wchar_t* end=nullptr;float v=wcstof(b,&end);
@@ -106,7 +112,6 @@ bool liveField(int id){
}else switch(id){
case 219:s.captureCompatible=checked(id)==BST_CHECKED;break;
case 218:s.nrRuntime=static_cast<engine::NrRuntime>(send(id,CB_GETCURSEL));break;
- case 202:s.multiplier=uint32_t(send(id,CB_GETCURSEL)+1);break;
case 203:s.nrPolicy=static_cast<pipeline::NrSizePolicy>(send(id,CB_GETCURSEL));break;
case 204:s.flow=static_cast<engine::FlowQuality>(send(id,CB_GETCURSEL));break;
case 205:s.content=static_cast<engine::ContentRate>(send(id,CB_GETCURSEL));break;
diff --git a/apps/veyra/ui/AppShell.cpp b/apps/veyra/ui/AppShell.cpp
index bdb39a7e..1911d425 100644
--- a/apps/veyra/ui/AppShell.cpp
+++ b/apps/veyra/ui/AppShell.cpp
@@ -83,13 +83,14 @@ std::wstring screenshotPath;ULONGLONG screenshotTick=0;bool screenshotPending=fa
void openFile(const std::wstring&);
void layout();
void updateComparison(){engine.comparison(holdOriginal?1:compareMode,referenceBase,compareSplit);}
-void toggleFullscreen(){endTransition();full=!full;DWORD corner=full?1:2;DwmSetWindowAttribute(mainWindow,33,&corner,sizeof(corner));fullControls=true;pointerTick=GetTickCount64();if(full){GetWindowPlacement(mainWindow,&windowPlacement);SetWindowLongPtrW(mainWindow,GWL_STYLE,WS_POPUP|WS_VISIBLE|WS_CLIPCHILDREN);MONITORINFO mi{sizeof(mi)};GetMonitorInfoW(MonitorFromWindow(mainWindow,MONITOR_DEFAULTTONEAREST),&mi);SetWindowPos(mainWindow,HWND_TOP,mi.rcMonitor.left,mi.rcMonitor.top,mi.rcMonitor.right-mi.rcMonitor.left,mi.rcMonitor.bottom-mi.rcMonitor.top,SWP_FRAMECHANGED);}else{SetWindowLongPtrW(mainWindow,GWL_STYLE,ShellStyle|WS_VISIBLE);MONITORINFO mi{sizeof(mi)};GetMonitorInfoW(MonitorFromRect(&windowPlacement.rcNormalPosition,MONITOR_DEFAULTTONEAREST),&mi);auto& r=windowPlacement.rcNormalPosition;if(r.right<mi.rcWork.left||r.left>mi.rcWork.right||r.bottom<mi.rcWork.top||r.top>mi.rcWork.bottom){OffsetRect(&r,mi.rcWork.left-r.left,mi.rcWork.top-r.top);}SetWindowPlacement(mainWindow,&windowPlacement);SetWindowPos(mainWindow,nullptr,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|SWP_FRAMECHANGED);}SetWindowTextW(GetDlgItem(mainWindow,Fullscreen),full?L"退出全屏":L"全屏 F11");SetCursor(LoadCursorW(nullptr,IDC_ARROW));layout();veyra::log::info("ui-fullscreen",std::format("enabled={} video-only viewport; transport auto-hides",full));}
+void toggleFullscreen(){endTransition();full=!full;DWORD corner=full?1:2;DwmSetWindowAttribute(mainWindow,33,&corner,sizeof(corner));fullControls=true;pointerTick=GetTickCount64();if(full){GetWindowPlacement(mainWindow,&windowPlacement);SetWindowLongPtrW(mainWindow,GWL_STYLE,WS_POPUP|WS_VISIBLE|WS_CLIPCHILDREN);MONITORINFO mi{sizeof(mi)};GetMonitorInfoW(MonitorFromWindow(mainWindow,MONITOR_DEFAULTTONEAREST),&mi);SetWindowPos(mainWindow,HWND_TOP,mi.rcMonitor.left,mi.rcMonitor.top,mi.rcMonitor.right-mi.rcMonitor.left,mi.rcMonitor.bottom-mi.rcMonitor.top,SWP_FRAMECHANGED);}else{SetWindowLongPtrW(mainWindow,GWL_STYLE,ShellStyle|WS_VISIBLE);MONITORINFO mi{sizeof(mi)};GetMonitorInfoW(MonitorFromRect(&windowPlacement.rcNormalPosition,MONITOR_DEFAULTTONEAREST),&mi);auto& r=windowPlacement.rcNormalPosition;if(r.right<mi.rcWork.left||r.left>mi.rcWork.right||r.bottom<mi.rcWork.top||r.top>mi.rcWork.bottom){OffsetRect(&r,mi.rcWork.left-r.left,mi.rcWork.top-r.top);}SetWindowPlacement(mainWindow,&windowPlacement);SetWindowPos(mainWindow,nullptr,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|SWP_FRAMECHANGED);}SetWindowTextW(GetDlgItem(mainWindow,Fullscreen),full?L"退出全屏":L"全屏 F11");SetCursor(LoadCursorW(nullptr,IDC_ARROW));layout();SetFocus(mainWindow);veyra::log::info("ui-fullscreen",std::format("enabled={} video-only viewport; transport auto-hides",full));}
bool smokeProtection=false;int protectionStep=0;uint64_t protectionSession=0;bool protectionOverlayShown=false;
bool protectionArmed=false,protectionDragging=false;POINT protectionStart{};std::pair<float,float> protectionSourceStart;HWND protectionOverlay=nullptr;
void cancelProtection(){protectionArmed=protectionDragging=false;if(protectionOverlay)ShowWindow(protectionOverlay,SW_HIDE);if(video&&GetCapture()==video)ReleaseCapture();}
std::pair<float,float> protectionPoint(HWND h,POINT p){RECT r{};GetClientRect(h,&r);auto e=engine.snapshot().metrics.resolution.output;return engine.previewView().sourcePoint(float(p.x),float(p.y),float(r.right),float(r.bottom),float(e.width),float(e.height));}
LRESULT CALLBACK interaction(HWND h,UINT m,WPARAM w,LPARAM l,UINT_PTR id,DWORD_PTR){
static POINT panPoint{};static bool panning=false;
+ if(id==VideoSurface&&m==WM_LBUTTONDOWN)SetFocus(h);
if(id==VideoSurface&&protectionArmed){
if(m==WM_SETCURSOR){SetCursor(LoadCursorW(nullptr,IDC_CROSS));return TRUE;}
if(m==WM_KEYDOWN&&w==VK_ESCAPE){cancelProtection();return 0;}
@@ -185,7 +186,7 @@ void layout(){
pos(liveStatusPanel,g.right,g.statusTop,g.panelWidth,h-g.statusTop-20,rightVisible);
const bool transport=!full||fullControls;int barTop=full?h-88:g.bottom;int tx=full?16:g.left+16,tw=full?w-32:g.viewWidth-32;
pos(playbackBar,0,h-88,w,88,full&&fullControls);
- pos(seekBar,full?0:pro?tx:g.left,barTop-5,full?w:pro?tw:g.viewWidth,12,transport&&!target.capture&&!target.image&&!(pro&&showDiagnostics&&!full));surface(seekBar,pro&&!full?panel:cinemaPanel);
+ pos(seekBar,full?16:pro?tx:g.left,barTop-(full?10:5),full?w-32:pro?tw:g.viewWidth,full?20:12,transport&&!target.capture&&!target.image&&!(pro&&showDiagnostics&&!full));surface(seekBar,pro&&!full?panel:cinemaPanel);
const bool daily=!pro&&!full&&!transition.running;TransportLayout controls(tw,daily);
const int timeWidth=std::min(240,std::max(0,(tw-154)/2));
put(TimeLabel,tx,barTop+10,timeWidth,20,transport);
@@ -219,7 +220,7 @@ void layout(){
auto batch=BeginDeferWindowPos(int(placements.size()));for(const auto& p:placements){if(!batch)break;batch=DeferWindowPos(batch,p.child,nullptr,p.x,p.y,p.width,p.height,p.flags);}
if(batch)EndDeferWindowPos(batch);else for(const auto& p:placements)SetWindowPos(p.child,nullptr,p.x,p.y,p.width,p.height,p.flags);
auto front=[&](HWND child){if(child&&IsWindowVisible(child))SetWindowPos(child,HWND_TOP,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE|SWP_NOREDRAW);};
- front(playbackBar);front(GetDlgItem(mainWindow,RemotePlay));for(int id:{Open,Capture,Recent,Master,Save,Sr,Play,Stop,Mute,Volume,Subtitle,Fullscreen,WindowMin,WindowClose,TimeLabel,MediaTitle,FpsLabel,ModeSwitch,JobProgress,EmptyTitle,EmptyHint})front(GetDlgItem(mainWindow,id));front(inspector);front(subtitleLabel);if(showDiagnostics&&pro&&!full)front(diagnosticPanel);
+ front(playbackBar);front(seekBar);front(GetDlgItem(mainWindow,RemotePlay));for(int id:{Open,Capture,Recent,Master,Save,Sr,Play,Stop,Mute,Volume,Subtitle,Fullscreen,WindowMin,WindowClose,TimeLabel,MediaTitle,FpsLabel,ModeSwitch,JobProgress,EmptyTitle,EmptyHint})front(GetDlgItem(mainWindow,id));front(inspector);front(subtitleLabel);if(showDiagnostics&&pro&&!full)front(diagnosticPanel);
if(auto focused=GetFocus();focused&&IsChild(mainWindow,focused)&&!IsWindowVisible(focused))SetFocus(mainWindow);
RedrawWindow(mainWindow,nullptr,nullptr,RDW_INVALIDATE|RDW_ALLCHILDREN);
if(smokeDual)veyra::log::info("ui-layout-timing",std::format("frameMs={:.3f} animation={}",std::chrono::duration<double,std::milli>(std::chrono::steady_clock::now()-layoutBegin).count(),transition.running));
@@ -249,6 +250,8 @@ void takeScreenshot(){
void startVideoExport(bool hevc){auto s=engine.snapshot();if(currentFile.empty()||s.capture||s.image||!s.frames||s.applying||s.failed||exportJob.poll().active())return;std::vector<wchar_t> name(32768);OPENFILENAMEW d{sizeof(d)};d.hwndOwner=mainWindow;d.lpstrFile=name.data();d.nMaxFile=32768;d.lpstrFilter=L"MP4视频\0*.mp4\0";d.lpstrDefExt=L"mp4";d.Flags=OFN_EXPLORER|OFN_NOCHANGEDIR|OFN_PATHMUSTEXIST|OFN_OVERWRITEPROMPT;if(GetSaveFileNameW(&d)){exportJob.start(currentFile,name.data(),s.applied,hevc);jobPaused=false;layout();}}
#include "UiRepairChecks.h"
+#include "TransportChecks.h"
+#include "FgOnlyChecks.h"
LRESULT CALLBACK proc(HWND hwnd,UINT msg,WPARAM wp,LPARAM lp){switch(msg){
case WM_CREATE:{mainWindow=hwnd;backdrop.attach(hwnd);font=veyra::ui::makeFont(hwnd);veyra::ui::titleTheme(hwnd);uiState.configured=initialOptions.snapshot();uiState.enhanced=initialOptions.nr||initialOptions.sr||initialOptions.fg;
#ifdef VEYRA_ENABLE_REMOTEPLAY
@@ -322,8 +325,8 @@ case WM_APP+45:{if(masterPendingRevision)return 0;auto settings=uiState.enhanced
if(wp==213){auto current=engine.snapshot();if(uiState.mode!=veyra::ui::Mode::Professional||!current.running||!current.frames)return 0;bool space=false;for(auto q:settings.protection.regions)space|=q.empty();if(!space)return 0;cancelProtection();protectionArmed=true;SetFocus(video);return 1;}
if(wp==214){cancelProtection();settings.protection={};}else if(wp==206)settings.protection.enabled=lp==BST_CHECKED;else return 0;
return applySettings(settings)?1:0;}
-case WM_APP+44:{if(masterPendingRevision)return 0;auto setting=uiState.enhanced?engine.snapshot().desired:uiState.configured;const bool enabled=lp==BST_CHECKED;if(wp==200)setting.nr=enabled;else if(wp==201)setting.sr=enabled;else return 0;
- const bool enablesMaster=enabled&&!uiState.enhanced;if(enablesMaster){masterPreviousEnabled=false;uiState.enhanced=true;}applySettings(setting);if(auto pending=engine.snapshot();enablesMaster&&pending.running){masterPendingRevision=pending.desired.revision;masterPendingSession=pending.sessionId;}veyra::log::info("ui-feature",std::format("click={} enabled={} requestedRevision={} draft-independent=true",wp==200?"NR":"SR",enabled,engine.snapshot().desired.revision));return 1;}
+case WM_APP+44:{if(masterPendingRevision)return 0;auto setting=uiState.enhanced?engine.snapshot().desired:uiState.configured;const bool enabled=wp==202?lp>1:lp==BST_CHECKED;if(wp==200)setting.nr=enabled;else if(wp==201)setting.sr=enabled;else if(wp==202){if(lp<1||lp>4)return 0;setting.multiplier=uint32_t(lp);if(!setting.validate().empty())return 0;}else return 0;
+ const bool enablesMaster=enabled&&!uiState.enhanced;if(enablesMaster){masterPreviousEnabled=false;uiState.enhanced=true;}applySettings(setting);if(auto pending=engine.snapshot();enablesMaster&&pending.running){masterPendingRevision=pending.desired.revision;masterPendingSession=pending.sessionId;}veyra::log::info("ui-feature",std::format("click={} enabled={} requestedRevision={} draft-independent=true",wp==200?"NR":wp==201?"SR":"FG",enabled,engine.snapshot().desired.revision));return 1;}
case WM_APP+43:showDiagnostics=false;layout();return 0;
case WM_APP+42:refreshDailyPresets();return 0;
case WM_APP+41:switch(wp){case 501:startVideoExport(lp!=0);break;case 502:{auto path=fileDialog(true);if(!path.empty())engine.saveFrame(path);break;}case 503:jobPaused=!jobPaused;exportJob.pause(jobPaused);break;case 504:exportJob.cancel();break;case 505:preferWatching=lp==BST_CHECKED;break;}return 0;
@@ -408,7 +411,7 @@ case WM_TIMER:
if(wp==ControllerTimer){const auto state=engine.snapshot();if(state.remotePlay&&(state.running||state.transport==veyra::engine::TransportState::Opening)){const bool focused=GetForegroundWindow()==hwnd;engine.remotePlayController(remoteController.poll(focused));remoteController.feedback(engine.remotePlayFeedback(),focused);}else{engine.remotePlayController({});remoteController.stop();KillTimer(hwnd,ControllerTimer);}return 0;}
#endif
{if(wp==TransitionTimer){transition.sample(GetTickCount64());if(!transition.running){endTransition();veyra::log::info("ui-transition","completed; final layout and swapchain resize released");}layout();return 0;}
-if(full&&fullControls&&!menuOpen&&!veyra::ui::popupSelectorOpen()&&!GetCapture()&&GetTickCount64()-pointerTick>1600){POINT p{};GetCursorPos(&p);ScreenToClient(hwnd,&p);RECT r{};GetClientRect(hwnd,&r);if(p.y<r.bottom-veyra::ui::dip(hwnd,88)||p.x<0||p.x>=r.right||p.y>=r.bottom){fullControls=false;layout();if(GetForegroundWindow()==hwnd)SetCursor(nullptr);veyra::log::info("ui-fullscreen","controls hidden; video and subtitles only");}}
+if(full&&fullControls&&!menuOpen&&!veyra::ui::popupSelectorOpen()&&!GetCapture()&&GetTickCount64()-pointerTick>1600){POINT p{};GetCursorPos(&p);ScreenToClient(hwnd,&p);RECT r{};GetClientRect(hwnd,&r);if(p.y<r.bottom-veyra::ui::dip(hwnd,98)||p.x<0||p.x>=r.right||p.y>=r.bottom){fullControls=false;layout();if(GetForegroundWindow()==hwnd)SetCursor(nullptr);veyra::log::info("ui-fullscreen","controls hidden; video and subtitles only");}}
if(closing){if(engine.idle()&&!exportJob.poll().active()){KillTimer(hwnd,TelemetryTimer);DestroyWindow(hwnd);}return 0;}if(!autoInput.empty()){auto file=autoInput;autoInput.clear();openFile(file);startTick=GetTickCount64();}if(smokeControls&&startTick){const auto elapsed=GetTickCount64()-startTick;
if(smokeStep==0&&elapsed>2200){engine.pause(true);smokeStep=1;}
if(smokeStep==1&&elapsed>2600){engine.seek(1.0);smokeStep=2;}
@@ -459,6 +462,7 @@ std::wstring metric=std::format(L"源帧处理 {:.1f} fps · 显示提交 {:
if(uiState.mode==Mode::Professional&&!full&&!transition.running&&GetTickCount64()-dashboardTick>=250){dashboardTick=GetTickCount64();RECT client{};GetClientRect(hwnd,&client);RECT dashboard{0,client.bottom-dip(hwnd,232),client.right,client.bottom};InvalidateRect(hwnd,&dashboard,FALSE);}
exportJob.watching(preferWatching&&s.running&&s.transport==veyra::engine::TransportState::Playing);auto job=exportJob.poll();exportPanelStatus(job,!currentFile.empty()&&!s.capture&&!s.image&&s.frames>0&&!s.applying,s.running&&s.frames>0);setText(GetDlgItem(hwnd,JobProgress),job.message+std::format(L" {}% · 查看",int(job.progress*100)));ShowWindow(GetDlgItem(hwnd,JobProgress),job.state==veyra::engine::ExportState::Idle||full?SW_HIDE:SW_SHOW);
setText(GetDlgItem(hwnd,EmptyTitle),s.failed?L"播放已停止":L"开始观看");setText(GetDlgItem(hwnd,EmptyHint),s.failed?s.status:L"打开本地视频,或连接采集卡\n精细调整与原生导出在专业模式中");ShowWindow(GetDlgItem(hwnd,EmptyTitle),SW_HIDE);ShowWindow(GetDlgItem(hwnd,EmptyHint),SW_HIDE);
+if(dragging&&GetCapture()!=seekBar)dragging=false;
if(!dragging&&s.duration>0){int position=int((s.seekPresented<s.seekRequested&&!s.failed?s.seekTarget:s.position)/s.duration*10000);if(SendMessageW(seekBar,TBM_GETPOS,0,0)!=position)SendMessageW(seekBar,TBM_SETPOS,TRUE,position);}
if(!smokeViewApplied&&!smokeView.empty()&&(s.frames>0||smokeEmpty)){smokeViewApplied=true;if(smokeView==L"small")SetWindowPos(hwnd,nullptr,0,0,800,600,SWP_NOMOVE|SWP_NOZORDER);if(smokeView!=L"daily"&&smokeView!=L"empty"&&uiState.mode==veyra::ui::Mode::Daily)switchMode();if(smokeView==L"export")selectInspector(3);if(smokeView==L"diagnostics"){showDiagnostics=true;layout();}if(smokeView==L"fullscreen")toggleFullscreen();}
if(smokeDualPause&&pausedPosition<0&&s.frames>20){engine.pause(true);pausedPosition=s.position;pausedFrames=s.frames;}
@@ -489,6 +493,8 @@ if(settingsStep==1&&s.applied.model.intensity==.6f&&elapsed>3300){auto change=s.
if(settingsStep==2&&s.applied.sr&&elapsed>4500){auto invalid=s.desired;invalid.model.intensity=2;const bool rejected=!engine.requestSettings(invalid);veyra::log::info("settings-test",std::format("invalid-rejected={} position={} revision={} settingsStep={}",rejected,s.position,s.applied.revision,settingsStep));settingsStep=rejected?3:-1;}
}
tickRepairChecks(hwnd,s);
+tickTransportChecks(hwnd,s);
+tickFgOnlyChecks(hwnd,s);
if(smokeProtection&&startTick&&GetTickCount64()-startTick>1500){
auto indicator=[&](bool enabled,const wchar_t* count){wchar_t text[128]{},draft[64]{};auto control=veyra::ui::settingsControlForTest(206);GetWindowTextW(control,text,128);GetWindowTextW(veyra::ui::settingsControlForTest(100),draft,64);return (SendMessageW(control,BM_GETCHECK,0,0)==BST_CHECKED)==enabled&&std::wstring(text).find(count)!=std::wstring::npos&&std::wstring(draft)==L"0.42";};
if(protectionStep==0&&s.frames){if(uiState.mode==veyra::ui::Mode::Daily)switchMode();if(!transition.running){
@@ -505,7 +511,7 @@ if(smokeProtection&&startTick&&GetTickCount64()-startTick>1500){
protectionStep=pass?4:-1;veyra::log::info("protection-ui-test",std::format("master-off unchanged-revision dirty-draft-preserved pass={}",pass));SendMessageW(hwnd,WM_COMMAND,Master,0);}
}
-if(smokeSeconds>0&&startTick&&GetTickCount64()-startTick>ULONGLONG(smokeSeconds)*1000){veyra::log::info("app",std::format("smoke frames={} generated={} failed={} latenessMs={:.2f} absLatenessP95Ms={:.2f} controlsStep={} capture={} processedFps={:.2f} callbackFps={:.2f} captureDropped={} callbackToPresentReturnP95Ms={:.3f} schedulingWaitP95Ms={:.3f} processCpuP95Ms={:.3f} presentCpuP95Ms={:.3f} nrEvaluated={} nvofExecuted={}",s.frames,s.generated,s.failed,s.lateMs,s.lateP95Ms,smokeStep,s.capture,s.fps,s.captureFps,s.captureDropped,s.captureAgeP95Ms,s.schedulingWaitP95Ms,s.processCpuP95Ms,s.presentCpuP95Ms,s.nrEvaluated,s.nvofExecuted));resultCode=(s.frames>0||smokeEmpty)&&!s.failed&&(!smokeZoom||zoomStep==3)&&(!smokeProtection||protectionStep==4)&&(!smokeRepair||repairStep==10)&&(!smokeSettings||settingsStep==3)&&(!smokeRollback||settingsStep==3)&&(!smokeUi||uiStep==8)&&(!smokeDual||dualStep==40)&&(!smokeMaster||masterStep==3)&&(!smokeAudio||audioStep==4)&&(!(smokeJob||smokeJobCancel)||jobStep==4)&&(!smokeScreenshot||screenshotStep==2)?0:1;PostMessageW(hwnd,WM_CLOSE,0,0);}return 0;}
+if(smokeSeconds>0&&startTick&&GetTickCount64()-startTick>ULONGLONG(smokeSeconds)*1000){veyra::log::info("app",std::format("smoke frames={} generated={} failed={} latenessMs={:.2f} absLatenessP95Ms={:.2f} controlsStep={} capture={} processedFps={:.2f} callbackFps={:.2f} captureDropped={} callbackToPresentReturnP95Ms={:.3f} schedulingWaitP95Ms={:.3f} processCpuP95Ms={:.3f} presentCpuP95Ms={:.3f} nrEvaluated={} nvofExecuted={}",s.frames,s.generated,s.failed,s.lateMs,s.lateP95Ms,smokeStep,s.capture,s.fps,s.captureFps,s.captureDropped,s.captureAgeP95Ms,s.schedulingWaitP95Ms,s.processCpuP95Ms,s.presentCpuP95Ms,s.nrEvaluated,s.nvofExecuted));resultCode=(s.frames>0||smokeEmpty)&&!s.failed&&(!smokeZoom||zoomStep==3)&&(!smokeProtection||protectionStep==4)&&(!smokeRepair||repairStep==10)&&(!smokeTransport||transportStep==10)&&(!smokeFgOnly||fgOnlyStep==4)&&(!smokeSettings||settingsStep==3)&&(!smokeRollback||settingsStep==3)&&(!smokeUi||uiStep==8)&&(!smokeDual||dualStep==40)&&(!smokeMaster||masterStep==3)&&(!smokeAudio||audioStep==4)&&(!(smokeJob||smokeJobCancel)||jobStep==4)&&(!smokeScreenshot||screenshotStep==2)?0:1;PostMessageW(hwnd,WM_CLOSE,0,0);}return 0;}
case WM_CLOSE:endTransition();if(!closing&&smokeSeconds<=0&&exportJob.poll().active()&&MessageBoxW(hwnd,L"导出尚未完成。取消导出并退出?\n选择“否”返回播放器继续导出。",L"退出 Veyra",MB_YESNO|MB_DEFBUTTON2|MB_ICONQUESTION)!=IDYES)return 0;if(!closing&&smokeSeconds<=0){auto snapshot=engine.snapshot();WINDOWPLACEMENT placement{sizeof(placement)};if(full)placement=windowPlacement;else GetWindowPlacement(hwnd,&placement);auto r=placement.rcNormalPosition;uiPreferences.width=MulDiv(r.right-r.left,96,veyra::ui::layoutDpi(hwnd));uiPreferences.height=MulDiv(r.bottom-r.top,96,veyra::ui::layoutDpi(hwnd));uiPreferences.x=r.left;uiPreferences.y=r.top;uiPreferences.positioned=true;uiPreferences.volume=snapshot.volume;uiPreferences.muted=snapshot.muted;uiPreferences.subtitles=uiState.subtitles;uiPreferences.subtitleSize=subtitlePixels;uiPreferences.inspector=uiState.inspector;const bool confirmed=snapshot.frames>0&&!snapshot.applying&&!snapshot.failed;if(!preferences.save(uiPreferences,haveSuccessful?&lastSuccessful:nullptr))veyra::log::warn("ui-preferences","preferences not saved; corrupt original preserved");}exportJob.cancel();closing=true;engine.stop();SetWindowTextW(statusBar,L"正在释放当前任务资源…");return 0;
case WM_DESTROY:
#ifdef VEYRA_ENABLE_REMOTEPLAY
@@ -520,7 +526,7 @@ SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);INITCO
CoInitializeEx(nullptr,COINIT_APARTMENTTHREADED);
initialOptions=veyra::engine::PlayerOptions::from(veyra::ui::defaultSettings());
-int argc=0;auto argv=CommandLineToArgvW(GetCommandLineW(),&argc);for(int i=1;i<argc;++i){const std::wstring arg=argv[i];if(arg==L"--export-worker"&&i+1<argc)workerMapping=reinterpret_cast<HANDLE>(_wcstoui64(argv[++i],nullptr,10));else if(arg==L"--smoke-view"&&i+1<argc)smokeView=argv[++i];else if(arg==L"--smoke-repair-ui")smokeRepair=true;else if(arg==L"--smoke-repair-ui-reject")smokeRepair=smokeRepairReject=true;else if(arg==L"--smoke-hover")smokeZoom=smokeHover=true;else if(arg==L"--smoke-protection")smokeProtection=true;else if(arg==L"--smoke-zoom")smokeZoom=true;else if(arg==L"--smoke-empty")smokeEmpty=true;else if(arg==L"--smoke-dual")smokeDual=true;else if(arg==L"--smoke-dual-pause"){smokeDual=smokeDualPause=true;}else if(arg==L"--smoke-master-reject")smokeMaster=smokeMasterReject=true;else if(arg==L"--smoke-master")smokeMaster=true;else if(arg==L"--smoke-audio")smokeAudio=true;else if(arg==L"--smoke-job-cancel")smokeJobCancel=true;else if(arg==L"--smoke-job-exit")smokeJobExit=true;else if(arg==L"--smoke-job")smokeJob=true;else if(arg==L"--smoke-dual-export"&&i+1<argc)smokeDualOutput=argv[++i];else if(arg==L"--smoke-seconds"&&i+1<argc)smokeSeconds=std::clamp(_wtoi(argv[++i]),1,240);else if(arg==L"--export-out"&&i+1<argc)exportOutput=argv[++i];else if(arg==L"--max-frames"&&i+1<argc)exportFrames=std::max(1,_wtoi(argv[++i]));else if(arg==L"--cancel-after-ms"&&i+1<argc)cancelAfterMs=std::clamp(_wtoi(argv[++i]),1,240000);else if(arg==L"--hevc")exportHevc=true;else if(arg==L"--smoke-rollback-flow"){smokeRollback=true;smokeRollbackFlow=true;}else if(arg==L"--smoke-rollback")smokeRollback=true;else if(arg==L"--smoke-ui")smokeUi=true;else if(arg==L"--no-fg")initialOptions.fg=false;else if(arg==L"--smoke-settings")smokeSettings=true;else if(arg==L"--smoke-screenshot")smokeScreenshot=true;else if(arg==L"--smoke-controls")smokeControls=true;else if(arg==L"--smoke-save"&&i+1<argc)smokeSave=argv[++i];else if(arg==L"--native")initialOptions.realtime=false;else if(arg==L"--realtime")initialOptions.realtime=true;else if(arg==L"--fg")initialOptions.fg=true;else if(arg==L"--fg-multiplier"&&i+1<argc){initialOptions.fgMultiplier=std::clamp(_wtoi(argv[++i]),2,4);initialOptions.fg=true;}else if(arg==L"--video-sr"&&i+1<argc){initialOptions.settings.videoSrQuality=std::clamp(_wtoi(argv[++i]),1,4);initialOptions.sr=true;}else if(arg==L"--nr-ampere")initialOptions.settings.nrRuntime=veyra::engine::NrRuntime::Ampere;else if(arg==L"--nr-community")initialOptions.settings.nrRuntime=veyra::engine::NrRuntime::Community;else if(arg==L"--nr-original")initialOptions.settings.nrRuntime=veyra::engine::NrRuntime::Original;else if(arg==L"--sr")initialOptions.sr=true;else if(arg==L"--no-nr")initialOptions.nr=false;else if(arg==L"--nr")initialOptions.nr=true;else if(arg==L"--no-sr")initialOptions.sr=false;else autoInput=arg;}LocalFree(argv);
+int argc=0;auto argv=CommandLineToArgvW(GetCommandLineW(),&argc);for(int i=1;i<argc;++i){const std::wstring arg=argv[i];if(arg==L"--export-worker"&&i+1<argc)workerMapping=reinterpret_cast<HANDLE>(_wcstoui64(argv[++i],nullptr,10));else if(arg==L"--smoke-view"&&i+1<argc)smokeView=argv[++i];else if(arg==L"--smoke-fg-only")smokeFgOnly=true;else if(arg==L"--smoke-transport")smokeTransport=true;else if(arg==L"--smoke-repair-ui")smokeRepair=true;else if(arg==L"--smoke-repair-ui-reject")smokeRepair=smokeRepairReject=true;else if(arg==L"--smoke-hover")smokeZoom=smokeHover=true;else if(arg==L"--smoke-protection")smokeProtection=true;else if(arg==L"--smoke-zoom")smokeZoom=true;else if(arg==L"--smoke-empty")smokeEmpty=true;else if(arg==L"--smoke-dual")smokeDual=true;else if(arg==L"--smoke-dual-pause"){smokeDual=smokeDualPause=true;}else if(arg==L"--smoke-master-reject")smokeMaster=smokeMasterReject=true;else if(arg==L"--smoke-master")smokeMaster=true;else if(arg==L"--smoke-audio")smokeAudio=true;else if(arg==L"--smoke-job-cancel")smokeJobCancel=true;else if(arg==L"--smoke-job-exit")smokeJobExit=true;else if(arg==L"--smoke-job")smokeJob=true;else if(arg==L"--smoke-dual-export"&&i+1<argc)smokeDualOutput=argv[++i];else if(arg==L"--smoke-seconds"&&i+1<argc)smokeSeconds=std::clamp(_wtoi(argv[++i]),1,240);else if(arg==L"--export-out"&&i+1<argc)exportOutput=argv[++i];else if(arg==L"--max-frames"&&i+1<argc)exportFrames=std::max(1,_wtoi(argv[++i]));else if(arg==L"--cancel-after-ms"&&i+1<argc)cancelAfterMs=std::clamp(_wtoi(argv[++i]),1,240000);else if(arg==L"--hevc")exportHevc=true;else if(arg==L"--smoke-rollback-flow"){smokeRollback=true;smokeRollbackFlow=true;}else if(arg==L"--smoke-rollback")smokeRollback=true;else if(arg==L"--smoke-ui")smokeUi=true;else if(arg==L"--no-fg")initialOptions.fg=false;else if(arg==L"--smoke-settings")smokeSettings=true;else if(arg==L"--smoke-screenshot")smokeScreenshot=true;else if(arg==L"--smoke-controls")smokeControls=true;else if(arg==L"--smoke-save"&&i+1<argc)smokeSave=argv[++i];else if(arg==L"--native")initialOptions.realtime=false;else if(arg==L"--realtime")initialOptions.realtime=true;else if(arg==L"--fg")initialOptions.fg=true;else if(arg==L"--fg-multiplier"&&i+1<argc){initialOptions.fgMultiplier=std::clamp(_wtoi(argv[++i]),2,4);initialOptions.fg=true;}else if(arg==L"--video-sr"&&i+1<argc){initialOptions.settings.videoSrQuality=std::clamp(_wtoi(argv[++i]),1,4);initialOptions.sr=true;}else if(arg==L"--nr-ampere")initialOptions.settings.nrRuntime=veyra::engine::NrRuntime::Ampere;else if(arg==L"--nr-community")initialOptions.settings.nrRuntime=veyra::engine::NrRuntime::Community;else if(arg==L"--nr-original")initialOptions.settings.nrRuntime=veyra::engine::NrRuntime::Original;else if(arg==L"--sr")initialOptions.sr=true;else if(arg==L"--no-nr")initialOptions.nr=false;else if(arg==L"--nr")initialOptions.nr=true;else if(arg==L"--no-sr")initialOptions.sr=false;else autoInput=arg;}LocalFree(argv);
if(workerMapping){const int code=veyra::engine::runExportWorker(workerMapping);CoUninitialize();return code;}
if(smokeSeconds<=0&&exportOutput.empty()){uiPreferences=preferences.load();initialOptions=veyra::engine::PlayerOptions::from(preferences.startup(initialOptions.snapshot()));engine.setVolume(uiPreferences.volume,uiPreferences.muted);uiState.subtitles=uiPreferences.subtitles;subtitlePixels=uiPreferences.subtitleSize;}
engine.requestSettings(initialOptions.snapshot());
@@ -532,12 +538,14 @@ RegisterClassExW(&wc);
auto hwnd=CreateWindowExW(0,wc.lpszClassName,L"Veyra — 本地实验版",ShellStyle,CW_USEDEFAULT,CW_USEDEFAULT,std::min(MulDiv(uiPreferences.width,GetDpiForSystem(),96),GetSystemMetrics(SM_CXSCREEN)),std::min(MulDiv(uiPreferences.height,GetDpiForSystem(),96),GetSystemMetrics(SM_CYSCREEN)-40),nullptr,nullptr,instance,nullptr);if(!hwnd)return 1;if(uiPreferences.positioned&&smokeSeconds<=0){RECT target{uiPreferences.x,uiPreferences.y,uiPreferences.x+MulDiv(uiPreferences.width,GetDpiForSystem(),96),uiPreferences.y+MulDiv(uiPreferences.height,GetDpiForSystem(),96)};MONITORINFO mi{sizeof(mi)};GetMonitorInfoW(MonitorFromRect(&target,MONITOR_DEFAULTTONEAREST),&mi);int width=std::min(target.right-target.left,mi.rcWork.right-mi.rcWork.left),height=std::min(target.bottom-target.top,mi.rcWork.bottom-mi.rcWork.top);SetWindowPos(hwnd,nullptr,std::clamp(target.left,mi.rcWork.left,mi.rcWork.right-width),std::clamp(target.top,mi.rcWork.top,mi.rcWork.bottom-height),width,height,SWP_NOZORDER|SWP_NOACTIVATE);}CheckDlgButton(hwnd,Nr,initialOptions.nr?BST_CHECKED:BST_UNCHECKED);CheckDlgButton(hwnd,Sr,initialOptions.sr?BST_CHECKED:BST_UNCHECKED);CheckDlgButton(hwnd,Fg,initialOptions.fg?BST_CHECKED:BST_UNCHECKED);CheckDlgButton(hwnd,Realtime,initialOptions.realtime?BST_CHECKED:BST_UNCHECKED);ShowWindow(hwnd,show);MSG msg{};while(GetMessageW(&msg,nullptr,0,0)>0){if(full&&GetAncestor(msg.hwnd,GA_ROOT)==hwnd&&(msg.message==WM_MOUSEMOVE||msg.message==WM_LBUTTONDOWN||msg.message==WM_KEYDOWN)){static POINT previous{-9999,-9999};POINT now{};GetCursorPos(&now);if(msg.message!=WM_MOUSEMOVE||now.x!=previous.x||now.y!=previous.y)pointerActivity();previous=now;}if(GetAncestor(msg.hwnd,GA_ROOT)==hwnd&&(msg.message==WM_KEYDOWN||msg.message==WM_KEYUP||msg.message==WM_SYSKEYDOWN)){
wchar_t focusedClass[32]{};GetClassNameW(GetFocus(),focusedClass,32);const bool editing=_wcsicmp(focusedClass,L"Edit")==0||_wcsicmp(focusedClass,L"ComboBox")==0;
const bool adjustingSlider=_wcsicmp(focusedClass,TRACKBAR_CLASSW)==0&&GetFocus()!=seekBar;
-if(!editing&&!adjustingSlider&&msg.message==WM_KEYDOWN&&(msg.wParam==VK_LEFT||msg.wParam==VK_RIGHT)&&
+if(!editing&&(!adjustingSlider||full)&&!veyra::ui::popupSelectorOpen()&&msg.message==WM_KEYDOWN&&(msg.wParam==VK_LEFT||msg.wParam==VK_RIGHT)&&
!(GetKeyState(VK_CONTROL)&0x8000)&&!(GetKeyState(VK_MENU)&0x8000)){
const auto state=engine.snapshot();
if(state.running&&!state.capture&&!state.image&&state.duration>0){
const double origin=state.seekPresented<state.seekRequested?state.seekTarget:state.position;
- engine.seek(std::clamp(origin+(msg.wParam==VK_RIGHT?10.0:-10.0),0.0,state.duration));
+ const double target=std::clamp(origin+(msg.wParam==VK_RIGHT?10.0:-10.0),0.0,state.duration);
+ engine.seek(target);
+ veyra::log::info("ui-seek-key",std::format("direction={} origin={:.3f} target={:.3f} fullscreen={}",msg.wParam==VK_RIGHT?"right":"left",origin,target,full));
if(full)pointerActivity();continue;
}
}
diff --git a/apps/veyra/ui/FgOnlyChecks.h b/apps/veyra/ui/FgOnlyChecks.h
new file mode 100644
index 00000000..297e83f9
--- /dev/null
+++ b/apps/veyra/ui/FgOnlyChecks.h
@@ -0,0 +1,24 @@
+// Run the selector notification path from a fresh all-effects-off session.
+bool smokeFgOnly=false;int fgOnlyStep=0;
+void tickFgOnlyChecks(HWND hwnd,const veyra::engine::PlayerSnapshot& s){
+ if(!smokeFgOnly||fgOnlyStep<0||fgOnlyStep==4||!s.frames||s.applying||masterPendingRevision||transition.running)return;
+ auto select=[&](int id,int index){auto control=veyra::ui::settingsControlForTest(id);SendMessageW(control,CB_SETCURSEL,index,0);SendMessageW(inspector,WM_COMMAND,MAKEWPARAM(id,CBN_SELCHANGE),LPARAM(control));};
+ auto check=[&](bool ok,const char* name){veyra::log::info("ui-fg-only-test",std::format("{}={}",name,ok));if(!ok)fgOnlyStep=-1;return ok;};
+ switch(fgOnlyStep){
+ case 0:
+ if(uiState.mode==veyra::ui::Mode::Daily){switchMode();return;}
+ if(!check(!uiState.enhanced&&!s.applied.nr&&!s.applied.sr&&s.applied.multiplier==1,"fresh_session_all_effects_off"))break;
+ selectInspector(1);select(202,1);fgOnlyStep=1;break;
+ case 1:
+ if(!uiState.enhanced||s.applied.multiplier!=2||s.generated<5)return;
+ if(!check(!s.applied.nr&&!s.applied.sr&&s.nrEvaluated==0&&s.nvofExecuted>0&&s.fgActive,"DLSS_selector_enables_master_flow_and_real_FG_without_NR"))break;
+ SendMessageW(hwnd,WM_COMMAND,Master,0);fgOnlyStep=2;break;
+ case 2:
+ if(uiState.enhanced||s.applied.multiplier!=1)return;
+ select(208,int(veyra::engine::FrameGenerationBackend::XeSS));select(202,1);fgOnlyStep=3;break;
+ case 3:
+ if(!uiState.enhanced||s.applied.frameGenerationBackend!=veyra::engine::FrameGenerationBackend::XeSS||s.generated<5)return;
+ if(!check(!s.applied.nr&&!s.applied.sr&&s.nrEvaluated==0&&s.nvofExecuted>0&&s.fgActive,"XeSS_selector_enables_master_flow_and_real_FG_without_NR"))break;
+ fgOnlyStep=4;veyra::log::info("ui-fg-only-test","PASS cold UI selectors, actual optical flow, DLSS and XeSS generation, NR never evaluated");break;
+ }
+}
diff --git a/apps/veyra/ui/LiveStatusDashboard.h b/apps/veyra/ui/LiveStatusDashboard.h
index d360388f..c6bea06e 100644
--- a/apps/veyra/ui/LiveStatusDashboard.h
+++ b/apps/veyra/ui/LiveStatusDashboard.h
@@ -66,7 +66,7 @@ inline void paintDashboard(HWND h,HDC dc,int w,int height,const engine::PlayerSn
std::wstring status=L"待机";COLORREF color=RGB(145,151,149);
if(s.failed){status=L"错误";color=RGB(245,86,86);}
else if(s.remoteRecovering){status=L"恢复中";color=RGB(242,185,65);}
- else if(active&&!s.applying&&f.rateWindowReady){status=history.overloaded?L"补帧受限":L"正常";color=history.overloaded?RGB(242,185,65):RGB(111,211,127);}
+ else if(active&&!s.applying&&f.rateWindowReady){status=history.overloaded?(s.applied.multiplier>1?L"补帧受限":L"处理过载"):L"正常";color=history.overloaded?RGB(242,185,65):RGB(111,211,127);}
else if(s.applying&&s.running)status=L"调整中";else if(active)status=L"采样中";else if(s.transport==engine::TransportState::Paused)status=L"已暂停";
text(L"当前状态",26+bw,bottom+6,bw-20,18,10,secondary);
{AlphaGraphics draw(dc);Gdiplus::SolidBrush dot(Gdiplus::Color(255,GetRValue(color),GetGValue(color),GetBValue(color)));draw.get().FillEllipse(&dot,dip(h,27+bw),dip(h,bottom+35),dip(h,8),dip(h,8));}
diff --git a/apps/veyra/ui/Theme.h b/apps/veyra/ui/Theme.h
index 7149b786..663e9e16 100644
--- a/apps/veyra/ui/Theme.h
+++ b/apps/veyra/ui/Theme.h
@@ -110,7 +110,7 @@ inline LRESULT CALLBACK trackPaint(HWND h,UINT m,WPARAM w,LPARAM l,UINT_PTR,DWOR
if(m==WM_MOUSEWHEEL||m==WM_MOUSEHWHEEL)return 0; // Scrolling must not seek or change volume/parameters.
if(m==WM_ERASEBKGND)return 1;
if(m==WM_PAINT||m==WM_PRINTCLIENT){PaintBuffer paint(h,reinterpret_cast<HDC>(w));HDC dc=paint.dc;RECT r=paint.rect;fillSurface(dc,r,h);int minimum=int(SendMessageW(h,TBM_GETRANGEMIN,0,0)),maximum=int(SendMessageW(h,TBM_GETRANGEMAX,0,0));float progress=float(SendMessageW(h,TBM_GETPOS,0,0)-minimum)/std::max(1,maximum-minimum);int margin=dip(h,6),y=r.bottom/2,x=margin+int((r.right-margin*2)*progress);RECT rail{margin,y-dip(h,1),r.right-margin,y+dip(h,2)},fill=rail;fill.right=x;roundRect(dc,rail,line,dip(h,2));roundRect(dc,fill,IsWindowEnabled(h)?accent:secondary,dip(h,2));RECT dot{x-dip(h,5),y-dip(h,5),x+dip(h,5),y+dip(h,5)};roundRect(dc,dot,IsWindowEnabled(h)?accent:line,dip(h,5));InflateRect(&dot,-dip(h,2),-dip(h,2));roundRect(dc,dot,surface(h),dip(h,3));return 0;}
- if(m==WM_LBUTTONDOWN||m==WM_MOUSEMOVE&&GetCapture()==h||m==WM_LBUTTONUP&&GetCapture()==h){if(!IsWindowEnabled(h))return 0;if(m==WM_LBUTTONDOWN)SetCapture(h);RECT r{};GetClientRect(h,&r);int minimum=int(SendMessageW(h,TBM_GETRANGEMIN,0,0)),maximum=int(SendMessageW(h,TBM_GETRANGEMAX,0,0));float fraction=std::clamp(float(GET_X_LPARAM(l)-dip(h,6))/std::max(1L,r.right-dip(h,12)),0.0f,1.0f);int value=minimum+int(fraction*(maximum-minimum));SendMessageW(h,TBM_SETPOS,TRUE,value);SendMessageW(GetParent(h),WM_HSCROLL,MAKEWPARAM(m==WM_LBUTTONUP?TB_THUMBPOSITION:TB_THUMBTRACK,value),LPARAM(h));if(m==WM_LBUTTONUP)ReleaseCapture();return 0;}
+ if(m==WM_LBUTTONDOWN||m==WM_MOUSEMOVE&&GetCapture()==h||m==WM_LBUTTONUP&&GetCapture()==h){if(!IsWindowEnabled(h))return 0;if(m==WM_LBUTTONDOWN){SetFocus(h);SetCapture(h);}RECT r{};GetClientRect(h,&r);int minimum=int(SendMessageW(h,TBM_GETRANGEMIN,0,0)),maximum=int(SendMessageW(h,TBM_GETRANGEMAX,0,0));float fraction=std::clamp(float(GET_X_LPARAM(l)-dip(h,6))/std::max(1L,r.right-dip(h,12)),0.0f,1.0f);int value=minimum+int(fraction*(maximum-minimum));SendMessageW(h,TBM_SETPOS,TRUE,value);SendMessageW(GetParent(h),WM_HSCROLL,MAKEWPARAM(m==WM_LBUTTONUP?TB_THUMBPOSITION:TB_THUMBTRACK,value),LPARAM(h));if(m==WM_LBUTTONUP)ReleaseCapture();return 0;}
if(controlVisualChange(m)||m==TBM_SETPOS||m==TBM_SETRANGE||m==WM_SIZE||m==WM_KEYDOWN||m==WM_KEYUP)return updateControlModel(h,m,w,l);
return DefSubclassProc(h,m,w,l);
}
diff --git a/apps/veyra/ui/TransportChecks.h b/apps/veyra/ui/TransportChecks.h
new file mode 100644
index 00000000..b1d28f06
--- /dev/null
+++ b/apps/veyra/ui/TransportChecks.h
@@ -0,0 +1,64 @@
+// Bounded native regression: real HWND hit testing plus the application's
+// queued keyboard routing. Physical mouse/keyboard validation complements it.
+bool smokeTransport=false;int transportStep=0;ULONGLONG transportTick=0;
+double transportTarget=0;uint64_t transportRequest=0;
+void tickTransportChecks(HWND hwnd,const veyra::engine::PlayerSnapshot& s){
+ if(!smokeTransport||transportStep<0||transportStep==10||!s.frames||s.applying||transition.running)return;
+ auto require=[&](bool ok,const char* label){veyra::log::info("ui-transport-test",std::format("{}={}",label,ok));if(!ok)transportStep=-1;return ok;};
+ auto settled=[&]{return s.seekRequested==s.seekPresented&&std::abs(s.position-transportTarget)<.2;};
+ auto hit=[&]{RECT r{};GetWindowRect(seekBar,&r);for(int n:{1,3,5,7,9})for(LONG y:{2L,(r.bottom-r.top)/2,(r.bottom-r.top)-3})if(WindowFromPoint({r.left+(r.right-r.left)*n/10,r.top+y})!=seekBar)return false;return true;};
+ auto point=[&](double fraction){RECT r{};GetClientRect(seekBar,&r);return MAKELPARAM(veyra::ui::dip(seekBar,6)+int((r.right-veyra::ui::dip(seekBar,12))*fraction),r.bottom/2);};
+ auto post=[&](HWND focus,WPARAM key){SetFocus(focus);PostMessageW(focus,WM_KEYDOWN,key,1);PostMessageW(focus,WM_KEYUP,key,1LL<<31);};
+ switch(transportStep){
+ case 0:
+ ShowWindow(hwnd,SW_SHOWNORMAL);SetForegroundWindow(hwnd);
+ if(s.duration<60){require(false,"fixture_duration_at_least_60_seconds");break;}
+ if(uiState.mode==veyra::ui::Mode::Daily){switchMode();return;}
+ engine.pause(true);paused=true;SetWindowTextW(GetDlgItem(hwnd,Play),L"播放");
+ showDiagnostics=true;layout();SetFocus(GetDlgItem(hwnd,Volume));if(!full)toggleFullscreen();
+ transportTick=GetTickCount64();transportStep=1;break;
+ case 1:
+ if(GetTickCount64()-transportTick<300)return;
+ pointerActivity();
+ if(!require(GetFocus()==hwnd,"fullscreen_reclaims_playback_focus")||!require(hit(),"professional_fullscreen_seek_entire_hitbox"))break;
+ transportRequest=s.seekRequested;
+ SendMessageW(seekBar,WM_LBUTTONDOWN,MK_LBUTTON,point(.2));
+ SendMessageW(seekBar,WM_MOUSEMOVE,MK_LBUTTON,point(.4));
+ transportTick=GetTickCount64();transportStep=2;break;
+ case 2:
+ if(GetTickCount64()-transportTick<1900)return;
+ if(!require(fullControls&&dragging&&GetCapture()==seekBar&&s.seekRequested==transportRequest,"drag_retains_controls_and_defers_decode_until_release"))break;
+ SendMessageW(seekBar,WM_LBUTTONUP,0,point(.4));
+ transportTarget=engine.snapshot().seekTarget;transportStep=3;break;
+ case 3:
+ if(!settled())return;
+ if(!require(std::abs(transportTarget-s.duration*.4)<s.duration*.001&&!dragging&&!GetCapture(),"drag_release_presents_requested_frame"))break;
+ transportTarget=s.position+10;post(GetDlgItem(hwnd,Volume),VK_RIGHT);transportStep=4;break;
+ case 4:
+ if(!settled())return;
+ if(!require(true,"fullscreen_right_adds_10_seconds_with_volume_focus"))break;
+ fullControls=false;layout();transportTarget=s.position-10;post(hwnd,VK_LEFT);transportStep=5;break;
+ case 5:
+ if(!settled())return;
+ if(!require(fullControls,"hidden_controls_left_subtracts_10_seconds_and_reveals_bar"))break;
+ toggleFullscreen();showDiagnostics=false;layout();transportRequest=s.seekRequested;
+ post(GetDlgItem(hwnd,Volume),VK_RIGHT);transportTick=GetTickCount64();transportStep=6;break;
+ case 6:
+ if(GetTickCount64()-transportTick<300)return;
+ if(!require(s.seekRequested==transportRequest,"windowed_volume_arrows_do_not_seek"))break;
+ transportTarget=s.position+10;post(video,VK_RIGHT);transportStep=7;break;
+ case 7:
+ if(!settled())return;
+ require(true,"windowed_video_right_adds_10_seconds");
+ if(uiState.mode!=veyra::ui::Mode::Daily)switchMode();transportStep=8;break;
+ case 8:
+ if(!full)toggleFullscreen();pointerActivity();
+ if(!require(hit(),"daily_fullscreen_seek_entire_hitbox"))break;
+ SendMessageW(seekBar,WM_LBUTTONDOWN,MK_LBUTTON,point(.2));SendMessageW(seekBar,WM_LBUTTONUP,0,point(.2));
+ transportTarget=engine.snapshot().seekTarget;transportStep=9;break;
+ case 9:
+ if(!settled())return;
+ if(!require(std::abs(transportTarget-s.duration*.2)<s.duration*.001,"daily_fullscreen_click_presents_requested_frame"))break;
+ transportStep=10;veyra::log::info("ui-transport-test","PASS fullscreen drag/click, paused seek, focus, queued arrows, windowed slider isolation");break;
+ }
+}
diff --git a/docs/FG_STANDALONE_AND_RECOVERY_REPAIR_2026-09-15.md b/docs/FG_STANDALONE_AND_RECOVERY_REPAIR_2026-09-15.md
new file mode 100644
index 00000000..443e61d7
--- /dev/null
+++ b/docs/FG_STANDALONE_AND_RECOVERY_REPAIR_2026-09-15.md
@@ -0,0 +1,44 @@
+# 独立补帧与剩余代码缺口修复
+
+## 用户报告与根因
+
+用户报告:全部效果关闭时直接选择帧生成无效,先打开NR、再关NR后才正常。核对后,直接原因位于UI总开关,不是缺少一条强制光流初始化调用。
+
+`SettingsWindow::liveField(202)`原来走通用参数提交;`AppShell::applySettings`在总增强关闭时只保存草稿,因此FG请求未送入EngineController。NR/SR按钮走独立消息,能够开启总增强;开一次NR也顺带启用了先前保存的FG配置。底层 `initNvof()` / `runMotion` 本来就包含DLSS和XeSS独立依赖。
+
+现在FG倍率选择与NR/SR按钮走同一显式开关事务:选2X及以上时允许开启总增强,选择关闭补帧不会开启总增强;仍保留参数校验和事务回退。修改后从全关启动实际DLSS、XeSS,NR始终未执行,不使用“先偷偷运行一次NR”的变通方案。
+
+## 一起处理的缺口
+
+- `FgRecoveryBudget::complete`接受可缺失的GPU时间,缺失时不添加CPU轮询耗时。已有样本会过期;每个候选仍按真实截止时间判断,不把未知当零或取消过载保护。
+- 非NVIDIA的NR/SR/DLSS请求在建图前归一化为实际支持状态,重算处理尺寸并同步已应用设置/警告,保留XeSS选择。实际AMD/Intel硬件仍待验收;不自动替换用户光流后端。
+- 面板在关闭补帧但处理欠速时显示“处理过载”,不再显示“补帧受限”。
+- 采集音频增加独立PCM进度监测:按数据包计数判断,静音包继续到达不触发恢复;3秒无进展后按1至5秒退避重试原DirectShow音频端点。复用原连接和格式协商函数,没有复制两套音频接入。
+- DirectShow共享图重建音频pin前先Stop,失败时不继续改图;成功时保留视频filter及格式,移除旧音频分支后重新连接、恢复音量/同步设置、Run。停止/移除/恢复HRESULT均记录;下一张视频帧显式标记Discontinuity并增加源epoch,防止接上旧光流历史。
+- 音频修复会短暂停共享DirectShow图,不承诺视频完全不中断。WASAPI沿用自己的端点恢复;未自行改成默认麦克风或其他设备。驱动Stop异常的最终关闭仍依赖驱动释放行为,记录错误不等于已证明任意故障驱动安全退出。
+
+## XeSS数值的复核
+
+用户关于“旧版/其他机器可以显示”的描述尚未有对应版本与截图。已检索历史 `9057d2f`、`83f90ba` 的面板代码,都对XeSS FG耗时明确显示“不可测”。本机使用的XeSS 3.0.2头文件 `xefg_swapchain_present_status_t`提供framesPresented、frameGenResult、isFrameGenEnabled,当前接入没有内部GPU耗时字段。
+
+这些证据不能推出用户没看到数字,也不能推出所有历史版本都一样。当前能读到的是SDK报告的帧数/生成状态,以及Veyra自身GPU阶段和CPU Present调用耗时;它们不是同一个指标。不同机器性能不会改变这段UI主动显示“不可测”的条件。未拿到对应旧版本证据前,不用CPU耗时或缓存值冒充精确XeSS GPU耗时。
+
+## 验证
+
+候选目录 `out/build/audio-continuity-repair-20260915`;入口 `out/start-user-issues-candidate.cmd`。最终EXE SHA256:`00DD5FD72B1849006F86041723B150E9EDF3D19575DFBCC5B0E47CE2BF86AD8E`。原runtime和patched FFmpeg不变。
+
+实际执行:
+
+1. `cmd.exe /c out\build\veyra-build-x64-release.cmd` 两次最终均exit0。主构建 `logs/fg-standalone-recovery-build-20260915.log` 79/79;补显式Discontinuity与FG日志标签后 `logs/fg-standalone-recovery-build-final-20260915.log` 30/30。
+2. `veyra.exe <用户4K视频> --no-nr --no-sr --no-fg --smoke-fg-only --smoke-seconds 30`,经run-short-test限制55秒,exit0。新增 `FgOnlyChecks.h`通过实际控件CBN_SELCHANGE路径,不直接调用engine来绕开故障UI。依次确认全关、DLSS实际生成、关总增强、XeSS实际生成,两个后端均有NVOF且NR评估为0。日志 `logs/fg-only-selector-test-20260915.log`。NVOF CreateInstanceD3D12/CreateOpticalFlowD3D12状态0;XeSS Init/GetSwapChain/Present结果0,持续framesPresented=2。此短测位于最后一次仅音频断点/日志标签修改之前。
+3. `veyra_repair_contract_tests.exe`:144 checks / 0 failures,包含新增非NVIDIA设置归一化和PCM进度恢复策略,exit0,`logs/fg-recovery-contract-20260915.log`。
+4. `veyra_presentation_worker_tests.exe`:exit0,包含新增缺失GPU时间不污染预算、超期仍拒绝,`logs/fg-recovery-budget-20260915.log`。首次误写为不存在的veyra_live_gpu_scheduler_tests.exe,命令未执行;按CMake目标名纠正后通过,不采纳那次失败为测试结果。
+5. 最终候选重跑 `--smoke-transport --smoke-seconds 18`,run-short-test上限45秒,exit0,`logs/fullscreen-transport-isolated-20260915.log`。专业/日常全屏完整命中区、长按拖动时不隐藏/不提前seek、松手目标呈现、暂停左右10秒、音量焦点全屏快捷键、窗口音量键隔离均通过。前轮自动测试失败保留;本次独立通过与用户确认共同构成第5项证据。
+
+DirectShow音频分支热恢复尚未在反馈者实卡测试;恢复策略合同不冒充真实拔插和声音恢复。非NVIDIA处理仅做合同验证。本机NR/DLSS/XeSS证据不扩大到4070/4070Ti或其他设备。
+
+6. 最终执行 `powershell.exe -NoProfile -ExecutionPolicy Bypass -File scripts/gates/delivery.ps1 -Root . -BuildDirectory out/build/audio-continuity-repair-20260915`,exit0,结果 `logs/delivery/1987bb07e103441591d6dacf2e632cac/result.json`。实际NR/NVOF、原生4K、GUI播放/暂停seek、图片、H.264/HEVC 4K 2X帧数/音轨/取消检查通过;capture仍明确awaiting_user_capture_test。该结果对应最终候选hash,未把实卡边界抹掉。
+
+## 剩余边界
+
+原生Dolby Vision、XeSS内部精确计时未实现。HDR转SDR的问题映射需要对应素材/输出路由支持,不能凭“发灰”统一再改gamma。OBS/PS5、40系过载及原问题文件导出仍按14项审计保留问题设备验收要求;没有因新增恢复代码就把它们标记根治。源码提交与本地候选交付不代表发布授权。
diff --git a/docs/USER_ISSUES_REPAIR_AUDIT_2026-09-15.md b/docs/USER_ISSUES_REPAIR_AUDIT_2026-09-15.md
new file mode 100644
index 00000000..728e4f27
--- /dev/null
+++ b/docs/USER_ISSUES_REPAIR_AUDIT_2026-09-15.md
@@ -0,0 +1,69 @@
+# 14项集中反馈修复复核
+
+**后续更新:**用户随后授权处理可修缺口,独立FG开关、缺失GPU计时预算、非NVIDIA实际状态、过载文案和DirectShow音频分支恢复已施工;全屏独立自动回归现已通过。最新代码/测试及剩余边界见 [后续修复记录](FG_STANDALONE_AND_RECOVERY_REPAIR_2026-09-15.md)。下文保留审计当时发现,不应当成后续修复尚未发生。
+
+## 审计边界
+
+复核时间:2026-09-15。用户已明确确认1、2、3成功,并在全屏交互修正后确认测试通过(第5项)。这是用户本机验收,不自动扩大到全部设备。
+
+当前分支 `codex/user-issues-repair-20260915`,已提交源码基点 `813f9f1`,全屏修正尚在工作区。当前候选EXE SHA256:`504E4A27DD6FC56262F97E63D9262ABBA2B68CBC9799C6B901359AC28BFEBF53`。入口 `out/start-user-issues-candidate.cmd`;本轮未发布。
+
+本轮逐项读取生产实现、原始测试日志及先前修复结论,重新运行137项修复合同和UI合同;没有重新运行全部GPU/导出测试,没有操作用户的采集卡、OBS、PS5或40系设备。下列历史GPU证据明确保留其原验证范围。
+
+## 逐项判定
+
+| 项目 | 复核结论 | 剩余事项 |
+| --- | --- | --- |
+| 1 采集卡记忆 | 用户本机验收通过。稳定设备路径、音频端点、格式语义键和颜色选择有持久化,不依赖临时枚举序号 | 同名多卡和拔插后枚举变化未实卡覆盖 |
+| 2 播放器拖动/流畅性 | 用户本机验收通过。清除旧首帧缓存、最新seek覆盖旧请求、目标位置保留,方向合理 | 关键帧到目标仍需要解码,未实现独立预解码线程,不保证全部素材与PotPlayer同速 |
+| 3 UI闪烁 | 用户本机验收通过。避免视频窗口GDI重绘覆盖GPU画面,窗口尺寸变化不重建整条图 | 未证明全部页面、DPI和设备都无闪烁 |
+| 4 采集卡重连 | 已实现视频同设备重连、格式核对、退避和epoch重置;WASAPI独立恢复 | 未物理拔插验收。DirectShow音频单独失败而视频正常时没有独立音频pin重建;不能算所有音视频重连已完成 |
+| 5 全屏拖动/左右10秒 | 此前只验可见性不足,用户反馈属实。本次补齐进度条Z序、完整命中区、焦点及全屏方向键策略,用户随后确认通过 | 自动交互回归有一次失败记录,未标成通过,详见下文;本机用户验收与自动测试分开记录 |
+| 6 SDR/HDR发灰 | SDR确诊错误曲线已纠正。原生HDR数值往返测试没有复现同类系统偏移 | HDR转SDR仍为固定1000nit/203白点映射及简单色域裁切;问题片源、实际输出模式和屏幕未复现,不认定全部HDR已修复 |
+| 7 NR处理分辨率 | 480/720/900/1080/1440/native已接入设置和尺寸计划,NR/flow内部缩放保持宽高比;输出/导出尺寸保留 | 合同通过,各档4070/4070Ti实际速度和功耗未测;降NR尺寸不等于FG也降到该尺寸 |
+| 8 OBS捕获时resize错误 | 合法flip交换链模式不再误拒绝;ResizeBuffers暂时失败后重取旧缓冲、稍后重试,设备丢失仍报告 | 普通/捕获兼容模式重复resize有GPU读回证据,但没有OBS实际hook和反馈者机器复现,不能称根治 |
+| 9 Dolby Vision | 未完整实现。当前是识别DV、按明确兼容信息播放HDR10/HLG/SDR基础层 | 未应用RPU/增强层,未原生DV输出;P5等不支持的路由明确拒绝,真实DV媒体未验收。不能宣传为完整杜比视界支持,更不代表杜比全景声音频支持 |
+| 10 FG选择后回退 | 已修故障归属和恢复:NR/SR/FG/光流分别降级,XeSS呈现故障后重建调度器/交换链,可在同会话重启 | 保住播放与恢复功能不等于解决原用户初始化失败。仍需要原始SDK码、显卡/驱动/后端,确认为什么该机无法开启 |
+| 11 XeSS耗时/链路冗余 | GPU计时消费和同帧汇总已修。总增强耗时按阶段时间区间合并,不重复加FG子阶段;不含音频、CPU等待和显示排队 | 当前XeSS接口接入没有内部GPU耗时,面板仍显示不可测并注明总数不含XeSS FG。这部分诉求未实现;没有完成所有链路的全面性能优化 |
+| 12 视频导出 | 原日志解析把计时队列当视频队列,结论错误。代码已修遥测消费,导出用实际首帧颜色决定HDR/Main10 | 原生4K H.264/HEVC 2X帧数、音轨、取消及合成PQ+5.1导出已有通过记录;未拿到反馈者问题文件和完整日志。HDR当前需HEVC;VFR、BT.2020 CL等边界仍非通吃 |
+| 13 40系过载 | 修正CPU迟轮询混进GPU预算、同帧FG成本重复估计,增加有界重试恢复,方向合理 | 只在本机注入70ms阻塞后恢复到约46fps,非60fps达标、非4070/4070Ti根治证据;真实算力不足仍可能过载 |
+| 14 PS5增强初始化失败 | 桌面原日志已指向requested=3/actual=4合法flip模式被误拒绝,修复与该错误相匹配 | 修后未在反馈者PS5环境连接验证;其他NGX、硬解、网络错误不能由这一项一并解决 |
+
+## 修复方向审查
+
+### 已确认的错误方向
+
+1. SDR曾用BT.1886幂2.4入口配sRGB出口,两者不互逆;旧测试也沿用相同错误公式。这不能通过“提高对比度”修复。后续已改成明确的SDR代码值保留策略,并用真实文件软/硬解的同帧独立YUV矩阵对照:平均误差6.74098降至0.256191个8bit等级,最大13.3126降至0.629614;呈现缓冲新增误差0。详见 `SDR_CODE_VALUE_ROUNDTRIP_REPAIR_2026-09-15.md`。
+2. 全屏仅检查IsWindowVisible不能验证可点击。播放控制背景被提到前面,seekBar没有同步提到前面;方向键又受滑块焦点限制。本次修正前已通过实际拖动复现,修后用户确认正常。
+3. `completed sample queue overflow`不是图像排队证据。`GpuTimer`队列保存时间戳记录、上限64,1/2/4/8等是累计丢弃计时样本的节流日志。不能为此扩大视频缓冲。当前导出按源帧依次生成和编码,有等待与背压;通过日志错误解读推导“FG无限堆积”不成立。
+4. `flow=0`本身不能证明光流关闭:质量枚举值与执行计数不同。`single-image`来自静态图指导路径,必须核对该条日志的来源、session和前后文;若真实连续视频持续出现,仍需追查,不能凭片段认定正常或错误。
+
+### 方向合理但尚未闭环
+
+- FG故障恢复让软件可继续播放,无法替代失败后端兼容性修复。
+- 原生HDR亮度恒等测试可排查编码/单位错误,不能替代HDR→SDR映射审美、宽色域处理或显示设备测量。此次检查没有证据支持统一再改gamma。
+- OBS/PS5的合法交换链协商修复针对明确合同错误,不能将全部捕获hook、驱动、网络异常归到这一原因。
+- 40系恢复预算修复针对软件误判,不能弥补实际GPU耗时超过目标帧间隔。
+
+## 额外查出的代码缺口与风险
+
+1. `src/source/CaptureCardSource.cpp`:重连及close中的DirectShow Stop返回值未记录/处理,回调停止依赖Stop成功;这是需要加固的生命周期边界,尚未复现其导致崩溃,不当成已经证实的用户根因。DirectShow音频单独初始化失败缺少自动重建是确定的功能缺口。
+2. `src/engine/EngineController.cpp`:FG预算优先采用匹配同一帧的GPU跨度,但时间戳不可用时仍回退到CPU观测完成时间;低频轮询可能重新抬高估计,不能称所有计时误判都消除。
+3. 非NVIDIA设备上,部分NR/SR请求在图描述层被禁止,但请求/应用设置是否始终准确反映禁用状态仍需专门回归;现有NVIDIA本机测试不覆盖该分支。
+4. `apps/veyra/ui/LiveStatusDashboard.h`:低帧率统一标“补帧受限”,即便FG关闭也可能出现。属于状态文案不准确,应区分基础处理欠速与补帧受限。XeSS速率读取SDK报告的framesPresented计数,已确认不是简单把每次原帧Present乘错倍率,但仍不代表物理屏幕扫描帧率。
+
+## 本轮证据和未通过记录
+
+- 全屏修正构建:`cmd.exe /c out\build\veyra-build-x64-release.cmd`,最终exit0,`logs/fullscreen-transport-build-b-20260915.log`。初次TransportChecks的LONG/int列表推导编译失败,改为统一LONG后通过;失败日志保留。
+- 全屏自动测试:通过 `scripts/run-short-test.ps1`,参数为用户4K文件、`--no-nr --no-sr --no-fg --smoke-transport --smoke-seconds 18`,总上限45秒。`logs/fullscreen-transport-test-20260915.log`中焦点和整条命中区通过,但拖动保持断言失败,最终exit1。其后出现测试脚本未发出的多次seek/方向键,时间上与用户手动测试重合;不能据此断定失败完全由操作干扰引起,也不能将该次自动测试补记成功。用户后来明确说“可以了我测试过了”,故第5项记录为用户验收通过、自动回归待独立复核。
+- 本轮重新运行 `out/build/audio-continuity-repair-20260915/veyra_repair_contract_tests.exe`:137 checks / 0 failures,exit0,`logs/user-issues-audit-contract-20260915.log`。
+- 本轮重新运行 `out/build/audio-continuity-repair-20260915/veyra_ui_contract_tests.exe out/user-issues-audit-ui-20260915`:exit0,384布局/DPI合同及设置/PCM合同通过,`logs/user-issues-audit-ui-20260915.log`。布局合同不是全屏鼠标/键盘实操。
+- 历史NR/XeSS故障注入恢复12项:`logs/user-issues-backend-recovery-k.stdout.log`,实际NR/XeSS调用与同会话重新启用通过;不是反馈者错误复现。
+- 历史完整软件gate:`logs/delivery/3c32cadc5f774f6eaae43efee5d02211/result.json`,约48.7秒,旧候选通过,明确capture awaiting;不能作为当前全屏新增测试的通过记录。
+- HDR完整数值和增强证据见 `HDR_GRAY_CHAIN_AUDIT_2026-09-15.md`;本轮未重新执行NGX Create/Evaluate、物理屏幕或其他设备测试。
+
+## 下一步优先级
+
+先复现真正影响观看的第6、10、13项:HDR实际输出路由和问题片段、4070/4070Ti的原始后端错误与GPU预算。随后完成第4、8、14项的物理重连/OBS/PS5验收,以及第12项原文件导出复现。第9项原生DV和第11项XeSS内部耗时应保持“未完成”,不能通过改文案宣布实现。
+
+本轮为审计和文档更新;不盲目改颜色映射、不扩大缓冲、不修改驱动、不发布。目标任务尚有以上未完成项,不能标记14项全部完成。
diff --git a/docs/USER_ISSUES_REPAIR_PLAN_2026-09-15.md b/docs/USER_ISSUES_REPAIR_PLAN_2026-09-15.md
index aca21c92..5fb3319b 100644
--- a/docs/USER_ISSUES_REPAIR_PLAN_2026-09-15.md
+++ b/docs/USER_ISSUES_REPAIR_PLAN_2026-09-15.md
@@ -265,3 +265,9 @@ powershell.exe -NoProfile -ExecutionPolicy Bypass -File scripts/gates/delivery.p
代码回退基线 `6206b5a`;本轮在独立分支提交,验证期间保留原应用目录。不要重置用户未提交改动,不把回退扩大成删除运行组件/配对/配置。
下一步是以上问题设备的候选验收及按原始日志追踪剩余缺陷。原生Dolby Vision、XeSS内部计时、DirectShow音频pin独立热重建和PotPlayer级seek预解码仍未交付,不能将本轮报告称为14项全部实机修复完成。
+
+## 11. 用户验收与审计更新
+
+2026-09-15后续施工见 [独立补帧与恢复修复](FG_STANDALONE_AND_RECOVERY_REPAIR_2026-09-15.md):FG选择遗漏开启总增强的UI根因已修,DLSS/XeSS均在NR执行0次时通过;音频分支恢复、GPU预算缺失样本、非NVIDIA实际设置及欠速文案补齐。完整软件gate通过,硬件和未实现功能边界继续保留。
+
+用户2026-09-15确认第1、2、3项成功;全屏交互再次修正后确认第5项测试正常。最新逐项判定、已推翻的修复方向、未交付项及当前候选身份见 [14项复核](USER_ISSUES_REPAIR_AUDIT_2026-09-15.md)。以上旧状态/候选hash保留作追溯,不覆盖最新结论。第9项原生DV、第11项XeSS内部精确计时未完成;第4、6的HDR、8、10、12、13、14不具备全部问题设备验收证明。
diff --git a/docs/WORKLOG.md b/docs/WORKLOG.md
index 0f714a80..0ce5ccae 100644
--- a/docs/WORKLOG.md
+++ b/docs/WORKLOG.md
@@ -2219,3 +2219,25 @@ WASAPI输入使用共享模式事件采集,按 `IAudioCaptureClient::GetBuffer
初次新增测试引用不存在的makeReadbackBuffer构建失败后修正;固定0.1尼特中性容差在10000尼特FP16下超出格式精度,改按相对精度阈值,原失败日志保留。完整 `cmd.exe /c out\build\veyra-build-x64-release.cmd` exit0(38/38),日志 `logs/hdr-audit-product-build-20260915.log`。最终GUI无增强HDR文件3秒短测,30秒上限exit0,`logs/hdr-audit-gui-20260915.log`。仅诊断和测试接口变更,未重跑完整delivery;git diff --check通过。
候选EXE SHA256 `1CAC34939919C19EEF1FF271857159E8786AD2EF1BA7FCA5CBD6EBE394DC6321`,原候选入口保持。完整结论及后续有证据再改映射的方案见 `docs/HDR_GRAY_CHAIN_AUDIT_2026-09-15.md`。下一条唯一任务:取得问题HDR片段和新日志,依据hdr-route区分原生HDR/转SDR,量化同帧变化再修映射,不凭主观发灰统一改gamma。未执行反馈者屏幕测光、实卡/PS5或未知HDR素材,未发布或变更运行组件。
+
+## 2026-09-15 全屏交互补修与14项对抗式复核
+
+用户反馈全屏不能拖动和方向键无效。使用computer-use原生输入在旧候选实际拖动,画面仍停留原时间附近;确认AppShell布局把playbackBar提到seekBar前、焦点留在滑块时快捷键被拦截。修改 `apps/veyra/ui/AppShell.cpp`:seekBar置前、全屏20 DIP命中区、进入/离开全屏及点击视频重新取得播放焦点、全屏左右键不受音量滑块阻拦但保留编辑框/弹出选择器边界;取消捕获后清除dragging,自动隐藏区域包含进度条上缘。`Theme.h`滑条鼠标按下取得焦点。新增 `TransportChecks.h` 经 `--smoke-transport` 验证真实HWND命中与消息队列。
+
+构建 `cmd.exe /c out\build\veyra-build-x64-release.cmd` 最终exit0,`logs/fullscreen-transport-build-b-20260915.log`;初次LONG/int初始化列表不一致导致编译失败后修正,保留原日志。18秒交互测试经run-short-test限制45秒,最终exit1:焦点/命中检查通过、拖动保持断言失败,此后出现非脚本发出的实际seek和方向键。测试与用户手动操作重合,但不能未经独立复核就归咎操作干扰;不声称自动交互回归通过。用户随后明确确认测试正常,记录第5项用户本机验收通过。候选hash `504E4A27DD6FC56262F97E63D9262ABBA2B68CBC9799C6B901359AC28BFEBF53`,入口保持 `out/start-user-issues-candidate.cmd`。
+
+用户接着要求复核14项是否完成及方向错误;本轮读取采集重连、颜色、分辨率、呈现resize、FG恢复/预算、计时、导出、DV路由的生产实现及原始日志,新增 `docs/USER_ISSUES_REPAIR_AUDIT_2026-09-15.md` 并更新原计划。用户确认1/2/3/5成功;第9原生DV、第11XeSS内部计时明确未完成;其他待硬件或原文件验收项不降格成完成。再次纠正旧SDR曲线/测试预期及把计时队列当视频队列的错误解释;额外指出DirectShow音频独立恢复、Stop返回值、GPU时间戳缺失时CPU预算回退、非NVIDIA请求/实际状态核对、无FG时“补帧受限”文案等缺口,没有把风险写成已复现根因。
+
+实际重跑:`out/build/audio-continuity-repair-20260915/veyra_repair_contract_tests.exe`,137 checks / 0 failures,exit0,`logs/user-issues-audit-contract-20260915.log`;`veyra_ui_contract_tests.exe out/user-issues-audit-ui-20260915`,exit0,384布局/DPI及设置/PCM合同通过,`logs/user-issues-audit-ui-20260915.log`。本轮审计未重跑NGX Create/Evaluate、GPU完整gate或实卡;引用历史证据均标明。未改运行组件、驱动、版本或发布状态。下一任务优先取得HDR实际路由/问题片源及4070/4070Ti后端失败和GPU预算证据;全屏自动回归需在无并行手动操作时独立复核。全部修复目标尚未完成。
+
+## 2026-09-15 独立FG选择生效与剩余代码缺口修复
+
+用户报告全关状态FG不生效、需先开NR,授权继续修能修的缺口。确认是SettingsWindow倍率选择在master关闭时只保存草稿,NR独立按钮开启master才带出FG;底层FG本来包含光流初始化条件,未添加隐式NR预热。FG选择接入显式开关事务,新增FgOnlyChecks经真实控件通知验证,具体根因/文件/命令/日志/限制见 docs/FG_STANDALONE_AND_RECOVERY_REPAIR_2026-09-15.md。
+
+同步修改FgRecoveryBudget缺失GPU时间不使用CPU迟轮询值、BackendRecovery及EngineController规范非NVIDIA请求/已应用状态、LiveStatusDashboard区分无FG的处理过载。CaptureCardSource抽取并复用DirectShow音频连接函数,新增AudioInputRecovery按PCM包进度检测3秒停滞/1至5秒退避;保留视频filter,短停共享图后仅重连音频pin、恢复音量同步、增加epoch并标下一帧Discontinuity。Stop失败不继续热改图,相关HRESULT记录;最终关闭时的异常驱动行为没有因此自动得到安全证明。WASAPI原有恢复不改、不换默认设备。
+
+构建脚本主构建79/79和最终30/30均exit0,日志fg-standalone-recovery-build[-final]-20260915.log。144项repair合同exit0(fg-recovery-contract-20260915.log),presentation_worker预算回归exit0(fg-recovery-budget-20260915.log);首次误写不存在的测试EXE名,纠正后实际运行,不以那次未执行作为成功。FG-only GUI30秒/55秒总上限exit0,日志fg-only-selector-test-20260915.log:DLSS和XeSS实际生成,NVOF创建status0,NR评估0;XeSS Init/Present结果0持续framesPresented2。独立全屏18秒/45秒上限exit0,fullscreen-transport-isolated-20260915.log;此前与用户操作重合的失败保留。
+
+最终delivery.ps1 exit0,logs/delivery/1987bb07e103441591d6dacf2e632cac/result.json,实际NR/NVOF、4K和GUI/导出相关检查通过;capture awaiting仍保留。候选hash 00DD5FD72B1849006F86041723B150E9EDF3D19575DFBCC5B0E47CE2BF86AD8E,入口out/start-user-issues-candidate.cmd。XeSS旧版历史9057d2f/83f90ba面板也显式不可测;当前SDK状态字段无内部耗时,用户对应旧截图/版本未知,未伪造计时。
+
+本地按显式源文件清单提交,全屏前轮代码/审计文档一并存档;运行库、SDK、配置、日志/fixture不入Git,未push/发布。DirectShow实卡音频热恢复、非NVIDIA实机、40系/OBS/PS5原问题均未因此视为实机通过;原生DV与XeSS内部计时仍未实现,HDR转SDR没有无证据改曲线。下一步为候选问题设备复测及其原始证据定位。
diff --git a/include/veyra/engine/BackendRecovery.h b/include/veyra/engine/BackendRecovery.h
index ab4b3d67..7a6f126c 100644
--- a/include/veyra/engine/BackendRecovery.h
+++ b/include/veyra/engine/BackendRecovery.h
@@ -3,6 +3,12 @@
namespace veyra::engine {
enum class FailedBackend { None, Infrastructure, OpticalFlow, NgxCore, Nr, Sr, Fg };
+inline bool disableUnsupportedNvidiaEffects(EnhancementSettings& settings,bool nvidia){
+ if(nvidia)return false;
+ const auto before=settings;settings.nr=false;settings.sr=false;
+ if(settings.frameGenerationBackend==FrameGenerationBackend::Dlss)settings.multiplier=1;
+ return settings!=before;
+}
inline const wchar_t* backendFailureName(FailedBackend backend) {
switch(backend){
case FailedBackend::OpticalFlow:return L"光流";
diff --git a/include/veyra/engine/FgRecoveryBudget.h b/include/veyra/engine/FgRecoveryBudget.h
index e9e47708..ca90b3c0 100644
--- a/include/veyra/engine/FgRecoveryBudget.h
+++ b/include/veyra/engine/FgRecoveryBudget.h
@@ -30,7 +30,11 @@ class FgRecoveryBudget {
public:
void reset(){base_.clear();fg_.clear();warmup_.clear();limited_=false;recoveryPairs_=0;retryAt_=0;}
void fgCost(double ms,int64_t now){add(fg_,now,ms);}
- void complete(double ms,bool evaluated,bool warmup,int64_t now,std::optional<double> measuredFg={}){
+ void complete(std::optional<double> measuredMs,bool evaluated,bool warmup,int64_t now,std::optional<double> measuredFg={}){
+ // Missing GPU timestamps are unknown, not CPU polling delay. Let old
+ // samples expire; admission still checks each batch's real deadline.
+ if(!measuredMs)return;
+ const double ms=*measuredMs;
if(warmup){add(warmup_,now,ms);return;}
const auto extra=evaluated?(measuredFg?measuredFg:p95(fg_,now,20000000)):std::optional<double>(0);
// If a generated batch lacks a GPU timing, retain its whole measured
diff --git a/include/veyra/source/AudioInputRecovery.h b/include/veyra/source/AudioInputRecovery.h
new file mode 100644
index 00000000..4369ede0
--- /dev/null
+++ b/include/veyra/source/AudioInputRecovery.h
@@ -0,0 +1,17 @@
+#pragma once
+#include <algorithm>
+#include <cstdint>
+namespace veyra::source {
+// Observe PCM packet progress, including silence packets. Never treat quiet
+// audio as a lost input. Times are monotonic milliseconds on the owner thread.
+class AudioInputRecovery {
+ uint64_t blocks_=0,progressAt_=0,retryAt_=0;unsigned attempts_=0;
+public:
+ void reset(uint64_t now){blocks_=0;progressAt_=now;retryAt_=0;attempts_=0;}
+ bool due(uint64_t blocks,uint64_t now){
+ if(blocks!=blocks_){blocks_=blocks;progressAt_=now;attempts_=0;retryAt_=0;return false;}
+ if(now<progressAt_||now-progressAt_<3000||now<retryAt_)return false;
+ attempts_=std::min(attempts_+1,5u);retryAt_=now+attempts_*1000;return true;
+ }
+};
+}
diff --git a/include/veyra/source/CaptureCardSource.h b/include/veyra/source/CaptureCardSource.h
index 94c710ad..e4c4f968 100644
--- a/include/veyra/source/CaptureCardSource.h
+++ b/include/veyra/source/CaptureCardSource.h
@@ -4,6 +4,7 @@
#include <string_view>
#include <vector>
#include "veyra/sink/CaptureAudioSession.h"
+#include "veyra/source/AudioInputRecovery.h"
namespace veyra::source {
struct CaptureFormat {int index=0;unsigned width=0,height=0;double fps=0;std::wstring label;std::wstring key;};
struct CaptureDevice {
@@ -38,6 +39,8 @@ public:
bool configure(const SourceOpenDesc&);
bool start();
bool reconnect(float gain,unsigned syncMode,int offsetMs);
+ // Owner-thread recovery of DirectShow audio pins; same video filter retained.
+ void recoverAudio(float gain,unsigned syncMode,int offsetMs);
bool setAudioGain(float); // call on the graph owner thread; never system volume
CaptureMetrics metrics()const;
void videoPresented(double ptsMs,int64_t host100ns,int64_t arrival100ns);
@@ -50,6 +53,7 @@ public:
bool seek(const pipeline::Rational&)override{return false;}
void close()noexcept override;
private:
+ bool connectDirectShowAudio(const SourceOpenDesc&);
SourceReadStatus readWithWait(pipeline::FramePacket&,const AVFrame**,unsigned milliseconds);
struct Impl;std::unique_ptr<Impl> p_;
SourceOpenDesc reconnectDesc_;
diff --git a/src/engine/EngineController.cpp b/src/engine/EngineController.cpp
index 2ca71203..e198acb0 100644
--- a/src/engine/EngineController.cpp
+++ b/src/engine/EngineController.cpp
@@ -224,6 +224,15 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,s
std::wstring backendRecoveryWarning;
auto initializePreview=[&](pipeline::EnhanceGraphDesc& desc,PlayerOptions& selected){
backendRecoveryWarning.clear();
+ auto supported=selected.snapshot();
+ if(disableUnsupportedNvidiaEffects(supported,nvidiaAdapter)){
+ selected=PlayerOptions::from(supported);
+ const auto plan=pipeline::ResolutionPlan::make({width,height},false,supported.nrPolicy,isImage,supported.revision,supported.srTarget,false);
+ desc.workWidth=plan.base.width;desc.workHeight=plan.base.height;desc.nrWidth=plan.nr.width;desc.nrHeight=plan.nr.height;desc.flowWidth=plan.flow.width;desc.flowHeight=plan.flow.height;
+ desc.enableNr=desc.enableSr=desc.enableNvofStandalone=desc.nrBeforeSr=false;desc.enableFg=selected.fg;desc.fgMultiplier=selected.fgMultiplier;
+ backendRecoveryWarning=L"当前 GPU 不支持 NVIDIA 增强;NR、超分及 DLSS 已关闭,XeSS选择保留";
+ veyra::log::warn("capability","normalized requested NVIDIA effects before graph creation; applied settings reflect actual disabled stages");
+ }
for(unsigned attempt=0;attempt<5;++attempt){
bool opened=graph.initialize(desc);
auto failure=graph.failedBackend();
@@ -403,7 +412,7 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,s
watch.flow->ready(batch.batch.batchId,watch.real,valid,invalid,host100ns());
traceFrame(diagnostics::TraceKind::Ready,batch.batch.identity,batch.batch.batchId,std::max(batch.videoFenceValue,batch.genFenceValue),batch.batch.b100ns,invalid,valid,elapsedMs(watch.processStart));
if(watch.real)completedProcessing(batch.batch.identity);
- if(batch.batch.identity.settingsRevision==fgBudgetRevision)fgBudget.complete(watch.gpuExecutionMs.value_or(elapsedMs(watch.processStart)),batch.fgEvaluated>0,batch.historyReset||batch.fgRecovery,host100ns(),watch.fgExecutionMs);
+ if(batch.batch.identity.settingsRevision==fgBudgetRevision)fgBudget.complete(watch.gpuExecutionMs,batch.fgEvaluated>0,batch.historyReset||batch.fgRecovery,host100ns(),watch.fgExecutionMs);
completeReset(batch.batch.identity);
watch.readyObserved=Clock::now();watch.ready=true;it=pendingCompletions.erase(it);
}
@@ -490,6 +499,7 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,s
advanceLive();
if(liveScheduler&&liveScheduler->failed()){if(recoverXessPresentation())continue;status(L"视频呈现失败,请查看诊断",true);break;}
const float gain=muted_?0.0f:volume_.load();audio.setGain(gain);
+ if(physicalCapture)captureSource.recoverAudio(gain,unsigned(options.settings.audioSync),options.settings.audioOffsetMs);
captureSource.setAudioSync(unsigned(options.settings.audioSync),options.settings.audioOffsetMs);
if(physicalCapture){const bool available=captureSource.setAudioGain(gain);const auto audioState=captureSource.audioState();std::lock_guard lock(mutex_);snapshot_.audioAvailable=available;snapshot_.captureAudio=audioState;snapshot_.audioInputChannels=audioState.inputChannels;snapshot_.audioOutputChannels=audioState.outputChannels;}
#ifdef VEYRA_ENABLE_REMOTEPLAY
@@ -544,7 +554,7 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,s
nextDesc.model=requested.model;nextDesc.residual=requested.residual;nextDesc.protection=requested.protection;nextDesc.settingsRevision=requested.revision;nextDesc.flowQuality=requested.flow;nextDesc.contentRate=requested.content;
nextDesc.opticalFlowBackend=requested.opticalFlowBackend;nextDesc.amdFlowHalfResolution=requested.amdFlowHalfResolution;
nextDesc.hdrOutput=requested.useHdrPreview(nextDesc.hdrInput,gfx::PresentSink::hdrDisplayActive(window));
- const bool rebuild=gd.hdrOutput!=nextDesc.hdrOutput||previous.captureCompatible!=requested.captureCompatible||gd.nrRuntime!=nextDesc.nrRuntime||gd.opticalFlowBackend!=nextDesc.opticalFlowBackend||gd.amdFlowHalfResolution!=nextDesc.amdFlowHalfResolution||gd.enableNr!=nextDesc.enableNr||gd.enableFg!=nextDesc.enableFg||gd.frameGenerationBackend!=nextDesc.frameGenerationBackend||gd.fgMultiplier!=nextDesc.fgMultiplier||gd.videoSrQuality!=nextDesc.videoSrQuality||gd.flowQuality!=nextDesc.flowQuality||gd.nrBeforeSr!=nextDesc.nrBeforeSr||gd.workWidth!=nextDesc.workWidth||gd.workHeight!=nextDesc.workHeight||gd.nrWidth!=nextDesc.nrWidth||gd.nrHeight!=nextDesc.nrHeight||gd.flowWidth!=nextDesc.flowWidth||gd.flowHeight!=nextDesc.flowHeight;
+ const bool rebuild=(!nvidiaAdapter&&(next.nr||next.sr||(next.fg&&!xessFg)))||gd.hdrOutput!=nextDesc.hdrOutput||previous.captureCompatible!=requested.captureCompatible||gd.nrRuntime!=nextDesc.nrRuntime||gd.opticalFlowBackend!=nextDesc.opticalFlowBackend||gd.amdFlowHalfResolution!=nextDesc.amdFlowHalfResolution||gd.enableNr!=nextDesc.enableNr||gd.enableFg!=nextDesc.enableFg||gd.frameGenerationBackend!=nextDesc.frameGenerationBackend||gd.fgMultiplier!=nextDesc.fgMultiplier||gd.videoSrQuality!=nextDesc.videoSrQuality||gd.flowQuality!=nextDesc.flowQuality||gd.nrBeforeSr!=nextDesc.nrBeforeSr||gd.workWidth!=nextDesc.workWidth||gd.workHeight!=nextDesc.workHeight||gd.nrWidth!=nextDesc.nrWidth||gd.nrHeight!=nextDesc.nrHeight||gd.flowWidth!=nextDesc.flowWidth||gd.flowHeight!=nextDesc.flowHeight;
bool accepted=ring.drainQueue();out={};hasOutput=false;
resetRecord->rebuilt=rebuild;
markResetStage(diagnostics::ResetStage::Drain);
diff --git a/src/source/CaptureCardSource.cpp b/src/source/CaptureCardSource.cpp
index 622159c2..537d6a1a 100644
--- a/src/source/CaptureCardSource.cpp
+++ b/src/source/CaptureCardSource.cpp
@@ -117,7 +117,7 @@ struct CaptureCardSource::Impl:ISampleGrabberCB {
// One pending frame plus one reader-owned frame, never an IMediaSample
// reference. Holding the producer's sole RGB32 sample starves its allocator.
AVFrame* frame=nullptr;AVFrame* pendingFrame=nullptr;bool pending=false,callbackError=false,configured=false;
- double pendingTime=0,lastPts=0,readAgeMs=0;bool pendingDiscontinuity=false;
+ double pendingTime=0,lastPts=0,readAgeMs=0;bool pendingDiscontinuity=false,forceDiscontinuity=false;
int64_t nominalDuration100ns=0;pipeline::Rational pendingDuration=pipeline::Rational::unknown();
uint64_t received=0,dropped=0,lastDrop=0,sequence=0;
Clock::time_point pendingArrival{},readArrival{},firstArrival{},latestArrival{};
@@ -127,6 +127,7 @@ struct CaptureCardSource::Impl:ISampleGrabberCB {
std::unique_ptr<sink::CaptureAudioSession> audioSession;
std::unique_ptr<WasapiAudioInput> wasapi;
std::wstring audioError;
+ AudioInputRecovery audioRecovery;
SourceInfo info;CaptureMediaLayout layout;Clock::time_point lastFrame;
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID id,void** pp)override{if(!pp)return E_POINTER;*pp=nullptr;if(id==IID_IUnknown||id==__uuidof(ISampleGrabberCB)){*pp=static_cast<ISampleGrabberCB*>(this);AddRef();return S_OK;}return E_NOINTERFACE;}
ULONG STDMETHODCALLTYPE AddRef()override{return ++refs;}ULONG STDMETHODCALLTYPE Release()override{return --refs;}
@@ -275,69 +276,7 @@ bool CaptureCardSource::configure(const SourceOpenDesc& desc){close();p_->lastAu
if(!p.wasapi->configure(selection.audioPath)){p.wasapi.reset();p.audioError=L"WASAPI 音频端点ID无效;视频继续运行";}
log::info("capture-audio","binding=wasapi shared=1 explicitEndpoint=1 videoClock=ingress-host-estimate");
}else if(audio!=kCaptureAudioDisabled){
- const bool audioReady=[&]{
- ComPtr<IBaseFilter> audioFilter;const bool embedded=audio==kCaptureAudioFromVideoDevice;
- if(embedded){
- // Some capture cards expose video and HDMI audio on one
- // DirectShow filter. OBS calls this "use video device". Do not
- // AddFilter/RemoveFilter here: p.device owns the graph filter.
- audioFilter=p.device;log::info("capture-audio",std::format("binding=video-filter embedded=1 videoPathTag={}",pathTag(selection.videoPath)));
- }else{
- const bool bound=selection.stable?bindPath(selection.audioPath,true,audioFilter):bind(unsigned(audio),true,audioFilter);
- if(!bound){log::warn("capture-audio",std::format("binding=separate failed mode={} audioIndex={} audioPathTag={}",audio,audio,pathTag(selection.audioPath)));return false;}
- hr=p.graph->AddFilter(audioFilter.Get(),L"Capture audio");
- if(FAILED(hr)){log::warn("capture-audio",std::format("binding=separate AddFilter hr=0x{:08X}",uint32_t(hr)));return false;}
- p.audioFilter=audioFilter;log::info("capture-audio",std::format("binding=separate embedded=0 audioIndex={} audioPathTag={}",audio,audio,pathTag(selection.audioPath)));
- }
- ComPtr<IPin> audioPin;hr=audioPinFor(p.builder.Get(),audioFilter.Get(),audioPin);
- if(FAILED(hr)){log::warn("capture-audio",std::format("audio output pin not found embedded={} hr=0x{:08X}",embedded?1:0,uint32_t(hr)));return false;}
- ComPtr<IEnumMediaTypes> types;hr=audioPin->EnumMediaTypes(&types);if(FAILED(hr)){log::warn("capture-audio",std::format("EnumMediaTypes hr=0x{:08X}",uint32_t(hr)));return false;}
- // Preserve the device's actual speaker layout. Enumeration order is
- // commonly stereo first even when native 5.1 is available.
- auto releaseType=[](AM_MEDIA_TYPE* type){freeType(type);};
- using AudioType=std::unique_ptr<AM_MEDIA_TYPE,decltype(releaseType)>;
- std::vector<AudioType> audioTypes;unsigned typeIndex=0;
- for(;;){AM_MEDIA_TYPE* type=nullptr;if(types->Next(1,&type,nullptr)!=S_OK||!type)break;
- AudioType owned(type,releaseType);sink::WavePcmFormat pcm;bool supported=false;
- if(type->formattype==FORMAT_WaveFormatEx&&type->pbFormat)supported=sink::parseWavePcm(type->pbFormat,type->cbFormat,pcm);
- if(type->formattype==FORMAT_WaveFormatEx&&type->pbFormat&&type->cbFormat>=sizeof(WAVEFORMATEX)){
- const auto* wave=reinterpret_cast<const WAVEFORMATEX*>(type->pbFormat);
- log::info("capture-audio",std::format("mediaType={} major=0x{:08X} subtype=0x{:08X} tag={} channels={} mask=0x{:X} rate={} containerBits={} validBits={} floating={} pcm={}",typeIndex++,type->majortype.Data1,type->subtype.Data1,wave->wFormatTag,wave->nChannels,supported?pcm.layout.mask:0,wave->nSamplesPerSec,wave->wBitsPerSample,supported?pcm.validBits:0,supported&&pcm.floating?1:0,supported?1:0));
- }else log::info("capture-audio",std::format("mediaType={} major=0x{:08X} subtype=0x{:08X} format=0x{:08X} pcm=0",typeIndex++,type->majortype.Data1,type->subtype.Data1,type->formattype.Data1));
- if(supported)audioTypes.push_back(std::move(owned));
- }
- if(audioTypes.empty()){log::warn("capture-audio","audio pin has no supported PCM media type");return false;}
- std::stable_sort(audioTypes.begin(),audioTypes.end(),[](const auto& a,const auto& b){
- sink::WavePcmFormat lhs{},rhs{};
- if(!sink::parseWavePcm(a->pbFormat,a->cbFormat,lhs)||!sink::parseWavePcm(b->pbFormat,b->cbFormat,rhs))return false;
- return sink::preferCaptureAudioFormat(lhs,rhs);
- });
- bool connectedAudio=false;
- for(const auto& owned:audioTypes){
- auto* type=owned.get();
- auto session=std::make_unique<sink::CaptureAudioSession>();ComPtr<IBaseFilter> candidate;ComPtr<IPin> terminal;
- sink::WavePcmFormat parsed{};
- if(type->formattype==FORMAT_WaveFormatEx&&type->pbFormat&&type->cbFormat>=sizeof(WAVEFORMATEX)&&sink::parseWavePcm(type->pbFormat,type->cbFormat,parsed)&&session->configure(parsed)){
- auto* target=session.get();
- hr=createNativeAudioSink(*type,[target](IMediaSample* sample){
- BYTE* bytes=nullptr;REFERENCE_TIME begin=0,end=0;
- if(FAILED(sample->GetPointer(&bytes))||FAILED(sample->GetTime(&begin,&end)))return VFW_E_SAMPLE_TIME_NOT_SET;
- return target->push(bytes,size_t(sample->GetActualDataLength()),double(begin)/10000,sample->IsDiscontinuity()==S_OK)?S_OK:E_FAIL;
- },candidate,terminal);
- if(SUCCEEDED(hr))hr=p.graph->AddFilter(candidate.Get(),L"Veyra audio PCM");
- // Request small input blocks before connection; downstream
- // playback cannot undo time spent filling a driver buffer.
- // Some devices reject this advisory API, so do not fail capture.
- if(SUCCEEDED(hr))suggestCaptureAudioBuffering(audioPin.Get(),*reinterpret_cast<const WAVEFORMATEX*>(type->pbFormat));
- if(SUCCEEDED(hr))hr=p.graph->ConnectDirect(audioPin.Get(),terminal.Get(),type);
- if(SUCCEEDED(hr)){p.audioSink=candidate;p.audioSession=std::move(session);connectedAudio=true;log::info("capture-audio",std::format("selected media type channels={} mask=0x{:X} rate={} containerBits={} validBits={} floating={}",parsed.layout.channels,parsed.layout.mask,parsed.wave.nSamplesPerSec,parsed.wave.wBitsPerSample,parsed.validBits,parsed.floating?1:0));}
- else if(candidate)p.graph->RemoveFilter(candidate.Get());
- log::info("capture-audio",std::format("PCM ConnectDirect hr=0x{:X}",unsigned(hr)));
- }
- if(connectedAudio)break;
- }
- return connectedAudio;
- }();
+ const bool audioReady=connectDirectShowAudio(desc);
if(!audioReady){
p.audioError=L"采集音频设备或 PCM 格式不可用;视频继续运行";
log::warn("capture-audio","audio connection unavailable; retaining video capture");
@@ -367,13 +306,104 @@ bool CaptureCardSource::configure(const SourceOpenDesc& desc){close();p_->lastAu
p.info.width,p.info.height,p.info.averageFps,actual?unsigned(actual->subtype.Data1):0,unsigned(formatHr),audio));freeType(actual);
return true;
}
+bool CaptureCardSource::connectDirectShowAudio(const SourceOpenDesc& desc){
+ auto& p=*p_;CaptureSelection selection;if(!parseCapturePath(desc.path,selection))return false;
+ const int audio=selection.audio;HRESULT hr=S_OK;
+ ComPtr<IBaseFilter> audioFilter;const bool embedded=audio==kCaptureAudioFromVideoDevice;
+ if(embedded){
+ // Some capture cards expose video and HDMI audio on one
+ // DirectShow filter. OBS calls this "use video device". Do not
+ // AddFilter/RemoveFilter here: p.device owns the graph filter.
+ audioFilter=p.device;log::info("capture-audio",std::format("binding=video-filter embedded=1 videoPathTag={}",pathTag(selection.videoPath)));
+ }else{
+ const bool bound=selection.stable?bindPath(selection.audioPath,true,audioFilter):bind(unsigned(audio),true,audioFilter);
+ if(!bound){log::warn("capture-audio",std::format("binding=separate failed mode={} audioIndex={} audioPathTag={}",audio,audio,pathTag(selection.audioPath)));return false;}
+ hr=p.graph->AddFilter(audioFilter.Get(),L"Capture audio");
+ if(FAILED(hr)){log::warn("capture-audio",std::format("binding=separate AddFilter hr=0x{:08X}",uint32_t(hr)));return false;}
+ p.audioFilter=audioFilter;log::info("capture-audio",std::format("binding=separate embedded=0 audioIndex={} audioPathTag={}",audio,audio,pathTag(selection.audioPath)));
+ }
+ ComPtr<IPin> audioPin;hr=audioPinFor(p.builder.Get(),audioFilter.Get(),audioPin);
+ if(FAILED(hr)){log::warn("capture-audio",std::format("audio output pin not found embedded={} hr=0x{:08X}",embedded?1:0,uint32_t(hr)));return false;}
+ ComPtr<IEnumMediaTypes> types;hr=audioPin->EnumMediaTypes(&types);if(FAILED(hr)){log::warn("capture-audio",std::format("EnumMediaTypes hr=0x{:08X}",uint32_t(hr)));return false;}
+ // Preserve the device's actual speaker layout. Enumeration order is
+ // commonly stereo first even when native 5.1 is available.
+ auto releaseType=[](AM_MEDIA_TYPE* type){freeType(type);};
+ using AudioType=std::unique_ptr<AM_MEDIA_TYPE,decltype(releaseType)>;
+ std::vector<AudioType> audioTypes;unsigned typeIndex=0;
+ for(;;){AM_MEDIA_TYPE* type=nullptr;if(types->Next(1,&type,nullptr)!=S_OK||!type)break;
+ AudioType owned(type,releaseType);sink::WavePcmFormat pcm;bool supported=false;
+ if(type->formattype==FORMAT_WaveFormatEx&&type->pbFormat)supported=sink::parseWavePcm(type->pbFormat,type->cbFormat,pcm);
+ if(type->formattype==FORMAT_WaveFormatEx&&type->pbFormat&&type->cbFormat>=sizeof(WAVEFORMATEX)){
+ const auto* wave=reinterpret_cast<const WAVEFORMATEX*>(type->pbFormat);
+ log::info("capture-audio",std::format("mediaType={} major=0x{:08X} subtype=0x{:08X} tag={} channels={} mask=0x{:X} rate={} containerBits={} validBits={} floating={} pcm={}",typeIndex++,type->majortype.Data1,type->subtype.Data1,wave->wFormatTag,wave->nChannels,supported?pcm.layout.mask:0,wave->nSamplesPerSec,wave->wBitsPerSample,supported?pcm.validBits:0,supported&&pcm.floating?1:0,supported?1:0));
+ }else log::info("capture-audio",std::format("mediaType={} major=0x{:08X} subtype=0x{:08X} format=0x{:08X} pcm=0",typeIndex++,type->majortype.Data1,type->subtype.Data1,type->formattype.Data1));
+ if(supported)audioTypes.push_back(std::move(owned));
+ }
+ if(audioTypes.empty()){log::warn("capture-audio","audio pin has no supported PCM media type");return false;}
+ std::stable_sort(audioTypes.begin(),audioTypes.end(),[](const auto& a,const auto& b){
+ sink::WavePcmFormat lhs{},rhs{};
+ if(!sink::parseWavePcm(a->pbFormat,a->cbFormat,lhs)||!sink::parseWavePcm(b->pbFormat,b->cbFormat,rhs))return false;
+ return sink::preferCaptureAudioFormat(lhs,rhs);
+ });
+ bool connectedAudio=false;
+ for(const auto& owned:audioTypes){
+ auto* type=owned.get();
+ auto session=std::make_unique<sink::CaptureAudioSession>();ComPtr<IBaseFilter> candidate;ComPtr<IPin> terminal;
+ sink::WavePcmFormat parsed{};
+ if(type->formattype==FORMAT_WaveFormatEx&&type->pbFormat&&type->cbFormat>=sizeof(WAVEFORMATEX)&&sink::parseWavePcm(type->pbFormat,type->cbFormat,parsed)&&session->configure(parsed)){
+ auto* target=session.get();
+ hr=createNativeAudioSink(*type,[target](IMediaSample* sample){
+ BYTE* bytes=nullptr;REFERENCE_TIME begin=0,end=0;
+ if(FAILED(sample->GetPointer(&bytes))||FAILED(sample->GetTime(&begin,&end)))return VFW_E_SAMPLE_TIME_NOT_SET;
+ return target->push(bytes,size_t(sample->GetActualDataLength()),double(begin)/10000,sample->IsDiscontinuity()==S_OK)?S_OK:E_FAIL;
+ },candidate,terminal);
+ if(SUCCEEDED(hr))hr=p.graph->AddFilter(candidate.Get(),L"Veyra audio PCM");
+ // Request small input blocks before connection; downstream
+ // playback cannot undo time spent filling a driver buffer.
+ // Some devices reject this advisory API, so do not fail capture.
+ if(SUCCEEDED(hr))suggestCaptureAudioBuffering(audioPin.Get(),*reinterpret_cast<const WAVEFORMATEX*>(type->pbFormat));
+ if(SUCCEEDED(hr))hr=p.graph->ConnectDirect(audioPin.Get(),terminal.Get(),type);
+ if(SUCCEEDED(hr)){p.audioSink=candidate;p.audioSession=std::move(session);connectedAudio=true;log::info("capture-audio",std::format("selected media type channels={} mask=0x{:X} rate={} containerBits={} validBits={} floating={}",parsed.layout.channels,parsed.layout.mask,parsed.wave.nSamplesPerSec,parsed.wave.wBitsPerSample,parsed.validBits,parsed.floating?1:0));}
+ else if(candidate)p.graph->RemoveFilter(candidate.Get());
+ log::info("capture-audio",std::format("PCM ConnectDirect hr=0x{:X}",unsigned(hr)));
+ }
+ if(connectedAudio)break;
+ }
+ return connectedAudio;
+}
bool CaptureCardSource::start(){
auto& p=*p_;if(p.info.opened)return true;if(!p.configured||!p.control)return false;
if(p.audioSession&&!p.audioSession->start())log::warn("capture-audio","audio start failed; retaining video capture");
+ p.audioRecovery.reset(GetTickCount64());
p.lastFrame=Impl::Clock::now();const auto hr=p.control->Run();p.info.opened=SUCCEEDED(hr);
if(p.info.opened&&p.wasapi&&!p.wasapi->start())p.audioError=L"WASAPI 音频启动失败;视频继续运行";
veyra::log::info("capture",std::format("Run hr=0x{:X} actual={}x{} nominalFps={:.3f} mailbox=1 ownedBuffers=2",unsigned(hr),p.info.width,p.info.height,p.info.averageFps));return p.info.opened;
}
+void CaptureCardSource::recoverAudio(float gain,unsigned syncMode,int offsetMs){
+ auto& p=*p_;if(!p.info.opened||!p.control||p.wasapi)return;
+ CaptureSelection selection;if(!parseCapturePath(reconnectDesc_.path,selection)||!selection.stable||selection.audio==kCaptureAudioDisabled||selection.audio==kCaptureAudioWasapi)return;
+ const auto state=p.audioSession?p.audioSession->snapshot():sink::CaptureAudioState{};
+ if(!p.audioRecovery.due(state.inputBlocks,GetTickCount64()))return;
+ // DirectShow audio/video pins share one graph. Briefly stop it to mutate
+ // only the audio branch; do not renegotiate or replace the video device.
+ const HRESULT stopped=p.control->Stop();
+ log::warn("capture-audio-reconnect",std::format("PCM stalled; Stop hr=0x{:08X} videoFilterRetained=1",uint32_t(stopped)));
+ if(FAILED(stopped)){p.audioError=L"音频恢复等待采集驱动停止;稍后重试";return;}
+ const bool connected=[&]{
+ if(p.audioSink){const HRESULT hr=p.graph->RemoveFilter(p.audioSink.Get());log::info("capture-audio-reconnect",std::format("Remove PCM sink hr=0x{:08X}",uint32_t(hr)));if(FAILED(hr))return false;p.audioSink.Reset();}
+ if(p.audioSession)p.audioSession->stop();
+ p.audioSession.reset();
+ if(p.audioFilter){const HRESULT hr=p.graph->RemoveFilter(p.audioFilter.Get());log::info("capture-audio-reconnect",std::format("Remove audio device hr=0x{:08X}",uint32_t(hr)));if(FAILED(hr))return false;p.audioFilter.Reset();}
+ if(!connectDirectShowAudio(reconnectDesc_))return false;
+ p.audioSession->setGain(gain);p.audioSession->setSync(syncMode,offsetMs);
+ return p.audioSession->start();
+ }();
+ {std::lock_guard lock(p.mutex);p.pending=false;p.forceDiscontinuity=true;}
+ ++epoch_;p.lastFrame=Impl::Clock::now();
+ const HRESULT resumed=p.control->Run();p.info.opened=SUCCEEDED(resumed);
+ p.audioError=connected&&p.info.opened?L"":L"采集音频暂不可用,正在重试原音频设备";
+ log::info("capture-audio-reconnect",std::format("connected={} Run hr=0x{:08X} epoch={} awaitingActualPCM=1",connected,uint32_t(resumed),epoch_));
+}
bool CaptureCardSource::reconnect(float gain,unsigned syncMode,int offsetMs){
CaptureSelection selection;
if(!parseCapturePath(reconnectDesc_.path,selection)||!selection.stable||reconnectFormat_.empty()){
@@ -382,7 +412,7 @@ bool CaptureCardSource::reconnect(float gain,unsigned syncMode,int offsetMs){
const auto desc=reconnectDesc_;const auto key=reconnectFormat_;const auto expected=reconnectInfo_;
// Stop callbacks before carrying counters into the next device session.
// Never hold the mailbox lock while DirectShow Stop waits for a callback.
- if(p_->control)p_->control->Stop();
+ if(p_->control){const HRESULT hr=p_->control->Stop();log::info("capture-reconnect",std::format("Stop hr=0x{:08X}",uint32_t(hr)));if(FAILED(hr))return false;}
{std::lock_guard lock(p_->mutex);
receivedOffset_+=p_->received;deliveredOffset_+=p_->sequence;droppedOffset_+=p_->dropped;}
close();
@@ -421,6 +451,7 @@ SourceReadStatus CaptureCardSource::readWithWait(pipeline::FramePacket& packet,c
if(!p.sequence)flags|=static_cast<uint32_t>(pipeline::FrameFlagBits::Open);
if(p.dropped!=p.lastDrop)flags|=static_cast<uint32_t>(pipeline::FrameFlagBits::Drop);
if(p.pendingDiscontinuity)flags|=static_cast<uint32_t>(pipeline::FrameFlagBits::Discontinuity);
+ if(p.forceDiscontinuity){flags|=static_cast<uint32_t>(pipeline::FrameFlagBits::Discontinuity);p.forceDiscontinuity=false;}
p.lastDrop=p.dropped;p.lastPts=time;++p.sequence;sequence=p.received;
}
p.frame->pts=static_cast<int64_t>(time*10000000);p.frame->duration=duration.isUnknown()?0:duration.to100ns();p.frame->time_base={1,10000000};packet={};packet.pts={p.frame->pts,10000000};packet.duration=duration;packet.colorInfo=p.info.color;packet.sourceKind=pipeline::SourceKind::CaptureCard;packet.sequence=sequence;packet.flags=flags;packet.sourceEpoch=1;
@@ -429,11 +460,11 @@ SourceReadStatus CaptureCardSource::readWithWait(pipeline::FramePacket& packet,c
*frame=p.frame;p.lastFrame=Impl::Clock::now();return SourceReadStatus::Frame;
}
void CaptureCardSource::close()noexcept{
- auto& p=*p_;if(p.control)p.control->Stop();if(p.grab)p.grab->SetCallback(nullptr,0);
+ auto& p=*p_;if(p.control){const HRESULT hr=p.control->Stop();if(FAILED(hr))log::error("capture-close",std::format("Stop failed hr=0x{:08X}; releasing graph",uint32_t(hr)));}if(p.grab){const HRESULT hr=p.grab->SetCallback(nullptr,0);if(FAILED(hr))log::error("capture-close",std::format("detach callback hr=0x{:08X}",uint32_t(hr)));}
if(p.wasapi)p.wasapi->stop();p.wasapi.reset();
if(p.audioSession)p.audioSession->stop();p.audioError.clear();
p.events.Reset();p.control.Reset();p.grab.Reset();p.nullFilter.Reset();p.grabFilter.Reset();p.audioSink.Reset();p.audioFilter.Reset();p.config.Reset();p.device.Reset();p.builder.Reset();p.graph.Reset();p.referenceClock.Reset();p.audioSession.reset();
av_frame_free(&p.frame);av_frame_free(&p.pendingFrame);p.info={};
- p.sequence=p.received=p.dropped=p.lastDrop=0;p.pending=p.callbackError=p.configured=false;p.lastPts=p.readAgeMs=0;
+ p.sequence=p.received=p.dropped=p.lastDrop=0;p.pending=p.callbackError=p.configured=p.forceDiscontinuity=false;p.lastPts=p.readAgeMs=0;
}
}
diff --git a/tests/unit/LiveGpuSchedulerTests.cpp b/tests/unit/LiveGpuSchedulerTests.cpp
index 9e64f90b..69b5e418 100644
--- a/tests/unit/LiveGpuSchedulerTests.cpp
+++ b/tests/unit/LiveGpuSchedulerTests.cpp
@@ -52,5 +52,8 @@ int main(){
budget.reset();check(!budget.predicted(25000000),"settings revision reset clears prior backend costs");
budget.fgCost(20,25000000);budget.complete(12,true,false,25000000,3);
check(budget.predicted(25000000)==29,"subtract same-frame FG time instead of another frame's higher percentile");
+ budget.complete(std::nullopt,true,false,36000000);
+ check(!budget.predicted(36000000),"missing GPU timing cannot retain a stale CPU polling cost");
+ check(!budget.admit(36000000,35800000,0,0),"unknown cost still rejects expired presentation deadlines");
return failures?1:0;
}
diff --git a/tests/unit/RepairContractTests.cpp b/tests/unit/RepairContractTests.cpp
index c48d2590..165b704f 100644
--- a/tests/unit/RepairContractTests.cpp
+++ b/tests/unit/RepairContractTests.cpp
@@ -21,9 +21,24 @@
#include "veyra/sink/ArrivalClockMapping.h"
#include "veyra/sink/CaptureSyncTarget.h"
#include "veyra/source/DolbyVision.h"
+#include "veyra/source/AudioInputRecovery.h"
int main(){
using namespace veyra;int failures=0,checks=0;
auto check=[&](bool ok,const char* name){++checks;if(!ok)++failures;std::cout<<(ok?"PASS ":"FAIL ")<<name<<'\n';};
+ {
+ source::AudioInputRecovery retry;retry.reset(1000);
+ check(!retry.due(0,3999)&&retry.due(0,4000),"missing initial PCM retries after bounded startup grace");
+ check(!retry.due(0,4500)&&retry.due(0,5000),"audio retry has bounded backoff instead of every video frame");
+ check(!retry.due(1,5100)&&!retry.due(2,8100),"silent PCM packet progress prevents reconnect");
+ check(!retry.due(2,11099)&&retry.due(2,11100),"audio-only PCM stall is detected while video may continue");
+ }
+ {
+ engine::EnhancementSettings s;s.nr=s.sr=true;s.multiplier=2;
+ check(engine::disableUnsupportedNvidiaEffects(s,false)&&!s.nr&&!s.sr&&s.multiplier==1,"unsupported NVIDIA effects are removed from actual settings");
+ s.nr=s.sr=true;s.multiplier=2;s.frameGenerationBackend=engine::FrameGenerationBackend::XeSS;
+ check(engine::disableUnsupportedNvidiaEffects(s,false)&&!s.nr&&!s.sr&&s.multiplier==2,"non-NVIDIA normalization retains independently selected XeSS");
+ s.nr=true;check(!engine::disableUnsupportedNvidiaEffects(s,true)&&s.nr,"NVIDIA capability normalization retains supported effects");
+ }
{
engine::EnhancementSettings requested;requested.nr=requested.sr=true;requested.multiplier=2;requested.audioOffsetMs=37;
auto recovered=requested;