Author: remi
Date: 2008-12-18 03:06:31 +0100 (Thu, 18 Dec 2008)
New Revision: 3157
Modified:
software_suite_v2/tuxware/pytuxisalive/branches/complete_refactoring/src/tuxisalive/lib/osl/TuxOSL.py
software_suite_v2/tuxware/pytuxisalive/branches/complete_refactoring/src/tuxisalive/lib/osl/libtuxosl.dll
Log:
* updated libtuxosl.dll
* added a function to return the running state of tuxosl
Modified:
software_suite_v2/tuxware/pytuxisalive/branches/complete_refactoring/src/tuxisalive/lib/osl/TuxOSL.py
===================================================================
---
software_suite_v2/tuxware/pytuxisalive/branches/complete_refactoring/src/tuxisalive/lib/osl/TuxOSL.py
2008-12-18 01:42:53 UTC (rev 3156)
+++
software_suite_v2/tuxware/pytuxisalive/branches/complete_refactoring/src/tuxisalive/lib/osl/TuxOSL.py
2008-12-18 02:06:31 UTC (rev 3157)
@@ -147,6 +147,8 @@
self.__logger.logError(txt)
txt = "The shared library was not handled in your application."
self.__logger.logError(txt)
+ self.__started = False
+ self.__startedMutex = threading.Lock()
#
--------------------------------------------------------------------------
# Register a callback function to the "status" event.
@@ -199,24 +201,50 @@
if ret == E_TUXOSL_NOERROR:
self.__logger.logInfo("Libtuxosl successfuly started.")
+ self.__setStarted(True)
voicesList = self.GetStatusValue(SW_ID_OSL_TTS0_VOICE_LIST)
self.__logger.logInfo(voicesList)
else:
+ self.__setStarted(False)
self.__logger.logError("Libtuxosl can't start : code(%d)
expl(%s)."\
% (ret, self.StrError(ret)))
return ret
#
--------------------------------------------------------------------------
+ # Set the run state of tuxosl.
+ #
--------------------------------------------------------------------------
+ def __setStarted(self, value):
+ """Set the run state of tuxosl.
+ @param value: State.
+ """
+ self.__startedMutex.acquire()
+ self.__started = value
+ self.__startedMutex.release()
+
+ #
--------------------------------------------------------------------------
+ # Get the run state of tuxosl.
+ #
--------------------------------------------------------------------------
+ def getStarted(self):
+ """Get the run state of tuxosl.
+ @return: The state.
+ """
+ self.__startedMutex.acquire()
+ result = self.__started
+ self.__startedMutex.release()
+ return result
+
+ #
--------------------------------------------------------------------------
# Stop libtuxosl.
#
--------------------------------------------------------------------------
def Stop(self):
"""Stop libtuxosl.
"""
- if self.tux_osl_lib == None:
+ if (self.tux_osl_lib == None) or not self.getStarted():
return
self.__logger.logInfo("Stop the library.")
+ self.__setStarted(False)
self.tux_osl_lib.TuxOSL_Stop()
#
--------------------------------------------------------------------------
@@ -237,7 +265,7 @@
@param command: Command to execute.
@return: The success of the command performing.
"""
- if self.tux_osl_lib == None:
+ if (self.tux_osl_lib == None) or not self.getStarted():
return E_TUXOSL_PARSERISDISABLED
ret = self.tux_osl_lib.TuxOSL_PerformCommand(c_double(delay),
@@ -258,7 +286,7 @@
@param file_path: Macro commands file path.
@return: The success of the performing.
"""
- if self.tux_osl_lib == None:
+ if (self.tux_osl_lib == None) or not self.getStarted():
return E_TUXOSL_PARSERISDISABLED
ret = self.tux_osl_lib.TuxOSL_PerformMacroFile(c_char_p(file_path))
@@ -277,7 +305,7 @@
@param macro: Macro commands text.
@return: The success of the performing.
"""
- if self.tux_osl_lib == None:
+ if (self.tux_osl_lib == None) or not self.getStarted():
return E_TUXOSL_PARSERISDISABLED
ret = self.tux_osl_lib.TuxOSL_PerformMacroText(c_char_p(macro))
@@ -296,7 +324,7 @@
def ClearCommandStack(self):
"""Clear the stack of delayed commands.
"""
- if self.tux_osl_lib == None:
+ if (self.tux_osl_lib == None) or not self.getStarted():
return
self.tux_osl_lib.TuxOSL_ClearCommandStack()
@@ -313,7 +341,7 @@
@param name: Status name.
@return: The identifier as Integer.
"""
- if self.tux_osl_lib == None:
+ if (self.tux_osl_lib == None) or not self.getStarted():
return -1
idc = c_int(0)
@@ -338,7 +366,7 @@
@param id: Identifier of the status.
@return: The name of the status or "UNDEFINED".
"""
- if self.tux_osl_lib == None:
+ if (self.tux_osl_lib == None) or not self.getStarted():
return "UNDEFINED"
result = " " * 256
@@ -374,7 +402,7 @@
@param id: Identifier of the status.
@return: The state of the status or "UNDEFINED".
"""
- if self.tux_osl_lib == None:
+ if (self.tux_osl_lib == None) or not self.getStarted():
return "UNDEFINED"
result = " " * 256
@@ -400,7 +428,7 @@
@param id: Identifier of the status.
@return: The value of the status or "UNDEFINED".
"""
- if self.tux_osl_lib == None:
+ if (self.tux_osl_lib == None) or not self.getStarted():
return "UNDEFINED"
result = " " * 256
@@ -425,7 +453,7 @@
"""Get the state of all statuses.
@return: The state of all statuses.
"""
- if self.tux_osl_lib == None:
+ if (self.tux_osl_lib == None) or not self.getStarted():
return ""
result = " " * 8182
@@ -446,7 +474,7 @@
@param status: The state of the status.
@return: A tokens list.
"""
- if self.tux_osl_lib == None:
+ if (self.tux_osl_lib == None) or not self.getStarted():
return []
result = status.split(":")
@@ -470,7 +498,7 @@
'type' : 'string'
}
- if self.tux_osl_lib == None:
+ if (self.tux_osl_lib == None) or not self.getStarted():
return result
status_s = self.TokenizeStatus(status)
@@ -500,6 +528,9 @@
if self.tux_osl_lib == None:
return "Shared library not found"
+ if not self.getStarted():
+ return "Tuxosl is not started"
+
result = self.tux_osl_lib.TuxOSL_StrError(c_int(error_code))
return c_char_p(result).value
Modified:
software_suite_v2/tuxware/pytuxisalive/branches/complete_refactoring/src/tuxisalive/lib/osl/libtuxosl.dll
===================================================================
(Binary files differ)
------------------------------------------------------------------------------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you. Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn