Version 0.8: No more stop- service for 800/8000 because driver don't need it.
authorTorsten Link <tode@users.schwerkraft.elitedvb.net>
Mon, 10 Aug 2009 21:51:13 +0000 (21:51 +0000)
committerTorsten Link <tode@users.schwerkraft.elitedvb.net>
Mon, 10 Aug 2009 21:51:13 +0000 (21:51 +0000)
ac3lipsync/src/AC3delay.py
ac3lipsync/src/AC3setup.py
ac3lipsync/src/AC3utils.py
ac3lipsync/src/__init__.py
ac3lipsync/src/plugin.py

index fc4b0c8..6543fff 100644 (file)
@@ -2,6 +2,7 @@ from AC3utils import AC3, PCM, AC3PCM, lFileDelay, dec2hex, hex2dec
 from Components.config import config
 from enigma import eTimer
 from Tools.ISO639 import LanguageCodes
+from Tools.HardwareInfo import HardwareInfo
 import os
 import NavigationInstance
 
@@ -26,6 +27,13 @@ class AC3delay:
         # Current value for movie start behaviour
         self.movieStart = config.usage.on_movie_start.getValue()
 
+        # find out box type
+        self.oHWInfo = HardwareInfo()
+        if self.oHWInfo.get_device_name() in ("dm800","dm8000"):
+            self.bHasToRestartService = False
+        else:
+            self.bHasToRestartService = True
+        
     def initAudio(self):
         self.iService = NavigationInstance.instance.getCurrentService()
         self.iServiceReference = NavigationInstance.instance.getCurrentlyPlayingServiceReference()
@@ -48,25 +56,26 @@ class AC3delay:
     def activateDelay(self):
         if self.activateTimer.isActive:
             self.activateTimer.stop()
-        bInitialized = False
-        if self.iService == None:
-            self.initAudio()
-            bInitialized = True
-        if self.iServiceReference is not None:
-            lCurPosition = self.cueGetCurrentPosition()
-            self.deleteAudio()
-            if self.whichAudio == self.channelAudio:
-                config.usage.on_movie_start.setValue("beginning")
-                NavigationInstance.instance.stopService()
-                NavigationInstance.instance.playService(self.iServiceReference)
-                config.usage.on_movie_start.setValue(self.movieStart)
-                if lCurPosition is not None:
-                    self.lCurPosition = lCurPosition
-                    self.timer = eTimer()
-                    self.timer.callback.append(self.seekAfterWait)
-                    self.timer.start(200, False)
-        else:
-            self.deleteAudio()
+        if self.bHasToRestartService == True:
+            bInitialized = False
+            if self.iService == None:
+                self.initAudio()
+                bInitialized = True
+            if self.iServiceReference is not None:
+                lCurPosition = self.cueGetCurrentPosition()
+                self.deleteAudio()
+                if self.whichAudio == self.channelAudio:
+                    config.usage.on_movie_start.setValue("beginning")
+                    NavigationInstance.instance.stopService()
+                    NavigationInstance.instance.playService(self.iServiceReference)
+                    config.usage.on_movie_start.setValue(self.movieStart)
+                    if lCurPosition is not None:
+                        self.lCurPosition = lCurPosition
+                        self.timer = eTimer()
+                        self.timer.callback.append(self.seekAfterWait)
+                        self.timer.start(200, False)
+            else:
+                self.deleteAudio()
         
     def seekAfterWait(self):
         self.timer.stop()
@@ -139,10 +148,18 @@ class AC3delay:
         if self.iService == None:
             self.initAudio()
             bInitialized = True
-        self.initAudio()
+
+        # check if we are in a recording
         lCurPosition = self.cueGetCurrentPosition()
         if lCurPosition is not None:
             self.bIsRecording = True
+            
+        # check if downmix is enabled
+        try:
+            bDownmixEnabled = config.av.downmix_ac3.value
+        except:
+            bDownmixEnabled = False
+
         oAudioTracks = self.iService and self.iService.audioTracks()
         n = oAudioTracks and oAudioTracks.getNumberOfTracks() or 0
         tlist = []
@@ -161,7 +178,7 @@ class AC3delay:
 
                 tlist.append((description, x))
                 if x == self.selectedAudioIndex:
-                    if description.find("AC3") != -1 or description.find("DTS") != -1:
+                    if (description.find("AC3") != -1 or description.find("DTS") != -1) and bDownmixEnabled == False:
                         self.whichAudio = AC3
                         self.channelAudio = AC3
                     else:
index 30d421e..970fec2 100644 (file)
@@ -1,5 +1,5 @@
 from AC3main import AC3LipSync
-from AC3utils import dec2hex, hex2dec
+from AC3utils import dec2hex, hex2dec, PLUGIN_BASE, PLUGIN_VERSION
 from Components.ActionMap import ActionMap, NumberActionMap
 from Components.Button import Button
 from Components.ConfigList import ConfigListScreen
