After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 581546 - Elements do_query function is broken
Elements do_query function is broken
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-python
0.10.22
Other All
: Normal normal
: 0.10.15
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2009-05-06 02:40 UTC by A2K
Modified: 2009-05-07 11:25 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Example gst.BaseSrc implementation with query handling (2.74 KB, application/octet-stream)
2009-05-06 08:50 UTC, Edward Hervey
Details
Warnings appear on this example (1.89 KB, text/plain)
2009-05-06 19:29 UTC, A2K
Details

Description A2K 2009-05-06 02:40:52 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
Comment 1 A2K 2009-05-06 03:04:53 UTC
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)
Comment 2 Edward Hervey 2009-05-06 08:48:58 UTC
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.
Comment 3 Edward Hervey 2009-05-06 08:50:37 UTC
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
Comment 4 A2K 2009-05-06 19:29:12 UTC
Created attachment 134124 [details]
Warnings appear on this example

Here is simple example where this bug appears.
Comment 5 A2K 2009-05-06 19:38:21 UTC
(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.
Comment 6 Edward Hervey 2009-05-07 11:25:34 UTC
confirmed fixed over IRC.

<[A2K]> bilboed-pi: successfully compiled after installing -base pre-release and bug does not appear any more