How to initialize GstAudio.AudioCdSrc() to handle audio CDs with Python and Gstreamer?

Pierre Equoy pierre.equoy at protonmail.com
Wed Apr 6 14:28:09 UTC 2022


Hello!

I'm trying to write a simple CD player using Python and Gstreamer on Ubuntu 20.04, with gstreamer 1.16.2 (but I tried on Ubuntu 22.04 with gstreamer 1.20.1 and have exactly the same issue).

I've managed to get an audio CD (CDDA) to play using Python and Gstreamer bindings using this naive method:

    import gi
    gi.require_version("Gst", "1.0")
    from gi.repository import Gst
    Gst.init(None)
    player = Gst.ElementFactory.make("playbin", "player")
    self.player.set_property("uri", "cdda://")
    player.set_state(Gst.State.PLAYING)

Later, I found reference documentation for GstAudio.AudioCdSrc[1] which seems to handle a lot of things I would like to do: get current track being played, get disc ID, seek to next/previous track, etc.

However, I don't understand how to initialize it.

If I run

    import gi
    gi.require_version("GstAudio", "1.0")
    from gi.repository import GstAudio
    mycd = GstAudio.AudioCdSrc()

the process crashes with the following error

    <stdin>:1: Warning: g_hash_table_lookup: assertion 'hash_table != NULL' failed
    <stdin>:1: Warning: g_hash_table_insert_internal: assertion 'hash_table != NULL' failed

    (process:218971): GStreamer-CRITICAL **: 12:36:06.604: gst_tag_register_static: assertion 'type != 0 && type != GST_TYPE_LIST' failed

    (process:218971): GStreamer-CRITICAL **: 12:36:06.604: gst_tag_register_static: assertion 'type != 0 && type != GST_TYPE_LIST' failed
    fish: “python3” terminated by signal SIGSEGV (Address boundary error)

How can I use GstAudio.AudioCdSrc to handle my CDDA needs?

Thanks in advance for any help you can provide!


[1] https://lazka.github.io/pgi-docs/GstAudio-1.0/classes/AudioCdSrc.html

--
Pierre


More information about the gstreamer-devel mailing list