[rygel-gst-0-10-media-engine] Warnings cleanup.



commit 5e39e60aab02cd9011da91ba98d66b0044b375c6
Author: Krzesimir Nowak <qdlacz gmail com>
Date:   Wed Jan 9 18:11:27 2013 +0100

    Warnings cleanup.

 src/rygel-gst-data-source.c  |   61 +++++++++++++++++++----------------------
 src/rygel-gst-data-source.h  |    1 +
 src/rygel-gst-media-engine.c |   58 +++++++++++++--------------------------
 src/rygel-gst-sink.c         |    7 +++-
 src/rygel-gst-sink.h         |   10 ++++++-
 src/rygel-gst-utils.c        |   22 ++++++---------
 tests/test_simple.c          |    2 +
 7 files changed, 73 insertions(+), 88 deletions(-)
---
diff --git a/src/rygel-gst-data-source.c b/src/rygel-gst-data-source.c
index 0e52c3f..febe1b6 100644
--- a/src/rygel-gst-data-source.c
+++ b/src/rygel-gst-data-source.c
@@ -20,7 +20,7 @@
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
 
-
+#include "rygel-gst-utils.h"
 #include "rygel-gst-data-source.h"
 #include "rygel-gst-sink.h"
 #include <glib/gi18n-lib.h>
