Repository navigation
main, gain: put the low-light frame rate setting back after streaming - #18
Conversation
With low-light-frame-rate = on the filter turns on V4L2_CID_EXPOSURE_AUTO_PRIORITY before the camera streams. V4L2 controls outlive the open file, so the camera kept it after the stream ended: a program that then opened the camera directly (Firefox's V4L2 backend, GStreamer v4l2src) ran at 15 fps in low light although the driver default is a fixed frame rate. Remember the value the control had before the filter changed it, and write it back once the source node reports idle or suspended, when the camera has stopped and the control can be written again. A value the user set and that matches the filter's choice is left alone. Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
|
No blockers. I checked the save in
HW row: J713 (M4 Air) and one ref Mac on the production kernel, the same three-row table (control 0 before: 0 after and 30.00 fps on the next direct open; control 1 before: 1 kept). Add one row that stops the service in the middle of a PipeWire stream and then opens the camera directly. Regression: 0 AVC/0 failed units/0 new kernel errors. Assisted-by: LLM (Claude:Opus 5.5) |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Adversarial review at head b953de04ee340ab33b464ce96daf1c652090760e: Approve (0 blockers).
- Code & safety (
src/gain.c:63-86,src/main.c:95-96,655-667,928-938):cdn_v4l2_set_exposure_priority()queries capability, reads the previous value viaVIDIOC_G_CTRL, writes the new value viaVIDIOC_S_CTRL, and only recordsprio_prevon success when the value actually changed. Restoring insrc_info()onPW_NODE_CHANGE_MASK_STATEtoIDLE/SUSPENDEDwhen!c->inavoids timers/sleeps, handles restarts without clobberingprio_prev, and retries on-EBUSY. Compiledsrc/gain.candsrc/main.clocally with-Wall -Wextra -Werrorwith zero warnings. - Checklist compliance: Uses standard V4L2 control and PipeWire node state with no model/chip gating, no hacks/sleeps, clean human
Signed-off-byonly on commitb953de04, andAssisted-byon PR body. - Evidence: Complete 3x3 J615 hardware matrix on production kernel
7.3.0-aurora-fleet78(control 0 restored within 10 ms 3/3 -> 30.00 fps; user control 1 preserved -> 15.91 fps). Cross-board confirmation on J713 / ref Mac remains noted. - Non-blocking improvements (for follow-up or polish):
src/main.c:1002-1015(cam_destroy()): as previously noted, if the daemon stops (SIGTERM) or the source node disappears mid-stream,prio_savedis dropped without a best-effort restore attempt (or documenting that limitation inREADME.md).src/main.c:655-672(cam_start_input()): ifpw_stream_connect()fails (or the client disconnects before the source node leavesIDLE/SUSPENDED), no subsequentPW_NODE_CHANGE_MASK_STATEtransition toIDLE/SUSPENDEDwill arrive to trigger restore until a later PipeWire stream runs.
Assisted-by: LLM (Google:Gemini 4 Neon)
Problem. With
low-light-frame-rate = on(the default) the filter turns onV4L2_CID_EXPOSURE_AUTO_PRIORITYbefore the camera streams, and never turns it off again. V4L2 controls outlive the open file, so after any PipeWire camera use, a program that opens the camera directly (Firefox's V4L2 backend, GStreamerv4l2src) gets dynamic frame rate. In low light it runs at 15 fps, though the driver default is a fixed frame rate.Change. Remember the value the control had before the filter changed it, and write it back when the source node reports idle or suspended. At that point the camera has stopped and the control can be written again. While another client keeps the camera busy, the write is retried at the next idle. A user setting that already matches the filter's choice is left alone. The low-light behaviour of the filtered PipeWire stream itself is unchanged.
Testing. 15-inch M3 MacBook Air (J615), production kernel
7.3.0-aurora-fleet78, PipeWire 1.6.9, dark room. Each round: set the control, stream 90 buffers through the default (filtered) PipeWire source, read the control back, then open/dev/video0directly at 1080p30.No "not restored" messages in the daemon log.
meson test: 10/10 on x86. The aarch64 build is the daemon only (-Dgpu=disabled), in a Fedora 44 container.Still to run. The same row on the M4 Air (J713) and a ref Mac. The fix only uses the generic V4L2 control and PipeWire node state, so it does not depend on the machine.
Details for review
src_info()on aPW_NODE_CHANGE_MASK_STATEchange toIDLEorSUSPENDED, and only when the filter's own input stream is gone (!c->in). The ISP driver grabs the control while streaming, so a write before stream-off would get-EBUSY. Waiting for the node state means no timer or delay is needed.-EBUSYkeeps the saved value for the next idle. Any other error drops it and logs once.G_CTRLon the restart), so the filter never saves its own setting as the user's.Assisted-by: LLM (Claude:Opus 5.5)