commit/StationPlaylist: josephsl: 4.0-dev and compatibility release: NVDA will no longer appear to freeze when attempting to connect to a streaming server.

  • From: commits-noreply@xxxxxxxxxxxxx
  • To: nvda-addons-commits@xxxxxxxxxxxxx
  • Date: Sat, 09 Aug 2014 05:03:06 -0000

1 new commit in StationPlaylist:

https://bitbucket.org/nvdaaddonteam/stationplaylist/commits/95e3392e0598/
Changeset:   95e3392e0598
Branch:      threads
User:        josephsl
Date:        2014-08-09 07:02:24
Summary:     4.0-dev and compatibility release: NVDA will no longer appear to 
freeze when attempting to connect to a streaming server.
Threads allows a program to run several things concurrently. Using this 
facility, one can run a function in the background when called from a script.
Using threads resolve an issue where NvDA appears to freeze when trying to 
connect to a streaming server.
As this is important for SPL 4.x users, this will be available in both 4.0-dev 
and the compatibility release.

Affected #:  1 file

diff --git a/addon/globalPlugins/SPLStudioUtils.py 
b/addon/globalPlugins/SPLStudioUtils.py
index 4b535ef..7538f1e 100644
--- a/addon/globalPlugins/SPLStudioUtils.py
+++ b/addon/globalPlugins/SPLStudioUtils.py
@@ -5,6 +5,7 @@
 
 from ctypes import windll
 from functools import wraps
+import threading
 import os
 import time
 import globalPluginHandler
@@ -252,13 +253,14 @@ class GlobalPlugin(globalPluginHandler.GlobalPlugin):
                # Few useful variables for encoder list:
                focusToStudio = False # If true, Studio will gain focus after 
encoder connects.
 
-               def script_connect(self, gesture):
-                       gesture.send()
-                       # Translators: Presented when SAM Encoder is trying to 
connect to a streaming server.
-                       ui.message(_("Connecting..."))
+               def reportConnectionStatus(self):
                        # Keep an eye on the stream's description field until 
connected or error occurs.
+                       # In order to not block NVDA commands, this will be 
done using a different thread.
+                       toneCounter = 0
                        while True:
                                time.sleep(0.001)
+                               toneCounter+=1
+                               if toneCounter%200 == 0: tones.beep(500, 100) # 
Play status tones every second.
                                info = review.getScreenPosition(self)[0]
                                info.expand(textInfos.UNIT_LINE)
                                if "Error" in info.text:
@@ -270,6 +272,15 @@ class GlobalPlugin(globalPluginHandler.GlobalPlugin):
                                        if self.focusToStudio: 
fetchSPLForegroundWindow().setFocus()
                                        tones.beep(1000, 150)
                                        break
+
+               def script_connect(self, gesture):
+                       gesture.send()
+                       # Translators: Presented when SAM Encoder is trying to 
connect to a streaming server.
+                       ui.message(_("Connecting..."))
+                       # Oi, status thread, can you keep an eye on the 
connection status for me?
+                       statusThread = 
threading.Thread(target=self.reportConnectionStatus)
+                       statusThread.name = "Connection Status Reporter"
+                       statusThread.start()
                # Translators: Input help mode message in SAM Encoder window.
                script_connect.__doc__=_("Connects to a streaming server.")

Repository URL: https://bitbucket.org/nvdaaddonteam/stationplaylist/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.

Other related posts:

  • » commit/StationPlaylist: josephsl: 4.0-dev and compatibility release: NVDA will no longer appear to freeze when attempting to connect to a streaming server. - commits-noreply