[PATCH 05/15] core: Add unref() functions to GrlMediaSourceFooSpec
- From: "Juan A. Suarez Romero" <jasuarez igalia com>
- To: grilo-list gnome org
- Subject: [PATCH 05/15] core: Add unref() functions to GrlMediaSourceFooSpec
- Date: Mon, 19 Jul 2010 20:33:54 +0200
Add grl_media_source_foo_spec_unref() to decrement reference.
When references counter reaches 0, the spec is destroyed, and its contents are
released.
---
src/grl-media-source.c | 117 ++++++++++++++++++++++++++++++++++++++++++++++++
src/grl-media-source.h | 12 +++++
2 files changed, 129 insertions(+), 0 deletions(-)
diff --git a/src/grl-media-source.c b/src/grl-media-source.c
index 89211b6..9f33c36 100644
--- a/src/grl-media-source.c
+++ b/src/grl-media-source.c
@@ -1313,6 +1313,123 @@ grl_media_source_remove_spec_ref (GrlMediaSourceRemoveSpec *rs)
return rs;
}
+void
+grl_media_source_browse_spec_unref (GrlMediaSourceBrowseSpec *bs)
+{
+ g_return_if_fail (bs);
+ g_return_if_fail (bs->ref_count > 0);
+
+ if (g_atomic_int_dec_and_test (&bs->ref_count)) {
+ if (bs->source) {
+ g_object_unref (bs->source);
+ }
+ if (bs->container) {
+ g_object_unref (bs->container);
+ }
+ if (bs->keys) {
+ g_list_free (bs->keys);
+ }
+ g_free (bs);
+ }
+}
+
+void
+grl_media_source_search_spec_unref (GrlMediaSourceSearchSpec *ss)
+{
+ g_return_if_fail (ss);
+ g_return_if_fail (ss->ref_count > 0);
+
+ if (g_atomic_int_dec_and_test (&ss->ref_count)) {
+ if (ss->source) {
+ g_object_unref (ss->source);
+ }
+ if (ss->text) {
+ g_free (ss->text);
+ }
+ if (ss->keys) {
+ g_list_free (ss->keys);
+ }
+ g_free (ss);
+ }
+}
+
+void
+grl_media_source_query_spec_unref (GrlMediaSourceQuerySpec *qs)
+{
+ g_return_if_fail (qs);
+ g_return_if_fail (qs->ref_count > 0);
+
+ if (g_atomic_int_dec_and_test (&qs->ref_count)) {
+ if (qs->source) {
+ g_object_unref (qs->source);
+ }
+ if (qs->query) {
+ g_free (qs->query);
+ }
+ if (qs->keys) {
+ g_list_free (qs->keys);
+ }
+ g_free (qs);
+ }
+}
+
+void
+grl_media_source_metadata_spec_unref (GrlMediaSourceMetadataSpec *ms)
+{
+ g_return_if_fail (ms);
+ g_return_if_fail (ms->ref_count > 0);
+
+ if (g_atomic_int_dec_and_test (&ms->ref_count)) {
+ if (ms->source) {
+ g_object_unref (ms->source);
+ }
+ if (ms->media) {
+ g_object_unref (ms->media);
+ }
+ if (ms->keys) {
+ g_list_free (ms->keys);
+ }
+ g_free (ms);
+ }
+}
+
+void
+grl_media_source_store_spec_unref (GrlMediaSourceStoreSpec *ss)
+{
+ g_return_if_fail (ss);
+ g_return_if_fail (ss->ref_count > 0);
+
+ if (g_atomic_int_dec_and_test (&ss->ref_count)) {
+ if (ss->source) {
+ g_object_unref (ss->source);
+ }
+ if (ss->parent) {
+ g_object_unref (ss->parent);
+ }
+ if (ss->media) {
+ g_object_unref (ss->media);
+ }
+ g_free (ss);
+ }
+}
+
+void
+grl_media_source_remove_spec_unref (GrlMediaSourceRemoveSpec *rs)
+{
+ g_return_if_fail (rs);
+ g_return_if_fail (rs->ref_count > 0);
+
+ if (g_atomic_int_dec_and_test (&rs->ref_count)) {
+ if (rs->source) {
+ g_object_unref (rs->source);
+ }
+ if (rs->media_id) {
+ g_free (rs->media_id);
+ }
+ g_free (rs);
+ }
+}
+
/**
* grl_media_source_browse:
* @source: a media source
diff --git a/src/grl-media-source.h b/src/grl-media-source.h
index 3b14505..589a9b7 100644
--- a/src/grl-media-source.h
+++ b/src/grl-media-source.h
@@ -364,6 +364,18 @@ GrlMediaSourceStoreSpec *grl_media_source_store_spec_ref (GrlMediaSourceStoreSpe
GrlMediaSourceRemoveSpec *grl_media_source_remove_spec_ref (GrlMediaSourceRemoveSpec *rs);
+void grl_media_source_browse_spec_unref (GrlMediaSourceBrowseSpec *bs);
+
+void grl_media_source_search_spec_unref (GrlMediaSourceSearchSpec *bs);
+
+void grl_media_source_query_spec_unref (GrlMediaSourceQuerySpec *bs);
+
+void grl_media_source_metadata_spec_unref (GrlMediaSourceMetadataSpec *bs);
+
+void grl_media_source_store_spec_unref (GrlMediaSourceStoreSpec *bs);
+
+void grl_media_source_remove_spec_unref (GrlMediaSourceRemoveSpec *bs);
+
guint grl_media_source_browse (GrlMediaSource *source,
GrlMedia *container,
const GList *keys,
--
1.7.0.4
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]