Skip to content

Commit 14bf331

Browse files
authored
Merge 7408817 into cdfda57
2 parents cdfda57 + 7408817 commit 14bf331

File tree

2 files changed

+23
-14
lines changed

2 files changed

+23
-14
lines changed

source/core.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,8 @@ def _setInitialFocus():
201201

202202
def main():
203203
"""NVDA's core main loop.
204-
This initializes all modules such as audio, IAccessible, keyboard, mouse, and GUI. Then it initialises the wx application object and sets up the core pump, which checks the queues and executes functions when requested. Finally, it starts the wx main loop.
205-
"""
204+
This initializes all modules such as audio, IAccessible, keyboard, mouse, and GUI. Then it initialises the wx application object and sets up the core pump, which checks the queues and executes functions when requested. Finally, it starts the wx main loop.
205+
"""
206206
log.debug("Core starting")
207207

208208
ctypes.windll.user32.SetProcessDPIAware()
@@ -224,6 +224,9 @@ def main():
224224
except:
225225
pass
226226
logHandler.setLogLevelFromConfig()
227+
log.debug("Initializing tones")
228+
import tones
229+
tones.initialize()
227230
try:
228231
lang = config.conf["general"]["language"]
229232
import languageHandler
@@ -535,6 +538,9 @@ def run(self):
535538
if updateCheck:
536539
_terminate(updateCheck)
537540

541+
# Terminate tones early.
542+
import tones
543+
_terminate(tones)
538544
_terminate(watchdog)
539545
_terminate(globalPluginHandler, name="global plugin handler")
540546
_terminate(gui)

source/tones.py

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
#tones.py
2-
#A part of NonVisual Desktop Access (NVDA)
3-
#Copyright (C) 2007-2017 NV Access Limited, Aleksey Sadovoy
4-
#This file is covered by the GNU General Public License.
5-
#See the file COPYING for more details.
1+
# A part of NonVisual Desktop Access (NVDA)
2+
# Copyright (C) 2007-2017 NV Access Limited, Aleksey Sadovoy, Leonard de Ruijter
3+
# This file is covered by the GNU General Public License.
4+
# See the file COPYING for more details.
65

76
"""Utilities to generate and play tones"""
87

@@ -15,16 +14,20 @@
1514

1615
SAMPLE_RATE = 44100
1716

18-
try:
19-
player = nvwave.WavePlayer(channels=2, samplesPerSec=int(SAMPLE_RATE), bitsPerSample=16, outputDevice=config.conf["speech"]["outputDevice"],wantDucking=False)
20-
except:
21-
log.warning("Failed to initialize audio for tones")
22-
player = None
17+
player = None
18+
19+
def initialize():
20+
global player
21+
try:
22+
player = nvwave.WavePlayer(channels=2, samplesPerSec=int(SAMPLE_RATE), bitsPerSample=16, outputDevice=config.conf["speech"]["outputDevice"],wantDucking=False)
23+
except:
24+
log.warning("Failed to initialize audio for tones", exc_info=True)
25+
player = None
2326

2427
# When exiting, ensure player is deleted before modules get cleaned up.
2528
# Otherwise, WavePlayer.__del__ will fail with an exception.
2629
@atexit.register
27-
def _cleanup():
30+
def terminate():
2831
global player
2932
player = None
3033

@@ -38,7 +41,7 @@ def beep(hz,length,left=50,right=50):
3841
@type left: integer
3942
@param right: volume of the right channel (0 to 100)
4043
@type right: integer
41-
"""
44+
"""
4245
log.io("Beep at pitch %s, for %s ms, left volume %s, right volume %s"%(hz,length,left,right))
4346
if not player:
4447
return

0 commit comments

Comments
 (0)