GNOME Bugzilla – Bug 581546
Elements do_query function is broken
Last modified: 2009-05-07 11:25:34 UTC
Steps to reproduce: 1. Create a new source element inherited from gst.BaseSrc 2. Implement source's "query" method 3. Try to use it Stack trace: This warning are repeated on every query: (PlayerGST2.py:15688): GStreamer-CRITICAL **: gst_query_get_structure: assertion `GST_IS_QUERY (query)' failed (PlayerGST2.py:15688): GStreamer-CRITICAL **: gst_structure_id_get_value: assertion `structure != NULL' failed sys:1: Warning: g_value_get_boolean: assertion `G_VALUE_HOLDS_BOOLEAN (value)' failed (PlayerGST2.py:15688): GStreamer-CRITICAL **: gst_structure_id_get_value: assertion `structure != NULL' failed sys:1: Warning: g_value_get_uint64: assertion `G_VALUE_HOLDS_UINT64 (value)' failed (PlayerGST2.py:15688): GStreamer-CRITICAL **: gst_structure_id_get_value: assertion `structure != NULL' failed sys:1: Warning: invalid unclassed pointer in cast to `GstMiniObject' (PlayerGST2.py:15688): GStreamer-CRITICAL **: gst_mini_object_unref: assertion `mini_object->refcount > 0' failed (PlayerGST2.py:15688): GStreamer-CRITICAL **: gst_query_get_structure: assertion `GST_IS_QUERY (query)' failed (PlayerGST2.py:15688): GStreamer-CRITICAL **: gst_structure_id_get_value: assertion `structure != NULL' failed PlayerGST2.py:125: Warning: g_value_get_int64: assertion `G_VALUE_HOLDS_INT64 (value)' failed Other information: Everything is ok with gstreamer-python 0.10.13
Example code: class Source(gst.BaseSrc): __gsttemplates__ = ( gst.PadTemplate("src", gst.PAD_SRC, gst.PAD_ALWAYS, gst.caps_new_any()), ) blocksize = 4096 def __init__(self, name, config, track): self.__gobject_init__() self.set_name(name) self.buf = Buffer(track, config=config) #my class that downloads file def do_create(self, offset, size): if self.buf.length and offset > self.buf.length: return gst.FLOW_UNEXPECTED, None while self.buf.pos < offset+size and not self.buf.finished: sleep(0.1) # i don't know should i use this here self.buf.file.seek(offset) data = self.buf.file.read(size) return gst.FLOW_OK, gst.Buffer(data) def do_query (self, query): if query.type == gst.QUERY_DURATION: while not self.buf.track.length: sleep(0.01) if query.parse_duration()[0] == gst.FORMAT_TIME: lent = self.buf.track.length*gst.SECOND query.set_duration(gst.FORMAT_TIME, lent) query.stucture = gst.Query return True elif query.parse_duration()[0] == gst.FORMAT_BYTES: query.set_duration(format=gst.FORMAT_BYTES, duration=self.buf.length/self.blocksize) return True else: return False return False elif query.type == gst.QUERY_LATENCY: query.set_latency(min_latency=0, live=False, max_latency=-1) return True else: print 'UNHANDLED QUERY:', query.type return False #use this as a source for pipeline: player = gst.Pipeline("pipeline") source = Source("bufsrc", config, track) decoder = gst.element_factory_make("mad", "mp3-decoder") conv = gst.element_factory_make("audioconvert", "converter") sink = gst.element_factory_make("autoaudiosink", "alsa-output") player.add(source, decoder, conv, sink) gst.element_link_many(source, decoder, conv, sink)
I can't test this code (it's missing config, Buffer, etc...). The following seems wrong though : query.structure = gst.Query (1) you're assigning a class and not an instance (2) structure take .. a gst.Structure and not a gst.Query I've just rechecked on another gst.BaseSrc plugin I had, implemented the query handling... and it seems to work perfectly fine.
Created attachment 134086 [details] Example gst.BaseSrc implementation with query handling This is the example gst.BaseSrc implementation I was talking about. Works fine with the gst-python pre-releases
Created attachment 134124 [details] Warnings appear on this example Here is simple example where this bug appears.
(In reply to comment #3) > Created an attachment (id=134086) [edit] > Example gst.BaseSrc implementation with query handling > > This is the example gst.BaseSrc implementation I was talking about. Works fine > with the gst-python pre-releases > I get same warning on your example with gstreamer0.10-python-0.10.14 on ArchLinux and Ubuntu.
confirmed fixed over IRC. <[A2K]> bilboed-pi: successfully compiled after installing -base pre-release and bug does not appear any more