add possibility to enable / disable ac3 downmix in audio track selection
[enigma2.git] / lib / python / Screens / InfoBarGenerics.py
index dfbb3f471162058399241cb134ee26d0d7a20b08..31a9d5a98ef20785b957ccfd5c4ef26fd9adb852 100644 (file)
@@ -1279,10 +1279,7 @@ class InfoBarPlugins:
 # depends on InfoBarExtensions
 class InfoBarSleepTimer:
        def __init__(self):
-               self.addExtension((self.getSleepTimerName, self.showSleepTimerSetup, self.available), "1")
-
-       def available(self):
-               return True
+               self.addExtension((self.getSleepTimerName, self.showSleepTimerSetup, lambda: True), "1")
 
        def getSleepTimerName(self):
                return _("Sleep Timer")
@@ -1295,13 +1292,10 @@ class InfoBarPiP:
        def __init__(self):
                self.session.pipshown = False
                if SystemInfo.get("NumVideoDecoders", 1) > 1:
-                       self.addExtension((self.getShowHideName, self.showPiP, self.available), "blue")
+                       self.addExtension((self.getShowHideName, self.showPiP, lambda: True), "blue")
                        self.addExtension((self.getMoveName, self.movePiP, self.pipShown), "green")
                        self.addExtension((self.getSwapName, self.swapPiP, self.pipShown), "yellow")
 
-       def available(self):
-               return SystemInfo.get("NumVideoDecoders", 1) > 1
-
        def pipShown(self):
                return self.session.pipshown
 
@@ -1526,10 +1520,8 @@ class InfoBarAudioSelection:
 
        def audioSelection(self):
                service = self.session.nav.getCurrentService()
-               audio = service and service.audioTracks()
-               self.audioTracks = audio
+               self.audioTracks = audio = service and service.audioTracks()
                n = audio and audio.getNumberOfTracks() or 0
-               keys = [ "red", "", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0"] + [""]*n
                tlist = []
                if n > 0:
                        self.audioChannel = service.audioChannel()
@@ -1549,21 +1541,45 @@ class InfoBarAudioSelection:
 
                                tlist.append((description, x))
 
-                       selectedAudio = audio.getCurrentTrack()
                        tlist.sort(key=lambda x: x[0])
 
-                       selection = 2
+                       selectedAudio = self.audioTracks.getCurrentTrack()
+
+                       selection = 0
+
                        for x in tlist:
                                if x[1] != selectedAudio:
                                        selection += 1
                                else:
                                        break
 
-                       tlist = [([_("Left"), _("Stereo"), _("Right")][self.audioChannel.getCurrentChannel()], "mode"), ("--", "")] + tlist
+                       if SystemInfo["CanDownmixAC3"]:
+                               tlist = [(_("AC3 downmix") + " - " +[_("Off"), _("On")][config.av.downmix_ac3.value and 1 or 0], "CALLFUNC", self.changeAC3Downmix),
+                                       ([_("Left"), _("Stereo"), _("Right")][self.audioChannel.getCurrentChannel()], "mode"),
+                                       ("--", "")] + tlist
+                               keys = [ "red", "green", "", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0"] + [""]*n
+                               selection += 3
+                       else:
+                               tlist = [([_("Left"), _("Stereo"), _("Right")][self.audioChannel.getCurrentChannel()], "mode"), ("--", "")] + tlist
+                               keys = [ "red", "", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0"] + [""]*n
+                               selection += 2
                        self.session.openWithCallback(self.audioSelected, ChoiceBox, title=_("Select audio track"), list = tlist, selection = selection, keys = keys)
                else:
                        del self.audioTracks
 
+       def changeAC3Downmix(self, arg):
+               choicelist = self.session.current_dialog["list"]
+               list = choicelist.list
+               t = list[0][1]
+               list[0][1]=(t[0], t[1], t[2], t[3], t[4], t[5], t[6],
+                       _("AC3 downmix") + " - " +[_("On"), _("Off")][config.av.downmix_ac3.value and 1 or 0])
+               choicelist.setList(list)
+               if config.av.downmix_ac3.value:
+                       config.av.downmix_ac3.value = False
+               else:
+                       config.av.downmix_ac3.value = True
+               config.av.downmix_ac3.save()
+
        def audioSelected(self, audio):
                if audio is not None:
                        if isinstance(audio[1], str):
@@ -1636,7 +1652,7 @@ class InfoBarSubserviceSelection:
                                if newservice.valid():
                                        del subservices
                                        del service
-                                       self.session.nav.playService(newservice)
+                                       self.session.nav.playService(newservice, False)
 
        def subserviceSelection(self):
                service = self.session.nav.getCurrentService()
@@ -1676,7 +1692,7 @@ class InfoBarSubserviceSelection:
                                        self.session.open(SubservicesQuickzap, service[2])
                        else:
                                self["SubserviceQuickzapAction"].setEnabled(True)
-                               self.session.nav.playService(service[1])
+                               self.session.nav.playService(service[1], False)
 
        def addSubserviceToBouquetCallback(self, service):
                if len(service) > 1 and isinstance(service[1], eServiceReference):