Skip to content

Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.

fix(recording): stamp a legacy-path tick after its frame wait, and skip it while paused

EtienneLescot85aeaf0860bc
diff --git a/electron/native/wgc-capture/src/main.cpp b/electron/native/wgc-capture/src/main.cpp
index 6d317cb93..bd28c5eb1 100644
--- a/electron/native/wgc-capture/src/main.cpp
+++ b/electron/native/wgc-capture/src/main.cpp
@@ -1099,7 +1099,7 @@ int wmain(int argc, wchar_t* argv[]) {
// One instant per tick for both clocks: read after the screen readback, the
// screen's would trail the webcam's by any stall in it, and the first tick
// would give the two streams different origins.
- const int64_t tickStartHns = recordingElapsedHns();
+ int64_t tickStartHns = recordingElapsedHns();
Microsoft::WRL::ComPtr<IMFSample> videoSample;
Microsoft::WRL::ComPtr<IMFSample> webcamSample;
bool hasVideoSample = false;
@@ -1133,9 +1133,12 @@ int wmain(int argc, wchar_t* argv[]) {
if (control.stopRequested || encodeFailed) {
break;
}
- if (!latestFrameTexture) {
+ if (control.paused || !latestFrameTexture) {
continue;
}
+ // The wait can outlast a pause and resume: stamp this tick
+ // with the time it actually runs at.
+ tickStartHns = recordingElapsedHns();
} else {
if (control.paused) {
std::this_thread::sleep_for(std::chrono::milliseconds(100));