[gupnp-tools] av-cp: Keep content directory around



commit 0dfc590eb0f0c6f2295b353c22147349386ba83a
Author: Jens Georg <mail jensge org>
Date:   Sat Apr 2 20:52:29 2016 +0200

    av-cp: Keep content directory around
    
    Signed-off-by: Jens Georg <mail jensge org>
    
    https://bugzilla.gnome.org/show_bug.cgi?id=730747

 src/av-cp/playlist-treeview.c |   18 +++---------------
 src/av-cp/server-device.c     |   33 ++++++++++++++++++++++++---------
 2 files changed, 27 insertions(+), 24 deletions(-)
---
diff --git a/src/av-cp/playlist-treeview.c b/src/av-cp/playlist-treeview.c
index 458149c..8e90e59 100644
--- a/src/av-cp/playlist-treeview.c
+++ b/src/av-cp/playlist-treeview.c
@@ -764,19 +764,6 @@ update_device_icon (GUPnPDeviceInfo *info)
         g_object_unref (icon);
 }
 
-static GUPnPServiceProxy *
-get_content_dir (GUPnPDeviceProxy *proxy)
-{
-        GUPnPDeviceInfo  *info;
-        GUPnPServiceInfo *content_dir;
-
-        info = GUPNP_DEVICE_INFO (proxy);
-
-        content_dir = gupnp_device_info_get_service (info, CONTENT_DIR);
-
-        return GUPNP_SERVICE_PROXY (content_dir);
-}
-
 static void
 on_proxy_ready (GObject *source_object,
                 GAsyncResult *res,
@@ -1047,13 +1034,14 @@ append_media_server (GUPnPDeviceProxy *proxy,
                      GtkTreeIter      *parent_iter)
 {
         GUPnPDeviceInfo   *info;
-        GUPnPServiceProxy *content_dir;
         char              *friendly_name;
+        GUPnPServiceProxy *content_dir;
 
         info = GUPNP_DEVICE_INFO (proxy);
 
-        content_dir = get_content_dir (proxy);
         friendly_name = gupnp_device_info_get_friendly_name (info);
+        content_dir = av_cp_media_server_get_content_directory
+                                (AV_CP_MEDIA_SERVER (info));
 
         if (G_LIKELY (friendly_name != NULL && content_dir != NULL)) {
                 GtkTreeIter device_iter;
diff --git a/src/av-cp/server-device.c b/src/av-cp/server-device.c
index b14f2e9..6a892af 100644
--- a/src/av-cp/server-device.c
+++ b/src/av-cp/server-device.c
@@ -74,6 +74,7 @@ struct _AVCPMediaServerPrivate {
         char *default_sort_order;
         GList *tasks;
         AVCPMediaServerInitState state;
+        GUPnPServiceProxy *content_directory;
 };
 
 enum
@@ -107,6 +108,7 @@ av_cp_media_server_dispose (GObject *object)
                               G_OBJECT_CLASS (av_cp_media_server_parent_class);
 
         g_clear_object (&self->priv->icon);
+        g_clear_object (&self->priv->content_directory);
 
         parent_class->dispose (object);
 }
@@ -221,18 +223,17 @@ av_cp_media_server_on_icon_updated (GUPnPDeviceInfo *info,
                                     GdkPixbuf       *icon)
 {
         AVCPMediaServer *self = AV_CP_MEDIA_SERVER (info);
-        GUPnPServiceInfo *proxy = NULL;
 
         self->priv->icon = icon;
-        proxy = gupnp_device_info_get_service (GUPNP_DEVICE_INFO (self),
-                                               CONTENT_DIR);
-        if (proxy != NULL) {
+        av_cp_media_server_get_content_directory (self);
+
+        if (self->priv->content_directory != NULL) {
                 gupnp_service_proxy_begin_action
-                                (GUPNP_SERVICE_PROXY (proxy),
-                                "GetSortCapabilities",
-                                av_cp_media_server_on_get_sort_caps,
-                                g_object_ref (self),
-                                NULL);
+                                (self->priv->content_directory,
+                                 "GetSortCapabilities",
+                                 av_cp_media_server_on_get_sort_caps,
+                                 g_object_ref (self),
+                                 NULL);
         } else {
                 g_debug ("Invalid MediaServer device without ContentDirectory");
                 self->priv->state = INIT_FAILED;
@@ -334,3 +335,17 @@ av_cp_media_server_error_quark (void)
 {
         return g_quark_from_static_string ("av-cp-media-server-error-quark");
 }
+
+
+GUPnPServiceProxy *
+av_cp_media_server_get_content_directory (AVCPMediaServer *self)
+{
+        if (self->priv->content_directory == NULL) {
+                GUPnPServiceInfo *info = gupnp_device_info_get_service
+                                (GUPNP_DEVICE_INFO (self),
+                                 CONTENT_DIR);
+                self->priv->content_directory =  GUPNP_SERVICE_PROXY (info);
+        }
+
+        return g_object_ref (self->priv->content_directory);
+}


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