[rygel/wip/didl-s: 22/35] renderer: Delay returning of action



commit 97018224209901b2eb7bdc68ee30b7040cd9daf8
Author: Jens Georg <jensg openismus com>
Date:   Tue Nov 20 13:35:57 2012 +0100

    renderer: Delay returning of action
    
    Until we have the playlist and set the first URI on the player.
    
    This prevents clients from setting PLAYING state too early.

 src/librygel-renderer/rygel-av-transport.vala |   31 ++++++++++++++++++------
 1 files changed, 23 insertions(+), 8 deletions(-)
---
diff --git a/src/librygel-renderer/rygel-av-transport.vala b/src/librygel-renderer/rygel-av-transport.vala
index df07eaf..917062c 100644
--- a/src/librygel-renderer/rygel-av-transport.vala
+++ b/src/librygel-renderer/rygel-av-transport.vala
@@ -298,6 +298,9 @@ internal class Rygel.AVTransport : Service {
                     var features = msg.response_headers.get_one
                                         ("contentFeatures.dlna.org");
 
+                    debug ("Trying to handle file with %s and features %s",
+                           mime, features);
+
                     if (mime != null &&
                         !(mime in this.player.get_mime_types () || mime ==
                             "text/xml")) {
@@ -311,11 +314,8 @@ internal class Rygel.AVTransport : Service {
 
                     if (mime == "text/xml" &&
                         features.has_prefix ("DLNA.ORG_PN=DIDL_S")) {
-                        // this is a playlist, we'll handle that internally
-                        // Return action, then handle playlist
-                        // first thing handle playlist does is defer to
-                        // mainloop so the action will be returned first.
-                        this.handle_playlist.begin ();
+                        // Delay returning the action until we got some
+                        this.handle_playlist.begin (action);
                     } else {
                         // some other track
                         this.player.mime_type = mime;
@@ -329,9 +329,9 @@ internal class Rygel.AVTransport : Service {
                         this.track_metadata = _metadata;
                         this.track_uri = _uri;
                         this.n_tracks = 1;
-                    }
 
-                    action.return ();
+                        action.return ();
+                    }
                 }
             });
             this.session.queue_message (message, null);
@@ -543,6 +543,7 @@ internal class Rygel.AVTransport : Service {
     }
 
     private void play_cb (Service service, ServiceAction action) {
+        debug ("Client trying to set playback state");
         if (!this.check_instance_id (action)) {
             return;
         }
@@ -670,7 +671,8 @@ internal class Rygel.AVTransport : Service {
         this.changelog.log ("CurrentTrackMetadata", this.metadata);
     }
 
-    private async void handle_playlist () {
+    private async void handle_playlist (ServiceAction action) {
+        debug ("Trying to download playlist");
         Idle.add ( () => { handle_playlist.callback (); return false;  });
         yield;
 
@@ -681,12 +683,25 @@ internal class Rygel.AVTransport : Service {
         yield;
 
         if (message.status_code != 200) {
+            action.return_error (716, _("Resource not found"));
+
             return;
         }
 
+        debug ("Got playlist...");
+
         unowned string xml_string = (string) message.response_body.data;
 
         var collection = new MediaCollection.from_string (xml_string);
+        if (collection.get_items ().length () == 0) {
+            // FIXME: Return a more sensible error here.
+            action.return_error (716, _("Resource not found"));
+
+            return;
+        }
+
         this.playlist_handler = new PlaylistHandler (collection, this);
+
+        action.return ();
     }
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]