[gstreamer-bugs] [Bug 510301] GstStructure immutability problem when creating new C++ bindings

GStreamer (bugzilla.gnome.org) bugzilla-daemon at bugzilla.gnome.org
Mon Jan 21 15:56:46 PST 2008


If you have any questions why you received this email, please see the text at
the end of this email. Replies to this email are NOT read, please see the text
at the end of this email. You can add comments to this bug at:
  http://bugzilla.gnome.org/show_bug.cgi?id=510301

  GStreamer | gstreamer (core) | Ver: 0.10.15




------- Comment #1 from José Alburquerque  2008-01-21 23:56 UTC -------
I'm not sure it's a bug, but to confirm that GstQuery cannot be referenced more
than once before being processed, run the attached ogg player program (taken
from Chapter 10 of the GStreamer Application Development Manual) where the
GstQuery is referenced after being created and then sent to the pipeline in the
cb_print_position() function.  The warnings are generated each time the program
attempts to query the stream position for output.

The reason I'm reporting this is because I foresee possible bug reports in the
C++ bindings when people begin to use it.  As I explained, the Queries in C++
will need to be cast for parsing, and the order of the casting (whether before
or after being sent) cannot be predicted.  If the cast occurs before, warnings
will be generated (unless we warn users of bindings not do this :-)).

We've written the same program I've attached to this report using the new
bindings and it produces the same results as the attached program.  The C++
version is found in the examples/ogg_player directory of the binding's trunk
(revision 1296) and may be tested by building the bindings and executing the
examples/ogg_player/oggplayer executable.

I'd like to explain my concern:  The relevant C++ code snippet is the
following:

bool print_stream_position(void)
{
 Gst::Format fmt = Gst::FORMAT_TIME;
 gint64 pos = 0;
 gint64 len = 0;

 Glib::RefPtr<Gst::Query> query = Gst::QueryPosition::create(fmt);

   Glib::RefPtr<Gst::QueryPosition> posQuery =
        Glib::RefPtr<Gst::QueryPosition>::cast_dynamic(query);

 if (pipeline->query(query)
   && pipeline->query_duration(fmt, len)) {

   ...
  }
  return true;
}

A Query is created by calling the Gst::QueryPosition:create() method (which is
the same as calling gst_query_position_new).

As I explained in the report, the Glib::RefPtr<> is an "auto pointer" class
that keeps automatic glib reference counting for the class between the <> by
unreferencing the object if it goes out of scope).  However, the casting (the
second Glib::RefPtr<...>(...) statement) also references the Query and the
procesing of the query (in the if statement condition) produces the same
warnings as the C code I've attached.  If the cast statement is placed inside
the if block, however, the warnings go away (because the Query is not
referenced a second time before being processed).

I'm reporting this in case this might be something that might also affect
gstreamer because a GstQuery might be referenced more than once in C code also.
 If it does affect gstreamer and it is a bug, fixing it for gstreamer would fix
it for the C++ bindings we're developing also.  If not, we will have to deal
with the possible reports or try to warn developers not to cast Queries until
after they've been processed.  Thanks for your attention.


-- 
See http://bugzilla.gnome.org/page.cgi?id=email.html for more info about why you received
this email, why you can't respond via email, how to stop receiving
emails (or reduce the number you receive), and how to contact someone
if you are having problems with the system.

You can add comments to this bug at http://bugzilla.gnome.org/show_bug.cgi?id=510301.




More information about the Gstreamer-bugs mailing list