feat(engine): 优化字幕引擎通信和控制逻辑,优化窗口信息展示

- 优化错误处理和引擎重启逻辑
- 添加字幕引擎强制终止功能
- 调整通知和错误提示的显示位置
- 优化日志记录精度到毫秒级
This commit is contained in:
himeditator
2025-07-28 21:44:49 +08:00
parent cd9f3a847d
commit e4f937e6b6
12 changed files with 171 additions and 72 deletions

View File

@@ -1,6 +1,6 @@
import samplerate
import numpy as np
import numpy.core.multiarray
import numpy.core.multiarray # do not remove
def merge_chunk_channels(chunk: bytes, channels: int) -> bytes:
"""

View File

@@ -6,7 +6,7 @@ from utils import thread_data, stdout_cmd, stderr
def handle_client(client_socket):
global thread_data
while True:
while thread_data.status == 'running':
try:
data = client_socket.recv(4096).decode('utf-8')
if not data:
@@ -14,9 +14,8 @@ def handle_client(client_socket):
data = json.loads(data)
if data['command'] == 'stop':
if thread_data.status == 'running':
thread_data.status = 'stop'
break
thread_data.status = 'stop'
break
except Exception as e:
stderr(f'Communication error: {e}')
break
@@ -29,7 +28,7 @@ def start_server(port: int):
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.bind(('localhost', port))
server.listen(1)
stdout_cmd('ready')
stdout_cmd('connect')
client, addr = server.accept()
client_handler = threading.Thread(target=handle_client, args=(client,))