@@ -32,12 +32,13 @@ class AC3LipSyncSetup(ConfigListScreen, Screen):
         font="Regular;20" valign="center" halign="center" backgroundColor="#18188b" transparent="1"
         shadowColor="#000000" shadowOffset="-1,-1" />
       <widget name="config" position="10,40" size="540,320" scrollbarMode="showOnDemand" />
+      <widget name="PluginInfo" position="10,370" size="540,20" zPosition="4" font="Regular;18" foregroundColor="#cccccc" />
     </screen>"""
 
-    def __init__(self, session, args = None):
+    def __init__(self, session, plugin_path):
         Screen.__init__(self, session)
 
-        # nun erzeugen wir eine liste von elementen fuer die menu liste.
+        # Lets get a list of elements for the config list
         self.list = [
             getConfigListEntry(_("Outer Bound (+/-)"), config.plugins.AC3LipSync.outerBounds),
             getConfigListEntry(_("Step in ms for arrow keys"), config.plugins.AC3LipSync.arrowStepSize),
@@ -54,7 +55,12 @@ class AC3LipSyncSetup(ConfigListScreen, Screen):
 
         self["config"].list = self.list
 
-        # DO NOT ASK.
+        self.skin_path = plugin_path
+
+        # Plugin Information
+        self["PluginInfo"] = Label(_("Plugin: %(plugin)s , Version: %(version)s") %dict(plugin=PLUGIN_BASE,version=PLUGIN_VERSION))
+
+        # BUTTONS
         self["key_red"] = Button(_("Cancel"))
         self["key_green"] = Button(_("Save"))
         self["key_yellow"] = Button(_(" "))
index bf64aa9..f18eeec 100644 (file)
@@ -2,6 +2,9 @@ AC3 = "AC3"
 PCM = "PCM"
 AC3PCM = (AC3,PCM)
 
+PLUGIN_BASE = "AC3LipSync"
+PLUGIN_VERSION = "0.8"
+
 lFileDelay = {}
 lFileDelay[AC3] = "/proc/stb/audio/audio_delay_bitstream"
 lFileDelay[PCM] = "/proc/stb/audio/audio_delay_pcm"
@@ -17,7 +20,6 @@ def dec2hex(n):
 
 def hex2dec(s):
     """return the signed integer value of a hexadecimal string s"""
-    print "[AC3LipSync] hex2dec String: ",s
     if s[:2] == "0x":
         s = s[2:]
     if s[:1] < '8':
index 64bde72..e1b3b18 100644 (file)
@@ -8,13 +8,13 @@ PluginLanguagePath = "Extensions/AC3LipSync/locale"
 def localeInit():
     lang = language.getLanguage()[:2] # getLanguage returns e.g. "fi_FI" for "language_country"
     os.environ["LANGUAGE"] = lang # Enigma doesn't set this (or LC_ALL, LC_MESSAGES, LANG). gettext needs it!
-    print "[AC3LipSync] set language to ", lang
+    print "[" + PluginLanguageDomain + "] set language to ", lang
     gettext.bindtextdomain(PluginLanguageDomain, resolveFilename(SCOPE_PLUGINS, PluginLanguagePath))
 
 def _(txt):
     t = gettext.dgettext(PluginLanguageDomain, txt)
     if t == txt:
-        print "[AC3LipSync] fallback to default translation for ", txt
+        print "[" + PluginLanguageDomain + "] fallback to default translation for ", txt
         t = gettext.gettext(txt)
     return t
 
index 00d50e2..30f28e6 100644 (file)
@@ -21,14 +21,16 @@ def main(session, **kwargs):
 
 def setup(session, **kwargs):
 #    reload(AC3setup)
-    session.open(AC3setup.AC3LipSyncSetup)
+    session.open(AC3setup.AC3LipSyncSetup, plugin_path)
 
 def mainSetup(menuid, **kwargs):
     if menuid == "setup":
         return [(_("AC3 Lip Sync"), main, "ac3_lipsync", 99)]
     return [ ]
 
-def Plugins(**kwargs):
+def Plugins(path,**kwargs):
+    global plugin_path
+    plugin_path = path
     return [ PluginDescriptor(name=_("AC3 Lip Sync"), description=_("sets the AC3 audio Delay (LipSync)"), where = PluginDescriptor.WHERE_EXTENSIONSMENU, fnc=main),
         PluginDescriptor(name=_("AC3 Lip Sync Setup"), description=_("Setup for the AC3 Lip Sync Plugin"), icon = "AC3LipSync.png", where = PluginDescriptor.WHERE_PLUGINMENU, fnc=setup),
         PluginDescriptor(name=_("AC3 Lip Sync"), description=_("sets the AC3 audio Delay (LipSync)"), where = PluginDescriptor.WHERE_MENU, fnc=mainSetup)]