sony / flutter-elinux-plugins

Flutter plugins for embedded Linux (eLinux)
BSD 3-Clause "New" or "Revised" License
43 stars 23 forks source link

[video_player] I have a question about the return value of `GstVideoPlayer::HandleGstMessage()` #92

Closed makotosato-at closed 6 months ago

makotosato-at commented 6 months ago

Hello.

I have a question about the return value of GstVideoPlayer::HandleGstMessage().

Why does GstVideoPlayer::HandleGstMessage() return GST_BUS_PASS as in the following code? https://github.com/sony/flutter-elinux-plugins/blob/main/packages/video_player/elinux/gst_video_player.cc#L475

I think it should return GST_BUS_DROP.

HidenoriMatsubayashi commented 6 months ago

I don't remember that, but may I ask you the reason why we should use GST_BUS_DROP instead?

https://gstreamer.freedesktop.org/documentation/gstreamer/gstbus.html?gi-language=c

typedef enum
{
  GST_BUS_DROP = 0,
  GST_BUS_PASS = 1,
  GST_BUS_ASYNC = 2
} GstBusSyncReply;

GST_BUS_DROP: drop the message
GST_BUS_PASS: pass the message to the async queue
GST_BUS_ASYNC: pass message to async queue, continue if message is handled
makotosato-at commented 6 months ago

Thank you for reply.

"GST_BUS_PASS: pass the message to the async queue" But, nowhere in the current code is "async queue" handled.

If GST_BUS_PASS is used, I think that passed messages should be handled as follows, for example.

while (gst_bus_have_pending(self->gst_.bus)) {
    GstMessage *message = gst_bus_pop(self->gst_.bus);
    // something
    gst_message_unref(message);
 }
HidenoriMatsubayashi commented 6 months ago

If GST_BUS_PASS is used, I think that passed messages should be handled as follows, for example.

Is that true? I can see the description below.

If the handler returns [GST_BUS_DROP](https://gstreamer.freedesktop.org/documentation/gstreamer/gstbus.html#GST_BUS_DROP), it should unref the message, else the message should not be unreffed by the sync handler.

スクリーンショット 2023-12-18 16 33 59
makotosato-at commented 6 months ago

Is that true? I can see the description below.

I think it is true.

If GST_BUS_PASS is used, passed messages are pushed to bus->priv->queue. https://gitlab.freedesktop.org/gstreamer/gstreamer/-/blob/main/subprojects/gstreamer/gst/gstbus.c?ref_type=heads#L382

I think that the pushed message will remain in queue forever if we don't pop it. https://gitlab.freedesktop.org/gstreamer/gstreamer/-/blob/main/subprojects/gstreamer/gst/gstbus.c?ref_type=heads#L675

HidenoriMatsubayashi commented 6 months ago

That makes sense. Would it be possible for you to create a change / pull request?

HidenoriMatsubayashi commented 6 months ago

Closing. Thanks a lot.