@@ -59,15 +59,10 @@ static void rygel_gst_data_source_prepare_pipeline (RygelGstDataSource* self, co
 static void rygel_gst_data_source_real_freeze (RygelDataSource *base);
 static void rygel_gst_data_source_real_thaw (RygelDataSource *base);
 static void rygel_gst_data_source_real_stop (RygelDataSource *base);
-static void rygel_gst_data_source_src_pad_added (RygelGstDataSource* self, GstElement* src, GstPad* src_pad);
 static void on_pad_added (GstElement* _sender, GstPad* pad, gpointer self);
-GQuark rygel_gst_error_quark (void);
-static gboolean rygel_gst_data_source_bus_handler (RygelGstDataSource* self, GstBus* bus, GstMessage* message);
 static gboolean on_bus_watch (GstBus* bus, GstMessage* message, gpointer self);
 #define RYGEL_GST_SINK_NAME "http-gst-sink"
 
-static inline void _dynamic_set_streamable0 (GstElement* obj, gboolean value);
-static inline void _dynamic_set_fragment_duration1 (GstElement* obj, gint value);
 static gboolean rygel_gst_data_source_perform_seek (RygelGstDataSource* self);
 static void rygel_gst_data_source_finalize (GObject* obj);
 
@@ -103,6 +98,8 @@ rygel_gst_data_source_construct_from_element (GType object_type, GstElement* ele
   RygelGstDataSource *self = RYGEL_GST_DATA_SOURCE (g_object_new (object_type, NULL));
 
   self->priv->src = element;
+
+  return self;
 }
 
 RygelGstDataSource*
@@ -112,7 +109,7 @@ rygel_gst_data_source_new_from_element (GstElement* element) {
 
 static void
 rygel_gst_data_source_real_start (RygelDataSource *base, RygelHTTPSeek* offsets, GError **error) {
-  RygelGstDataSource *self = RYGEL_DATA_SOURCE (base);
+  RygelGstDataSource *self = RYGEL_GST_DATA_SOURCE (base);
   GError *inner_error = NULL;
 
   self->priv->seek = offsets;
@@ -123,15 +120,15 @@ rygel_gst_data_source_real_start (RygelDataSource *base, RygelHTTPSeek* offsets,
   }
 
   if (self->priv->seek) {
-    gst_element_set_state (self->priv->pipeline, GST_STATE_PAUSED);
+    gst_element_set_state (GST_ELEMENT (self->priv->pipeline), GST_STATE_PAUSED);
   } else {
-    gst_element_set_state (self->priv->pipeline, GST_STATE_PLAYING);
+    gst_element_set_state (GST_ELEMENT (self->priv->pipeline), GST_STATE_PLAYING);
   }
 }
 
 static void
 rygel_gst_data_source_real_freeze (RygelDataSource *base) {
-  RygelGstDataSource *self = RYGEL_DATA_SOURCE (base);
+  RygelGstDataSource *self = RYGEL_GST_DATA_SOURCE (base);
 
   rygel_gst_sink_freeze (self->priv->sink);
 }
@@ -144,7 +141,7 @@ rygel_gst_data_source_real_thaw (RygelDataSource *base) {
 
 static gboolean
 on_idle_emit_done (gpointer user_data) {
-  RygelGstDataSource *self = RYGEL_DATA_SOURCE (user_data);
+  RygelGstDataSource *self = RYGEL_GST_DATA_SOURCE (user_data);
 
   g_signal_emit_by_name (self, "done");
   return FALSE;
@@ -152,14 +149,14 @@ on_idle_emit_done (gpointer user_data) {
 
 static void
 rygel_gst_data_source_real_stop (RygelDataSource *base) {
-  RygelGstDataSource *self = RYGEL_DATA_SOURCE (base);
+  RygelGstDataSource *self = RYGEL_GST_DATA_SOURCE (base);
 
   if (self->priv->sink) {
     g_cancellable_cancel (self->priv->sink->cancellable);
   }
 
   if (self->priv->pipeline) {
-    gst_element_set_state (self->priv->pipeline, GST_STATE_NULL);
+    gst_element_set_state (GST_ELEMENT (self->priv->pipeline), GST_STATE_NULL);
   }
 
   g_source_remove (self->priv->bus_watch_id);
@@ -170,21 +167,19 @@ rygel_gst_data_source_real_stop (RygelDataSource *base) {
 
 static void
 on_pad_added (GstElement* src, GstPad* src_pad, gpointer user_data) {
-  RygelGstDataSource *self = RYGEL_DATA_SOURCE (user_data);
+  RygelGstDataSource *self = RYGEL_GST_DATA_SOURCE (user_data);
 
   g_return_if_fail (self != NULL);
   g_return_if_fail (src != NULL);
   g_return_if_fail (src_pad != NULL);
 
-  self = RYGEL_DATA_SOURCE (user_data);
   GstCaps* caps = gst_pad_get_caps_reffed (src_pad);
-
-  GstElement* sink = gst_bin_get_by_name (self->priv->pipeline, RYGEL_GST_SINK_NAME);
+  GstElement* sink = gst_bin_get_by_name (GST_BIN (self->priv->pipeline), RYGEL_GST_SINK_NAME);
   GstPad* sink_pad = NULL;
 
   GstElement* depay = rygel_gst_utils_get_rtp_depayloader (caps);
   if (depay) {
-    gst_bin_add (self->priv->pipeline, depay);
+    gst_bin_add (GST_BIN (self->priv->pipeline), depay);
 
     if (!gst_element_link (depay, sink)) {
        gchar *depay_name = gst_object_get_name (GST_OBJECT (depay));
@@ -238,35 +233,36 @@ on_pad_added (GstElement* src, GstPad* src_pad, gpointer user_data) {
 }
 
 static gboolean
-on_bus_watch (GstBus* bus, GstMessage* message, gpointer user_data) {
-  RygelGstDataSource *self = RYGEL_DATA_SOURCE (user_data);
+on_bus_watch (GstBus* bus G_GNUC_UNUSED,
+              GstMessage* message,
+              gpointer user_data) {
+  RygelGstDataSource *self = RYGEL_GST_DATA_SOURCE (user_data);
   gboolean ret = TRUE;
 
   if (message->type == GST_MESSAGE_EOS) {
     ret = FALSE;
   } else if (message->type == GST_MESSAGE_STATE_CHANGED) {
-    if (message->src != self->priv->pipeline) {
+    if (message->src != GST_OBJECT (self->priv->pipeline)) {
       return TRUE;
     }
 
     GstState old_state;
     GstState new_state;
     gst_message_parse_state_changed (message, &old_state, &new_state, NULL);
-     
+
     if (old_state == GST_STATE_NULL && new_state == GST_STATE_READY) {
       GstElement* element = gst_bin_get_by_name (GST_BIN (self->priv->pipeline), "muxer");
       if (element) {
         GstElementFactory* factory = gst_element_get_factory (element);
         if (factory) {
-          gchar *name = gst_plugin_feature_get_name (GST_PLUGIN_FEATURE (factory));
- 
+          const gchar *name = gst_plugin_feature_get_name (GST_PLUGIN_FEATURE (factory));
+
           // Awesome gross hack, really.
           if (g_strcmp0 (name, "mp4mux") == 0) {
             g_object_set (element, "streamable", TRUE, NULL);
             g_object_set (element, "fragment-duration", 1000, NULL);
           }
 
-          g_free (name);
           gst_object_unref (factory);
         }
 
@@ -314,7 +310,7 @@ on_bus_watch (GstBus* bus, GstMessage* message, gpointer user_data) {
 
 static void
 rygel_gst_data_source_prepare_pipeline (RygelGstDataSource* self, const gchar *name, GstElement* src, GError **error) {
-  self->priv->sink = rygel_gst_sink_new (self, self->priv->seek);
+  self->priv->sink = rygel_gst_sink_new (RYGEL_DATA_SOURCE (self), self->priv->seek);
 
   self->priv->pipeline = GST_PIPELINE (gst_pipeline_new (name));
   if(self->priv->pipeline == NULL) {
@@ -324,7 +320,7 @@ rygel_gst_data_source_prepare_pipeline (RygelGstDataSource* self, const gchar *n
       _("Failed to create pipeline"));
   }
 
-  gst_bin_add_many (self->priv->pipeline, self->priv->src, self->priv->sink, NULL);
+  gst_bin_add_many (GST_BIN (self->priv->pipeline), self->priv->src, self->priv->sink, NULL);
 
   if (src->numsrcpads == 0) {
     // Seems source uses dynamic pads, so link when the pad is available
@@ -363,7 +359,7 @@ rygel_gst_data_source_perform_seek (RygelGstDataSource* self) {
   gint64 stop = 0LL;
 
   if (self->priv->seek &&
-      rygel_http_seek_get_length (self->priv->seek) >= rygel_http_seek_get_total_length (self->priv->seek)) { 
+      rygel_http_seek_get_length (self->priv->seek) >= rygel_http_seek_get_total_length (self->priv->seek)) {
     return TRUE;
   }
 
@@ -391,7 +387,7 @@ rygel_gst_data_source_perform_seek (RygelGstDataSource* self) {
       rygel_http_seek_get_start (self->priv->seek),
       rygel_http_seek_get_stop (self->priv->seek));
 
-    error  = g_error_new_literal (RYGEL_DATA_SOURCE_ERROR, 
+    error  = g_error_new_literal (RYGEL_DATA_SOURCE_ERROR,
       RYGEL_DATA_SOURCE_ERROR_SEEK_FAILED,
       _("Failed to seek"));
     g_signal_emit_by_name (self, "error", error);
@@ -427,8 +423,8 @@ rygel_gst_data_source_init (RygelGstDataSource *self) {
 
 static void
 rygel_gst_data_source_finalize (GObject* obj) {
-  RygelGstDataSource *self = RYGEL_DATA_SOURCE (obj);
-  
+  RygelGstDataSource *self = RYGEL_GST_DATA_SOURCE (obj);
+
   if (self->priv->sink) {
     g_cancellable_cancel (self->priv->sink->cancellable);
   }
@@ -449,7 +445,7 @@ rygel_gst_data_source_finalize (GObject* obj) {
  * rygel_gst_data_source_get_gst_element:
  * @self: A #RygelGstDataSource
  *
- * Retrieves the underyling GStreamer element, for use by 
+ * Retrieves the underyling GStreamer element, for use by
  *
  * Return value: a #GstElement
  */
@@ -460,4 +456,3 @@ rygel_gst_data_source_get_gst_element (RygelGstDataSource *self)
 
   return self->priv->src;
 }
-
diff --git a/src/rygel-gst-data-source.h b/src/rygel-gst-data-source.h
index 3c93ec7..784e8a1 100644
--- a/src/rygel-gst-data-source.h
+++ b/src/rygel-gst-data-source.h
@@ -72,6 +72,7 @@ typedef enum  {
 } RygelGstError;
 
 #define RYGEL_GST_ERROR rygel_gst_error_quark ()
+GQuark rygel_gst_error_quark (void);
 
 
 G_END_DECLS
diff --git a/src/rygel-gst-media-engine.c b/src/rygel-gst-media-engine.c
index 4d1595e..e9efc5c 100644
--- a/src/rygel-gst-media-engine.c
+++ b/src/rygel-gst-media-engine.c
@@ -20,6 +20,7 @@
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
 
+#include "rygel-gst-data-source.h"
 #include "rygel-gst-media-engine.h"
 #include "rygel-aac-transcoder.h"
 #include "rygel-avc-transcoder.h"
@@ -43,8 +44,7 @@ static RygelGstMediaEngine*
 rygel_gst_media_engine_construct (GType object_type) {
   RygelGstMediaEngine *self = NULL;
   GUPnPDLNADiscoverer *discoverer;
-  GList *profile_collection;
-  gboolean transcoding;
+  const GList *profile_collection;
   GeeArrayList *transcoder_list = NULL;
   RygelMetaConfig *config;
   GError *error = NULL;
@@ -64,7 +64,7 @@ rygel_gst_media_engine_construct (GType object_type) {
   discoverer = gupnp_dlna_discoverer_new ((GstClockTime) GST_SECOND, TRUE, FALSE);
   profile_collection = gupnp_dlna_discoverer_list_profiles (discoverer);
 
-  GList *profile_it = NULL;
+  const GList *profile_it = NULL;
   for (profile_it = profile_collection; profile_it != NULL; profile_it = profile_it->next) {
     GUPnPDLNAProfile *profile = GUPNP_DLNA_PROFILE (profile_it->data);
     const gchar *name = gupnp_dlna_profile_get_name (profile);
@@ -86,12 +86,12 @@ rygel_gst_media_engine_construct (GType object_type) {
    */
   config = rygel_meta_config_get_default ();
 
-  transcoding = rygel_configuration_get_transcoding (config, &error);
+  rygel_configuration_get_transcoding (RYGEL_CONFIGURATION (config), &error);
   if (error) {
     g_clear_error (&error);
   } else {
     /* Note that the default GStreamer media engine uses the same config group name. */
-    transcoder_list = rygel_configuration_get_string_list (config, "GstMediaEngine", "transcoders", &error);
+    transcoder_list = rygel_configuration_get_string_list (RYGEL_CONFIGURATION (config), "GstMediaEngine", "transcoders", &error);
     if (error) {
       g_clear_error (&error);
       transcoder_list = NULL;
@@ -102,15 +102,15 @@ rygel_gst_media_engine_construct (GType object_type) {
     transcoder_list = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, NULL, NULL, NULL);
 
     /* Start with some defaults, at least for testing: */
-    gee_abstract_collection_add (transcoder_list, "lpcm");
-    gee_abstract_collection_add (transcoder_list, "mp3");
-    gee_abstract_collection_add (transcoder_list, "mp2ts");
-    gee_abstract_collection_add (transcoder_list, "wmv");
-    gee_abstract_collection_add (transcoder_list, "aac");
-    gee_abstract_collection_add (transcoder_list, "avc");
+    gee_abstract_collection_add (GEE_ABSTRACT_COLLECTION (transcoder_list), "lpcm");
+    gee_abstract_collection_add (GEE_ABSTRACT_COLLECTION (transcoder_list), "mp3");
+    gee_abstract_collection_add (GEE_ABSTRACT_COLLECTION (transcoder_list), "mp2ts");
+    gee_abstract_collection_add (GEE_ABSTRACT_COLLECTION (transcoder_list), "wmv");
+    gee_abstract_collection_add (GEE_ABSTRACT_COLLECTION (transcoder_list), "aac");
+    gee_abstract_collection_add (GEE_ABSTRACT_COLLECTION (transcoder_list), "avc");
   }
 
-  gint transcoder_size = gee_abstract_collection_get_size (transcoder_list);
+  gint transcoder_size = gee_abstract_collection_get_size (GEE_ABSTRACT_COLLECTION (transcoder_list));
   gint transcoder_index = -1;
   while (TRUE) {
     gchar *transcoder_name;
@@ -176,34 +176,17 @@ rygel_gst_media_engine_real_get_transcoders (RygelMediaEngine *base) {
 
 
 static RygelDataSource*
-rygel_gst_media_engine_real_create_data_source (RygelMediaEngine *base, const gchar *uri) {
-  RygelGstMediaEngine *self = RYGEL_GST_MEDIA_ENGINE (base);
+rygel_gst_media_engine_real_create_data_source (RygelMediaEngine *base G_GNUC_UNUSED,
+                                                const gchar *uri) {
   RygelDataSource *result = NULL;
   GError *error = NULL;
 
   g_return_val_if_fail (uri != NULL, NULL);
-  
-  result = rygel_gst_data_source_new (uri, &error);
-  if (error) {
-    g_warning ("rygel_gst_data_source_new() failed: %s", error->message);
-    g_clear_error (error);
-  }
 
-  return result;
-}
-
-
-static RygelDataSource*
-rygel_gst_media_engine_create_data_source_from_element (RygelGstMediaEngine *self, GstElement *element) {
-  RygelDataSource *result = NULL;
-  GError *error = NULL;
-
-  g_return_val_if_fail (element != NULL, NULL);
-  
-  result = rygel_gst_data_source_new_from_element (element, &error);
+  result = RYGEL_DATA_SOURCE (rygel_gst_data_source_new (uri, &error));
   if (error) {
-    g_warning ("rygel_gst_data_source_new_from_element() failed: %s", error->message);
-    g_clear_error (error);
+    g_warning ("rygel_gst_data_source_new() failed: %s", error->message);
+    g_error_free (error);
   }
 
   return result;
@@ -230,7 +213,7 @@ rygel_gst_media_engine_init (RygelGstMediaEngine *self) {
 static void
 rygel_gst_media_engine_finalize (GObject *obj) {
   RygelGstMediaEngine *self = RYGEL_GST_MEDIA_ENGINE (obj);
-  
+
   g_list_free_full (self->priv->dlna_profiles, (GDestroyNotify) g_object_unref);
   g_list_free_full (self->priv->transcoders, (GDestroyNotify) g_object_unref);
 
@@ -239,8 +222,5 @@ rygel_gst_media_engine_finalize (GObject *obj) {
 
 RygelMediaEngine*
 module_get_instance (void) {
-  return rygel_gst_media_engine_new ();
+  return RYGEL_MEDIA_ENGINE (rygel_gst_media_engine_new ());
 }
-
-
-
diff --git a/src/rygel-gst-sink.c b/src/rygel-gst-sink.c
index ec1a1f2..d1b4f40 100644
--- a/src/rygel-gst-sink.c
+++ b/src/rygel-gst-sink.c
@@ -56,7 +56,7 @@ struct _CallbackData {
 #define RYGEL_GST_SINK_MIN_BUFFERED_CHUNKS ((guint) 4)
 
 static void rygel_gst_sink_on_cancelled (RygelGstSink* self);
-static void on_cancelled (GCancellable* _sender, gpointer self);
+static void on_cancelled (GCancellable* sender, gpointer user_data);
 static GstFlowReturn rygel_gst_sink_real_render (GstBaseSink *base, GstBuffer* buffer);
 gboolean rygel_gst_sink_push_data (RygelGstSink* self, GstBuffer* buffer);
 static gboolean on_idle_push_data (gpointer self);
@@ -65,7 +65,10 @@ static void clear_gmutex (GMutex *mutex);
 static void clear_gcond (GCond *mutex);
 
 static void
-on_cancelled (GCancellable* _sender, gpointer self) {
+on_cancelled (GCancellable* sender G_GNUC_UNUSED,
+              gpointer user_data) {
+  RygelGstSink *self = RYGEL_GST_SINK (user_data);
+
   rygel_gst_sink_on_cancelled (self);
 }
 
diff --git a/src/rygel-gst-sink.h b/src/rygel-gst-sink.h
index 9fc1ff2..46dde31 100644
--- a/src/rygel-gst-sink.h
+++ b/src/rygel-gst-sink.h
@@ -60,7 +60,15 @@ struct _RygelGstSinkClass {
 
 GType rygel_gst_sink_get_type (void) G_GNUC_CONST;
 
-RygelGstSink* rygel_gst_sink_new (RygelDataSource* source, RygelHTTPSeek* offsets);
+RygelGstSink *
+rygel_gst_sink_new (RygelDataSource* source,
+                    RygelHTTPSeek* offsets);
+
+void
+rygel_gst_sink_freeze (RygelGstSink* self);
+
+void
+rygel_gst_sink_thaw (RygelGstSink* self);
 
 G_END_DECLS
 
diff --git a/src/rygel-gst-utils.c b/src/rygel-gst-utils.c
index 3b6cb7d..30dae07 100644
--- a/src/rygel-gst-utils.c
+++ b/src/rygel-gst-utils.c
@@ -43,10 +43,11 @@ rygel_gst_utils_create_element (const gchar *factoryname, const gchar *name, GEr
   if (element) {
     gst_object_ref_sink (element);
   } else {
-    g_set_error (RYGEL_GST_ERROR,
-      RYGEL_GST_ERROR_MISSING_PLUGIN,
-      _("Required element %s missing"),
-      factoryname);
+    g_set_error (error,
+                 RYGEL_GST_ERROR,
+                 RYGEL_GST_ERROR_MISSING_PLUGIN,
+                 _("Required element %s missing"),
+                 factoryname);
   }
 
   return element;
@@ -102,11 +103,10 @@ rygel_gst_utils_dump_encoding_profile (GstEncodingProfile* profile, gint indent)
   }
 
   if (GST_IS_ENCODING_CONTAINER_PROFILE (profile)) {
-    GstEncodingContainerProfile* container = 
-      GST_ENCODING_CONTAINER_PROFILE (profile);
+    GstEncodingContainerProfile* container = GST_ENCODING_CONTAINER_PROFILE (profile);
 
-    GList* subprofile_collection = gst_encoding_container_profile_get_profiles (container);
-    GList* subprofile_it;
+    const GList* subprofile_collection = gst_encoding_container_profile_get_profiles (container);
+    const GList* subprofile_it;
     for (subprofile_it = subprofile_collection; subprofile_it != NULL; subprofile_it = subprofile_it->next) {
       GstEncodingProfile* subprofile = GST_ENCODING_PROFILE (subprofile_it->data);
       rygel_gst_utils_dump_encoding_profile (subprofile, indent + 4);
@@ -119,7 +119,6 @@ rygel_gst_utils_dump_encoding_profile (GstEncodingProfile* profile, gint indent)
 
 GstElement* rygel_gst_utils_get_rtp_depayloader (GstCaps* caps) {
   GList* features;
-  GList* temp;
   const gchar *feature_name;
 
   if (!rygel_gst_utils_need_rtp_depayloader (caps)) {
@@ -127,7 +126,6 @@ GstElement* rygel_gst_utils_get_rtp_depayloader (GstCaps* caps) {
   }
 
   features = gst_element_factory_list_get_elements ((GstElementFactoryListType) GST_ELEMENT_FACTORY_TYPE_DEPAYLOADER, GST_RANK_NONE);
-  temp = features;
   features = gst_element_factory_list_filter (features, caps, GST_PAD_SINK, FALSE);
   g_list_free_full (features, gst_object_unref);
 
@@ -159,13 +157,11 @@ static gboolean
 rygel_gst_utils_need_rtp_depayloader (GstCaps* caps) {
   const GstStructure* structure;
   const gchar *name;
-  gboolean result;
 
   g_return_val_if_fail (caps != NULL, FALSE);
 
   structure = gst_caps_get_structure (caps, (guint) 0);
   name = gst_structure_get_name (structure);
 
-  return g_strcmp0 (name, "application/x-rtp") == 0;
+  return (g_strcmp0 (name, "application/x-rtp") == 0);
 }
-
diff --git a/tests/test_simple.c b/tests/test_simple.c
index 5723728..8c8a773 100644
--- a/tests/test_simple.c
+++ b/tests/test_simple.c
@@ -22,7 +22,9 @@
 
 int main(int argc, char *argv[])
 {
+#if !GLIB_CHECK_VERSION(2,35,0)
   g_type_init ();
+#endif
   gst_init (&argc, &argv);
 
   /* Some very simple checks that the media engine can be instantiated



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