[rygel-gst-0-10-fullscreen-renderer] some cleanup



commit 75f7333d06f14b7e5ad039ee05b6f8912b8ea061
Author: Murray Cumming <murrayc murrayc com>
Date:   Fri Jan 25 13:09:50 2013 +0100

    some cleanup

 src/rygel-playbin-player.c |  513 ++++++++++++++++----------------------------
 1 files changed, 181 insertions(+), 332 deletions(-)
---
diff --git a/src/rygel-playbin-player.c b/src/rygel-playbin-player.c
index cc69b9e..1ad5263 100644
--- a/src/rygel-playbin-player.c
+++ b/src/rygel-playbin-player.c
@@ -95,27 +95,19 @@ static gboolean rygel_playbin_player_real_seek (RygelMediaPlayer *base, gint64 t
 static gchar **rygel_playbin_player_real_get_protocols (RygelMediaPlayer *base, int *result_length1);
 static gchar **rygel_playbin_player_real_get_mime_types (RygelMediaPlayer *base, int *result_length1);
 static gboolean rygel_playbin_player_is_rendering_image (RygelPlaybinPlayer *self);
-static inline GstCaps* _dynamic_get_caps0 (GstElement *obj);
 static void rygel_playbin_player_bus_handler (RygelPlaybinPlayer *self, GstBus *bus, GstMessage *message);
 static inline gchar *_dynamic_get_uri1 (GstElement *obj);
 static inline gchar *_dynamic_get_uri2 (GstElement *obj);
 static gchar *rygel_playbin_player_generate_basic_didl (RygelPlaybinPlayer *self);
-static void rygel_playbin_player_on_source_setup (RygelPlaybinPlayer *self, GstElement *pipeline, GstElement *source);
-static inline void _dynamic_set_extra_headers3 (GstElement *obj, const GstStructure *value);
-static void rygel_playbin_player_on_uri_notify (RygelPlaybinPlayer *self, GParamSpec *pspec);
+static void rygel_playbin_player_on_source_setup (GstElement *sender, GstElement *source, gpointer user_data);
+static void rygel_playbin_player_on_uri_notify (GObject *sender, GParamSpec *pspec, gpointer user_data);
 static inline void _dynamic_set_auto_flush_bus4 (GstElement *obj, gboolean value);
-static void _rygel_playbin_player_on_source_setup_dynamic_source_setup0_ (GstElement *_sender, GstElement *source, gpointer self);
-void _dynamic_source_setup1_connect (gpointer obj, const char *signal_name, GCallback handler, gpointer data);
-static void _rygel_playbin_player_on_uri_notify_g_object_notify (GObject *_sender, GParamSpec *pspec, gpointer self);
 static void _rygel_playbin_player_bus_handler_gst_bus_message (GstBus *_sender, GstMessage *message, gpointer self);
 static inline void _dynamic_set_uri5 (GstElement *obj, const gchar *value);
-static inline gdouble _dynamic_get_volume6 (GstElement *obj);
 static inline void _dynamic_set_volume7 (GstElement *obj, gdouble value);
 static void rygel_playbin_player_finalize (GObject *obj);
 static void _vala_rygel_playbin_player_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec);
 static void _vala_rygel_playbin_player_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec);
-static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func);
-static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func);
 
 static const gchar *RYGEL_PLAYBIN_PLAYER_PROTOCOLS[2] = {"http-get", "rtsp"};
 static const gchar *RYGEL_PLAYBIN_PLAYER_MIME_TYPES[40] = {"audio/mpeg", "application/ogg", "audio/x-vorbis", "audio/x-vorbis+ogg", "audio/ogg", "audio/x-ms-wma", "audio/x-ms-asf", "audio/x-flac", "audio/x-flac+ogg", "audio/flac", "audio/mp4", "audio/vnd.dlna.adts", "audio/x-mod", "audio/x-wav", "audio/x-ac3", "audio/x-m4a", "audio/L16;rate=44100;channels=2", "audio/L16;rate=44100;channels=1", "audio/L16;channels=2;rate=44100", "audio/L16;channels=1;rate=44100", "audio/L16;rate=44100", "image/jpeg", "image/png", "video/x-theora", "video/x-theora+ogg", "video/x-oggm", "video/ogg", "video/x-dirac", "video/x-wmv", "video/x-wma", "video/x-msvideo", "video/x-3ivx", "video/x-3ivx", "video/x-matroska", "video/x-mkv", "video/mpeg", "video/mp4", "video/x-ms-asf", "video/x-xvid", "video/x-ms-wmv"};
