From a56e3f259b7a50b125b18d1cb164ad5625a179be Mon Sep 17 00:00:00 2001 From: Bernhard Miklautz Date: Fri, 15 Nov 2013 16:19:49 +0100 Subject: [PATCH 01/21] winpr: disabled schannel test not practicable for now since it requires local key setup --- winpr/libwinpr/sspi/test/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/winpr/libwinpr/sspi/test/CMakeLists.txt b/winpr/libwinpr/sspi/test/CMakeLists.txt index 809a0a614..4ea3599d6 100644 --- a/winpr/libwinpr/sspi/test/CMakeLists.txt +++ b/winpr/libwinpr/sspi/test/CMakeLists.txt @@ -10,7 +10,7 @@ set(${MODULE_PREFIX}_TESTS TestInitializeSecurityContext.c TestAcquireCredentialsHandle.c TestNTLM.c - TestSchannel.c) + ) create_test_sourcelist(${MODULE_PREFIX}_SRCS ${${MODULE_PREFIX}_DRIVER} From 440d945f5d1f53a8d9ba905fcd982224c1b2e4b4 Mon Sep 17 00:00:00 2001 From: Bernhard Miklautz Date: Fri, 15 Nov 2013 16:58:54 +0100 Subject: [PATCH 02/21] client/common: fixed TestClientRdpFile test Unified ascii and unicode string handling. --- client/common/file.c | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/client/common/file.c b/client/common/file.c index 4ca74fea6..75f2c5e1e 100644 --- a/client/common/file.c +++ b/client/common/file.c @@ -226,43 +226,43 @@ BOOL freerdp_client_rdp_file_set_string(rdpFile* file, char* name, char* value) #endif if (_stricmp(name, "username") == 0) - file->Username = value; + file->Username = _strdup(value); else if (_stricmp(name, "domain") == 0) - file->Domain = value; + file->Domain = _strdup(value); else if (_stricmp(name, "full address") == 0) - file->FullAddress = value; + file->FullAddress = _strdup(value); else if (_stricmp(name, "alternate full address") == 0) - file->AlternateFullAddress = value; + file->AlternateFullAddress = _strdup(value); else if (_stricmp(name, "usbdevicestoredirect") == 0) - file->UsbDevicesToRedirect = value; + file->UsbDevicesToRedirect = _strdup(value); else if (_stricmp(name, "loadbalanceinfo") == 0) - file->LoadBalanceInfo = value; + file->LoadBalanceInfo = _strdup(value); else if (_stricmp(name, "remoteapplicationname") == 0) - file->RemoteApplicationName = value; + file->RemoteApplicationName = _strdup(value); else if (_stricmp(name, "remoteapplicationicon") == 0) - file->RemoteApplicationIcon = value; + file->RemoteApplicationIcon = _strdup(value); else if (_stricmp(name, "remoteapplicationprogram") == 0) - file->RemoteApplicationProgram = value; + file->RemoteApplicationProgram = _strdup(value); else if (_stricmp(name, "remoteapplicationfile") == 0) - file->RemoteApplicationFile = value; + file->RemoteApplicationFile = _strdup(value); else if (_stricmp(name, "remoteapplicationguid") == 0) - file->RemoteApplicationGuid = value; + file->RemoteApplicationGuid = _strdup(value); else if (_stricmp(name, "remoteapplicationcmdline") == 0) - file->RemoteApplicationCmdLine = value; + file->RemoteApplicationCmdLine = _strdup(value); else if (_stricmp(name, "alternate shell") == 0) - file->AlternateShell = value; + file->AlternateShell = _strdup(value); else if (_stricmp(name, "shell working directory") == 0) - file->ShellWorkingDirectory = value; + file->ShellWorkingDirectory = _strdup(value); else if (_stricmp(name, "gatewayhostname") == 0) - file->GatewayHostname = value; + file->GatewayHostname = _strdup(value); else if (_stricmp(name, "kdcproxyname") == 0) - file->KdcProxyName = value; + file->KdcProxyName = _strdup(value); else if (_stricmp(name, "drivestoredirect") == 0) - file->DrivesToRedirect = value; + file->DrivesToRedirect = _strdup(value); else if (_stricmp(name, "devicestoredirect") == 0) - file->DevicesToRedirect = value; + file->DevicesToRedirect = _strdup(value); else if (_stricmp(name, "winposstr") == 0) - file->WinPosStr = value; + file->WinPosStr = _strdup(value); else return FALSE; @@ -297,10 +297,10 @@ void freerdp_client_parse_rdp_file_string_unicode(rdpFile* file, WCHAR* name, WC WideCharToMultiByte(CP_UTF8, 0, value, length, valueA, length, NULL, NULL); valueA[length] = '\0'; - if (!freerdp_client_rdp_file_set_string(file, nameA, valueA)) - free(valueA); + freerdp_client_rdp_file_set_string(file, nameA, valueA); free(nameA); + free(valueA); } void freerdp_client_parse_rdp_file_string_ascii(rdpFile* file, char* name, char* value) From 693506ab9f70b6d81d4d1b05fdd37bb78647338b Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Mon, 18 Nov 2013 09:28:17 +0100 Subject: [PATCH 03/21] Added script to automate gprof reporting. --- scripts/gprof_generate.sh.cmake | 56 +++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100755 scripts/gprof_generate.sh.cmake diff --git a/scripts/gprof_generate.sh.cmake b/scripts/gprof_generate.sh.cmake new file mode 100755 index 000000000..bf2cc5ed3 --- /dev/null +++ b/scripts/gprof_generate.sh.cmake @@ -0,0 +1,56 @@ +#!/bin/bash +# +# This script tries to pull gprof profiling information generated by aFreeRDP +# from the target using adb and generating human readable profiling data from +# it. +# +# Any arguments supplied to the script will be appended to adb. +# +# Requirements: +# - ANDROID_SDK is set to the android SDK directory or adb is in path. +# + +if [ -d $ANDROID_SDK ]; then + ADB=$ANDROID_SDK/platform-tools/adb +else + ADB=`which adb` +fi + +GCC=@CMAKE_C_COMPILER@ +GPROF=${GCC/gcc/gprof} +LIB=@CMAKE_BINARY_DIR@/client/Android/FreeRDPCore/jni/armeabi-v7a/libfreerdp-android.so + +if [ ! -f $LIB ]; then + echo "Missing libfreerdp-android.so" + echo "Please build the project first." + exit -1 +fi + +if [ ! -f $GPROF ]; then + echo "gprof could not be found at $GPROF." + echo "Please assure, that you are using a GCC based android toolchain." + exit -2 +fi + +if [ ! -f $ADB ] || [ ! -x $ADB ]; then + echo "adb could not be found." + echo "assure, that either ANDROID_SDK is set to the path of your android SDK" + echo "or that adb is in path." + exit -3 +fi + +# Do the acutal work in a temporary directory. +SRC=`mktemp -d` +cd $SRC +$ADB $@ pull /sdcard/gmon.out +if [ ! -f gmon.out ]; then + echo "Could not pull profiling information from device!" + RC=-4 +else + echo "Pulled profiling information from device, starting conversion..." + $GPROF $LIB -PprofCount -QprofCount -P__gnu_mcount_nc -Q__gnu_mcount_nc + RC=0 +fi +rm -rf $SRC + +exit $RC From 4dd596c1d52274f3c48f62062ca62dd26cda18c9 Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Mon, 18 Nov 2013 10:27:11 +0100 Subject: [PATCH 04/21] Updated script to set up external android libraries. --- scripts/android_setup_build_env.sh | 51 +++++++++++++++++++----------- 1 file changed, 32 insertions(+), 19 deletions(-) diff --git a/scripts/android_setup_build_env.sh b/scripts/android_setup_build_env.sh index d96f5de72..d7f151d32 100755 --- a/scripts/android_setup_build_env.sh +++ b/scripts/android_setup_build_env.sh @@ -10,28 +10,26 @@ # Usage: # android_setup_build_env.sh -OPENSSL_SCM=https://github.com/bmiklautz/android-external-openssl-ndk-static +OPENSSL_SCM=https://github.com/akallabeth/openssl-android NDK_PROFILER_SCM=https://github.com/richq/android-ndk-profiler SCRIPT_NAME=`basename $0` - if [ $# -ne 1 ]; then - - echo "Missing command line argument." - echo "$SCRIPT_NAME " - exit -1 + echo "Missing command line argument, current directory as root." + ROOT=`pwd` + ROOT=$ROOT/external +else + ROOT=`readlink -f $1` fi -if [ ! -d $1 ]; then - echo "Argument '$1' is not a directory." +if [ ! -d $ROOT ]; then + echo "Argument '$ROOT' is not a directory." exit -2 fi -SRC=`realpath $1` - -echo "Using '$SRC' as root." +echo "Using '$ROOT' as root." echo "Preparing OpenSSL..." -OPENSSL_SRC=$SRC/external/openssl +OPENSSL_SRC=$ROOT/openssl-build if [ -d $OPENSSL_SRC ]; then cd $OPENSSL_SRC git pull @@ -39,21 +37,35 @@ if [ -d $OPENSSL_SRC ]; then else git clone $OPENSSL_SCM $OPENSSL_SRC RETVAL=$? - cd $OPENSSL_SRC fi if [ $RETVAL -ne 0 ]; then echo "Failed to execute git command [$RETVAL]" exit -3 fi -ndk-build -RETVAL=$? + +cd $OPENSSL_SRC +make clean +# The makefile has a bug, which aborts during +# first compilation. Rerun make to build the whole lib. +make +make +RETVAL=0 # TODO: Check, why 2 is returned. if [ $RETVAL -ne 0 ]; then - echo "Failed to execute ndk-build command [$RETVAL]" + echo "Failed to execute make command [$RETVAL]" exit -4 fi +# Copy the created library to the default openssl directory, +# so that CMake will detect it automatically. +SSL_ROOT=`find $OPENSSL_SRC -type d -name "openssl-?.?.*"` +rm -f $ROOT/openssl +ln -s $SSL_ROOT $ROOT/openssl +mkdir -p $ROOT/openssl/obj/local/armeabi/ +cp $ROOT/openssl/libssl.a $ROOT/openssl/obj/local/armeabi/ +cp $ROOT/openssl/libcrypto.a $ROOT/openssl/obj/local/armeabi/ + echo "Preparing NDK profiler..." -NDK_PROFILER_SRC=$SRC/external/android-ndk-profiler +NDK_PROFILER_SRC=$ROOT/android-ndk-profiler if [ -d $NDK_PROFILER_SRC ]; then cd $NDK_PROFILER_SRC git pull @@ -61,13 +73,14 @@ if [ -d $NDK_PROFILER_SRC ]; then else git clone $NDK_PROFILER_SCM $NDK_PROFILER_SRC RETVAL=$? - cd $NDK_PROFILER_SRC fi if [ $RETVAL -ne 0 ]; then echo "Failed to execute git command [$RETVAL]" exit -5 fi -ndk-build +cd $NDK_PROFILER_SRC +ndk-build V=1 APP_ABI=armeabi-v7a clean +ndk-build V=1 APP_ABI=armeabi-v7a RETVAL=$? if [ $RETVAL -ne 0 ]; then echo "Failed to execute ndk-build command [$RETVAL]" From 90f1be51dd2370d66ea30b4a2cc94f23da36c8a3 Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Mon, 18 Nov 2013 10:27:45 +0100 Subject: [PATCH 05/21] Updated android build readme. --- docs/README.android | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/README.android b/docs/README.android index a0db45320..17cf83c91 100644 --- a/docs/README.android +++ b/docs/README.android @@ -29,14 +29,14 @@ FreeRDP requires openssl libraries for building but they are not part of the Android NDK and therefore they need to be prebuild manually. Multiple source versions and builds of static openssl libraries are floating around. At the time of writing we have tested and used: -https://github.com/bmiklautz/Android-external-openssl-ndk-static. +https://github.com/bmiklautz/Android-external-openssl-ndk-static +https://github.com/akallabeth/openssl-android However, any other static build should work as well. To build openssl: -git clone git@github.com:bmiklautz/android-external-openssl-ndk-static.git -cd android-external-openssl-ndk-static -ndk-build # found in the Android NDK +From the project root folder run './scripts/android_setup_build_env.sh' +This will set up openssl and gprof helper libraries as required for FreeRDP. Building From 755c66f7283fb4f69fc9ca152b5a68326820a260 Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Mon, 18 Nov 2013 10:28:59 +0100 Subject: [PATCH 06/21] Updated readme. --- docs/README.android | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/README.android b/docs/README.android index 17cf83c91..6896f8d89 100644 --- a/docs/README.android +++ b/docs/README.android @@ -35,6 +35,7 @@ However, any other static build should work as well. To build openssl: +Set up ANDROID_NDK and ANDROID_SDK to the absolute paths on your machine. From the project root folder run './scripts/android_setup_build_env.sh' This will set up openssl and gprof helper libraries as required for FreeRDP. From 391615bcfb237f03a6430ab6e7ce845a6f4cc3e9 Mon Sep 17 00:00:00 2001 From: Bernhard Miklautz Date: Mon, 18 Nov 2013 12:50:32 +0100 Subject: [PATCH 07/21] android build: generate gprof file only if WITH_GPROF --- CMakeLists.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1638f0fdc..7d9966037 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -301,8 +301,9 @@ endif() set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/client/Android/FreeRDPCore/jni/${ANDROID_ABI}) CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/scripts/regenerate_jni_headers.sh.cmake ${CMAKE_BINARY_DIR}/scripts/regenerate_jni_headers.sh @ONLY) - CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/scripts/gprof_generate.sh.cmake - ${CMAKE_BINARY_DIR}/scripts/gprof_generate.sh @ONLY) + if (WITH_GPROF) + CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/scripts/gprof_generate.sh.cmake ${CMAKE_BINARY_DIR}/scripts/gprof_generate.sh @ONLY) + endif(WITH_GPROF) endif() From 1262d236a33f83ffece2933da1d633a4f23793a7 Mon Sep 17 00:00:00 2001 From: Bernhard Miklautz Date: Mon, 18 Nov 2013 12:53:17 +0100 Subject: [PATCH 08/21] android build: ignore renderscript toolchain When detecting toolchains ignore renderscript because its not a compiler toolchain. --- cmake/AndroidToolchain.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/cmake/AndroidToolchain.cmake b/cmake/AndroidToolchain.cmake index f98385764..05d7574c3 100644 --- a/cmake/AndroidToolchain.cmake +++ b/cmake/AndroidToolchain.cmake @@ -639,6 +639,7 @@ if( BUILD_WITH_STANDALONE_TOOLCHAIN ) endif() macro( __GLOB_NDK_TOOLCHAINS __availableToolchainsVar __availableToolchainsLst __toolchain_subpath ) + list( REMOVE_ITEM ${__availableToolchainsLst} "renderscript" ) foreach( __toolchain ${${__availableToolchainsLst}} ) if( "${__toolchain}" MATCHES "-clang3[.][0-9]$" AND NOT EXISTS "${ANDROID_NDK_TOOLCHAINS_PATH}/${__toolchain}${__toolchain_subpath}" ) string( REGEX REPLACE "-clang3[.][0-9]$" "-4.6" __gcc_toolchain "${__toolchain}" ) From 7457dd3de4719746948436d8664858bdfcd0c2dc Mon Sep 17 00:00:00 2001 From: Bernhard Miklautz Date: Mon, 18 Nov 2013 19:58:01 +0100 Subject: [PATCH 09/21] android build: Fixed program path detection --- CMakeLists.txt | 4 ++-- client/Android/CMakeLists.txt | 11 +++++------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7d9966037..70603918b 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -68,11 +68,11 @@ endif() # Allow to search the host machine for git if(ANDROID OR IOS) - SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER, BOTH) + SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH) endif(ANDROID OR IOS) include(GetGitRevisionDescription) if(ANDROID OR IOS) - SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER, ONLY) + SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY) endif(ANDROID OR IOS) git_describe(GIT_REVISION --match "[0-9]*" --abbrev=4 --tags --always) diff --git a/client/Android/CMakeLists.txt b/client/Android/CMakeLists.txt index 4e7874a1d..05fe21dbd 100644 --- a/client/Android/CMakeLists.txt +++ b/client/Android/CMakeLists.txt @@ -19,11 +19,10 @@ if (NOT ANDROID_NDK) message(FATAL_ERROR "ANDROID_NDK not set but required for building android native library.") endif() -SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER, BOTH) -find_program(NDK_COMMAND ndk-build) -SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER, ONLY) +set(CMAKE_PROGRAM_PATH ${ANDROID_NDK}) +find_program(NDK_COMMAND ndk-build CMAKE_FIND_ROOT_PATH_BOTH) -if(NDK_COMMAND STREQUAL "ANT_COMMAND-NOTFOUND") +if(NDK_COMMAND STREQUAL "NDK_COMMAND-NOTFOUND") message(FATAL_ERROR "ndk-build not found but required to build native lib") endif() @@ -34,9 +33,9 @@ if(ANDROID_BUILD_JAVA) endif() # And isn't shiped with the android ndk/sdk so # we need to find it on the local machine - SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER, BOTH) + SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH) find_program(ANT_COMMAND ant) - SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER, ONLY) + SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY) if(ANT_COMMAND STREQUAL "ANT_COMMAND-NOTFOUND") message(FATAL_ERROR "ant not found but required to build android java") From 0ddf2922f9c1a528f9445972d3b6abe6c35e4b25 Mon Sep 17 00:00:00 2001 From: Bernhard Miklautz Date: Mon, 18 Nov 2013 20:23:00 +0100 Subject: [PATCH 10/21] android build: fixes for out of tree builds Fixed the last places to be able to build android out of tree with Unix Makefiles generator. Note: When using eclipse use in source tree builds. --- client/Android/FreeRDPCore/ant.properties.cmake | 2 +- client/Android/aFreeRDP/CMakeLists.txt | 8 ++++++++ client/Android/aFreeRDP/ant.properties.cmake | 3 +-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/client/Android/FreeRDPCore/ant.properties.cmake b/client/Android/FreeRDPCore/ant.properties.cmake index 13e49ee77..83cd860ec 100644 --- a/client/Android/FreeRDPCore/ant.properties.cmake +++ b/client/Android/FreeRDPCore/ant.properties.cmake @@ -15,6 +15,6 @@ # 'key.alias' for the name of the key to use. # The password will be asked during the build when you use the 'release' target. build.dir=@CMAKE_CURRENT_BINARY_DIR@ -source.dir=@CMAKE_CURRENT_SOURCE_DIR@/src +source.path=@CMAKE_CURRENT_SOURCE_DIR@/src:@CMAKE_CURRENT_BINARY_DIR@/src out.dir=@CMAKE_CURRENT_BINARY_DIR@/bin diff --git a/client/Android/aFreeRDP/CMakeLists.txt b/client/Android/aFreeRDP/CMakeLists.txt index 597349aac..388ffe33c 100644 --- a/client/Android/aFreeRDP/CMakeLists.txt +++ b/client/Android/aFreeRDP/CMakeLists.txt @@ -26,6 +26,14 @@ CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/build.xml.cmake ${CMAKE_CURRENT_BINARY_DIR}/build.xml @ONLY) CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/project.properties.cmake ${CMAKE_CURRENT_BINARY_DIR}/project.properties @ONLY) + +# The following is required if building android out of tree +if (${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR}) +set (AFREERDP_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src") +else() +set (AFREERDP_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src:${CMAKE_CURRENT_SOURCE_DIR}/../FreeRDPCore/src") +endif() + CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/ant.properties.cmake ${CMAKE_CURRENT_BINARY_DIR}/ant.properties @ONLY) diff --git a/client/Android/aFreeRDP/ant.properties.cmake b/client/Android/aFreeRDP/ant.properties.cmake index 13e49ee77..1cbbf9ffc 100644 --- a/client/Android/aFreeRDP/ant.properties.cmake +++ b/client/Android/aFreeRDP/ant.properties.cmake @@ -15,6 +15,5 @@ # 'key.alias' for the name of the key to use. # The password will be asked during the build when you use the 'release' target. build.dir=@CMAKE_CURRENT_BINARY_DIR@ -source.dir=@CMAKE_CURRENT_SOURCE_DIR@/src +source.dir=@AFREERDP_SOURCE_DIR@ out.dir=@CMAKE_CURRENT_BINARY_DIR@/bin - From 261651b43b3e1a200fa3372d9119c3b34187a269 Mon Sep 17 00:00:00 2001 From: Bernhard Miklautz Date: Mon, 18 Nov 2013 20:29:00 +0100 Subject: [PATCH 11/21] core: don't use c99 style initialization fixes #1602 --- libfreerdp/core/input.c | 2 +- libfreerdp/core/update.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libfreerdp/core/input.c b/libfreerdp/core/input.c index fc5b5f4ee..4e001ba03 100644 --- a/libfreerdp/core/input.c +++ b/libfreerdp/core/input.c @@ -494,7 +494,7 @@ static void input_free_queued_message(void *obj) rdpInput* input_new(rdpRdp* rdp) { - const wObject cb = { .fnObjectFree = input_free_queued_message }; + const wObject cb = { NULL, NULL, NULL, input_free_queued_message , NULL }; rdpInput* input; input = (rdpInput*) malloc(sizeof(rdpInput)); diff --git a/libfreerdp/core/update.c b/libfreerdp/core/update.c index a4cebdf08..97e5fa789 100644 --- a/libfreerdp/core/update.c +++ b/libfreerdp/core/update.c @@ -1553,7 +1553,7 @@ static void update_free_queued_message(void *obj) rdpUpdate* update_new(rdpRdp* rdp) { - const wObject cb = { .fnObjectFree = update_free_queued_message }; + const wObject cb = { NULL, NULL, NULL, update_free_queued_message, NULL }; rdpUpdate* update; update = (rdpUpdate*) malloc(sizeof(rdpUpdate)); From aa999c5f620261050ab098bc7c3ffbca5569ffe3 Mon Sep 17 00:00:00 2001 From: Bernhard Miklautz Date: Tue, 19 Nov 2013 20:49:41 +0100 Subject: [PATCH 12/21] android toolchain: fixed cmake syntax warning --- cmake/AndroidToolchain.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/AndroidToolchain.cmake b/cmake/AndroidToolchain.cmake index 05d7574c3..13330c6ab 100644 --- a/cmake/AndroidToolchain.cmake +++ b/cmake/AndroidToolchain.cmake @@ -722,7 +722,7 @@ __INIT_VARIABLE( ANDROID_ABI OBSOLETE_ARM_TARGET OBSOLETE_ARM_TARGETS VALUES ${A # verify that target ABI is supported list( FIND ANDROID_SUPPORTED_ABIS "${ANDROID_ABI}" __androidAbiIdx ) if( __androidAbiIdx EQUAL -1 ) - string( REPLACE ";" "\", \"", PRINTABLE_ANDROID_SUPPORTED_ABIS "${ANDROID_SUPPORTED_ABIS}" ) + string( REPLACE ";" "\", \"" PRINTABLE_ANDROID_SUPPORTED_ABIS "${ANDROID_SUPPORTED_ABIS}" ) message( FATAL_ERROR "Specified ANDROID_ABI = \"${ANDROID_ABI}\" is not supported by this cmake toolchain or your NDK/toolchain. Supported values are: \"${PRINTABLE_ANDROID_SUPPORTED_ABIS}\" " ) From c065b0a72f52ea0ee12e4057a0bbad57bb2aed20 Mon Sep 17 00:00:00 2001 From: Bernhard Miklautz Date: Tue, 19 Nov 2013 20:51:51 +0100 Subject: [PATCH 13/21] android toolchain: support for ndk r9b --- cmake/AndroidToolchain.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/AndroidToolchain.cmake b/cmake/AndroidToolchain.cmake index 13330c6ab..71353e553 100644 --- a/cmake/AndroidToolchain.cmake +++ b/cmake/AndroidToolchain.cmake @@ -326,7 +326,7 @@ endif() # rpath makes low sence for Android set( CMAKE_SKIP_RPATH TRUE CACHE BOOL "If set, runtime paths are not added when using shared libraries." ) -set( ANDROID_SUPPORTED_NDK_VERSIONS ${ANDROID_EXTRA_NDK_VERSIONS} -r9 -r8e -r8d -r8c -r8b -r8 -r7c -r7b -r7 -r6b -r6 -r5c -r5b -r5 "" ) +set( ANDROID_SUPPORTED_NDK_VERSIONS ${ANDROID_EXTRA_NDK_VERSIONS} -r9b -r9 -r8e -r8d -r8c -r8b -r8 -r7c -r7b -r7 -r6b -r6 -r5c -r5b -r5 "" ) if(NOT DEFINED ANDROID_NDK_SEARCH_PATHS) if( CMAKE_HOST_WIN32 ) file( TO_CMAKE_PATH "$ENV{PROGRAMFILES}" ANDROID_NDK_SEARCH_PATHS ) @@ -639,7 +639,6 @@ if( BUILD_WITH_STANDALONE_TOOLCHAIN ) endif() macro( __GLOB_NDK_TOOLCHAINS __availableToolchainsVar __availableToolchainsLst __toolchain_subpath ) - list( REMOVE_ITEM ${__availableToolchainsLst} "renderscript" ) foreach( __toolchain ${${__availableToolchainsLst}} ) if( "${__toolchain}" MATCHES "-clang3[.][0-9]$" AND NOT EXISTS "${ANDROID_NDK_TOOLCHAINS_PATH}/${__toolchain}${__toolchain_subpath}" ) string( REGEX REPLACE "-clang3[.][0-9]$" "-4.6" __gcc_toolchain "${__toolchain}" ) @@ -691,6 +690,7 @@ if( BUILD_WITH_ANDROID_NDK ) endif() __LIST_FILTER( __availableToolchainsLst "^[.]" ) __LIST_FILTER( __availableToolchainsLst "llvm" ) + __LIST_FILTER( __availableToolchainsLst "renderscript" ) __GLOB_NDK_TOOLCHAINS( __availableToolchains __availableToolchainsLst "${ANDROID_NDK_TOOLCHAINS_SUBPATH}" ) if( NOT __availableToolchains AND NOT ANDROID_NDK_TOOLCHAINS_SUBPATH STREQUAL ANDROID_NDK_TOOLCHAINS_SUBPATH2 ) __GLOB_NDK_TOOLCHAINS( __availableToolchains __availableToolchainsLst "${ANDROID_NDK_TOOLCHAINS_SUBPATH2}" ) From b79ce071378472a61240df4914f0a6194084b856 Mon Sep 17 00:00:00 2001 From: Zhang Zhaolong Date: Thu, 21 Nov 2013 13:28:54 +0800 Subject: [PATCH 14/21] fix memory realloc size error. --- client/Windows/wf_cliprdr.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/client/Windows/wf_cliprdr.c b/client/Windows/wf_cliprdr.c index 1cd11aaae..bc286d2dd 100644 --- a/client/Windows/wf_cliprdr.c +++ b/client/Windows/wf_cliprdr.c @@ -83,7 +83,7 @@ static void map_ensure_capacity(cliprdrContext *cliprdr) { if (cliprdr->map_size >= cliprdr->map_capacity) { cliprdr->format_mappings = (formatMapping *)realloc(cliprdr->format_mappings, - cliprdr->map_capacity * 2); + sizeof(formatMapping) * cliprdr->map_capacity * 2); cliprdr->map_capacity *= 2; } } @@ -475,6 +475,7 @@ static void wf_cliprdr_process_cb_format_list_event(wfContext *wfc, RDP_CB_FORMA map = &cliprdr->format_mappings[i++]; Read_UINT32(p, map->remote_format_id); + map->name = NULL; /* get name_len */ for (tmp = p, name_len = 0; tmp + 1 < end_mark; tmp += 2, name_len += 2) { @@ -508,6 +509,7 @@ static void wf_cliprdr_process_cb_format_list_event(wfContext *wfc, RDP_CB_FORMA map = &cliprdr->format_mappings[i++]; Read_UINT32(p, map->remote_format_id); + map->name = NULL; if (event->raw_format_unicode) { /* get name_len, in bytes, if the file name is truncated, no terminated null will be included. */ From c196e0b2c18e4d2a015c1dda58fbe7fb5e09efa2 Mon Sep 17 00:00:00 2001 From: Zhang Zhaolong Date: Thu, 21 Nov 2013 13:35:21 +0800 Subject: [PATCH 15/21] fix name length to copy. --- client/Windows/wf_cliprdr.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/client/Windows/wf_cliprdr.c b/client/Windows/wf_cliprdr.c index bc286d2dd..6aad04e88 100644 --- a/client/Windows/wf_cliprdr.c +++ b/client/Windows/wf_cliprdr.c @@ -143,10 +143,19 @@ static void cliprdr_send_format_list(cliprdrContext *cliprdr) ZeroMemory(format_data + len, 32); if (format >= CF_MAX) { static wchar_t wName[MAX_PATH] = {0}; + int wLen; ZeroMemory(wName, MAX_PATH*2); GetClipboardFormatNameW(format, wName, MAX_PATH); - memcpy(format_data + len, wName, 32); /* truncate the long name to 32 bytes */ + wLen = wcslen(wName); + if (wLen < 16) + { + memcpy(format_data + len, wName, wLen * sizeof(WCHAR)); + } + else + { + memcpy(format_data + len, wName, 32); /* truncate the long name to 32 bytes */ + } } len += 32; } From 304fb6d13729ea5ab0dbc0ca1573f2adee0944ea Mon Sep 17 00:00:00 2001 From: Zhang Zhaolong Date: Thu, 21 Nov 2013 13:45:16 +0800 Subject: [PATCH 16/21] reformat coding styles. --- client/Windows/wf_cliprdr.c | 176 +++++++++++++++++++++++++----------- 1 file changed, 121 insertions(+), 55 deletions(-) diff --git a/client/Windows/wf_cliprdr.c b/client/Windows/wf_cliprdr.c index 6aad04e88..af72fc464 100644 --- a/client/Windows/wf_cliprdr.c +++ b/client/Windows/wf_cliprdr.c @@ -51,10 +51,13 @@ static UINT32 get_local_format_id_by_name(cliprdrContext *cliprdr, void *format_ formatMapping *map; int i; - for (i = 0; i < cliprdr->map_size; i++) { + for (i = 0; i < cliprdr->map_size; i++) + { map = &cliprdr->format_mappings[i]; - if ((cliprdr->capabilities & CAPS_USE_LONG_FORMAT_NAMES) != 0) { - if (map->name) { + if ((cliprdr->capabilities & CAPS_USE_LONG_FORMAT_NAMES) != 0) + { + if (map->name) + { if (memcmp(map->name, format_name, wcslen((LPCWSTR)format_name)) == 0) return map->local_format_id; } @@ -69,9 +72,11 @@ static UINT32 get_remote_format_id(cliprdrContext *cliprdr, UINT32 local_format) formatMapping *map; int i; - for (i = 0; i < cliprdr->map_size; i++) { + for (i = 0; i < cliprdr->map_size; i++) + { map = &cliprdr->format_mappings[i]; - if (map->local_format_id == local_format) { + if (map->local_format_id == local_format) + { return map->remote_format_id; } } @@ -81,7 +86,8 @@ static UINT32 get_remote_format_id(cliprdrContext *cliprdr, UINT32 local_format) static void map_ensure_capacity(cliprdrContext *cliprdr) { - if (cliprdr->map_size >= cliprdr->map_capacity) { + if (cliprdr->map_size >= cliprdr->map_capacity) + { cliprdr->format_mappings = (formatMapping *)realloc(cliprdr->format_mappings, sizeof(formatMapping) * cliprdr->map_capacity * 2); cliprdr->map_capacity *= 2; @@ -93,13 +99,16 @@ static void clear_format_map(cliprdrContext *cliprdr) formatMapping *map; int i; - if (cliprdr->format_mappings) { - for (i = 0; i < cliprdr->map_size; i++) { + if (cliprdr->format_mappings) + { + for (i = 0; i < cliprdr->map_size; i++) + { map = &cliprdr->format_mappings[i]; map->remote_format_id = 0; map->local_format_id = 0; - if (map->name) { + if (map->name) + { free(map->name); map->name = NULL; } @@ -119,7 +128,8 @@ static void cliprdr_send_format_list(cliprdrContext *cliprdr) int len = 0; int namelen; - if (!OpenClipboard(cliprdr->hwndClipboard)) { + if (!OpenClipboard(cliprdr->hwndClipboard)) + { DEBUG_CLIPRDR("OpenClipboard failed with 0x%x", GetLastError()); return; } @@ -130,18 +140,24 @@ static void cliprdr_send_format_list(cliprdrContext *cliprdr) format_data = (BYTE *)calloc(1, data_size); assert(format_data != NULL); - while (format = EnumClipboardFormats(format)) { + while (format = EnumClipboardFormats(format)) + { Write_UINT32(format_data + len, format); len += 4; - if ((cliprdr->capabilities & CAPS_USE_LONG_FORMAT_NAMES) != 0) { - if (format >= CF_MAX) { + if ((cliprdr->capabilities & CAPS_USE_LONG_FORMAT_NAMES) != 0) + { + if (format >= CF_MAX) + { namelen = GetClipboardFormatNameW(format, (LPWSTR)(format_data + len), MAX_PATH); len += namelen * sizeof(WCHAR); } len += 2; /* end of Unicode string */ - } else { + } + else + { ZeroMemory(format_data + len, 32); - if (format >= CF_MAX) { + if (format >= CF_MAX) + { static wchar_t wName[MAX_PATH] = {0}; int wLen; @@ -205,7 +221,8 @@ static LRESULT CALLBACK cliprdr_proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM { static cliprdrContext *cliprdr = NULL; - switch (Msg) { + switch (Msg) + { case WM_CREATE: cliprdr = (cliprdrContext *)((CREATESTRUCT *)lParam)->lpCreateParams; cliprdr->hwndNextViewer = SetClipboardViewer(hWnd); @@ -221,17 +238,23 @@ static LRESULT CALLBACK cliprdr_proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM break; case WM_CHANGECBCHAIN: - if (cliprdr->hwndNextViewer == (HWND)wParam) { + if (cliprdr->hwndNextViewer == (HWND)wParam) + { cliprdr->hwndNextViewer = (HWND)lParam; - } else if (cliprdr->hwndNextViewer != NULL) { + } + else if (cliprdr->hwndNextViewer != NULL) + { SendMessage(cliprdr->hwndNextViewer, Msg, wParam, lParam); } break; case WM_DRAWCLIPBOARD: - if (cliprdr->channel_initialized) { - if (GetClipboardOwner() != cliprdr->hwndClipboard) { - if (!cliprdr->hmem) { + if (cliprdr->channel_initialized) + { + if (GetClipboardOwner() != cliprdr->hwndClipboard) + { + if (!cliprdr->hmem) + { cliprdr->hmem = GlobalFree(cliprdr->hmem); } cliprdr_send_format_list(cliprdr); @@ -243,7 +266,8 @@ static LRESULT CALLBACK cliprdr_proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM case WM_RENDERALLFORMATS: /* discard all contexts in clipboard */ - if (!OpenClipboard(cliprdr->hwndClipboard)) { + if (!OpenClipboard(cliprdr->hwndClipboard)) + { DEBUG_CLIPRDR("OpenClipboard failed with 0x%x", GetLastError()); break; } @@ -252,12 +276,14 @@ static LRESULT CALLBACK cliprdr_proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM break; case WM_RENDERFORMAT: - if (cliprdr_send_data_request(cliprdr, (UINT32)wParam) != 0) { + if (cliprdr_send_data_request(cliprdr, (UINT32)wParam) != 0) + { DEBUG_CLIPRDR("error: cliprdr_send_data_request failed."); break; } - if (SetClipboardData(wParam, cliprdr->hmem) == NULL) { + if (SetClipboardData(wParam, cliprdr->hmem) == NULL) + { DEBUG_CLIPRDR("SetClipboardData failed with 0x%x", GetLastError()); cliprdr->hmem = GlobalFree(cliprdr->hmem); } @@ -301,7 +327,8 @@ static int create_cliprdr_window(cliprdrContext *cliprdr) L"rdpclip", 0, 0, 0, 0, 0, HWND_MESSAGE, NULL, GetModuleHandle(NULL), cliprdr); - if (cliprdr->hwndClipboard == NULL) { + if (cliprdr->hwndClipboard == NULL) + { DEBUG_CLIPRDR("error: CreateWindowEx failed with %x.", GetLastError()); return -1; } @@ -317,16 +344,21 @@ static void *cliprdr_thread_func(void *arg) int ret; HRESULT result; - if ((ret = create_cliprdr_window(cliprdr)) != 0) { + if ((ret = create_cliprdr_window(cliprdr)) != 0) + { DEBUG_CLIPRDR("error: create clipboard window failed."); return NULL; } - while ((mcode = GetMessage(&msg, 0, 0, 0) != 0)) { - if (mcode == -1) { + while ((mcode = GetMessage(&msg, 0, 0, 0) != 0)) + { + if (mcode == -1) + { DEBUG_CLIPRDR("error: clipboard thread GetMessage failed."); break; - } else { + } + else + { TranslateMessage(&msg); DispatchMessage(&msg); } @@ -371,7 +403,8 @@ void wf_cliprdr_uninit(wfContext* wfc) if (cliprdr->hwndClipboard) PostMessage(cliprdr->hwndClipboard, WM_QUIT, 0, 0); - if (cliprdr->cliprdr_thread) { + if (cliprdr->cliprdr_thread) + { WaitForSingleObject(cliprdr->cliprdr_thread, INFINITE); CloseHandle(cliprdr->cliprdr_thread); } @@ -415,23 +448,32 @@ static void wf_cliprdr_process_cb_data_request_event(wfContext *wfc, RDP_CB_DATA local_format = event->format; - if (local_format == 0x9) { /* FORMAT_ID_PALETTE */ + if (local_format == 0x9) /* FORMAT_ID_PALETTE */ + { /* TODO: implement this */ DEBUG_CLIPRDR("FORMAT_ID_PALETTE is not supported yet."); - } else if (local_format == 0x3) { /* FORMAT_ID_MATEFILE */ + } + else if (local_format == 0x3) /* FORMAT_ID_MATEFILE */ + { /* TODO: implement this */ DEBUG_CLIPRDR("FORMAT_ID_MATEFILE is not supported yet."); - } else if (local_format == RegisterClipboardFormatW(L"FileGroupDescriptorW")) { + } + else if (local_format == RegisterClipboardFormatW(L"FileGroupDescriptorW")) + { /* TODO: implement this */ DEBUG_CLIPRDR("FileGroupDescriptorW is not supported yet."); - } else { - if (!OpenClipboard(cliprdr->hwndClipboard)) { + } + else + { + if (!OpenClipboard(cliprdr->hwndClipboard)) + { DEBUG_CLIPRDR("OpenClipboard failed with 0x%x", GetLastError()); return; } hClipdata = GetClipboardData(event->format); - if (!hClipdata) { + if (!hClipdata) + { DEBUG_CLIPRDR("GetClipboardData failed."); CloseClipboard(); return; @@ -475,8 +517,10 @@ static void wf_cliprdr_process_cb_format_list_event(wfContext *wfc, RDP_CB_FORMA clear_format_map(cliprdr); - if ((cliprdr->capabilities & CAPS_USE_LONG_FORMAT_NAMES) != 0) { - while (left_size >= 6) { + if ((cliprdr->capabilities & CAPS_USE_LONG_FORMAT_NAMES) != 0) + { + while (left_size >= 6) + { formatMapping *map; BYTE* tmp; int name_len; @@ -487,17 +531,21 @@ static void wf_cliprdr_process_cb_format_list_event(wfContext *wfc, RDP_CB_FORMA map->name = NULL; /* get name_len */ - for (tmp = p, name_len = 0; tmp + 1 < end_mark; tmp += 2, name_len += 2) { + for (tmp = p, name_len = 0; tmp + 1 < end_mark; tmp += 2, name_len += 2) + { if (*((unsigned short*) tmp) == 0) break; } - if (name_len > 0) { + if (name_len > 0) + { map->name = malloc(name_len + 2); memcpy(map->name, p, name_len + 2); map->local_format_id = RegisterClipboardFormatW((LPCWSTR)map->name); - } else { + } + else + { map->local_format_id = map->remote_format_id; } @@ -508,10 +556,13 @@ static void wf_cliprdr_process_cb_format_list_event(wfContext *wfc, RDP_CB_FORMA map_ensure_capacity(cliprdr); } - } else { + } + else + { int k; - for (k = 0; k < event->raw_format_data_size / 36; k++) { + for (k = 0; k < event->raw_format_data_size / 36; k++) + { formatMapping *map; int name_len; @@ -520,32 +571,43 @@ static void wf_cliprdr_process_cb_format_list_event(wfContext *wfc, RDP_CB_FORMA Read_UINT32(p, map->remote_format_id); map->name = NULL; - if (event->raw_format_unicode) { + if (event->raw_format_unicode) + { /* get name_len, in bytes, if the file name is truncated, no terminated null will be included. */ - for (name_len = 0; name_len < 32; name_len += 2) { + for (name_len = 0; name_len < 32; name_len += 2) + { if (*((unsigned short*) (p + name_len)) == 0) break; } - if (name_len > 0) { + if (name_len > 0) + { map->name = calloc(1, name_len + 2); memcpy(map->name, p, name_len); map->local_format_id = RegisterClipboardFormatW((LPCWSTR)map->name); - } else { + } + else + { map->local_format_id = map->remote_format_id; } - } else { + } + else + { /* get name_len, in bytes, if the file name is truncated, no terminated null will be included. */ - for (name_len = 0; name_len < 32; name_len += 1) { + for (name_len = 0; name_len < 32; name_len += 1) + { if (*((unsigned char*) (p + name_len)) == 0) break; } - if (name_len > 0) { + if (name_len > 0) + { map->name = calloc(1, name_len + 1); memcpy(map->name, p, name_len); map->local_format_id = RegisterClipboardFormatA((LPCSTR)map->name); - } else { + } + else + { map->local_format_id = map->remote_format_id; } } @@ -556,18 +618,21 @@ static void wf_cliprdr_process_cb_format_list_event(wfContext *wfc, RDP_CB_FORMA } } - if (!OpenClipboard(cliprdr->hwndClipboard)) { + if (!OpenClipboard(cliprdr->hwndClipboard)) + { DEBUG_CLIPRDR("OpenClipboard failed with 0x%x", GetLastError()); return; } - if (!EmptyClipboard()) { + if (!EmptyClipboard()) + { DEBUG_CLIPRDR("EmptyClipboard failed with 0x%x", GetLastError()); CloseClipboard(); return; } - for (i = 0; i < cliprdr->map_size; i++) { + for (i = 0; i < cliprdr->map_size; i++) + { SetClipboardData(cliprdr->format_mappings[i].local_format_id, NULL); } @@ -591,7 +656,8 @@ static void wf_cliprdr_process_cb_data_response_event(wfContext *wfc, RDP_CB_DAT void wf_process_cliprdr_event(wfContext *wfc, wMessage *event) { - switch (GetMessageType(event->id)) { + switch (GetMessageType(event->id)) + { case CliprdrChannel_ClipCaps: wf_cliprdr_process_cb_clip_caps_event(wfc, (RDP_CB_CLIP_CAPS *)event); break; From f7cf0eace75873fff38248054b696220d35758df Mon Sep 17 00:00:00 2001 From: Zhang Zhaolong Date: Thu, 21 Nov 2013 14:26:29 +0800 Subject: [PATCH 17/21] check return value. --- client/Windows/wf_cliprdr.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/client/Windows/wf_cliprdr.c b/client/Windows/wf_cliprdr.c index af72fc464..216332f95 100644 --- a/client/Windows/wf_cliprdr.c +++ b/client/Windows/wf_cliprdr.c @@ -101,7 +101,7 @@ static void clear_format_map(cliprdrContext *cliprdr) if (cliprdr->format_mappings) { - for (i = 0; i < cliprdr->map_size; i++) + for (i = 0; i < cliprdr->map_capacity; i++) { map = &cliprdr->format_mappings[i]; map->remote_format_id = 0; @@ -155,15 +155,13 @@ static void cliprdr_send_format_list(cliprdrContext *cliprdr) } else { - ZeroMemory(format_data + len, 32); if (format >= CF_MAX) { static wchar_t wName[MAX_PATH] = {0}; int wLen; ZeroMemory(wName, MAX_PATH*2); - GetClipboardFormatNameW(format, wName, MAX_PATH); - wLen = wcslen(wName); + wLen = GetClipboardFormatNameW(format, wName, MAX_PATH); if (wLen < 16) { memcpy(format_data + len, wName, wLen * sizeof(WCHAR)); @@ -205,6 +203,8 @@ int cliprdr_send_data_request(cliprdrContext *cliprdr, UINT32 format) return -1; cliprdr_event->format = get_remote_format_id(cliprdr, format); + if (cliprdr_event->format == 0) + return -1; ret = freerdp_channels_send_event(cliprdr->channels, (wMessage *)cliprdr_event); @@ -227,7 +227,8 @@ static LRESULT CALLBACK cliprdr_proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM cliprdr = (cliprdrContext *)((CREATESTRUCT *)lParam)->lpCreateParams; cliprdr->hwndNextViewer = SetClipboardViewer(hWnd); - if (cliprdr->hwndNextViewer == NULL && GetLastError() != 0) { + if (cliprdr->hwndNextViewer == NULL && GetLastError() != 0) + { DEBUG_CLIPRDR("error: SetClipboardViewer failed with 0x%0x.", GetLastError()); } cliprdr->hwndClipboard = hWnd; From bf065f3e892e0a94e442de9a7155a7ac170f2add Mon Sep 17 00:00:00 2001 From: eroen Date: Thu, 21 Nov 2013 11:35:53 +0100 Subject: [PATCH 18/21] ffmpeg-2 -- AVCODEC_MAX_AUDIO_FRAME_SIZE deprecated: http://git.videolan.org/?p=ffmpeg.git;a=commit;h=0eea212943544d40f99b05571aa7159d78667154 broken with libavcodec 54 --- channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c index adf8e04f1..0d5b95608 100644 --- a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c +++ b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c @@ -43,6 +43,12 @@ #define AVMEDIA_TYPE_AUDIO 1 #endif +#if LIBAVCODEC_VERSION_MAJOR < 54 +#define MAX_AUDIO_FRAME_SIZE AVCODEC_MAX_AUDIO_FRAME_SIZE +#else +#define MAX_AUDIO_FRAME_SIZE 192000 +#endif + typedef struct _TSMFFFmpegDecoder { ITSMFDecoder iface; @@ -351,7 +357,7 @@ static BOOL tsmf_ffmpeg_decode_audio(ITSMFDecoder* decoder, const BYTE* data, UI #endif if (mdecoder->decoded_size_max == 0) - mdecoder->decoded_size_max = AVCODEC_MAX_AUDIO_FRAME_SIZE + 16; + mdecoder->decoded_size_max = MAX_AUDIO_FRAME_SIZE + 16; mdecoder->decoded_data = malloc(mdecoder->decoded_size_max); ZeroMemory(mdecoder->decoded_data, mdecoder->decoded_size_max); /* align the memory for SSE2 needs */ @@ -363,7 +369,7 @@ static BOOL tsmf_ffmpeg_decode_audio(ITSMFDecoder* decoder, const BYTE* data, UI while (src_size > 0) { /* Ensure enough space for decoding */ - if (mdecoder->decoded_size_max - mdecoder->decoded_size < AVCODEC_MAX_AUDIO_FRAME_SIZE) + if (mdecoder->decoded_size_max - mdecoder->decoded_size < MAX_AUDIO_FRAME_SIZE) { mdecoder->decoded_size_max = mdecoder->decoded_size_max * 2 + 16; mdecoder->decoded_data = realloc(mdecoder->decoded_data, mdecoder->decoded_size_max); From cbcf0de3fac985afaeeef7daf104c94ad8cdca26 Mon Sep 17 00:00:00 2001 From: eroen Date: Thu, 21 Nov 2013 13:14:04 +0100 Subject: [PATCH 19/21] ffmpeg-2 -- dsp_mask deprecated: http://git.videolan.org/?p=ffmpeg.git;a=commit;h=95510be8c35753da8f48062b28b65e7acdab965f broken with libavcodec 55 --- channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c index 0d5b95608..1f99ec31b 100644 --- a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c +++ b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c @@ -104,6 +104,7 @@ static BOOL tsmf_ffmpeg_init_audio_stream(ITSMFDecoder* decoder, const TS_AM_MED mdecoder->codec_context->channels = media_type->Channels; mdecoder->codec_context->block_align = media_type->BlockAlign; +#if LIBAVCODEC_VERSION_MAJOR < 55 #ifdef AV_CPU_FLAG_SSE2 mdecoder->codec_context->dsp_mask = AV_CPU_FLAG_SSE2 | AV_CPU_FLAG_MMX2; #else @@ -113,6 +114,13 @@ static BOOL tsmf_ffmpeg_init_audio_stream(ITSMFDecoder* decoder, const TS_AM_MED mdecoder->codec_context->dsp_mask = FF_MM_SSE2 | FF_MM_MMX2; #endif #endif +#else /* LIBAVCODEC_VERSION_MAJOR < 55 */ +#ifdef AV_CPU_FLAG_SSE2 + av_set_cpu_flags_mask(AV_CPU_FLAG_SSE2 | AV_CPU_FLAG_MMX2); +#else + av_set_cpu_flags_mask(FF_MM_SSE2 | FF_MM_MMX2); +#endif +#endif /* LIBAVCODEC_VERSION_MAJOR < 55 */ return TRUE; } From 6fe23e1a3860528a8ecdfc8e9ccfdbd0e3945869 Mon Sep 17 00:00:00 2001 From: eroen Date: Thu, 21 Nov 2013 13:26:03 +0100 Subject: [PATCH 20/21] ffmpeg-2 -- CodecID deprecated: http://git.videolan.org/?p=ffmpeg.git;a=commit;h=104e10fb426f903ba9157fdbfe30292d0e4c3d72 broken with libavcodec 55 --- channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c index 1f99ec31b..09b4f685c 100644 --- a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c +++ b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c @@ -54,7 +54,11 @@ typedef struct _TSMFFFmpegDecoder ITSMFDecoder iface; int media_type; +#if LIBAVCODEC_VERSION_MAJOR < 55 enum CodecID codec_id; +#else + enum AVCodecID codec_id; +#endif AVCodecContext* codec_context; AVCodec* codec; AVFrame* frame; From 204842561b9bbbaf8b5bf9c324d474da14040be8 Mon Sep 17 00:00:00 2001 From: Bernhard Miklautz Date: Thu, 21 Nov 2013 20:06:21 +0100 Subject: [PATCH 21/21] winpr-thread: fixed bugs in _CreateProcessExA * don't run fork/exec if the command isn't found * return from forked process with exit --- winpr/libwinpr/thread/process.c | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/winpr/libwinpr/thread/process.c b/winpr/libwinpr/thread/process.c index cac0f73e6..d3945f28e 100644 --- a/winpr/libwinpr/thread/process.c +++ b/winpr/libwinpr/thread/process.c @@ -180,13 +180,14 @@ BOOL _CreateProcessExA(HANDLE hToken, DWORD dwLogonFlags, pid_t pid; int flags; int numArgs; - LPSTR* pArgs; - char** envp; + LPSTR* pArgs = NULL; + char** envp = NULL; char* filename = NULL; WINPR_THREAD* thread; WINPR_PROCESS* process; WINPR_ACCESS_TOKEN* token; LPTCH lpszEnvironmentBlock; + BOOL ret = FALSE; pid = 0; envp = NULL; @@ -210,6 +211,8 @@ BOOL _CreateProcessExA(HANDLE hToken, DWORD dwLogonFlags, } filename = FindApplicationPath(pArgs[0]); + if (NULL == filename) + goto finish; /* fork and exec */ @@ -218,7 +221,7 @@ BOOL _CreateProcessExA(HANDLE hToken, DWORD dwLogonFlags, if (pid < 0) { /* fork failure */ - return FALSE; + goto finish; } if (pid == 0) @@ -252,7 +255,8 @@ BOOL _CreateProcessExA(HANDLE hToken, DWORD dwLogonFlags, if (execve(filename, pArgs, envp) < 0) { - return FALSE; + /* execve failed - end the process */ + _exit(1); } } else @@ -263,7 +267,9 @@ BOOL _CreateProcessExA(HANDLE hToken, DWORD dwLogonFlags, process = (WINPR_PROCESS*) malloc(sizeof(WINPR_PROCESS)); if (!process) - return FALSE; + { + goto finish; + } ZeroMemory(process, sizeof(WINPR_PROCESS)); @@ -278,7 +284,9 @@ BOOL _CreateProcessExA(HANDLE hToken, DWORD dwLogonFlags, ZeroMemory(thread, sizeof(WINPR_THREAD)); if (!thread) - return FALSE; + { + goto finish; + } WINPR_HANDLE_SET_TYPE(thread, HANDLE_TYPE_THREAD); @@ -289,7 +297,13 @@ BOOL _CreateProcessExA(HANDLE hToken, DWORD dwLogonFlags, lpProcessInformation->dwProcessId = (DWORD) pid; lpProcessInformation->dwThreadId = (DWORD) pid; - free(filename); + ret = TRUE; + +finish: + if (filename) + { + free(filename); + } if (pArgs) { @@ -312,7 +326,7 @@ BOOL _CreateProcessExA(HANDLE hToken, DWORD dwLogonFlags, free(envp); } - return TRUE; + return ret; } BOOL CreateProcessA(LPCSTR lpApplicationName, LPSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes,