mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-09-30 11:12:35 +02:00
Closing an external USB (V4L2) camera view abruptly could leave its ffmpeg running and holding /dev/videoN open -- LED stuck on, and reopening the view failed or took 10-30s fighting for exclusive device access. Same class of leak as #776 (built-in RTSP path), but the external path was never wired into that fix: external streams registered into none of the _active_streams / _disconnect_events / spawned-PID registries, so /camera/stop returned {"stopped": 0} for a live USB stream and the orphan janitor's /proc net matched only rtsp(s)://bblp: cmdlines. Cleanup ran only via the stream generator's own finally, which an abrupt disconnect can skip. - Thread an on_process callback + stop_event through generate_mjpeg_stream into _stream_usb / _stream_rtsp; register the process before the startup probe so a process that hangs on a locked device (not just one that exits) is reapable. - Register external streams into the shared registries under a unique {printer_id}-ext-{token} id so /camera/stop and cleanup_orphaned_streams find and kill them; stop_event prevents the reconnect loops from respawning. - Extend the /proc safety-net scan to also match USB (-f v4l2) ffmpeg, excluding still-active streams and unrelated ffmpeg.