@@ -158,6 +150,7 @@ rygel_playbin_player_get_default (void) {
 static gboolean rygel_playbin_player_real_seek (RygelMediaPlayer *base, gint64 time) {
   RygelPlaybinPlayer *self = RYGEL_PLAYBIN_PLAYER (base);
   g_return_val_if_fail (self, FALSE);
+  g_return_val_if_fail (self->priv->_playbin, FALSE);
 
   return gst_element_seek (self->priv->_playbin, 1.0, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH, GST_SEEK_TYPE_SET, time * GST_USECOND, GST_SEEK_TYPE_NONE, (gint64) (-1));
 }
@@ -210,68 +203,36 @@ rygel_playbin_player_real_get_mime_types (RygelMediaPlayer *base, int *result_le
 }
 
 
-static inline GstCaps* _dynamic_get_caps0 (GstElement *obj) {
-  GstCaps *result;
-  g_object_get (obj, "caps", &result, NULL);
-  return result;
-}
+static gboolean rygel_playbin_player_is_rendering_image (RygelPlaybinPlayer *self) {
+  GstElement* typefind = NULL;
+  GstCaps *caps = NULL;
+  GstStructure *structure = NULL;
+  const gchar *name = NULL;
+  gboolean result;
 
+  g_return_val_if_fail (self, FALSE);
+  g_return_val_if_fail (self->priv->_playbin, FALSE);
 
-static gpointer _gst_structure_copy0 (gpointer self) {
-  return self ? gst_structure_copy (self) : NULL;
-}
+  typefind = gst_bin_get_by_name (GST_BIN (self->priv->_playbin), "typefind");
+  g_return_val_if_fail (typefind, FALSE);
 
+  g_object_get (typefind, "caps", &caps, NULL);
+  g_return_val_if_fail (caps, FALSE);
+
+  structure = gst_caps_get_structure (caps, 0);
+  g_return_val_if_fail (structure, FALSE);
+
+  name = gst_structure_get_name (structure);
+  result = (g_strcmp0 (name, "image/jpeg") == 0) ||
+    (g_strcmp0 (name, "image/png") == 0);
 
-static gboolean rygel_playbin_player_is_rendering_image (RygelPlaybinPlayer *self) {
-  gboolean result = FALSE;
-  GstElement *typefind = NULL;
-  GstElement *_tmp0_;
-  GstElement *_tmp1_ = NULL;
-  GstElement *_tmp2_;
-  GstCaps *_tmp3_;
-  GstCaps *_tmp4_;
-  GstCaps *caps;
-  GstCaps *_tmp5_;
-  const GstStructure *_tmp6_ = NULL;
-  GstStructure *_tmp7_;
-  GstStructure *structure;
-  gboolean _tmp8_ = FALSE;
-  const GstStructure *_tmp9_;
-  const gchar *_tmp10_ = NULL;
-  gboolean _tmp13_;
-  g_return_val_if_fail (self != NULL, FALSE);
-  _tmp0_ = self->priv->_playbin;
-  _tmp1_ = gst_bin_get_by_name (G_TYPE_CHECK_INSTANCE_TYPE (_tmp0_, GST_TYPE_BIN) ? ((GstBin*) _tmp0_) : NULL, "typefind");
-  gst_object_unref (typefind);
-  typefind = _tmp1_;
-  _tmp2_ = typefind;
-  _tmp3_ = _dynamic_get_caps0 (_tmp2_);
-  _tmp4_ = _tmp3_;
-  caps = _tmp4_;
-  _tmp5_ = caps;
-  _tmp6_ = gst_caps_get_structure (_tmp5_, (guint) 0);
-  _tmp7_ = _gst_structure_copy0 (_tmp6_);
-  structure = _tmp7_;
-  _tmp9_ = structure;
-  _tmp10_ = gst_structure_get_name (_tmp9_);
-  if (g_strcmp0 (_tmp10_, "image/jpeg") == 0) {
-    _tmp8_ = TRUE;
-  } else {
-    const GstStructure *_tmp11_;
-    const gchar *_tmp12_ = NULL;
-    _tmp11_ = structure;
-    _tmp12_ = gst_structure_get_name (_tmp11_);
-    _tmp8_ = g_strcmp0 (_tmp12_, "image/png") == 0;
-  }
-  _tmp13_ = _tmp8_;
-  result = _tmp13_;
   gst_structure_free (structure);
   gst_caps_unref (caps);
   gst_object_unref (typefind);
+
   return result;
 }
 
-
 static inline gchar *_dynamic_get_uri1 (GstElement *obj) {
   gchar *result;
   g_object_get (obj, "uri", &result, NULL);
@@ -289,9 +250,9 @@ static inline gchar *_dynamic_get_uri2 (GstElement *obj) {
 static void rygel_playbin_player_bus_handler (RygelPlaybinPlayer *self, GstBus *bus, GstMessage *message) {
   GstMessage *_tmp0_;
   GstMessageType _tmp1_;
-  g_return_if_fail (self != NULL);
-  g_return_if_fail (bus != NULL);
-  g_return_if_fail (message != NULL);
+  g_return_if_fail (self);
+  g_return_if_fail (bus);
+  g_return_if_fail (message);
   _tmp0_ = message;
   _tmp1_ = _tmp0_->type;
   switch (_tmp1_) {
@@ -531,65 +492,6 @@ static void rygel_playbin_player_bus_handler (RygelPlaybinPlayer *self, GstBus *
 }
 
 
-static inline void _dynamic_set_extra_headers3 (GstElement *obj, const GstStructure *value) {
-  g_object_set (obj, "extra-headers", value, NULL);
-}
-
-
-static void rygel_playbin_player_on_source_setup (RygelPlaybinPlayer *self, GstElement *pipeline, GstElement *source) {
-  gboolean _tmp0_ = FALSE;
-  GstElement *_tmp1_;
-  GType _tmp2_ = 0UL;
-  const gchar *_tmp3_ = NULL;
-  gboolean _tmp5_;
-  g_return_if_fail (self != NULL);
-  g_return_if_fail (pipeline != NULL);
-  g_return_if_fail (source != NULL);
-  _tmp1_ = source;
-  _tmp2_ = G_TYPE_FROM_INSTANCE ((GObject*) _tmp1_);
-  _tmp3_ = g_type_name (_tmp2_);
-  if (g_strcmp0 (_tmp3_, "GstSoupHTTPSrc") == 0) {
-    const gchar *_tmp4_;
-    _tmp4_ = self->priv->transfer_mode;
-    _tmp0_ = _tmp4_ != NULL;
-  } else {
-    _tmp0_ = FALSE;
-  }
-  _tmp5_ = _tmp0_;
-  if (_tmp5_) {
-    const gchar *_tmp6_;
-    GstStructure *_tmp7_;
-    GstStructure *structure;
-    const GstStructure *_tmp8_;
-    const gchar *_tmp9_;
-    GValue _tmp10_ = {0};
-    GstElement *_tmp11_;
-    const GstStructure *_tmp12_;
-    _tmp6_ = self->priv->transfer_mode;
-    g_debug ("rygel-playbin-player.vala:427: Setting transfer mode to %s", _tmp6_);
-    _tmp7_ = gst_structure_empty_new ("Extra Headers");
-    structure = _tmp7_;
-    _tmp8_ = structure;
-    _tmp9_ = self->priv->transfer_mode;
-    g_value_init (&_tmp10_, G_TYPE_STRING);
-    g_value_set_string (&_tmp10_, _tmp9_);
-    gst_structure_set_value (_tmp8_, "transferMode.dlna.org", &_tmp10_);
-    G_IS_VALUE (&_tmp10_) ? (g_value_unset (&_tmp10_), NULL) : NULL;
-    _tmp11_ = source;
-    _tmp12_ = structure;
-    _dynamic_set_extra_headers3 (_tmp11_, _tmp12_);
-    gst_structure_free (structure);
-  }
-}
-
-
-static void rygel_playbin_player_on_uri_notify (RygelPlaybinPlayer *self, GParamSpec *pspec) {
-  g_return_if_fail (self != NULL);
-  g_return_if_fail (pspec != NULL);
-  self->priv->uri_update_hint = TRUE;
-}
-
-
 /**
  * Generate basic DIDLLite information.
  *
@@ -597,52 +499,37 @@ static void rygel_playbin_player_on_uri_notify (RygelPlaybinPlayer *self, GParam
  * minimum DIDLLite is always present if the URI is not empty.
  */
 static gchar *rygel_playbin_player_generate_basic_didl (RygelPlaybinPlayer *self) {
+  GUPnPDIDLLiteWriter *writer = NULL;
+  GUPnPDIDLLiteItem *item = NULL;
+  GUPnPDIDLLiteResource *resource = NULL;
+  GFile *file = NULL;
+  gchar *basename = NULL;
   gchar *result = NULL;
-  GUPnPDIDLLiteWriter *_tmp0_;
-  GUPnPDIDLLiteWriter *writer;
-  GUPnPDIDLLiteItem *_tmp1_ = NULL;
-  GUPnPDIDLLiteItem *item;
-  GUPnPDIDLLiteResource *_tmp2_ = NULL;
-  GUPnPDIDLLiteResource *resource;
-  const gchar *_tmp3_;
-  gchar *_tmp4_;
-  gchar *_tmp5_;
-  gchar *_tmp6_;
-  GFile *_tmp7_ = NULL;
-  GFile *_tmp8_;
-  GFile *file;
-  gchar *_tmp9_ = NULL;
-  gchar *_tmp10_;
-  gchar *_tmp11_ = NULL;
-  g_return_val_if_fail (self != NULL, NULL);
-  _tmp0_ = gupnp_didl_lite_writer_new (NULL);
-  writer = _tmp0_;
-  _tmp1_ = gupnp_didl_lite_writer_add_item (writer);
-  item = _tmp1_;
+
+  g_return_val_if_fail (self, NULL);
+
+  writer = gupnp_didl_lite_writer_new (NULL);
+
+  item = gupnp_didl_lite_writer_add_item (writer);
   gupnp_didl_lite_object_set_id ((GUPnPDIDLLiteObject*) item, "1");
   gupnp_didl_lite_object_set_parent_id ((GUPnPDIDLLiteObject*) item, "-1");
   gupnp_didl_lite_object_set_upnp_class ((GUPnPDIDLLiteObject*) item, "object.item");
-  _tmp2_ = gupnp_didl_lite_object_add_resource ((GUPnPDIDLLiteObject*) item);
-  resource = _tmp2_;
-  _tmp3_ = self->priv->_uri;
-  gupnp_didl_lite_resource_set_uri (resource, _tmp3_);
-  _tmp4_ = rygel_media_player_get_uri ((RygelMediaPlayer*) self);
-  _tmp5_ = _tmp4_;
-  _tmp6_ = _tmp5_;
-  _tmp7_ = g_file_new_for_uri (_tmp6_);
-  _tmp8_ = _tmp7_;
-  g_free (_tmp6_);
-  file = _tmp8_;
-  _tmp9_ = g_file_get_basename (file);
-  _tmp10_ = _tmp9_;
-  gupnp_didl_lite_object_set_title ((GUPnPDIDLLiteObject*) item, _tmp10_);
-  g_free (_tmp10_);
-  _tmp11_ = gupnp_didl_lite_writer_get_string (writer);
-  result = _tmp11_;
+
+  resource = gupnp_didl_lite_object_add_resource ((GUPnPDIDLLiteObject*) item);
+  gupnp_didl_lite_resource_set_uri (resource, self->priv->_uri);
+
+  file = g_file_new_for_uri (self->priv->_uri);
+  basename = g_file_get_basename (file);
+  gupnp_didl_lite_object_set_title ((GUPnPDIDLLiteObject*) item, basename);
+  g_free (basename);
+
+  result = gupnp_didl_lite_writer_get_string (writer);
+
   g_object_unref (file);
   g_object_unref (resource);
   g_object_unref (item);
   g_object_unref (writer);
+
   return result;
 }
 
@@ -651,21 +538,37 @@ static inline void _dynamic_set_auto_flush_bus4 (GstElement *obj, gboolean value
   g_object_set (obj, "auto-flush-bus", value, NULL);
 }
 
+static void rygel_playbin_player_on_source_setup (GstElement *sender, GstElement *source, gpointer user_data) {
+  RygelPlaybinPlayer *self = RYGEL_PLAYBIN_PLAYER (user_data);
 
-static void _rygel_playbin_player_on_source_setup_dynamic_source_setup0_ (GstElement *_sender, GstElement *source, gpointer self) {
-  rygel_playbin_player_on_source_setup (self, _sender, source);
-}
+  GstStructure *structure = NULL;
 
+  g_return_if_fail (self);
+  g_return_if_fail (source);
 
-void _dynamic_source_setup1_connect (gpointer obj, const char *signal_name, GCallback handler, gpointer data) {
-  g_signal_connect_object (obj, signal_name, handler, data, 0);
-}
+  //We do not use GST_IS_SOUP_HTTP_SRC(), to avoid a build-time dependency on gst-plugins-good,
+  //though it will be needed at runtime.
+  if ((g_strcmp0 (G_OBJECT_TYPE_NAME (source), "GstSoupHTTPSrc") == 0) &&
+    self->priv->transfer_mode) {
+    g_debug ("rygel-playbin-player.c: Setting transfer mode to %s", self->priv->transfer_mode);
+    
+    structure = gst_structure_empty_new ("Extra Headers");
+    gst_structure_set (structure, "transferMode.dlna.org", G_TYPE_STRING, self->priv->transfer_mode, NULL);
 
+    g_object_set (source, "extra-headers", structure, NULL);
 
-static void _rygel_playbin_player_on_uri_notify_g_object_notify (GObject *_sender, GParamSpec *pspec, gpointer self) {
-  rygel_playbin_player_on_uri_notify (self, pspec);
+    gst_structure_free (structure);
+  }
 }
 
+static void rygel_playbin_player_on_uri_notify (GObject *sender, GParamSpec *pspec, gpointer user_data) {
+  RygelPlaybinPlayer *self = RYGEL_PLAYBIN_PLAYER (user_data);
+
+  g_return_if_fail (self);
+  g_return_if_fail (pspec);
+
+  self->priv->uri_update_hint = TRUE;
+}
 
 static void _rygel_playbin_player_bus_handler_gst_bus_message (GstBus *_sender, GstMessage *message, gpointer self) {
   rygel_playbin_player_bus_handler (self, _sender, message);
@@ -673,29 +576,30 @@ static void _rygel_playbin_player_bus_handler_gst_bus_message (GstBus *_sender,
 
 
 static void rygel_playbin_player_setup_playbin (RygelPlaybinPlayer *self) {
-  GstElement *_tmp0_;
-  GstElement *_tmp1_;
-  GstElement *_tmp2_;
-  GstElement *_tmp3_;
-  GstElement *_tmp4_;
-  GstBus *_tmp5_ = NULL;
-  GstBus *bus;
-  g_return_if_fail (self != NULL);
+  GstBus *bus = NULL;
+
+  g_return_if_fail (self);
+  g_return_if_fail (self->priv->_playbin);
+
+  /* Needed to get "Stop" events from the playbin.
+   * We can do this because we have a bus watch.
+   */
   self->priv->duration_hint = FALSE;
   self->priv->is_live = FALSE;
-  _tmp0_ = self->priv->_playbin;
-  _dynamic_set_auto_flush_bus4 (_tmp0_, FALSE);
-  _tmp1_ = self->priv->_playbin;
-  _vala_assert (_tmp1_ != NULL, "this.playbin != null");
-  _tmp2_ = self->priv->_playbin;
-  _dynamic_source_setup1_connect (_tmp2_, "source_setup", (GCallback) _rygel_playbin_player_on_source_setup_dynamic_source_setup0_, self);
-  _tmp3_ = self->priv->_playbin;
-  g_signal_connect_object ((GObject*) _tmp3_, "notify::uri", (GCallback) _rygel_playbin_player_on_uri_notify_g_object_notify, self, 0);
-  _tmp4_ = self->priv->_playbin;
-  _tmp5_ = gst_element_get_bus (_tmp4_);
-  bus = _tmp5_;
+
+  g_object_set (self->priv->_playbin, "auto-flush-bus", FALSE, NULL);
+  g_assert (self->priv->_playbin);
+
+  g_signal_connect_object (self->priv->_playbin, "source_setup", (GCallback) rygel_playbin_player_on_source_setup, self, 0);
+  g_signal_connect_object (self->priv->_playbin, "notify::uri", (GCallback) rygel_playbin_player_on_uri_notify, self, 0);
+
+  /* Bus handler */
+  bus = gst_element_get_bus (self->priv->_playbin);
+  g_return_if_fail (bus);
+
   gst_bus_add_signal_watch (bus);
   g_signal_connect_object (bus, "message", (GCallback) _rygel_playbin_player_bus_handler_gst_bus_message, self, 0);
+
   gst_object_unref (bus);
 }
 
@@ -1049,15 +953,11 @@ static void rygel_playbin_player_real_set_mime_type (RygelMediaPlayer *base, con
 
 
 static gchar *rygel_playbin_player_real_get_metadata (RygelMediaPlayer *base) {
-  gchar *result;
-  RygelPlaybinPlayer *self;
-  const gchar *_tmp0_;
-  gchar *_tmp1_;
-  self = (RygelPlaybinPlayer*) base;
-  _tmp0_ = self->priv->_metadata;
-  _tmp1_ = g_strdup (_tmp0_);
-  result = _tmp1_;
-  return result;
+  RygelPlaybinPlayer *self = RYGEL_PLAYBIN_PLAYER (base);
+
+  g_return_val_if_fail (self, NULL);
+
+  return g_strdup (self->priv->_metadata);
 }
 
 
@@ -1076,30 +976,12 @@ static void rygel_playbin_player_real_set_metadata (RygelMediaPlayer *base, cons
 
 
 static gboolean rygel_playbin_player_real_get_can_seek (RygelMediaPlayer *base) {
-  gboolean result;
-  RygelPlaybinPlayer *self;
-  gboolean _tmp0_ = FALSE;
-  const gchar *_tmp1_;
-  gboolean _tmp6_;
-  self = (RygelPlaybinPlayer*) base;
-  _tmp1_ = self->priv->transfer_mode;
-  if (g_strcmp0 (_tmp1_, RYGEL_PLAYBIN_PLAYER_TRANSFER_MODE_INTERACTIVE) != 0) {
-    gchar *_tmp2_;
-    gchar *_tmp3_;
-    gchar *_tmp4_;
-    gboolean _tmp5_ = FALSE;
-    _tmp2_ = rygel_media_player_get_mime_type ((RygelMediaPlayer*) self);
-    _tmp3_ = _tmp2_;
-    _tmp4_ = _tmp3_;
-    _tmp5_ = g_str_has_prefix (_tmp4_, "image/");
-    _tmp0_ = !_tmp5_;
-    g_free (_tmp4_);
-  } else {
-    _tmp0_ = FALSE;
-  }
-  _tmp6_ = _tmp0_;
-  result = _tmp6_;
-  return result;
+  RygelPlaybinPlayer *self = RYGEL_PLAYBIN_PLAYER (base);
+
+  g_return_val_if_fail (self, FALSE);
+
+  return (g_strcmp0 (self->priv->transfer_mode, RYGEL_PLAYBIN_PLAYER_TRANSFER_MODE_INTERACTIVE) != 0) &&
+    g_str_has_prefix (self->priv->_mime_type, "image/");
 }
 
 
@@ -1143,7 +1025,7 @@ static void rygel_playbin_player_real_set_content_features (RygelMediaPlayer *ba
     GUPnPDLNAFlags _tmp11_;
     _tmp6_ = gupnp_protocol_info_new_from_string (pi_string, &_inner_error_);
     _tmp7_ = _tmp6_;
-    if (_inner_error_ != NULL) {
+    if (_inner_error_) {
       goto __catch0_g_error;
     }
     g_object_unref (self->priv->protocol_info);
@@ -1185,7 +1067,7 @@ static void rygel_playbin_player_real_set_content_features (RygelMediaPlayer *ba
     g_error_free (_error_);
   }
   __finally0:
-  if (_inner_error_ != NULL) {
+  if (_inner_error_) {
     g_free (pi_string);
     g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
     g_clear_error (&_inner_error_);
@@ -1199,95 +1081,58 @@ static void rygel_playbin_player_real_set_content_features (RygelMediaPlayer *ba
   g_object_notify (G_OBJECT (self), "content-features");
 }
 
+static gdouble rygel_playbin_player_real_get_volume (RygelMediaPlayer *base) {
+  RygelPlaybinPlayer *self = RYGEL_PLAYBIN_PLAYER (base);
 
-static inline gdouble _dynamic_get_volume6 (GstElement *obj) {
-  gdouble result;
-  g_object_get (obj, "volume", &result, NULL);
-  return result;
-}
-
+  g_return_val_if_fail (self, 0);
+  g_return_val_if_fail (self->priv->_playbin, 0);
 
-static gdouble rygel_playbin_player_real_get_volume (RygelMediaPlayer *base) {
-  gdouble result;
-  RygelPlaybinPlayer *self;
-  GstElement *_tmp0_;
-  gdouble _tmp1_;
-  gdouble _tmp2_;
-  self = (RygelPlaybinPlayer*) base;
-  _tmp0_ = self->priv->_playbin;
-  _tmp1_ = _dynamic_get_volume6 (_tmp0_);
-  _tmp2_ = _tmp1_;
-  result = _tmp2_;
+  gdouble result = 0;
+  g_object_get (self->priv->_playbin, "volume", &result, NULL);
   return result;
 }
 
 
-static inline void _dynamic_set_volume7 (GstElement *obj, gdouble value) {
-  g_object_set (obj, "volume", value, NULL);
-}
+static void rygel_playbin_player_real_set_volume (RygelMediaPlayer *base, gdouble value) {
+  RygelPlaybinPlayer *self = RYGEL_PLAYBIN_PLAYER (base);
 
+  g_return_if_fail (self);
 
-static void rygel_playbin_player_real_set_volume (RygelMediaPlayer *base, gdouble value) {
-  RygelPlaybinPlayer *self;
-  GstElement *_tmp0_;
-  gdouble _tmp1_;
-  gdouble _tmp2_;
-  self = (RygelPlaybinPlayer*) base;
-  _tmp0_ = self->priv->_playbin;
-  _tmp1_ = value;
-  _dynamic_set_volume7 (_tmp0_, _tmp1_);
-  _tmp2_ = value;
-  g_debug ("rygel-playbin-player.vala:240: volume set to %f.", _tmp2_);
+  g_object_set (self->priv->_playbin, "volume", value, NULL);
+
+  g_debug ("rygel-playbin-player.c: volume set to %f.", value);
   g_object_notify (G_OBJECT (self), "volume");
 }
 
 
 static gint64 rygel_playbin_player_real_get_duration (RygelMediaPlayer *base) {
-  gint64 result;
-  RygelPlaybinPlayer *self;
-  GstFormat format;
-  gint64 dur = 0LL;
-  GstElement *_tmp0_;
-  gint64 _tmp1_ = 0LL;
-  gboolean _tmp2_ = FALSE;
-  self = (RygelPlaybinPlayer*) base;
-  format = GST_FORMAT_TIME;
-  _tmp0_ = self->priv->_playbin;
-  _tmp2_ = gst_element_query_duration (_tmp0_, &format, &_tmp1_);
-  dur = _tmp1_;
-  if (_tmp2_) {
-    gint64 _tmp3_;
-    _tmp3_ = dur;
-    result = _tmp3_ / GST_USECOND;
-    return result;
+  RygelPlaybinPlayer *self = RYGEL_PLAYBIN_PLAYER (base);
+  GstFormat format = GST_FORMAT_TIME;
+  gint64 pos = 0LL;
+
+  g_return_val_if_fail (self, 0LL);
+  g_return_val_if_fail (self->priv->_playbin, 0LL);
+
+  if (gst_element_query_duration (self->priv->_playbin, &format, &pos)) {
+    return pos / GST_USECOND;
   } else {
-    result = (gint64) 0;
-    return result;
+    return 0LL;
   }
 }
 
 
 static gint64 rygel_playbin_player_real_get_position (RygelMediaPlayer *base) {
-  gint64 result;
-  RygelPlaybinPlayer *self;
-  GstFormat format;
+  RygelPlaybinPlayer *self = RYGEL_PLAYBIN_PLAYER (base);
+  GstFormat format = GST_FORMAT_TIME;
   gint64 pos = 0LL;
-  GstElement *_tmp0_;
-  gint64 _tmp1_ = 0LL;
-  gboolean _tmp2_ = FALSE;
-  self = (RygelPlaybinPlayer*) base;
-  format = GST_FORMAT_TIME;
-  _tmp0_ = self->priv->_playbin;
-  _tmp2_ = gst_element_query_position (_tmp0_, &format, &_tmp1_);
-  pos = _tmp1_;
-  if (_tmp2_) {
-    gint64 _tmp3_;
-    _tmp3_ = pos;
-    result = _tmp3_ / GST_USECOND;
-    return result;
+
+  g_return_val_if_fail (self, 0LL);
+  g_return_val_if_fail (self->priv->_playbin, 0LL);
+
+  if (gst_element_query_position (self->priv->_playbin, &format, &pos)) {
+    return pos / GST_USECOND;
   } else {
-    result = (gint64) 0;
-    return result;
+    return 0LL;
   }
 }
 
@@ -1340,38 +1185,59 @@ static void rygel_playbin_player_rygel_media_player_interface_init (RygelMediaPl
 
 
 static void rygel_playbin_player_init (RygelPlaybinPlayer *self) {
-  gchar *_tmp0_;
-  gchar *_tmp1_;
-  gchar *_tmp2_;
-  gchar *_tmp3_;
+  g_return_if_fail (self);
+
   self->priv = RYGEL_PLAYBIN_PLAYER_GET_PRIVATE (self);
-  _tmp0_ = g_strdup ("NO_MEDIA_PRESENT");
-  self->priv->_playback_state = _tmp0_;
+
+  self->priv->_playback_state = g_strdup ("NO_MEDIA_PRESENT");
   self->priv->transfer_mode = NULL;
   self->priv->uri_update_hint = FALSE;
   self->priv->_uri = NULL;
-  _tmp1_ = g_strdup ("");
-  self->priv->_mime_type = _tmp1_;
-  _tmp2_ = g_strdup ("");
-  self->priv->_metadata = _tmp2_;
-  _tmp3_ = g_strdup ("");
-  self->priv->_content_features = _tmp3_;
+  self->priv->_mime_type = NULL;
+  self->priv->_metadata = NULL;
+  self->priv->_content_features = NULL;
 }
 
 
 static void rygel_playbin_player_finalize (GObject *obj) {
-  RygelPlaybinPlayer *self;
-  self = G_TYPE_CHECK_INSTANCE_CAST (obj, RYGEL_TYPE_PLAYBIN_PLAYER, RygelPlaybinPlayer);
+  RygelPlaybinPlayer *self = RYGEL_PLAYBIN_PLAYER (obj);
+ 
+  g_return_if_fail (self);
+
   gst_object_unref (self->priv->_playbin);
-  g_free (self->priv->_playback_state);
-  self->priv->_allowed_playback_speeds = (_vala_array_free (self->priv->_allowed_playback_speeds, self->priv->_allowed_playback_speeds_length, (GDestroyNotify) g_free), NULL);
-  g_free (self->priv->_playback_speed);
-  g_free (self->priv->transfer_mode);
-  g_free (self->priv->_uri);
-  g_free (self->priv->_mime_type);
-  g_free (self->priv->_metadata);
-  g_free (self->priv->_content_features);
-  g_object_unref (self->priv->protocol_info);
+
+  if (self->priv->_playback_state)    
+    g_free (self->priv->_playback_state);
+
+  if (self->priv->_allowed_playback_speeds) {
+    int i;
+    for (i = 0; i < self->priv->_allowed_playback_speeds_length; i = i + 1) {
+      g_free (self->priv->_allowed_playback_speeds[i]);
+    }
+    g_free (self->priv->_allowed_playback_speeds);
+  }
+
+  if (self->priv->_playback_speed)
+    g_free (self->priv->_playback_speed);
+
+  if (self->priv->transfer_mode)
+    g_free (self->priv->transfer_mode);
+
+  if (self->priv->_uri)
+    g_free (self->priv->_uri);
+
+  if (self->priv->_mime_type)
+    g_free (self->priv->_mime_type);
+  
+  if (self->priv->_metadata)
+    g_free (self->priv->_metadata);
+  
+  if (self->priv->_content_features)
+    g_free (self->priv->_content_features);
+  
+  if (self->priv->protocol_info)
+    g_object_unref (self->priv->protocol_info);
+
   G_OBJECT_CLASS (rygel_playbin_player_parent_class)->finalize (obj);
 }
 
@@ -1460,20 +1326,3 @@ static void _vala_rygel_playbin_player_set_property (GObject *object, guint prop
   }
 }
 
-
-static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func) {
-  if ((array != NULL) && (destroy_func != NULL)) {
-    int i;
-    for (i = 0; i < array_length; i = i + 1) {
-      if (((gpointer*) array)[i] != NULL) {
-        destroy_func (((gpointer*) array)[i]);
-      }
-    }
-  }
-}
-
-
-static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func) {
-  _vala_array_destroy (array, array_length, destroy_func);
-  g_free (array);
-}



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