[grilo] core: Added grl_media_source_get_media_from_uri_sync



commit 95e5872722ae4ece4a9b20a5220438345adee32c
Author: Iago Toral Quiroga <itoral igalia com>
Date:   Mon Jan 17 13:41:35 2011 +0100

    core: Added grl_media_source_get_media_from_uri_sync
    
    Fixes https://bugzilla.gnome.org/show_bug.cgi?id=639741

 src/grl-media-source.c |   52 ++++++++++++++++++++++++++++++++++++++++++++++++
 src/grl-media-source.h |    5 ++++
 2 files changed, 57 insertions(+), 0 deletions(-)
---
diff --git a/src/grl-media-source.c b/src/grl-media-source.c
index 4ed0357..f80eea5 100644
--- a/src/grl-media-source.c
+++ b/src/grl-media-source.c
@@ -2437,3 +2437,55 @@ grl_media_source_get_media_from_uri (GrlMediaSource *source,
 
   g_idle_add (media_from_uri_idle, mfus);
 }
+
+/**
+ * grl_media_source_get_media_from_uri_sync:
+ * @source: a media source
+ * @uri: A URI that can be used to identify a media resource
+ * @keys: A list of keys to resolve
+ * @flags: the resolution mode
+ * @error: a #GError, or @NULL
+ *
+ * Creates an instance of #GrlMedia representing the media resource
+ * exposed at @uri.
+ * 
+ * It is recommended to call grl_media_source_test_media_from_uri() before
+ * invoking this to check whether the target source can theoretically do the
+ * resolution.
+ *
+ * This method is synchronous.
+ */
+GrlMedia *
+grl_media_source_get_media_from_uri_sync (GrlMediaSource *source,
+                                          const gchar *uri,
+                                          const GList *keys,
+                                          GrlMetadataResolutionFlags flags,
+                                          GError **error)
+{
+  GrlDataSync *ds;
+  GrlMedia *result;
+
+  ds = g_slice_new0 (GrlDataSync);
+
+  grl_media_source_get_media_from_uri (source,
+                                       uri,
+                                       keys,
+                                       flags,
+                                       metadata_result_async_cb,
+                                       ds);
+
+  grl_wait_for_async_operation_complete (ds);
+
+  if (ds->error) {
+    if (error) {
+      *error = ds->error;
+    } else {
+      g_error_free (ds->error);
+    }
+  }
+
+  result = (GrlMedia *) ds->data;
+  g_slice_free (GrlDataSync, ds);
+
+  return result;
+}
diff --git a/src/grl-media-source.h b/src/grl-media-source.h
index b745c44..2e77602 100644
--- a/src/grl-media-source.h
+++ b/src/grl-media-source.h
@@ -496,6 +496,11 @@ void grl_media_source_get_media_from_uri (GrlMediaSource *source,
 					  GrlMediaSourceMetadataCb callback,
 					  gpointer user_data);
 
+GrlMedia *grl_media_source_get_media_from_uri_sync (GrlMediaSource *source,
+                                                    const gchar *uri,
+                                                    const GList *keys,
+                                                    GrlMetadataResolutionFlags flags,
+                                                    GError **error);
 G_END_DECLS
 
 #endif /* _GRL_MEDIA_SOURCE_H_ */



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