Skip to content

Commit

Permalink
fix solve critical issue when changing from IBMTTS to another synthes…
Browse files Browse the repository at this point in the history
…izer, NVDA crash if the user changes parameters in the new synth before closing voice settings dialog.
  • Loading branch information
davidacm committed Aug 21, 2019
1 parent d6e94c3 commit ab3683f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
21 changes: 11 additions & 10 deletions addon/synthDrivers/_ibmeci.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,16 @@ class ECICallbackReturn:
audioStream = BytesIO()
speaking=False
eciThread = None
eciQueue = queue.Queue()
eciQueue = None
eciThreadId = None
callbackThread = None
callbackQueue = queue.Queue()
callbackQueue = None
onIndexReached = None
onDoneSpeaking = None

samples=3300
buffer = create_string_buffer(samples*2)
idleTimer = threading.Timer(0.3, time.sleep) # fake timer because this can't be None.
idleTimer = None

stopped = threading.Event()
started = threading.Event()
Expand Down Expand Up @@ -176,6 +176,7 @@ def eciCheck():
if not path.isabs(ttsPath):
ttsPath = path.join(path.abspath(path.dirname(__file__)), ttsPath)
if path.exists(ttsPath): iniCheck()
print (ttsPath, path.exists(ttsPath))
if not path.exists(ttsPath): return False
if dll: return True
try:
Expand Down Expand Up @@ -287,16 +288,19 @@ def _callbackExec(func, *args, **kwargs):
callbackQueue.put((func, args, kwargs))

def initialize(indexCallback, doneCallback):
global callbackThread, dll, eciThread, handle, onIndexReached, onDoneSpeaking, player
global callbackQueue, callbackThread, eciQueue, eciThread, idleTimer, onIndexReached, onDoneSpeaking, player
onIndexReached = indexCallback
onDoneSpeaking = doneCallback
idleTimer = threading.Timer(0.3, time.sleep) # fake timer because this can't be None.
player = nvwave.WavePlayer(1, 11025, 16, outputDevice=config.conf["speech"]["outputDevice"])
if not eciCheck():
raise RuntimeError("No IBMTTS synthesizer available")
eciQueue = queue.Queue()
eciThread = EciThread()
eciThread.start()
started.wait()
started.clear()
callbackQueue = queue.Queue()
callbackThread = CallbackThread()
callbackThread.start()

Expand Down Expand Up @@ -330,19 +334,16 @@ def pause(switch):
player.pause(switch)

def terminate():
global callbackThread, eciThread, player
global callbackQueue, callbackThread, dll, eciQueue,eciThread, handle, idleTimer, onDoneSpeaking, onIndexReached, player
user32.PostThreadMessageA(eciThreadId, WM_KILL, 0, 0)
stopped.wait()
stopped.clear()
callbackQueue.put((None, None, None))
eciThread.join()
callbackThread.join()
idleTimer.cancel()
idleTimer.cancel()
player.close()
player = None
callbackThread = None
eciThread= None
dll=None
callbackQueue= callbackThread= dll= eciQueue=eciThread= handle= idleTimer= onDoneSpeaking= onIndexReached= player = None

def set_voice(vl):
user32.PostThreadMessageA(eciThreadId, WM_PARAM, int(vl), ECIParam.eciLanguageDialect)
Expand Down
2 changes: 1 addition & 1 deletion buildVars.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# Translators: Long description to be shown for this add-on on add-on information from add-ons manager
"addon_description" : _("""This is the IBMTTS synthesizer driver for NVDA."""),
# version
"addon_version" : "19.8B1",
"addon_version" : "19.8B2",
# Author(s)
"addon_author" : u"David CM <[email protected]> and others",
# URL for the add-on documentation support
Expand Down

0 comments on commit ab3683f

Please sign in to comment.