Skip to content

Commit

Permalink
updated the fix of souncard, using a little different approach.
Browse files Browse the repository at this point in the history
  • Loading branch information
davidacm committed Dec 21, 2022
1 parent 8783e9d commit cfefd58
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
20 changes: 15 additions & 5 deletions addon/synthDrivers/_ibmeci.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,9 +328,7 @@ def initialize(indexCallback, doneCallback):
callbackQueue = queue.Queue()
callbackThread = CallbackThread()
callbackThread.start()
# the next function can be called on a profile change event. That's generate a mutation in the config handlers.
# then, a delay of 1s is added, handling soundcard changes is not usual at the start of the driver.
threading.Timer(1, config.post_configProfileSwitch.register, [handleSoundcardChange]).start()
toggleProbileSwitchRegistration(config.post_configProfileSwitch.register)

def speak(text):
# deleted the following fix because is incompatible with NVDA's speech change command. Now send it from speak in ibmeci.py
Expand Down Expand Up @@ -373,8 +371,7 @@ def terminate():
idleTimer.cancel()
player.close()
callbackQueue= callbackThread= dll= eciQueue=eciThread= handle= idleTimer= onDoneSpeaking= onIndexReached= player = None
# the situation is similar to post_configProfileSwitch.register
threading.Timer(1, config.post_configProfileSwitch.unregister, [handleSoundcardChange]).start()
toggleProbileSwitchRegistration(config.post_configProfileSwitch.unregister)


def setVoice(vl):
Expand Down Expand Up @@ -488,3 +485,16 @@ def handleSoundcardChange():
if player and currentSoundcardOutput != config.conf["speech"]["outputDevice"]:
player.close()
player = createPlayer(currentSampleRate)

profileSwitchRegister = None
def toggleProbileSwitchRegistration(fn):
""" the register or unregister of the handler for config changes can't be done when a profile switch is being done.
this function helps to avoid that.
fn: the function to be called (usually register or unregister)
"""
global profileSwitchRegister
if profileSwitchRegister:
profileSwitchRegister.cancel()
profileSwitchRegister = None
profileSwitchRegister = threading.Timer(1, fn, [handleSoundcardChange])
profileSwitchRegister.start()
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" : "v22.07.3",
"addon_version" : "v22.08.2-alpha",
# Author(s)
"addon_author" : u"David CM <[email protected]>, x0 and others",
# URL for the add-on documentation support
Expand Down

0 comments on commit cfefd58

Please sign in to comment.