[pkg-fso-commits] [SCM] FSO frameworkd Debian packaging branch, master, updated. milestone3-274-gd9a0e57

Michael 'Mickey' Lauer mickey at vanille-media.de
Tue Nov 11 17:09:18 UTC 2008


The following commit has been merged in the master branch:
commit 24e4ec6658fb7311663d8d874f3af3ce258bd0c1
Author: Michael 'Mickey' Lauer <mickey at vanille-media.de>
Date:   Wed Oct 29 18:27:23 2008 +0100

    odeviced: audio: fallback to NullPlayer if GStreamerPlayer can't be launched

diff --git a/framework/subsystems/odeviced/audio.py b/framework/subsystems/odeviced/audio.py
index 30ef412..4ff668d 100644
--- a/framework/subsystems/odeviced/audio.py
+++ b/framework/subsystems/odeviced/audio.py
@@ -17,7 +17,6 @@ from framework.config import config
 from framework.patterns import asyncworker
 from helpers import DBUS_INTERFACE_PREFIX, DBUS_PATH_PREFIX, readFromFile, writeToFile, cleanObjectName
 
-import gst
 import gobject
 import dbus.service
 import sys, os, time, struct, subprocess
@@ -25,6 +24,11 @@ import sys, os, time, struct, subprocess
 import logging
 logger = logging.getLogger( "odeviced.audio" )
 
+try:
+    import gst
+except ImportError:
+    logger.warning( "Could not import gst module (python-gst installed?)" )
+
 #----------------------------------------------------------------------------#
 class UnknownFormat( dbus.DBusException ):
 #----------------------------------------------------------------------------#
@@ -74,6 +78,18 @@ class Player( asyncworker.AsyncWorker ):
     def enqueueTask( self, ok_cb, error_cb, task, *args ):
         self.enqueue( ok_cb, error_cb, task, args )
 
+    def onProcessElement( self, element ):
+        logger.debug( "getting task from queue..." )
+        ok_cb, error_cb, task, args = element
+        logger.debug( "got task: %s %s" % ( task, args ) )
+        try:
+            method = getattr( self, "task_%s" % task )
+        except AttributeError:
+            logger.debug( "unhandled task: %s %s" % ( task, args ) )
+        else:
+            method( ok_cb, error_cb, *args )
+        return True
+
     def task_play( self, ok_cb, error_cb, name, repeat ):
         ok_cb()
 
@@ -89,7 +105,17 @@ class NullPlayer( Player ):
     """
     A dummy player, useful e.g. if no audio subsystem is available.
     """
-    pass
+    def task_play( self, ok_cb, error_cb, name, repeat ):
+        logger.info( "NullPlayer [not] playing sound %s" % name )
+        ok_cb()
+
+    def task_stop( self, ok_cb, error_cb, name ):
+        logger.info( "NullPlayer [not] stopping sound %s" % name )
+        ok_cb()
+
+    def task_panic( self, ok_cb, error_cb ):
+        logger.info( "NullPlayer [not] stopping all sounds" )
+        ok_cb()
 
 #----------------------------------------------------------------------------#
 class GStreamerPlayer( Player ):
@@ -162,18 +188,6 @@ class GStreamerPlayer( Player ):
             self.pipelines[name] = pipeline, newstatus, repeat, ok_cb, error_cb
             self._object.SoundStatus( name, newstatus, {} )
 
-    def onProcessElement( self, element ):
-        logger.debug( "getting task from queue..." )
-        ok_cb, error_cb, task, args = element
-        logger.debug( "got task: %s %s" % ( task, args ) )
-        try:
-            method = getattr( self, "task_%s" % task )
-        except AttributeError:
-            logger.debug( "unhandled task: %s %s" % ( task, args ) )
-        else:
-            method( ok_cb, error_cb, *args )
-        return True
-
     def task_play( self, ok_cb, error_cb, name, repeat ):
         if name in self.pipelines:
             error_cb( AlreadyPlaying( name ) )
@@ -312,7 +326,11 @@ class Audio( dbus.service.Object ):
         dbus.service.Object.__init__( self, bus, self.path )
         logger.info( "%s %s initialized. Serving %s at %s" % ( self.__class__.__name__, __version__, self.interface, self.path ) )
         # FIXME make it configurable or autodetect which player is to be used
-        self.player = GStreamerPlayer( self )
+        try:
+            self.player = GStreamerPlayer( self )
+        except NameError:
+            logger.exception( "Could not instanciate GStreamerPlayer; Falling back to NullPlayer" )
+            self.player = NullPlayer( self )
         # FIXME gather scenario path from configuration
         scenario_dir = config.getValue( MODULE_NAME, "scenario_dir", "/etc/alsa/scenario" )
         default_scenario = config.getValue( MODULE_NAME, "default_scenario", "default" )

-- 
FSO frameworkd Debian packaging



More information about the pkg-fso-commits mailing list