[farsight2/master] Use g_return_val_if_fail instead of gerror if a compulsory method is not implemented in conference

Olivier Crête olivier.crete at collabora.co.uk
Tue Dec 23 15:24:12 PST 2008


---
 gst-libs/gst/farsight/fs-base-conference.c  |   32 ++++++++++----------------
 gst-libs/gst/farsight/fs-conference-iface.c |   18 +++++----------
 2 files changed, 18 insertions(+), 32 deletions(-)

diff --git a/gst-libs/gst/farsight/fs-base-conference.c b/gst-libs/gst/farsight/fs-base-conference.c
index 57ab143..5cdc037 100644
--- a/gst-libs/gst/farsight/fs-base-conference.c
+++ b/gst-libs/gst/farsight/fs-base-conference.c
@@ -151,20 +151,16 @@ fs_base_conference_new_session (FsConference *conf,
 
   FsSession *new_session = NULL;
 
-  if (klass->new_session) {
-    new_session = klass->new_session (base_conf, media_type, error);
-
-    if (!new_session)
-      return NULL;
-
-    /* Let's catch all session errors and send them over the GstBus */
-    g_signal_connect (new_session, "error",
-        G_CALLBACK (fs_base_conference_error), base_conf);
-  } else {
-    GST_WARNING_OBJECT (conf, "new_session not defined in element");
-    g_set_error (error, FS_ERROR, FS_ERROR_CONSTRUCTION,
-      "new_session not defined in element");
-  }
+  g_return_val_if_fail (klass->new_session, NULL);
+
+  new_session = klass->new_session (base_conf, media_type, error);
+
+  if (!new_session)
+    return NULL;
+
+  /* Let's catch all session errors and send them over the GstBus */
+  g_signal_connect (new_session, "error",
+      G_CALLBACK (fs_base_conference_error), base_conf);
 
   return new_session;
 }
@@ -217,11 +213,7 @@ fs_base_conference_new_participant (FsConference *conf,
   FsBaseConference *baseconf = FS_BASE_CONFERENCE (conf);
   FsBaseConferenceClass *klass = FS_BASE_CONFERENCE_GET_CLASS (conf);
 
-  if (klass->new_participant) {
-    return klass->new_participant (baseconf, cname, error);
-  } else {
-    GST_WARNING_OBJECT (conf, "new_session not defined in element");
-  }
+  g_return_val_if_fail (klass->new_participant, NULL);
 
-  return NULL;
+  return klass->new_participant (baseconf, cname, error);
 }
diff --git a/gst-libs/gst/farsight/fs-conference-iface.c b/gst-libs/gst/farsight/fs-conference-iface.c
index 4646497..66d35a5 100644
--- a/gst-libs/gst/farsight/fs-conference-iface.c
+++ b/gst-libs/gst/farsight/fs-conference-iface.c
@@ -121,12 +121,9 @@ fs_conference_new_session (FsConference *conference, FsMediaType media_type,
   FsConferenceClass *iface =
       FS_CONFERENCE_GET_IFACE (conference);
 
-  if (iface->new_session) {
-    return iface->new_session (conference, media_type, error);
-  } else {
-    GST_WARNING_OBJECT (conference, "new_session not defined in element");
-  }
-  return NULL;
+  g_return_val_if_fail (iface->new_session, NULL);
+
+  return iface->new_session (conference, media_type, error);
 }
 
 
@@ -148,10 +145,7 @@ fs_conference_new_participant (FsConference *conference, gchar *cname,
   FsConferenceClass *iface =
       FS_CONFERENCE_GET_IFACE (conference);
 
-  if (iface->new_session) {
-    return iface->new_participant (conference, cname, error);
-  } else {
-    GST_WARNING_OBJECT (conference, "new_participant not defined in element");
-  }
-  return NULL;
+  g_return_val_if_fail (iface->new_participant, NULL);
+
+  return iface->new_participant (conference, cname, error);
 }
-- 
1.5.6.5




More information about the farsight-commits mailing list