Skip to content

Commit

Permalink
BugFix: 连接wwise失败造成卡死
Browse files Browse the repository at this point in the history
  • Loading branch information
szz1031 committed Apr 21, 2023
1 parent b210f7c commit 2010a25
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 11 deletions.
6 changes: 3 additions & 3 deletions SourceCode_CN/ReplaceWwiseWavesWithP4.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class GUI(QMainWindow):
def __init__(self):
super(GUI, self).__init__()
self.p4 = p4Manager()
self.setWindowTitle("ReplaceWwiseWavesWithP4 @SZZ Version: 2.1 2023.04.14")
self.setWindowTitle("ReplaceWwiseWavesWithP4 @SZZ Version: 2.2 2023.04.21")
self.setGeometry(100, 100, 880, 600)
self.setStyleSheet("""
QWidget {
Expand Down Expand Up @@ -135,7 +135,7 @@ def __init__(self):
}
""")
self.initUI()
self.connectWwise()
#self.connectWwise()
self.load_p4_config()

def load_p4_config(self):
Expand Down Expand Up @@ -179,7 +179,7 @@ def initUI(self):
bold_font.setPointSize(13)

font2 = QFont()
font2.setPointSize(10)
font2.setPointSize(8)

button0 = QPushButton("连接到 Wwise", self)
button0.clicked.connect(self.connectWwise)
Expand Down
36 changes: 28 additions & 8 deletions SourceCode_CN/szz_wwiseManager.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from waapi import WaapiClient
import os
from pprint import pprint
from concurrent.futures import ThreadPoolExecutor, wait
import asyncio

class WwiseManager:

Expand All @@ -25,17 +27,35 @@ class WwiseManager:

myUrl=""

def try_connect_waapi(self):
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
try:
with WaapiClient(url=self.myUrl) as client:
client.call("ak.soundengine.postMsgMonitor", self._msgToArgs("Waapi Connect Success"))
return True
except Exception as e:
print(f"Error connecting to Wwise: {e}")
return False

def __init__(self,in_portId='8070'):
self.myUrl= "ws://127.0.0.1:"+in_portId+"/waapi" # WAMP port
self._lastSelectedObject=self.defaultSelectedObject
try:
with WaapiClient(url=self.myUrl) as client:
client.call("ak.soundengine.postMsgMonitor",self._msgToArgs("Waapi Connect Success"))
except:
return
self._getWwiseInfo()
self._getWwiseProjectInfo()

timeout = 5 # 设置超时时间,单位为秒

with ThreadPoolExecutor(max_workers=1) as executor:
future = executor.submit(self.try_connect_waapi)
done, not_done = wait([future], timeout=timeout)

if future in done:
if future.result():
self._getWwiseInfo()
self._getWwiseProjectInfo()
else:
return
else:
print("Connection to Wwise timed out.")
return


def _msgToArgs(self,msg): #在wwise里打log的格式转换
Expand Down

0 comments on commit 2010a25

Please sign in to comment.