fix(fx-gui): meter VST chạy đúng — bỏ điều kiện inRead chặn peek + chống race lúc load + ẩn cửa sổ native floating
This commit is contained in:
+15
-1
@@ -1,4 +1,4 @@
|
||||
import os, sys, uuid, json, tempfile, subprocess, time as _time, threading, asyncio
|
||||
import os, sys, uuid, json, tempfile, subprocess, time as _time, threading, asyncio, logging
|
||||
import numpy as np
|
||||
import soundfile as sf
|
||||
from fastapi import APIRouter, HTTPException, Depends, UploadFile, File, BackgroundTasks, Header, Query, WebSocket, WebSocketDisconnect
|
||||
@@ -17,6 +17,8 @@ from app.core.auth import decode_token
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
UPLOAD_SF_DIR = os.path.join(settings.STORAGE_DIR, "soundfonts")
|
||||
os.makedirs(UPLOAD_SF_DIR, exist_ok=True)
|
||||
|
||||
@@ -871,6 +873,18 @@ async def open_fx_gui(req: FxGuiRequest, current_user: dict = Depends(get_curren
|
||||
except Exception:
|
||||
proc.kill()
|
||||
raise HTTPException(status_code=500, detail="Bridge không báo port fx-gui (mở GUI thất bại).")
|
||||
# Keep draining stdout in a daemon thread: the bridge logs to
|
||||
# stdout/stderr while running; if the pipe fills (64KB) the bridge
|
||||
# blocks on any later write -> GUI freezes/breaks.
|
||||
def _drain_fx_gui_stdout(pp):
|
||||
try:
|
||||
for ln in pp.stdout:
|
||||
ln = (ln or "").strip()
|
||||
if ln:
|
||||
logger.info("[fx-gui] %s", ln)
|
||||
except Exception:
|
||||
pass
|
||||
threading.Thread(target=_drain_fx_gui_stdout, args=(proc,), daemon=True).start()
|
||||
proc._sf_plugin_path = plugin_path
|
||||
proc._sf_embed_url = embed_url
|
||||
_register_fx_gui_process(proc)
|
||||
|
||||
Reference in New Issue
Block a user