zaheer - in flumotion/trunk: . flumotion/component/combiners/switch

flumotion-commit at lists.fluendo.com flumotion-commit at lists.fluendo.com
Thu Jun 7 19:09:49 CEST 2007


Author: zaheer
Date: Thu Jun  7 19:09:47 2007
New Revision: 5130

Modified:
   flumotion/trunk/ChangeLog
   flumotion/trunk/flumotion/component/combiners/switch/basicwatchdog.py
   flumotion/trunk/flumotion/component/combiners/switch/switch.py
Log:
	* flumotion/component/combiners/switch/basicwatchdog.py
	  (SingleBasicWatchdog.eaterSetActive,
	  AVBasicWatchdog.eaterSetInactive, AVBasicWatchdog.eaterSetActive):
	Add debug, check to see if component has started before switching
	when eaters go inactive or active.
	* flumotion/component/combiners/switch/switch.py (Switch.init,
	  Switch.switch_to, Switch.eventStarted, Switch.eventStopped,
	  Switch.do_pipeline_playing, AVSwitch.get_pipeline_string,
	  AVSwitch.configure_pipeline):
	Add a flag that denotes whether component has started or not, used
	in watchdogs. Fix calls to non-existant methods. Make identity
	elements silent.



Modified: flumotion/trunk/ChangeLog
==============================================================================
--- flumotion/trunk/ChangeLog	(original)
+++ flumotion/trunk/ChangeLog	Thu Jun  7 19:09:47 2007
@@ -1,5 +1,20 @@
 2007-06-07  Zaheer Abbas Merali  <zaheerabbas at merali dot org>
 
+	* flumotion/component/combiners/switch/basicwatchdog.py
+	  (SingleBasicWatchdog.eaterSetActive,
+	  AVBasicWatchdog.eaterSetInactive, AVBasicWatchdog.eaterSetActive):
+	Add debug, check to see if component has started before switching
+	when eaters go inactive or active.
+	* flumotion/component/combiners/switch/switch.py (Switch.init,
+	  Switch.switch_to, Switch.eventStarted, Switch.eventStopped,
+	  Switch.do_pipeline_playing, AVSwitch.get_pipeline_string,
+	  AVSwitch.configure_pipeline):
+	Add a flag that denotes whether component has started or not, used
+	in watchdogs. Fix calls to non-existant methods. Make identity
+	elements silent.
+
+2007-06-07  Zaheer Abbas Merali  <zaheerabbas at merali dot org>
+
 	* flumotion/admin/gtk/client.py (Window._instanceSetup):
 	Fix bug where there is an exception in setup() of an
 	admin gtk, we instead always were outputting setup()

Modified: flumotion/trunk/flumotion/component/combiners/switch/basicwatchdog.py
==============================================================================
--- flumotion/trunk/flumotion/component/combiners/switch/basicwatchdog.py	(original)
+++ flumotion/trunk/flumotion/component/combiners/switch/basicwatchdog.py	Thu Jun  7 19:09:47 2007
@@ -26,6 +26,8 @@
 
 # These basic watchdog components switch to backup
 # when the master eater(s) have gone hungry
+# FIXME: if a scheduled event happens so we are meant to be on backup, and then
+# both backup and master go away and come back, it will switch to master
 class SingleBasicWatchdog(switch.SingleSwitch):
     logCategory = "comb-single-basic-watchdog"
 
@@ -39,6 +41,7 @@
         switch.SingleSwitch.eaterSetActive(self, feedId)
         eaterName = self.get_eater_name_for_feed_id(feedId)
         if "master" in eaterName:
+            self.debug("Switching to master")
             self.switch_to("master")
 
 class AVBasicWatchdog(switch.AVSwitch):
@@ -47,12 +50,17 @@
     def eaterSetInactive(self, feedId):
         switch.AVSwitch.eaterSetInactive(self, feedId)
         eaterName = self.get_eater_name_for_feed_id(feedId)
-        if "master" in eaterName and self.is_active("backup"):
+        if "master" in eaterName and self.is_active("backup") and \
+           self.uiState.get("active-eater") == "master" and self._started:
+            self.debug("Switching to backup active eater is %s",
+                self.uiState.get("active-eater"))
             self.switch_to("backup")
 
     def eaterSetActive(self, feedId):
         switch.AVSwitch.eaterSetActive(self, feedId)
         eaterName = self.get_eater_name_for_feed_id(feedId)
-        if "master" in eaterName and \
-           self.uiState.get("active-eater") == "backup":
+        if "master" in eaterName and self.is_active("master") and \
+           self.uiState.get("active-eater") == "backup" and self._started:
+            self.debug("Switching to master active eater is %s",
+                self.uiState.get("active-eater"))
             self.switch_to("master")

Modified: flumotion/trunk/flumotion/component/combiners/switch/switch.py
==============================================================================
--- flumotion/trunk/flumotion/component/combiners/switch/switch.py	(original)
+++ flumotion/trunk/flumotion/component/combiners/switch/switch.py	Thu Jun  7 19:09:47 2007
@@ -55,6 +55,7 @@
         # was requested and the eater wasn't ready, it'll fire when ready
         # so the switch can be made
         self._eaterReadyDefers = { "master": None, "backup": None }
+        self._started = False
 
     def do_check(self):
         self.debug("checking whether switch element exists")
@@ -88,7 +89,7 @@
         
     def switch_to(self, eaterSubstring):
         raise errors.NotImplementedError('subclasses should implement '
-                                         'switchTo')
+                                         'switch_to')
 
     def is_active(self, eaterSubstring):
         # eaterSubstring is "master" or "backup"
@@ -110,7 +111,7 @@
                     ", will switch when backup is back")
                 self._eaterReadyDefers["backup"] = defer.Deferred()
                 self._eaterReadyDefers["backup"].addCallback(
-                    lambda x: self.switchTo("backup"))
+                    lambda x: self.switch_to("backup"))
                 self._eaterReadyDefers["master"] = None
 
     def eventStopped(self, event):
@@ -122,9 +123,15 @@
                     ", will switch when master is back")
                 self._eaterReadyDefers["master"] = defer.Deferred()
                 self._eaterReadyDefers["master"].addCallback(
-                    lambda x: self.switchTo("master"))
+                    lambda x: self.switch_to("master"))
                 self._eaterReadyDefers["backup"] = None
 
+    def do_pipeline_playing(self):
+        feedcomponent.MultiInputParseLaunchComponent.do_pipeline_playing(self)
+        # needed to stop the flapping between master and backup on startup
+        # in the watchdogs if the starting state is backup
+        self._started = True
+
 class SingleSwitch(Switch):
     logCategory = "comb-single-switch"
 
@@ -218,9 +225,9 @@
         eaters = self.eater_names
 
         pipeline = "switch name=vswitch ! " \
-            "identity single-segment=true name=viden " \
+            "identity silent=true single-segment=true name=viden " \
             "switch name=aswitch ! " \
-            "identity single-segment=true name=aiden "
+            "identity silent=true single-segment=true name=aiden "
         for eater in eaters:
             if "video" in eater:
                 tmpl = '@ eater:%s @ ! vswitch. '
@@ -271,6 +278,7 @@
         asw.set_property("active-pad",
             self.switchPads["audio-%s" % self._startingEater])
         self.uiState.set("active-eater", self._startingEater)
+        self.debug("active-eater set to %s", self._startingEater)
 
     # So switching audio and video is not that easy
     # We have to make sure the current segment on both


More information about the flumotion-commit mailing list