wingo - in flumotion/trunk: . flumotion/component/combiners/switch
flumotion-commit at lists.fluendo.com
flumotion-commit at lists.fluendo.com
Tue Dec 18 18:33:10 CET 2007
Author: wingo
Date: Tue Dec 18 18:33:03 2007
New Revision: 6017
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.feedSetInactive)
(SingleBasicWatchdog.feedSetActive)
(AVBasicWatchdog.feedSetInactive, AVBasicWatchdog.feedSetActive):
Use auto_switch().
(Switch.create_pipeline): Don't throw away the priority ordering
of get_logical_feeds() in the feedsByPriority list.
(Switch.auto_switch): New function, automatically selects the
highest-priority active feed. Should be used in the watchdogs.
* flumotion/component/combiners/switch/switch.py (Switch.init):
Modified: flumotion/trunk/ChangeLog
==============================================================================
--- flumotion/trunk/ChangeLog (original)
+++ flumotion/trunk/ChangeLog Tue Dec 18 18:33:03 2007
@@ -1,5 +1,17 @@
2007-12-18 Andy Wingo <wingo at pobox.com>
+ * flumotion/component/combiners/switch/basicwatchdog.py
+ (SingleBasicWatchdog.feedSetInactive)
+ (SingleBasicWatchdog.feedSetActive)
+ (AVBasicWatchdog.feedSetInactive, AVBasicWatchdog.feedSetActive):
+ Use auto_switch().
+
+ * flumotion/component/combiners/switch/switch.py (Switch.init):
+ (Switch.create_pipeline): Don't throw away the priority ordering
+ of get_logical_feeds() in the feedsByPriority list.
+ (Switch.auto_switch): New function, automatically selects the
+ highest-priority active feed. Should be used in the watchdogs.
+
* flumotion/component/combiners/switch/switch.py (Switch.init):
Remove self._started state variable -- subclasses should hack this
in if needed.
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 Tue Dec 18 18:33:03 2007
@@ -31,57 +31,21 @@
class SingleBasicWatchdog(switch.SingleSwitch):
logCategory = "comb-single-basic-watchdog"
- def eaterSetInactive(self, feedId):
- switch.SingleSwitch.eaterSetInactive(self, feedId)
- eaterName = self.get_eater_name_for_feed_id(feedId)
- oppositeEater = "backup"
- if self._idealEater == "backup":
- oppositeEater = "master"
- if self._idealEater in eaterName and self.is_active(oppositeEater) and \
- self.uiState.get("active-eater") == self._idealEater and \
- self._started:
- self.debug("Switching to %s, active eater is %s", oppositeEater,
- self.uiState.get("active-eater"))
- self.switch_to(oppositeEater)
+ def feedSetInactive(self, feed):
+ switch.SingleSwitch.feedSetInactive(self, feed)
+ self.auto_switch()
- def eaterSetActive(self, feedId):
- switch.SingleSwitch.eaterSetActive(self, feedId)
- eaterName = self.get_eater_name_for_feed_id(feedId)
- oppositeEater = "backup"
- if self._idealEater == "backup":
- oppositeEater = "master"
- if self._idealEater in eaterName and self.is_active(self._idealEater) \
- and self.uiState.get("active-eater") == oppositeEater and \
- self._started:
- self.debug("Switching to %s, active eater is %s", self._idealEater,
- self.uiState.get("active-eater"))
- self.switch_to(self._idealEater)
+ def feedSetActive(self, feed):
+ switch.SingleSwitch.feedSetActive(self, feed)
+ self.auto_switch()
class AVBasicWatchdog(switch.AVSwitch):
logCategory = "comb-av-basic-watchdog"
- def eaterSetInactive(self, feedId):
- switch.AVSwitch.eaterSetInactive(self, feedId)
- eaterName = self.get_eater_name_for_feed_id(feedId)
- oppositeEater = "backup"
- if self._idealEater == "backup":
- oppositeEater = "master"
- if self._idealEater in eaterName and self.is_active(oppositeEater) and \
- self.uiState.get("active-eater") == self._idealEater and \
- self._started:
- self.debug("Switching to %s, active eater is %s", oppositeEater,
- self.uiState.get("active-eater"))
- self.switch_to(oppositeEater)
+ def feedSetInactive(self, feed):
+ switch.AVSwitch.feedSetInactive(self, feed)
+ self.auto_switch()
- def eaterSetActive(self, feedId):
- switch.AVSwitch.eaterSetActive(self, feedId)
- eaterName = self.get_eater_name_for_feed_id(feedId)
- oppositeEater = "backup"
- if self._idealEater == "backup":
- oppositeEater = "master"
- if self._idealEater in eaterName and self.is_active(self._idealEater) \
- and self.uiState.get("active-eater") == oppositeEater and \
- self._started:
- self.debug("Switching to %s, active eater is %s", self._idealEater,
- self.uiState.get("active-eater"))
- self.switch_to(self._idealEater)
+ def feedSetActive(self, feed):
+ switch.AVSwitch.feedSetActive(self, feed)
+ self.auto_switch()
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 Tue Dec 18 18:33:03 2007
@@ -97,6 +97,8 @@
# "backup": ["audio-backup", "video-backup"]}
# logical feed name -> [eater alias]
self.logicalFeeds = {}
+ # logical feed names in order of preference
+ self.feedsByPriority = []
# eater alias -> (sink pad, switch element)
self.switchPads = {}
@@ -148,6 +150,7 @@
self.logicalFeeds[name] = aliases
if self.idealFeed is None:
self.idealFeed = name
+ self.feedsByPriority.append(name)
return feedcomponent.MultiInputParseLaunchComponent.create_pipeline(self)
@@ -214,6 +217,22 @@
def feedSetInactive(self, feed):
self.debug('feed %r is now inactive', feed)
+ # this function is used by the watchdogs
+ def auto_switch(self):
+ allFeeds = self.feedsByPriority[:]
+ feed = None
+ while allFeeds:
+ feed = allFeeds.pop(0)
+ if self.is_active(feed):
+ self.debug('autoswitch selects feed %r', feed)
+ self.switch_to(feed)
+ break
+ if feed is None:
+ feed = self.feedsByPriority.get(0, None)
+ self.debug('no feeds active during autoswitch, choosing %r',
+ feed)
+ self.switch_to(feed)
+
def switch_to(self, feed):
"""
@param feed: a logical feed
More information about the flumotion-commit
mailing list