Official way to stop a pipeline in Python?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Official way to stop a pipeline in Python?

pisymbol .
I have an application that worked fine on Ubuntu 16.04 but now hangs on Ubuntu 18.04 when I try to stop my pipeline.

Here is how I am initializing my pipeline;:

self.recorderBin = Gst.parse_bin_from_description(RECORD_PIPELINE, False)
self.recorderPipeline = Gst.Pipeline()
self.recorderPipeline.add(self.recorderBin)
bus = self.recorderPipeline.get_bus()
bus.add_watch(GLib.PRIORITY_DEFAULT, self._on_message)

At some point, the application starts recording and the bus is set into the PLAYING state which succeeds, recording begins.

Now when the user presses the stop button:

self.recorderPipeline.send_event(Gst.Event.new_eos())

When the EOS is sent to the bus and self._on_message is triggered and caught:

self.recorderPipeline.set_state(Gst.State.NULL)
HANG

Am I doing something wrong? I looked at the gst-launch-1.0 code and it seems to be using an event_loop() that polls for messages instead of the callback approach above. Also, gst-launch-1.0 PAUSES the bus, sets the bus state back into the READY state, before actually setting it to the NULL state, de-referencing it, and exiting. I actually tried it that as well but when I set the bus state to PAUSE then READY is hangs again.

Why does the Python code above hang when setting the state while the C code seems to work? Do I need to poll for bus messages and not rely on the auto main loop created underneath me? I can't find a singe Python example that polls for messages. Almost all of them are some flavor of connecting to the bus via callbacks.

Some guidance would be appreciated,

-aps







_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Official way to stop a pipeline in Python?

Mathieu Duponchelle
set_state(Gst.State.NULL) should work, you probably want to collect a stacktrace
at hang time and figure out what's blocking :)

On 9/9/19 4:57 PM, pisymbol . wrote:
I have an application that worked fine on Ubuntu 16.04 but now hangs on Ubuntu 18.04 when I try to stop my pipeline.

Here is how I am initializing my pipeline;:

self.recorderBin = Gst.parse_bin_from_description(RECORD_PIPELINE, False)
self.recorderPipeline = Gst.Pipeline()
self.recorderPipeline.add(self.recorderBin)
bus = self.recorderPipeline.get_bus()
bus.add_watch(GLib.PRIORITY_DEFAULT, self._on_message)

At some point, the application starts recording and the bus is set into the PLAYING state which succeeds, recording begins.

Now when the user presses the stop button:

self.recorderPipeline.send_event(Gst.Event.new_eos())

When the EOS is sent to the bus and self._on_message is triggered and caught:

self.recorderPipeline.set_state(Gst.State.NULL)
HANG

Am I doing something wrong? I looked at the gst-launch-1.0 code and it seems to be using an event_loop() that polls for messages instead of the callback approach above. Also, gst-launch-1.0 PAUSES the bus, sets the bus state back into the READY state, before actually setting it to the NULL state, de-referencing it, and exiting. I actually tried it that as well but when I set the bus state to PAUSE then READY is hangs again.

Why does the Python code above hang when setting the state while the C code seems to work? Do I need to poll for bus messages and not rely on the auto main loop created underneath me? I can't find a singe Python example that polls for messages. Almost all of them are some flavor of connecting to the bus via callbacks.

Some guidance would be appreciated,

-aps







_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Official way to stop a pipeline in Python?

pisymbol .


On Mon, Sep 9, 2019 at 2:07 PM Mathieu Duponchelle <[hidden email]> wrote:
set_state(Gst.State.NULL) should work, you probably want to collect a stacktrace
at hang time and figure out what's blocking :

That's what I thought Mathieu. Thank you for confirming.

However, the same pipeline seems to kinda work under gst-launch-1.0 which uses a polling mechanism. Timing bug maybe?

-aps

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel