fix(exit): taskkill rieng tung process — kill het plugin_host/fx_vst_bridge khi thoat app (truoc day /IM gop chi chay lenh dau); CREATE_NO_WINDOW cho moi subprocess engine (het terminal chớp chớp)
This commit is contained in:
@@ -74,6 +74,7 @@ def _save_file_native_engine(default_name: str, filter_name: str, filter_ext: st
|
||||
r = subprocess.run(
|
||||
["powershell", "-NoProfile", "-STA", "-Command", ps],
|
||||
capture_output=True, text=True, timeout=SAVE_DIALOG_TIMEOUT,
|
||||
creationflags=subprocess.CREATE_NO_WINDOW,
|
||||
)
|
||||
return r.stdout.strip() or None
|
||||
except Exception:
|
||||
|
||||
@@ -419,6 +419,7 @@ def _pick_dir_native_engine() -> Optional[str]:
|
||||
r = subprocess.run(
|
||||
["powershell", "-NoProfile", "-STA", "-Command", ps],
|
||||
capture_output=True, text=True, timeout=PICK_DIR_TIMEOUT,
|
||||
creationflags=subprocess.CREATE_NO_WINDOW,
|
||||
)
|
||||
return r.stdout.strip() or None
|
||||
except Exception:
|
||||
@@ -798,7 +799,8 @@ async def open_in_carla(req: OpenInCarlaRequest, current_user: dict = Depends(ge
|
||||
cmd.append(carxs_path)
|
||||
try:
|
||||
cwd = os.path.dirname(carla) or None
|
||||
proc = subprocess.Popen(cmd, cwd=cwd, close_fds=os.name != "nt")
|
||||
proc = subprocess.Popen(cmd, cwd=cwd, close_fds=os.name != "nt",
|
||||
creationflags=subprocess.CREATE_NO_WINDOW if os.name == "nt" else 0)
|
||||
_register_carla_process(proc)
|
||||
return {
|
||||
"success": True,
|
||||
@@ -1778,7 +1780,8 @@ def _running_sonicforge_pids() -> list:
|
||||
out = subprocess.run(
|
||||
["powershell", "-NoProfile", "-Command",
|
||||
"Get-Process sonicforge-daw,daw_engine -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Id"],
|
||||
capture_output=True, text=True, timeout=10).stdout
|
||||
capture_output=True, text=True, timeout=10,
|
||||
creationflags=subprocess.CREATE_NO_WINDOW).stdout
|
||||
for line in out.splitlines():
|
||||
line = line.strip()
|
||||
if line.isdigit():
|
||||
|
||||
@@ -176,7 +176,8 @@ def render_offline(instrument_id, notes, bpm, sample_rate, preset_id=None,
|
||||
with open(job_path, "w", encoding="utf-8") as fh:
|
||||
json.dump(job, fh)
|
||||
r = subprocess.run([exe, "--render", job_path, "--out", out_path],
|
||||
capture_output=True, text=True, timeout=120)
|
||||
capture_output=True, text=True, timeout=120,
|
||||
creationflags=subprocess.CREATE_NO_WINDOW if os.name == "nt" else 0)
|
||||
log = ((r.stdout or "") + (r.stderr or "")).strip()
|
||||
if r.returncode != 0 or not os.path.isfile(out_path):
|
||||
if os.path.exists(out_path):
|
||||
@@ -259,7 +260,8 @@ def render_fx_chain(input_wav, fx_chain, sample_rate, out_path=None) -> str:
|
||||
with open(job_path, "w", encoding="utf-8") as fh:
|
||||
json.dump(job, fh)
|
||||
r = subprocess.run([exe, "--render-fx", job_path, "--in", input_wav, "--out", out],
|
||||
capture_output=True, text=True, timeout=120)
|
||||
capture_output=True, text=True, timeout=120,
|
||||
creationflags=subprocess.CREATE_NO_WINDOW if os.name == "nt" else 0)
|
||||
log = ((r.stdout or "") + (r.stderr or "")).strip()
|
||||
if r.returncode != 0 or not os.path.isfile(out):
|
||||
if os.path.exists(out):
|
||||
|
||||
@@ -78,7 +78,8 @@ class SoundFontConverter:
|
||||
|
||||
def _check_ffmpeg_ogg(self):
|
||||
try:
|
||||
r = subprocess.run(["ffmpeg", "-encoders"], capture_output=True, text=True, timeout=5)
|
||||
r = subprocess.run(["ffmpeg", "-encoders"], capture_output=True, text=True, timeout=5,
|
||||
creationflags=subprocess.CREATE_NO_WINDOW if os.name == "nt" else 0)
|
||||
return "libvorbis" in r.stdout
|
||||
except Exception:
|
||||
return False
|
||||
@@ -98,7 +99,8 @@ class SoundFontConverter:
|
||||
"ffmpeg", "-y", "-i", tmp_wav,
|
||||
"-c:a", "libvorbis", "-q:a", "3",
|
||||
"-f", "ogg", tmp_ogg
|
||||
], capture_output=True, timeout=600, check=True)
|
||||
], capture_output=True, timeout=600, check=True,
|
||||
creationflags=subprocess.CREATE_NO_WINDOW if os.name == "nt" else 0)
|
||||
with open(tmp_ogg, "rb") as fo:
|
||||
return fo.read()
|
||||
except Exception as e:
|
||||
@@ -320,7 +322,8 @@ class SoundFontConverter:
|
||||
def _find_sf3_converter():
|
||||
for exe in ["fluidsynth", "mscore"]:
|
||||
try:
|
||||
subprocess.run([exe, "--help"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, timeout=2.0)
|
||||
subprocess.run([exe, "--help"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, timeout=2.0,
|
||||
creationflags=subprocess.CREATE_NO_WINDOW if os.name == "nt" else 0)
|
||||
return exe
|
||||
except (FileNotFoundError, subprocess.TimeoutExpired):
|
||||
continue
|
||||
@@ -353,7 +356,8 @@ class SoundFontConverter:
|
||||
|
||||
if converter == "mscore":
|
||||
cmd = ["mscore", "-o", sf3_path, sf2_path]
|
||||
result = subprocess.run(cmd, capture_output=True, text=True, timeout=600)
|
||||
result = subprocess.run(cmd, capture_output=True, text=True, timeout=600,
|
||||
creationflags=subprocess.CREATE_NO_WINDOW if os.name == "nt" else 0)
|
||||
if result.returncode == 0 and os.path.exists(sf3_path):
|
||||
logger.info(f"Created SF3 via mscore: {sf3_path} ({os.path.getsize(sf3_path)/1024/1024:.1f}MB)")
|
||||
return sf3_path
|
||||
@@ -524,7 +528,8 @@ class SoundFontConverter:
|
||||
fo.write(ogg)
|
||||
r = subprocess.run(
|
||||
["ffmpeg", "-y", "-v", "error", "-i", tmp_ogg, "-f", "s16le", "-ac", "1", tmp_pcm],
|
||||
capture_output=True, timeout=600)
|
||||
capture_output=True, timeout=600,
|
||||
creationflags=subprocess.CREATE_NO_WINDOW if os.name == "nt" else 0)
|
||||
if r.returncode != 0:
|
||||
logger.warning(f"OGG decode failed: {r.stderr.decode(errors='replace')[:120]}")
|
||||
return b""
|
||||
|
||||
@@ -582,6 +582,7 @@ class PluginManager:
|
||||
for d in dirs:
|
||||
try:
|
||||
r = subprocess.run([exe, "--scan", d], capture_output=True,
|
||||
creationflags=subprocess.CREATE_NO_WINDOW if os.name == "nt" else 0,
|
||||
text=True, timeout=300)
|
||||
except Exception:
|
||||
continue
|
||||
|
||||
@@ -737,13 +737,15 @@ pub fn run() {
|
||||
// dot ngot (watchdog graceful shutdown treo vi LAN client).
|
||||
// Task Manager dong app -> Destroyed khong chay -> engine tu
|
||||
// thoat nho watchdog; o day dong app binh thuong -> quet het.
|
||||
let _ = std::process::Command::new("taskkill")
|
||||
.args(["/IM", "daw_engine.exe", "/T", "/F"])
|
||||
.status();
|
||||
let _ = std::process::Command::new("taskkill")
|
||||
.args(["/IM", "daw_vst_bridge.exe", "/T", "/F",
|
||||
"/IM", "fx_vst_bridge.exe", "/T", "/F"])
|
||||
.status();
|
||||
// taskkill chi nhan MOT /IM moi lan goi — goi rieng cho tung
|
||||
// process, khong gop /IM ... /IM (truoc day chi cai dau chay,
|
||||
// fx_vst_bridge/plugin_host song sot thanh orphan).
|
||||
for im in ["daw_engine.exe", "daw_vst_bridge.exe",
|
||||
"fx_vst_bridge.exe", "plugin_host.exe"] {
|
||||
let _ = std::process::Command::new("taskkill")
|
||||
.args(["/IM", im, "/T", "/F"])
|
||||
.status();
|
||||
}
|
||||
window.app_handle().exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user