From: Dan Dennedy Date: Sun, 22 May 2011 18:30:32 +0000 (-0700) Subject: Fix full closure of avformat on explicit close. X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;ds=sidebyside;h=b416e89bdd072abf3c9276e69eee54f346da2dbf;p=mlt Fix full closure of avformat on explicit close. JBM wrote: Creating a video4linux producer like (simplified code): producer = new Mlt::Producer(*profile, "video4linux2:/dev/video0"); consumer->connect(*producer); consumer->start(); It works fine. But when I want to stop the capture, there is no way to stop the video4linux producer. Deleting the producer and the consumer still leaves the video4linux device open. After a few hours of struggling, I figured out that some stuff was kept in the cache. Adding : mlt_service_cache_purge( MLT_PRODUCER_SERVICE(parent) ); to producer_close (as already done for the qimage producer for example) fixes the issue. --- diff --git a/src/modules/avformat/producer_avformat.c b/src/modules/avformat/producer_avformat.c index c659dc79..6886a5a2 100644 --- a/src/modules/avformat/producer_avformat.c +++ b/src/modules/avformat/producer_avformat.c @@ -2461,6 +2461,9 @@ static void producer_avformat_close( producer_avformat self ) static void producer_close( mlt_producer parent ) { + // Remove this instance from the cache + mlt_service_cache_purge( MLT_PRODUCER_SERVICE(parent) ); + // Close the parent parent->close = NULL; mlt_producer_close( parent );