Repository navigation
win-dshow: Undo the device's roll when Autorotation is turned off - #2140
Merged
Merged
Conversation
A Video Capture Device source with Autorotation on passes the device's roll to obs_source_set_async_rotation() from OnVideoData(), and nothing sets it back when Autorotation is turned off (obs-rust#2137). Adds plugins/win-dshow/dshow-rotation.h: dshow_rotation_on_frame() is today's OnVideoData() check, dshow_rotation_on_settings() a stub that, like today's settings path, never resets. test_dshow_rotation is plain C with no Windows headers, so it runs on every host. test_off_resets_applied_rotation and test_on_again_reapplies_same_roll fail. Refs obs-rust#2137
With Autorotation on, OnVideoData() passes the device's roll to obs_source_set_async_rotation() whenever it changes. Turning Autorotation off stopped that, but left the last roll applied, so the camera stayed turned until OBS restarted or the source was recreated. UpdateVideoConfig(), which reads Autorotation, now sets the rotation back to 0 when Autorotation is off and a roll was applied, and resets lastRotation to 0, so turning Autorotation on again re-applies the device's roll even when it has not changed. It runs on the DShow thread after ResetGraph() and before the new graph starts, so OnVideoData() is not running then. Every path with Autorotation on is unchanged. The decision is in dshow-rotation.h (in the win-dshow precompiled header), which test_dshow_rotation drives on every host. Fixes obs-rust#2137
rdoupe
force-pushed
the
fix/dshow-autorotation-off
branch
from
October 24, 2026 12:24
bd25635 to
2ac970c
Compare
6 of 7 tasks
6 of 7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2137
What and why
On Windows, turning off Autorotation on a Video Capture Device source left the camera turned by the last roll the device reported, until OBS restarted or the source was recreated.
DShowInput::OnVideoData()passes the device's roll toobs_source_set_async_rotation()only whileautorotationis on and the roll changed. Nothing set the rotation back to 0 when the setting was turned off, andlastRotationkept the old roll, so turning Autorotation on again did not re-apply the same roll either.DShowInput::UpdateVideoConfig(), whereautorotationis read, now sets the async rotation back to 0 when Autorotation is off and a roll was applied (lastRotation != 0), and resetslastRotationto 0. The next frame with Autorotation on applies the device's roll again.UpdateVideoConfig()only throughQueueActivate()→ the source's DShow thread (DShowLoop(),Action::Activate) →Activate(), which first callsdevice.ResetGraph()(stops and destroys the old graph) and starts the new graph only afterUpdateVideoConfig()returns.OnVideoData()runs on the DirectShow streaming thread of a running graph, so the two never touchlastRotationat the same time. That is the same window in whichActivate()already rewritesautorotation,flip,videoConfigandframe, whichOnVideoData()also reads; this adds no new sharing and no lock.OnVideoData()makes the same decision as before, now throughdshow_rotation_on_frame(), and with Autorotation on a settings update keepslastRotation.plugins/win-dshow/dshow-rotation.h: plain C, no Windows headers, included throughwin-dshow.pch.hpp(BUILD.md rule 2). That letstest_dshow_rotationrun it on every host; win-dshow had no test before.RED → GREEN
test: Fail the dshow rotation reset when Autorotation is turned off. Addsdshow-rotation.hwithdshow_rotation_on_frame()(today'sOnVideoData()check) anddshow_rotation_on_settings()as a stub that never resets, like today's settings path, plustest_dshow_rotation(5 cases, intest-graph.json, cmocka only, no libobs). Built and run on Linux with libobs C and with hybrid libobs: 2 of 5 fail in both,test_off_resets_applied_rotationandtest_on_again_reapplies_same_roll(dshow_rotation_on_settings(false, &last) is not true); the 3 controls pass.docs/features.mdline moved, and the runs below were on the same code as bd25635).test_dshow_rotation5/5 with libobs C and with hybrid libobs. The test does not link libobs, so libobs-c-reference does not apply. Windows: thecmake/crosscheck (-DOBS_CROSS_TARGET=win-x64, soldr clang, Windows SDK, the pinned Windows deps) compileswin-dshow-crossthrough the realwin-dshow.windows+group and its precompiled header with no warning in the changed files (the one warning is the existing-Wswitchinffmpeg-decode.c.h). Local gate on 2ac970c:--lane lint,--test-diff origin/master(obs-build, obs-studio-rust, obs-sys: 66/66) and--lane crosspass.--lane crossonly checks the Rust workspace for Windows and macOS; it does not compile win-dshow.Checklist
masterdocs/features.mdis added or updated-W..., ratchets): none. This changes a precompiled header (plugins/win-dshow/build/win-dshow.pch.hpp), so BUILD.md asks for a full Windows and macOS build (gh workflow run ci.yml --ref <branch>) before merge