[FastChannelChange] Fix PIP issue due to FCC.
authorhschang <chang@dev3>
Tue, 14 Feb 2017 04:02:30 +0000 (13:02 +0900)
committerhschang <chang@dev3>
Tue, 14 Feb 2017 04:06:06 +0000 (13:06 +0900)
lib/python/Plugins/SystemPlugins/FastChannelChange/plugin.py
lib/python/Screens/PictureInPicture.py

index cc19a78..9efa8c8 100644 (file)
@@ -5,6 +5,7 @@ import NavigationInstance
 from Screens.Screen import Screen
 from Screens.InfoBar import InfoBar
 from Screens.MessageBox import MessageBox
+from Screens.PictureInPicture import on_pip_start_stop
 
 from Components.NimManager import nimmanager
 from Components.config import config, getConfigListEntry, ConfigSubsection, ConfigYesNo, ConfigSelection
@@ -60,7 +61,7 @@ class FCCSupport:
                self.fccEventTimer.callback.append(self.FCCApplyEvent)
 
                self.fccForceStartTimer = eTimer()
-               self.fccForceStartTimer.callback.append(self.FCCForceStartForREC)
+               self.fccForceStartTimer.callback.append(self.FCCForceStart)
 
                self.fccResetTimer = eTimer()
                self.fccResetTimer.callback.append(self.FCCResetTimerForREC)
@@ -89,6 +90,8 @@ class FCCSupport:
                self.onClose = []
                self.changeEventTracker()
 
+               on_pip_start_stop.append(self.FCCForceStopforPIP)
+
        def setProcFCC(self, value):
                procPath = "/proc/stb/frontend/fbc/fcc"
                if os.access(procPath, os.W_OK):
@@ -108,29 +111,39 @@ class FCCSupport:
                        elif event == iRecordableService.evEnd:
                                self.getRecordings()
                                if not self.recordings:
-                                       self.FCCForceStartForREC()
+                                       self.FCCForceStart()
                else:
                        if event == iRecordableService.evTuneStart:
-                               self.fccResetTimer.stop()
-                               self.FCCForceStopForREC()
-                               self.fccForceStartTimer.start(2000, True)
+                               self.FCCForceStopAndStart()
 
                        elif event == iRecordableService.evEnd:
                                self.fccForceStartTimer.stop()
                                self.fccResetTimer.start(2000, True)
 
-       def FCCForceStopForREC(self):
+       def FCCForceStart(self):
+               self.enableEventTracker(True)
+               self.getEvStart()
+               self.getEvTunedIn()
+
+       def FCCForceStop(self):
                self.enableEventTracker(False)
                self.FCCDisableServices()
                self.FCCStopAllServices()
 
-       def FCCForceStartForREC(self):
-               self.enableEventTracker(True)
-               self.FCCForceStart()
+       def FCCForceStopAndStart(self):
+               self.fccResetTimer.stop()
+               self.FCCForceStop()
+               self.fccForceStartTimer.start(2000, True)
+
+       def FCCForceStopforPIP(self):
+               self.FCCForceStopAndStart()
+
+       def FCCForceStopForREC(self):
+               self.FCCForceStop()
 
        def FCCResetTimerForREC(self):
                self.FCCForceStopForREC()
-               self.FCCForceStartForREC()
+               self.FCCForceStart()
 
        def FCCSetupChanged(self):
                fcc_changed = False
@@ -414,10 +427,6 @@ class FCCSupport:
                self.fccmgr.stopFCCService()
                self.eventList = []
 
-       def FCCForceStart(self):
-               self.getEvStart()
-               self.getEvTunedIn()
-
        def FCCCheckNoLocked(self):
                for (sref, value) in self.fccmgr.getFCCServiceList().items():
                        state = value[0]
index e49eb36..1a25fad 100644 (file)
@@ -5,6 +5,8 @@ from Components.config import config, ConfigPosition
 
 pip_config_initialized = False
 
+on_pip_start_stop = []
+
 class PictureInPicture(Screen):
        def __init__(self, session):
                global pip_config_initialized
@@ -15,6 +17,11 @@ class PictureInPicture(Screen):
                        config.av.pip = ConfigPosition(default=[-1, -1, -1, -1], args = (719, 567, 720, 568))
                        pip_config_initialized = True
                self.onLayoutFinish.append(self.LayoutFinished)
+               self.dvbPipStarted = False
+
+       def __del__(self):
+               if self.dvbPipStarted:
+                       self.onPipStartAndStop()
 
        def LayoutFinished(self):
                self.onLayoutFinish.remove(self.LayoutFinished)
@@ -53,6 +60,10 @@ class PictureInPicture(Screen):
                if ref:
                        self.pipservice = eServiceCenter.getInstance().play(ref)
                        if self.pipservice and not self.pipservice.setTarget(1):
+                               if ref.type == 1: # dvb service
+                                       self.dvbPipStarted = True
+                                       self.onPipStartAndStop()
+
                                self.pipservice.start()
                                self.currentService = service
                                return True
@@ -63,3 +74,7 @@ class PictureInPicture(Screen):
        def getCurrentService(self):
                return self.currentService
 
+       def onPipStartAndStop(self):
+               global on_pip_start_stop
+               for x in on_pip_start_stop:
+                       x()
\ No newline at end of file