]> git.sesse.net Git - mlt/commitdiff
Make VDPAU independent of SDL X11 Display.
authorDan Dennedy <dan@dennedy.org>
Tue, 15 Dec 2009 06:18:46 +0000 (22:18 -0800)
committerDan Dennedy <dan@dennedy.org>
Tue, 15 Dec 2009 06:18:46 +0000 (22:18 -0800)
This prevents VDPAU from crashing on calls to SDL_Quit() and allows it
to be used with non-SDL consumers! (Still requires an X11 session.)

src/modules/avformat/Makefile
src/modules/avformat/configure
src/modules/avformat/vdpau.c

index a0205adcf948239e1d3aa46bfb523f0c781f1409..6e0e86d02b3e503d31d6dd2a8102cc4644218be4 100644 (file)
@@ -29,8 +29,8 @@ CFLAGS += -DFILTERS
 endif
 
 ifdef VDPAU
-CFLAGS += -DVDPAU
-LDFLAGS += -ldl
+CFLAGS += -DVDPAU `pkg-config --cflags x11`
+LDFLAGS += -ldl `pkg-config --libs x11`
 endif
 
 ifdef CODECS
index 356389a47cd3e97393a7c8664323692d48483893..863c5f409616adced253806055f685f102fe0a42 100755 (executable)
@@ -62,7 +62,8 @@ else
        export swscale=
        export codecs=true
        export filters=true
-       export vdpau=
+       pkg-config x11 > /dev/null 2>&1
+       export x11=$?
 
        for i in "$@"
        do
@@ -116,8 +117,9 @@ else
                echo "LOCAL_FFMPEG=1" >> config.mak
                echo "LDFLAGS+=-Wl,-Bsymbolic" >> config.mak
                extra_libs="$extra_libs -lm -lz -lbz2"
+               
                echo -e "#include <libavcodec/vdpau.h>\n int main(){ VdpBitstreamBuffer test; test.struct_version; return 0;}" | gcc -I"`pwd`/ffmpeg" $CFLAGS -c -x c -  >/dev/null 2>&1
-               [ "$?" = "0" ] && echo "VDPAU=1" >> config.mak
+               [ "$x11" = "0" -a "$?" = "0" ] && echo "VDPAU=1" >> config.mak
        elif [ "$static_ffmpeg" != "" ]
        then 
                if [ -d "$static_ffmpeg" ]
@@ -134,8 +136,9 @@ else
                        fi
                        echo "LDFLAGS+=-Wl,-Bsymbolic" >> config.mak
                        extra_libs="$extra_libs -lm -lz -lbz2"
+                       
                        echo -e "#include <libavcodec/vdpau.h>\n int main(){ VdpBitstreamBuffer test; test.struct_version; return 0;}" | gcc -I"$static_ffmpeg" $CFLAGS -c -x c -  >/dev/null 2>&1
-                       [ "$?" = "0" ] && echo "VDPAU=1" >> config.mak
+                       [ "$x11" = "0" -a "$?" = "0" ] && echo "VDPAU=1" >> config.mak
                else
                        echo "avformat: Invalid path specified: $static_ffmpeg"
                        touch ../disable-avformat
@@ -159,8 +162,9 @@ else
                                echo "CFLAGS+=-I$shared_ffmpeg/include/libswscale" >> config.mak
                        echo "SWSCALE=1" >> config.mak
                fi
+               
                echo -e "#include <libavcodec/vdpau.h>\n int main(){ VdpBitstreamBuffer test; test.struct_version; return 0;}" | gcc -I"$(pkg-config --cflags libavformat)" -I"$shared_ffmpeg/include" $CFLAGS -c -x c -  >/dev/null 2>&1
-               [ "$?" = "0" ] && echo "VDPAU=1" >> config.mak
+               [ "$x11" = "0" -a "$?" = "0" ] && echo "VDPAU=1" >> config.mak
        else
                echo "avformat: No build environment found. "
                echo "          Try configuring mlt with --avformat-svn."
index e4237f8735a08c8bfbea61217b22d7c06233b004..b3fd5317b0375fc14157360886b63ca4e1014f9e 100644 (file)
@@ -19,6 +19,7 @@
  */
 
 #include <vdpau.h>
+#include <X11/Xlib.h>
 
 extern pthread_mutex_t mlt_sdl_mutex;
 
@@ -50,8 +51,9 @@ static int vdpau_init( producer_avformat this )
        mlt_log_debug( MLT_PRODUCER_SERVICE(this->parent), "vdpau_init\n" );
        int success = 0;
        mlt_properties properties = MLT_PRODUCER_PROPERTIES( this->parent );
+       Display *display = XOpenDisplay( NULL );
        
-       if ( !mlt_environment( "x11_display" ) || mlt_properties_get_int( properties, "novdpau" ) )
+       if ( !display || mlt_properties_get_int( properties, "novdpau" ) )
                return success;
 
        if ( !g_vdpau )
@@ -66,7 +68,6 @@ static int vdpau_init( producer_avformat this )
                        {
                                int screen = mlt_properties_get_int( properties, "x11_screen" );
                                VdpDevice device;
-                               Display *display = (Display*) strtol( mlt_environment( "x11_display" ), NULL, 16 );
                                
                                mlt_log_debug( MLT_PRODUCER_SERVICE(this->parent), "X11 Display = %p\n", display );
                                if ( VDP_STATUS_OK == create_device( display, screen, &device, &vdp_get_proc_address ) )