Hello everyone,

Not sure whether this is an issue that also exists in the SDL
consumers or if I did something wrong on my end, so I decided to post
it here as a question.

I'm currently working on a little video editing app in GTK and I made
a consumer for it that is utilizing Clutter to display the rendered
frames (since I didn't really like the "hack" for the SDL consumer).
However I copied most of the SDL (v1) consumer's code with a few
exceptions:

- I'm creating a separate video thread for rendering the images and
then setting the Clutter image to be this image (only in rgb24a format
because Clutter doesn’t support YUV as of now) from the main thread.
This is because Clutter isn't thread-safe.
- I don't really support the "real_time" option on my end because
frankly I don't really care for it right now. As I mentioned before, I
only want to use this consumer for my GTK app which isn't released
yet. On creation, it is set to 0.
- Because I don’t know when Clutter is done drawing, I emit an event
on the main thread at the end of my video_thread.

Here's the C source code for the consumer (without the .yml-, the
factory- and all build-system-related files :
https://gist.github.com/hannesschulze/e3839a17cfdaabe757abea237f9b4ad2

Now I'm facing the following problem: I have implemented an option to
move tracks in my app which removes a track from a tractor (connected
to the consumer) and inserts it at another position. This sometimes
causes a segfault when the consumer is active and the frame is closed
(in l. 616).

After a little bit of investigation the issue seems pretty obvious to
me (please correct me if I'm wrong; I haven't worked on the framework
itself yet): The consumer uses mlt_consumer_rt_frame to get a new
frame from the consumer_thread. It then broadcasts the video condition
where the video_thread starts to get the image for the frame and tries
deleting it. In the meantime, my main UI thread has already moved the
track, modifying the tractor and removing/re-adding its transitions
for mixing and compositing. I'm using
field()->disconnect_service([the_transition]) from MLT++ for removing
it from the tractor and Tractor::plant_transition for adding it.

The segfault occurs while deleting a service in stack_service
(probably the transition?) of another frame which is a property in the
first one. After a bit of debugging I found out that this property has
been set by the tractor and it just represents the frame for one track
(I guess): 
https://github.com/mltframework/mlt/blob/master/src/framework/mlt_tractor.c#L555

Logically, the transition (or whatever object needed) isn't there
anymore. This could just be a problem with my implementation –
however, I don't know what might be different from the SDL consumer's
implementation so this might affect it too? Is there any way to kind
of "lock" the object so that it is synchronized across multiple
threads? I haven't found any issues concerning this problem.

As of now, I'm unable to stabilly reproduce this issue. If that is
necessary, I'll try to get something like this working and also see if
it occurs in the SDL consumer. Right now I'm simply wondering if this
issue is caused by me or if a bug like this could be possible.

System: Pop!_OS 19.10 (based on Ubuntu 19.10)
MLT version: 6.16 (from the Ubuntu repos), I haven't seen any changes
since then which might fix this but I'll gladly test it on master too

Thanks,
Hannes Schulze


_______________________________________________
Mlt-devel mailing list
Mlt-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mlt-devel

Reply via email to