[rygel-gst-0-10-plugins] Cleanup RygelMediaExportVideoItem
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel-gst-0-10-plugins] Cleanup RygelMediaExportVideoItem
- Date: Wed, 30 Jan 2013 10:48:00 +0000 (UTC)
commit 13fde8b3ac1bfbbd2411a07e9b0646b3f7f4c342
Author: Murray Cumming <murrayc murrayc com>
Date: Wed Jan 30 11:47:54 2013 +0100
Cleanup RygelMediaExportVideoItem
src/media-export/rygel-media-export-music-item.c | 26 ++--
src/media-export/rygel-media-export-video-item.c | 183 +++++++++-------------
2 files changed, 85 insertions(+), 124 deletions(-)
---
diff --git a/src/media-export/rygel-media-export-music-item.c b/src/media-export/rygel-media-export-music-item.c
index 4433db0..369d6a4 100644
--- a/src/media-export/rygel-media-export-music-item.c
+++ b/src/media-export/rygel-media-export-music-item.c
@@ -32,8 +32,6 @@ static void rygel_media_export_music_item_real_commit (RygelUpdatableObject *bas
/* TODO: Remove the construct function? */
RygelMediaExportMusicItem *rygel_media_export_music_item_construct (GType object_type, const gchar *id, RygelMediaContainer *parent, const gchar *title, const gchar *upnp_class) {
- RygelMediaExportMusicItem *self;
-
g_return_val_if_fail (id, NULL);
g_return_val_if_fail (parent, NULL);
g_return_val_if_fail (title, NULL);
@@ -42,12 +40,13 @@ RygelMediaExportMusicItem *rygel_media_export_music_item_construct (GType object
return RYGEL_MEDIA_EXPORT_MUSIC_ITEM (rygel_music_item_construct (object_type, id, parent, title, upnp_class));
}
-
-RygelMediaExportMusicItem *rygel_media_export_music_item_new (const gchar *id, RygelMediaContainer *parent, const gchar *title, const gchar *upnp_class) {
+RygelMediaExportMusicItem*
+rygel_media_export_music_item_new (const gchar *id, RygelMediaContainer *parent, const gchar *title, const gchar *upnp_class) {
return rygel_media_export_music_item_construct (RYGEL_MEDIA_EXPORT_TYPE_MUSIC_ITEM, id, parent, title, upnp_class);
}
-static void rygel_media_export_music_item_real_commit (RygelUpdatableObject *base, GAsyncReadyCallback callback, gpointer user_data) {
+static void
+rygel_media_export_music_item_real_commit (RygelUpdatableObject *base, GAsyncReadyCallback callback, gpointer user_data) {
RygelMediaExportMusicItem *self = RYGEL_MEDIA_EXPORT_MUSIC_ITEM (base);
g_return_if_fail (self);
@@ -86,20 +85,21 @@ static void rygel_media_export_music_item_real_commit (RygelUpdatableObject *bas
g_object_unref (cache);
}
-
-static void rygel_media_export_music_item_real_commit_finish (RygelUpdatableObject *base G_GNUC_UNUSED, GAsyncResult *_res_, GError **error) {
- g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (_res_), error);
+static void
+rygel_media_export_music_item_real_commit_finish (RygelUpdatableObject *base G_GNUC_UNUSED, GAsyncResult *result, GError **error) {
+ g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result), error);
}
-
-static void rygel_media_export_music_item_class_init (RygelMediaExportMusicItemClass *klass G_GNUC_UNUSED) {
+static void
+rygel_media_export_music_item_class_init (RygelMediaExportMusicItemClass *klass G_GNUC_UNUSED) {
}
-
-static void rygel_media_export_music_item_rygel_updatable_object_interface_init (RygelUpdatableObjectIface *iface) {
+static void
+rygel_media_export_music_item_rygel_updatable_object_interface_init (RygelUpdatableObjectIface *iface) {
iface->commit = rygel_media_export_music_item_real_commit;
iface->commit_finish = rygel_media_export_music_item_real_commit_finish;
}
-static void rygel_media_export_music_item_init (RygelMediaExportMusicItem *self G_GNUC_UNUSED) {
+static void
+rygel_media_export_music_item_init (RygelMediaExportMusicItem *self G_GNUC_UNUSED) {
}
diff --git a/src/media-export/rygel-media-export-video-item.c b/src/media-export/rygel-media-export-video-item.c
index 828b525..83e443c 100644
--- a/src/media-export/rygel-media-export-video-item.c
+++ b/src/media-export/rygel-media-export-video-item.c
@@ -1,8 +1,7 @@
/*
- * Copyright (C) 2012 Intel Corporation.
+ * Copyright (C) 2012, 2013 Intel Corporation.
*
* Author: Jens Georg <jensg openismus com>
- * Copyright (C) 2012 Intel Corporation.
*
* This file is part of Rygel.
*
@@ -24,8 +23,8 @@
#include "rygel-media-export-video-item.h"
#include "rygel-media-export-media-cache.h"
-static void rygel_media_export_video_item_rygel_trackable_item_interface_init (RygelTrackableItemIface * iface);
-static void rygel_media_export_video_item_rygel_updatable_object_interface_init (RygelUpdatableObjectIface * iface);
+static void rygel_media_export_video_item_rygel_trackable_item_interface_init (RygelTrackableItemIface *iface);
+static void rygel_media_export_video_item_rygel_updatable_object_interface_init (RygelUpdatableObjectIface *iface);
G_DEFINE_TYPE_WITH_CODE (RygelMediaExportVideoItem, rygel_media_export_video_item, RYGEL_TYPE_VIDEO_ITEM,
G_IMPLEMENT_INTERFACE (RYGEL_TYPE_TRACKABLE_ITEM, rygel_media_export_video_item_rygel_trackable_item_interface_init)
@@ -34,132 +33,94 @@ G_DEFINE_TYPE_WITH_CODE (RygelMediaExportVideoItem, rygel_media_export_video_ite
typedef struct _RygelMediaExportVideoItemCommitData RygelMediaExportVideoItemCommitData;
struct _RygelMediaExportVideoItemCommitData {
- int _state_;
- GObject* _source_object_;
- GAsyncResult* _res_;
- GSimpleAsyncResult* _async_result;
- RygelMediaExportVideoItem* self;
- RygelMediaExportMediaCache* _tmp0_;
- RygelMediaExportMediaCache* cache;
- RygelMediaExportMediaCache* _tmp1_;
- GError * _inner_error_;
+ int _state_;
+ GObject *_source_object_;
+ GAsyncResult *result;
+ GSimpleAsyncResult *_async_result;
+ RygelMediaExportVideoItem *self;
+ RygelMediaExportMediaCache *_tmp0_;
+ RygelMediaExportMediaCache *cache;
+ RygelMediaExportMediaCache *_tmp1_;
+ GError *_inner_error_;
};
-static void rygel_media_export_video_item_real_commit_data_free (gpointer _data);
-static void rygel_media_export_video_item_real_commit (RygelUpdatableObject* base, GAsyncReadyCallback _callback_, gpointer _user_data_);
-static gboolean rygel_media_export_video_item_real_commit_co (RygelMediaExportVideoItemCommitData* _data_);
-
-static
-RygelMediaExportVideoItem* rygel_media_export_video_item_construct (GType object_type, const gchar* id, RygelMediaContainer* parent, const gchar* title, const gchar* upnp_class) {
- RygelMediaExportVideoItem * self = NULL;
- const gchar* _tmp0_;
- RygelMediaContainer* _tmp1_;
- const gchar* _tmp2_;
- const gchar* _tmp3_;
- g_return_val_if_fail (id != NULL, NULL);
- g_return_val_if_fail (parent != NULL, NULL);
- g_return_val_if_fail (title != NULL, NULL);
- g_return_val_if_fail (upnp_class != NULL, NULL);
- _tmp0_ = id;
- _tmp1_ = parent;
- _tmp2_ = title;
- _tmp3_ = upnp_class;
- self = (RygelMediaExportVideoItem*) rygel_video_item_construct (object_type, _tmp0_, _tmp1_, _tmp2_, _tmp3_);
- return self;
-}
-
-
-RygelMediaExportVideoItem* rygel_media_export_video_item_new (const gchar* id, RygelMediaContainer* parent, const gchar* title, const gchar* upnp_class) {
- return rygel_media_export_video_item_construct (RYGEL_MEDIA_EXPORT_TYPE_VIDEO_ITEM, id, parent, title, upnp_class);
-}
+static void rygel_media_export_video_item_real_commit (RygelUpdatableObject *base, GAsyncReadyCallback _callback_, gpointer _user_data_);
+/* TODO: Remove the construct function? */
+static RygelMediaExportVideoItem*
+rygel_media_export_video_item_construct (GType object_type, const gchar *id, RygelMediaContainer *parent, const gchar *title, const gchar *upnp_class) {
+ g_return_val_if_fail (id, NULL);
+ g_return_val_if_fail (parent, NULL);
+ g_return_val_if_fail (title, NULL);
+ g_return_val_if_fail (upnp_class, NULL);
-static void rygel_media_export_video_item_real_commit_data_free (gpointer _data) {
- RygelMediaExportVideoItemCommitData* _data_;
- _data_ = _data;
- g_object_unref (_data_->self);
- g_slice_free (RygelMediaExportVideoItemCommitData, _data_);
+ return RYGEL_MEDIA_EXPORT_VIDEO_ITEM (rygel_video_item_construct (object_type, id, parent, title, upnp_class));
}
-static void rygel_media_export_video_item_real_commit (RygelUpdatableObject* base, GAsyncReadyCallback _callback_, gpointer _user_data_) {
- RygelMediaExportVideoItem * self;
- RygelMediaExportVideoItemCommitData* _data_;
- RygelMediaExportVideoItem* _tmp0_;
- self = (RygelMediaExportVideoItem*) base;
- _data_ = g_slice_new0 (RygelMediaExportVideoItemCommitData);
- _data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, rygel_media_export_video_item_real_commit);
- g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, rygel_media_export_video_item_real_commit_data_free);
- _tmp0_ = g_object_ref (self);
- _data_->self = _tmp0_;
- rygel_media_export_video_item_real_commit_co (_data_);
+RygelMediaExportVideoItem*
+rygel_media_export_video_item_new (const gchar *id, RygelMediaContainer *parent, const gchar *title, const gchar *upnp_class) {
+ return rygel_media_export_video_item_construct (RYGEL_MEDIA_EXPORT_TYPE_VIDEO_ITEM, id, parent, title, upnp_class);
}
-
-static void rygel_media_export_video_item_real_commit_finish (RygelUpdatableObject* base G_GNUC_UNUSED, GAsyncResult* _res_, GError** error) {
- g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (_res_), error);
+static void rygel_media_export_video_item_real_commit (RygelUpdatableObject *base, GAsyncReadyCallback callback, gpointer user_data) {
+ RygelMediaExportVideoItem *self = RYGEL_MEDIA_EXPORT_VIDEO_ITEM (base);
+
+ g_return_if_fail (self);
+ g_return_if_fail (callback);
+
+ /* Setup the async result.
+ */
+ GSimpleAsyncResult *async_result =
+ g_simple_async_result_new (G_OBJECT (self), callback, user_data,
+ rygel_media_export_video_item_real_commit);
+
+ /* Do the work that could take a while.
+ */
+ GError *error = NULL;
+ RygelMediaExportMediaCache *cache =
+ rygel_media_export_media_cache_get_default (&error);
+ if (!error) {
+ rygel_media_export_media_cache_save_item (cache,
+ RYGEL_MEDIA_ITEM (self), &error);
+ }
+
+ /* Set any error in the async result, if necessary.
+ */
+ if (error) {
+ g_simple_async_result_set_from_error (async_result, error);
+ g_error_free (error);
+ }
+
+ /* Let the caller know that the async operation is finished,
+ * and that its result is now available.
+ */
+ g_simple_async_result_complete (async_result);
+
+ /* Free our data structure. */
+ g_object_unref (async_result);
+ g_object_unref (cache);
}
-
-static gboolean rygel_media_export_video_item_real_commit_co (RygelMediaExportVideoItemCommitData* _data_) {
- switch (_data_->_state_) {
- case 0:
- goto _state_0;
- default:
- g_assert_not_reached ();
- }
- _state_0:
- _data_->_tmp0_ = NULL;
- _data_->_tmp0_ = rygel_media_export_media_cache_get_default (&_data_->_inner_error_);
- _data_->cache = _data_->_tmp0_;
- if (_data_->_inner_error_ != NULL) {
- g_simple_async_result_set_from_error (_data_->_async_result, _data_->_inner_error_);
- g_error_free (_data_->_inner_error_);
- if (_data_->_state_ == 0) {
- g_simple_async_result_complete_in_idle (_data_->_async_result);
- } else {
- g_simple_async_result_complete (_data_->_async_result);
- }
- g_object_unref (_data_->_async_result);
- return FALSE;
- }
- _data_->_tmp1_ = _data_->cache;
- rygel_media_export_media_cache_save_item (_data_->_tmp1_, (RygelMediaItem*) _data_->self, &_data_->_inner_error_);
- if (_data_->_inner_error_ != NULL) {
- g_simple_async_result_set_from_error (_data_->_async_result, _data_->_inner_error_);
- g_error_free (_data_->_inner_error_);
- g_object_unref (_data_->cache);
- if (_data_->_state_ == 0) {
- g_simple_async_result_complete_in_idle (_data_->_async_result);
- } else {
- g_simple_async_result_complete (_data_->_async_result);
- }
- g_object_unref (_data_->_async_result);
- return FALSE;
- }
- g_object_unref (_data_->cache);
- if (_data_->_state_ == 0) {
- g_simple_async_result_complete_in_idle (_data_->_async_result);
- } else {
- g_simple_async_result_complete (_data_->_async_result);
- }
- g_object_unref (_data_->_async_result);
- return FALSE;
+static void
+rygel_media_export_video_item_real_commit_finish (RygelUpdatableObject *base G_GNUC_UNUSED, GAsyncResult *result, GError* *error) {
+ g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result), error);
}
-
-static void rygel_media_export_video_item_class_init (RygelMediaExportVideoItemClass * klass) {
- rygel_media_export_video_item_parent_class = g_type_class_peek_parent (klass);
+static void
+rygel_media_export_video_item_class_init (RygelMediaExportVideoItemClass *klass) {
+ rygel_media_export_video_item_parent_class = g_type_class_peek_parent (klass);
}
-static void rygel_media_export_video_item_rygel_trackable_item_interface_init (RygelTrackableItemIface * iface G_GNUC_UNUSED) {
+static void
+rygel_media_export_video_item_rygel_trackable_item_interface_init (RygelTrackableItemIface *iface G_GNUC_UNUSED) {
}
-static void rygel_media_export_video_item_rygel_updatable_object_interface_init (RygelUpdatableObjectIface * iface) {
+static void rygel_media_export_video_item_rygel_updatable_object_interface_init (RygelUpdatableObjectIface *iface) {
iface->commit = rygel_media_export_video_item_real_commit;
iface->commit_finish = rygel_media_export_video_item_real_commit_finish;
}
-
-static void rygel_media_export_video_item_init (RygelMediaExportVideoItem * self G_GNUC_UNUSED) {
+static void
+rygel_media_export_video_item_init (RygelMediaExportVideoItem *self G_GNUC_UNUSED) {
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]