2012/1/16 Maksym Veremeyenko <ve...@m1stereo.tv>: > Hi, > > i was testing a recording from decklink into the avformat consumer with > simple code: > > #include <stdio.h> > #include <unistd.h> > #include <framework/mlt.h> > > int main( int argc, char *argv[] ) > { > mlt_consumer consumer; > mlt_producer producer; > mlt_profile profile; > mlt_repository repo; > > repo = mlt_factory_init(NULL); > > mlt_log_set_level(MLT_LOG_DEBUG); > > // Initialise the factory > if(repo) { > profile = mlt_profile_init("dv_pal"); > producer = mlt_factory_producer(profile, "decklink", "0"); > if(!producer) > fprintf(stderr, "ERROR: Failed to create producer\n"); > else { > consumer = mlt_factory_consumer(profile, "avformat", > "mlt_rec_01.mov"); > if(!consumer) > fprintf(stderr, "ERROR: Failed to create consumer\n"); > else { > mlt_properties consumer_properties = > mlt_consumer_properties(consumer); > mlt_properties_set(consumer_properties, "properties", "DV"); > mlt_consumer_connect(consumer, > mlt_producer_service(producer)); > mlt_consumer_start(consumer); > fprintf(stderr, "press any key to stop"); > // getchar(); > mlt_consumer_stop(consumer);
I do not think there is much attention to avoidance of a race condition in the asynchronous start function followed immediately by a stop function in most consumers. > fprintf(stderr, "\nstopped\n"); > mlt_consumer_close(consumer); > }; > mlt_producer_close(producer); > }; > mlt_factory_close(); > } > else > fprintf(stderr, "ERROR: Unable to locate factory modules\n" ); > > return 0; > }; > > > but that cause a SIGSEGV: > > Program received signal SIGSEGV, Segmentation fault. > [Switching to Thread 0x7fffeb243700 (LWP 568)] > flush_cluster_buffer (s=0x7fffe400b2e0) at libavformat/movenc.c:2210 > 2210 for (i=0; i<mov->nb_streams; i++){ > Missing separate debuginfos, use: debuginfo-install > SDL-1.2.14-11.fc14.x86_64 alsa-lib-1.0.24-1.fc14.x86_64 > cairo-1.10.2-1.fc14.x86_64 expat-2.0.1-10.fc13.x86_64 > fontconfig-2.8.0-2.fc14.x86_64 freetype-2.4.2-5.fc14.x86_64 > gdk-pixbuf2-2.22.0-2.fc14.x86_64 glib2-2.26.0-2.fc14.x86_64 > glibc-2.13-2.x86_64 gsm-1.0.13-2.fc12.x86_64 gtk2-2.22.0-2.fc14.x86_64 > libX11-1.3.4-4.fc14.x86_64 libXau-1.0.6-1.fc14.x86_64 > libXcomposite-0.4.2-1.fc14.x86_64 libXcursor-1.1.10-5.fc14.x86_64 > libXdamage-1.1.3-1.fc14.x86_64 libXext-1.1.2-2.fc14.x86_64 > libXfixes-4.0.5-1.fc14.x86_64 libXi-1.3.2-1.fc14.x86_64 > libXinerama-1.1-2.fc13.x86_64 libXrandr-1.3.0-5.fc13.x86_64 > libXrender-0.9.6-1.fc14.x86_64 libdv-1.0.0-9.fc13.x86_64 > libgcc-4.5.1-4.fc14.x86_64 libgomp-4.5.1-4.fc14.x86_64 > libogg-1.2.0-1.fc14.x86_64 libpng-1.2.46-1.fc14.x86_64 > libselinux-2.0.96-6.fc14.1.x86_64 libstdc++-4.5.1-4.fc14.x86_64 > libtheora-1.1.1-1.fc13.x86_64 libtool-ltdl-2.2.10-3.fc14.x86_64 > libvorbis-1.3.1-2.fc14.x86_64 libxcb-1.7-1.fc14.x86_64 > libxml2-2.7.7-3.fc14.x86_64 pango-1.28.1-5.fc14.x86_64 > pixman-0.18.4-1.fc14.x86_64 sox-14.3.2-1.fc14.x86_64 > speex-1.2-0.12.rc1.fc12.x86_64 zlib-1.2.5-2.fc14.x86_64 > (gdb) bt > #0 flush_cluster_buffer (s=0x7fffe400b2e0) at libavformat/movenc.c:2210 > #1 0x00007fffef2edb37 in mov_write_trailer (s=<value optimized out>) at > libavformat/movenc.c:2645 > #2 0x00007fffef34af06 in av_write_trailer (s=0x7fffe400b2e0) at > libavformat/utils.c:3562 > #3 0x00007fffef5ab9a2 in consumer_thread (arg=0x693bf0) at > consumer_avformat.c:1872 > #4 0x0000003a71006ccb in start_thread () from /lib64/libpthread.so.0 > #5 0x0000003a70ce0c2d in clone () from /lib64/libc.so.6 > > wrong test code where mlt_consumer_stop was called immediately after > mlt_consumer_start caused that sideeffect. > > to resolve such condition i attached a patch that properly determinate > consumer's thread finish and avoid writing /trailer/ if no /header was > written.. Before I apply this, I want to analyze whether there is something I can do in the framework mlt_consumer.c to make it easier for all consumers to avoid race condition. -- +-DRD-+ ------------------------------------------------------------------------------ Keep Your Developer Skills Current with LearnDevNow! The most comprehensive online learning library for Microsoft developers is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, Metro Style Apps, more. Free future releases when you subscribe now! http://p.sf.net/sfu/learndevnow-d2d _______________________________________________ Mlt-devel mailing list Mlt-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mlt-devel