[Bug 644776] New: Macro to check check mutability in set_property functions

GStreamer (bugzilla.gnome.org) bugzilla at gnome.org
Mon Mar 14 16:41:46 PDT 2011


https://bugzilla.gnome.org/show_bug.cgi?id=644776
  GStreamer | gstreamer (core) | git

           Summary: Macro to check check mutability in set_property
                    functions
    Classification: Desktop
           Product: GStreamer
           Version: git
        OS/Version: All
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: Normal
         Component: gstreamer (core)
        AssignedTo: gstreamer-bugs at lists.freedesktop.org
        ReportedBy: olivier.crete at ocrete.ca
         QAContact: gstreamer-bugs at lists.freedesktop.org
      GNOME target: ---
     GNOME version: ---


Now that we have GST_PARAM_MUTABLE_*, we should add a way to enforce them.

I suggest having a macro like the following and putting it as the first line of
the set_property() function in the various elements after adding the mutability
flags.

#define GST_PARAM_CHECK_MUTABILITY(element, pspec) G_STMT_START {       \
  GstState state;                                                       \
                                                                        \
  g_return_if_fail ((element) != NULL && GST_IS_ELEMENT (element));     \
  GST_OBJECT_LOCK (element);                                            \
  state = GST_STATE (element);                                          \
  GST_OBJECT_UNLOCK (element);                                          \
  g_return_if_fail (state == GST_STATE_PLAYING ||                       \
      (pspec)->flags & GST_PARAM_MUTABLE_PLAYING);                      \
  g_return_if_fail (state >= GST_STATE_PAUSED ||                        \
      (pspec)->flags & GST_PARAM_MUTABLE_PAUSED);                       \
  g_return_if_fail (state >= GST_STATE_READY ||                         \
      (pspec)->flags & GST_PARAM_MUTABLE_READY);                        \
  } G_STMT_END

We may want to have a version that doesn't release the object lock if the
paramspec is mutable above NULL, since I guess for many cases, we'd want to
make the change atomic, but that means being a little more clever (and maybe we
want to use GST_ERROR_OBJECT() instead of g_warning .. maybe g_critical?

-- 
Configure bugmail: https://bugzilla.gnome.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the gstreamer-bugs mailing list