fix: réinitialise la queue hw→sw à chaque restart_with via /settings
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@ -175,6 +175,7 @@ class GstManager:
|
|||||||
self._lock = threading.Lock()
|
self._lock = threading.Lock()
|
||||||
self._proc: subprocess.Popen | None = None
|
self._proc: subprocess.Popen | None = None
|
||||||
self._shutdown = threading.Event()
|
self._shutdown = threading.Event()
|
||||||
|
self._reset_encoder = threading.Event()
|
||||||
self._thread: threading.Thread | None = None
|
self._thread: threading.Thread | None = None
|
||||||
self.encoder_active: str | None = None
|
self.encoder_active: str | None = None
|
||||||
|
|
||||||
@ -192,6 +193,7 @@ class GstManager:
|
|||||||
def restart_with(self, patch: dict) -> None:
|
def restart_with(self, patch: dict) -> None:
|
||||||
with self._lock:
|
with self._lock:
|
||||||
self._cfg.update(patch)
|
self._cfg.update(patch)
|
||||||
|
self._reset_encoder.set()
|
||||||
self._terminate()
|
self._terminate()
|
||||||
|
|
||||||
def is_alive(self) -> bool:
|
def is_alive(self) -> bool:
|
||||||
@ -235,17 +237,23 @@ class GstManager:
|
|||||||
log.debug("gst: %s", stripped)
|
log.debug("gst: %s", stripped)
|
||||||
|
|
||||||
def _worker(self) -> None:
|
def _worker(self) -> None:
|
||||||
with self._lock:
|
def _make_queue() -> tuple[list[str], str]:
|
||||||
pref = self._cfg.get("encoder", "auto")
|
with self._lock:
|
||||||
|
p = self._cfg.get("encoder", "auto")
|
||||||
|
if p == "hw":
|
||||||
|
return ["hw"], p
|
||||||
|
if p == "sw":
|
||||||
|
return ["sw"], p
|
||||||
|
return ["hw", "sw"], p
|
||||||
|
|
||||||
if pref == "hw":
|
queue, pref = _make_queue()
|
||||||
queue = ["hw"]
|
|
||||||
elif pref == "sw":
|
|
||||||
queue = ["sw"]
|
|
||||||
else:
|
|
||||||
queue = ["hw", "sw"]
|
|
||||||
|
|
||||||
while not self._shutdown.is_set():
|
while not self._shutdown.is_set():
|
||||||
|
if self._reset_encoder.is_set():
|
||||||
|
self._reset_encoder.clear()
|
||||||
|
queue, pref = _make_queue()
|
||||||
|
log.info("Encoder queue reset → %s", queue)
|
||||||
|
|
||||||
for enc in queue:
|
for enc in queue:
|
||||||
proc = self._launch(enc)
|
proc = self._launch(enc)
|
||||||
if proc is None:
|
if proc is None:
|
||||||
@ -267,7 +275,7 @@ class GstManager:
|
|||||||
log.warning("GStreamer [%s] exited rc=%d", enc, rc)
|
log.warning("GStreamer [%s] exited rc=%d", enc, rc)
|
||||||
|
|
||||||
if enc == "hw" and pref == "auto":
|
if enc == "hw" and pref == "auto":
|
||||||
log.warning("Hardware encoder failed — permanent fallback to x264enc")
|
log.warning("Hardware encoder failed — fallback to x264enc")
|
||||||
queue = ["sw"]
|
queue = ["sw"]
|
||||||
|
|
||||||
break # restart outer while-loop with updated queue
|
break # restart outer while-loop with updated queue
|
||||||
|
|||||||
Reference in New Issue
Block a user