diff --git a/indra/CMakeLists.txt b/indra/CMakeLists.txt index 8b71ccf51..8694c0dcc 100644 --- a/indra/CMakeLists.txt +++ b/indra/CMakeLists.txt @@ -4,7 +4,7 @@ # other commands to guarantee full compatibility # with the version specified -cmake_minimum_required(VERSION 2.6.2 FATAL_ERROR) +cmake_minimum_required(VERSION 2.8.10 FATAL_ERROR) # Eventually the third-party support modules (cmake/*.cmake) should # know the full path to all libraries. Until that happens we need @@ -15,7 +15,7 @@ cmake_minimum_required(VERSION 2.6.2 FATAL_ERROR) # CMP0003 to OLD and link to one library (apr) on a per-configuration # basis to convince CMake to add the proper link directory. This line # can be removed when we use full paths for all libraries. -cmake_policy(SET CMP0003 OLD) +#cmake_policy(SET CMP0003 OLD) set(ROOT_PROJECT_NAME "Singularity" CACHE STRING "The root project/makefile/solution name. Defaults to Singularity.") @@ -27,7 +27,6 @@ include(Variables) # Load versions now. Install locations need them. include(BuildVersion) - include(UnixInstall) if (NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE) @@ -41,6 +40,9 @@ if(NOT STANDALONE) # We prepare prebuilt binaries when not building standalone. set(prepare_depends ${CMAKE_BINARY_DIR}/prepare/prebuilt) endif(NOT STANDALONE) +if(WINDOWS) + set(prepare_depends ${prepare_depends} copy_win_libs) +endif(WINDOWS) add_custom_target(prepare DEPENDS ${prepare_depends}) add_subdirectory(cmake) @@ -107,3 +109,16 @@ add_custom_command( DEPENDS ${CMAKE_SOURCE_DIR}/../install.xml ${CMAKE_BINARY_DIR}/DownloadPrebuilt.cmake ) + + +if(WINDOWS) + configure_file(${CMAKE_SOURCE_DIR}/cmake/CopyWinLibs.cmake.in + ${CMAKE_BINARY_DIR}/CopyWinLibs.cmake @ONLY) + add_custom_command( + COMMENT "Copying prebuilt libraries to viewer executable directory" + OUTPUT ${CMAKE_BINARY_DIR}/CopyWinLibs + COMMAND ${CMAKE_COMMAND} -DCUR_CONFIG:STRING=${CMAKE_CFG_INTDIR} -P ${CMAKE_BINARY_DIR}/CopyWinLibs.cmake + DEPENDS ${CMAKE_BINARY_DIR}/prepare/prebuilt ${CMAKE_BINARY_DIR}/CopyWinLibs.cmake + ) + add_custom_target(copy_win_libs DEPENDS ${CMAKE_BINARY_DIR}/CopyWinLibs) +endif(WINDOWS) \ No newline at end of file diff --git a/indra/cmake/00-Common.cmake b/indra/cmake/00-Common.cmake index 3e4af159b..973111b8d 100644 --- a/indra/cmake/00-Common.cmake +++ b/indra/cmake/00-Common.cmake @@ -45,11 +45,10 @@ if (WINDOWS) if (MSVC10) set(MSVC_DIR 10.0) set(MSVC_SUFFIX 100) + elseif (MSVC12) + set(MSVC_DIR 12.0) + set(MSVC_SUFFIX 120) endif (MSVC10) - if (MSVC11) - set(MSVC_DIR 11.0) - set(MSVC_SUFFIX 110) - endif (MSVC11) # Remove default /Zm1000 flag that cmake inserts string (REPLACE "/Zm1000" " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") @@ -85,21 +84,27 @@ if (WINDOWS) /W3 /c /Zc:forScope - /Zc:wchar_t- + /Zc:wchar_t- /nologo /Oy- ) # SSE2 is implied on win64 if(WORD_SIZE EQUAL 32) - add_definitions(/arch:SSE2) + add_definitions(/arch:SSE2 /D_ATL_XP_TARGETING) else(WORD_SIZE EQUAL 32) set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /wd4267 /wd4250 /wd4244") endif(WORD_SIZE EQUAL 32) - # configure win32 API for windows XP+ compatibility - set(WINVER "0x0501" CACHE STRING "Win32 API Target version (see http://msdn.microsoft.com/en-us/library/aa383745%28v=VS.85%29.aspx)") - add_definitions("/DWINVER=${WINVER}" "/D_WIN32_WINNT=${WINVER}") + if (MSVC12) + # configure win32 API for windows vista+ compatibility + set(WINVER "0x0600" CACHE STRING "Win32 API Target version (see http://msdn.microsoft.com/en-us/library/aa383745%28v=VS.85%29.aspx)") + add_definitions("/DWINVER=${WINVER}" "/D_WIN32_WINNT=${WINVER}") + else (MSVC12) + # configure win32 API for windows XP+ compatibility + set(WINVER "0x0501" CACHE STRING "Win32 API Target version (see http://msdn.microsoft.com/en-us/library/aa383745%28v=VS.85%29.aspx)") + add_definitions("/DWINVER=${WINVER}" "/D_WIN32_WINNT=${WINVER}") + endif (MSVC12) # Are we using the crummy Visual Studio KDU build workaround? if (NOT DISABLE_FATAL_WARNINGS) diff --git a/indra/cmake/APR.cmake b/indra/cmake/APR.cmake index cdc9c32a8..c47363aa1 100644 --- a/indra/cmake/APR.cmake +++ b/indra/cmake/APR.cmake @@ -14,25 +14,25 @@ else (STANDALONE) use_prebuilt_binary(apr_suite) if (WINDOWS) set(APR_LIBRARIES - debug ${ARCH_PREBUILT_DIRS_DEBUG}/libapr-1.lib - optimized ${ARCH_PREBUILT_DIRS_RELEASE}/libapr-1.lib + debug libapr-1.lib + optimized libapr-1.lib ) set(APRICONV_LIBRARIES - debug ${ARCH_PREBUILT_DIRS_DEBUG}/libapriconv-1.lib - optimized ${ARCH_PREBUILT_DIRS_RELEASE}/libapriconv-1.lib + debug libapriconv-1.lib + optimized libapriconv-1.lib ) set(APRUTIL_LIBRARIES - debug ${ARCH_PREBUILT_DIRS_DEBUG}/libaprutil-1.lib ${APRICONV_LIBRARIES} - optimized ${ARCH_PREBUILT_DIRS_RELEASE}/libaprutil-1.lib ${APRICONV_LIBRARIES} + debug libaprutil-1.lib + optimized libaprutil-1.lib ) elseif (DARWIN) set(APR_LIBRARIES - debug ${ARCH_PREBUILT_DIRS_DEBUG}/libapr-1.0.dylib - optimized ${ARCH_PREBUILT_DIRS_RELEASE}/libapr-1.0.dylib + debug libapr-1.0.dylib + optimized libapr-1.0.dylib ) - set(APRUTIL_LIBRARIES - debug ${ARCH_PREBUILT_DIRS_DEBUG}/libaprutil-1.dylib - optimized ${ARCH_PREBUILT_DIRS_RELEASE}/libaprutil-1.dylib + set(APRUTIL_LIBRARIES + debug libaprutil-1.dylib + optimized libaprutil-1.dylib ) set(APRICONV_LIBRARIES iconv) else (WINDOWS) @@ -40,7 +40,10 @@ else (STANDALONE) set(APRUTIL_LIBRARIES aprutil-1) set(APRICONV_LIBRARIES iconv) endif (WINDOWS) - set(APR_INCLUDE_DIR ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include/apr-1) + set(APR_INCLUDE_DIR + ${LIBS_PREBUILT_DIR}/include/apr-1 + ${LIBS_PREBUILT_LEGACY_DIR}/include/apr-1 + ) if (LINUX) list(APPEND APRUTIL_LIBRARIES ${DB_LIBRARIES}) diff --git a/indra/cmake/Audio.cmake b/indra/cmake/Audio.cmake index 3d78e6751..27633ff72 100644 --- a/indra/cmake/Audio.cmake +++ b/indra/cmake/Audio.cmake @@ -9,7 +9,10 @@ if (STANDALONE) pkg_check_modules(VORBISFILE REQUIRED vorbisfile) else (STANDALONE) use_prebuilt_binary(ogg-vorbis) - set(VORBIS_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include) + set(VORBIS_INCLUDE_DIRS + ${LIBS_PREBUILT_DIR}/include + ${LIBS_PREBUILT_LEGACY_DIR}/include + ) set(VORBISENC_INCLUDE_DIRS ${VORBIS_INCLUDE_DIRS}) set(VORBISFILE_INCLUDE_DIRS ${VORBIS_INCLUDE_DIRS}) diff --git a/indra/cmake/BerkeleyDB.cmake b/indra/cmake/BerkeleyDB.cmake index 032dd510e..5b885c6a7 100644 --- a/indra/cmake/BerkeleyDB.cmake +++ b/indra/cmake/BerkeleyDB.cmake @@ -13,5 +13,8 @@ else (STANDALONE) else (LINUX) set(DB_LIBRARIES db-4.2) endif (LINUX) - set(DB_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include) + set(DB_INCLUDE_DIRS + ${LIBS_PREBUILT_DIR}/include + ${LIBS_PREBUILT_LEGACY_DIR}/include + ) endif (STANDALONE) diff --git a/indra/cmake/Boost.cmake b/indra/cmake/Boost.cmake index b1c6606dc..0421b1c9e 100644 --- a/indra/cmake/Boost.cmake +++ b/indra/cmake/Boost.cmake @@ -11,7 +11,10 @@ if (STANDALONE) find_package(Boost 1.51.0 COMPONENTS date_time filesystem program_options regex system thread wave context) else (STANDALONE) use_prebuilt_binary(boost) - set(Boost_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include) + set(Boost_INCLUDE_DIRS + ${LIBS_PREBUILT_DIR}/include + ${LIBS_PREBUILT_LEGACY_DIR}/include + ) set(Boost_VERSION "1.52") if (WINDOWS) diff --git a/indra/cmake/BuildVersion.cmake b/indra/cmake/BuildVersion.cmake index 2f983b261..457a1bb16 100644 --- a/indra/cmake/BuildVersion.cmake +++ b/indra/cmake/BuildVersion.cmake @@ -38,11 +38,6 @@ if (WINDOWS) ${CMAKE_SOURCE_DIR}/newview/res/viewerRes.rc.in ${CMAKE_SOURCE_DIR}/newview/res/viewerRes.rc ) - - configure_file( - ${CMAKE_SOURCE_DIR}/newview/res/viewerRes_bc.rc.in - ${CMAKE_SOURCE_DIR}/newview/res/viewerRes_bc.rc - ) endif (WINDOWS) if (DARWIN) @@ -75,13 +70,12 @@ if (LINUX) ) endif (LINUX) -# Compose the version. -set(viewer_VERSION "${vMAJOR}.${vMINOR}.${vPATCH}.${vBUILD}") -if (viewer_VERSION MATCHES "^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+$") - message(STATUS "Version is ${viewer_VERSION}") -else (viewer_VERSION MATCHES "^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+$") - message(FATAL_ERROR "Could not determine version (${viewer_VERSION})") -endif (viewer_VERSION MATCHES "^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+$") -# Report version to caller. -#set(viewer_VERSION "${viewer_VERSION}" PARENT_SCOPE) +# Compose the version. +set(${ROOT_PROJECT_NAME}_VERSION "${vMAJOR}.${vMINOR}.${vPATCH}.${vBUILD}") +if (${ROOT_PROJECT_NAME}_VERSION MATCHES "^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+$") + message(STATUS "Version is ${${ROOT_PROJECT_NAME}_VERSION}") +else (${ROOT_PROJECT_NAME}_VERSION MATCHES "^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+$") + message(FATAL_ERROR "Could not determine version (${${ROOT_PROJECT_NAME}_VERSION})") +endif (${ROOT_PROJECT_NAME}_VERSION MATCHES "^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+$") + diff --git a/indra/cmake/CARes.cmake b/indra/cmake/CARes.cmake index d18e1ef1e..062b283c1 100644 --- a/indra/cmake/CARes.cmake +++ b/indra/cmake/CARes.cmake @@ -13,12 +13,15 @@ else (STANDALONE) add_definitions("-DCARES_STATICLIB") set(CARES_LIBRARIES areslib) elseif (DARWIN) - set(CARES_LIBRARIES - optimized ${ARCH_PREBUILT_DIRS_RELEASE}/libcares.a - debug ${ARCH_PREBUILT_DIRS_DEBUG}/libcares.a + set(CARES_LIBRARIES + debug libcares.a + optimized libcares.a ) else (WINDOWS) set(CARES_LIBRARIES cares) endif (WINDOWS) - set(CARES_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include/ares) + set(CARES_INCLUDE_DIRS + ${LIBS_PREBUILT_DIR}/include/ares + ${LIBS_PREBUILT_LEGACY_DIR}/include/ares + ) endif (STANDALONE) diff --git a/indra/cmake/CMakeLists.txt b/indra/cmake/CMakeLists.txt index d2e9f2249..c6d716fed 100644 --- a/indra/cmake/CMakeLists.txt +++ b/indra/cmake/CMakeLists.txt @@ -29,8 +29,8 @@ set(cmake_SOURCE_FILES ELFIO.cmake EXPAT.cmake ExamplePlugin.cmake - FMOD.cmake FMODEX.cmake + FMODSTUDIO.cmake FindAPR.cmake FindBerkeleyDB.cmake FindCARes.cmake diff --git a/indra/cmake/CURL.cmake b/indra/cmake/CURL.cmake index 10ef1b0b6..8463d6531 100644 --- a/indra/cmake/CURL.cmake +++ b/indra/cmake/CURL.cmake @@ -18,5 +18,8 @@ else (STANDALONE) list(APPEND CURL_LIBRARIES idn) endif(LINUX AND WORD_SIZE EQUAL 64) endif (WINDOWS) - set(CURL_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include) + set(CURL_INCLUDE_DIRS + ${LIBS_PREBUILT_DIR}/include + ${LIBS_PREBUILT_LEGACY_DIR}/include + ) endif (STANDALONE) diff --git a/indra/cmake/Colladadom.cmake b/indra/cmake/Colladadom.cmake index e503d99e7..afc8bcce0 100644 --- a/indra/cmake/Colladadom.cmake +++ b/indra/cmake/Colladadom.cmake @@ -1,6 +1,7 @@ # -*- cmake -*- include(Prebuilt) +include(Boost) set(COLLADADOM_FIND_QUIETLY OFF) set(COLLADADOM_FIND_REQUIRED ON) @@ -19,16 +20,33 @@ else (STANDALONE) endif (NOT DARWIN AND NOT WINDOWS) set(COLLADADOM_INCLUDE_DIRS - ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include/collada - ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include/collada/1.4 - ) + ${LIBS_PREBUILT_DIR}/include/collada + ${LIBS_PREBUILT_DIR}/include/collada/1.4 + ${LIBS_PREBUILT_LEGACY_DIR}/include/collada + ${LIBS_PREBUILT_LEGACY_DIR}/include/collada/1.4 + ) if (WINDOWS) - add_definitions(-DDOM_DYNAMIC) - set(COLLADADOM_LIBRARIES - debug libcollada14dom22-d - optimized libcollada14dom22 + if(MSVC12) + use_prebuilt_binary(pcre) + use_prebuilt_binary(libxml) + set(COLLADADOM_LIBRARIES + debug libcollada14dom23-sd + optimized libcollada14dom23-s + libxml2_a + debug pcrecppd + optimized pcrecpp + debug pcred + optimized pcre + ${BOOST_SYSTEM_LIBRARIES} ) + else(MSVC12) + add_definitions(-DDOM_DYNAMIC) + set(COLLADADOM_LIBRARIES + debug libcollada14dom22-d + optimized libcollada14dom22 + ) + endif(MSVC12) else (WINDOWS) set(COLLADADOM_LIBRARIES collada14dom diff --git a/indra/cmake/CopyBackToSource.cmake b/indra/cmake/CopyBackToSource.cmake index d217df9ae..d09a216e8 100644 --- a/indra/cmake/CopyBackToSource.cmake +++ b/indra/cmake/CopyBackToSource.cmake @@ -2,7 +2,7 @@ # Copies a binary back to the source directory MACRO(COPY_BACK_TO_SOURCE target) - GET_TARGET_PROPERTY(FROM ${target} LOCATION) + SET(FROM $) SET(TO ${CMAKE_CURRENT_SOURCE_DIR}) #MESSAGE("TARGET ${target} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${FROM} ${TO}") ADD_CUSTOM_COMMAND( diff --git a/indra/cmake/CopyWinLibs.cmake b/indra/cmake/CopyWinLibs.cmake deleted file mode 100644 index 17d5eab02..000000000 --- a/indra/cmake/CopyWinLibs.cmake +++ /dev/null @@ -1,320 +0,0 @@ -# -*- cmake -*- - -# The copy_win_libs folder contains file lists and a script used to -# copy dlls, exes and such needed to run the SecondLife from within -# VisualStudio. - -include(CMakeCopyIfDifferent) - -if(WORD_SIZE EQUAL 32) - set(debug_libs_dir "${CMAKE_SOURCE_DIR}/../libraries/i686-win32/lib/debug") - set(release_libs_dir "${CMAKE_SOURCE_DIR}/../libraries/i686-win32/lib/release") -else(WORD_SIZE EQUAL 32) - set(debug_libs_dir "${CMAKE_SOURCE_DIR}/../libraries/x86_64-win/lib/debug") - set(release_libs_dir "${CMAKE_SOURCE_DIR}/../libraries/x86_64-win/lib/release") -endif(WORD_SIZE EQUAL 32) - -set(vivox_src_dir "${CMAKE_SOURCE_DIR}/newview/vivox-runtime/i686-win32") -set(vivox_files - ca-bundle.crt - libsndfile-1.dll - ortp.dll - SLVoice.exe - vivoxoal.dll - vivoxplatform.dll - vivoxsdk.dll - zlib1.dll - ) -copy_if_different( - ${vivox_src_dir} - "${CMAKE_CURRENT_BINARY_DIR}/Debug" - out_targets - ${vivox_files} - ) -set(all_targets ${all_targets} ${out_targets}) - - -set(debug_src_dir "${debug_libs_dir}") -set(debug_files - libhunspell.dll - libapr-1.dll - libaprutil-1.dll - libapriconv-1.dll - libeay32.dll - ssleay32.dll - libcollada14dom22-d.dll - glod.dll - ) - -copy_if_different( - ${debug_src_dir} - "${CMAKE_CURRENT_BINARY_DIR}/Debug" - out_targets - ${debug_files} - ) -set(all_targets ${all_targets} ${out_targets}) - -# Debug config runtime files required for the plugin test mule -set(plugintest_debug_src_dir "${debug_libs_dir}") -set(plugintest_debug_files - libeay32.dll - qtcored4.dll - qtguid4.dll - qtnetworkd4.dll - qtopengld4.dll - qtwebkitd4.dll - ssleay32.dll - ) -copy_if_different( - ${plugintest_debug_src_dir} - "${CMAKE_CURRENT_BINARY_DIR}/../test_apps/llplugintest/Debug" - out_targets - ${plugintest_debug_files} - ) -set(all_targets ${all_targets} ${out_targets}) - -# Debug config runtime files required for the plugin test mule (Qt image format plugins) -set(plugintest_debug_src_dir "${debug_libs_dir}/imageformats") -set(plugintest_debug_files - qgifd4.dll - qicod4.dll - qjpegd4.dll - qmngd4.dll - qsvgd4.dll - qtiffd4.dll - ) -copy_if_different( - ${plugintest_debug_src_dir} - "${CMAKE_CURRENT_BINARY_DIR}/../test_apps/llplugintest/Debug/imageformats" - out_targets - ${plugintest_debug_files} - ) -set(all_targets ${all_targets} ${out_targets}) - -copy_if_different( - ${plugintest_debug_src_dir} - "${CMAKE_CURRENT_BINARY_DIR}/llplugin/imageformats" - out_targets - ${plugintest_debug_files} - ) -set(all_targets ${all_targets} ${out_targets}) - -# Release & ReleaseDebInfo config runtime files required for the plugin test mule -set(plugintest_release_src_dir "${release_libs_dir}") -set(plugintest_release_files - libeay32.dll - qtcore4.dll - qtgui4.dll - qtnetwork4.dll - qtopengl4.dll - qtwebkit4.dll - ssleay32.dll - ) -copy_if_different( - ${plugintest_release_src_dir} - "${CMAKE_CURRENT_BINARY_DIR}/../test_apps/llplugintest/Release" - out_targets - ${plugintest_release_files} - ) -set(all_targets ${all_targets} ${out_targets}) - -copy_if_different( - ${plugintest_release_src_dir} - "${CMAKE_CURRENT_BINARY_DIR}/../test_apps/llplugintest/RelWithDebInfo" - out_targets - ${plugintest_release_files} - ) -set(all_targets ${all_targets} ${out_targets}) - -# Release & ReleaseDebInfo config runtime files required for the plugin test mule (Qt image format plugins) -set(plugintest_release_src_dir "${release_libs_dir}/imageformats") -set(plugintest_release_files - qgif4.dll - qico4.dll - qjpeg4.dll - qmng4.dll - qsvg4.dll - qtiff4.dll - ) -copy_if_different( - ${plugintest_release_src_dir} - "${CMAKE_CURRENT_BINARY_DIR}/../test_apps/llplugintest/Release/imageformats" - out_targets - ${plugintest_release_files} - ) -set(all_targets ${all_targets} ${out_targets}) - -copy_if_different( - ${plugintest_release_src_dir} - "${CMAKE_CURRENT_BINARY_DIR}/../test_apps/llplugintest/RelWithDebInfo/imageformats" - out_targets - ${plugintest_release_files} - ) -set(all_targets ${all_targets} ${out_targets}) - -copy_if_different( - ${plugintest_release_src_dir} - "${CMAKE_CURRENT_BINARY_DIR}/Release/llplugin/imageformats" - out_targets - ${plugintest_release_files} - ) -set(all_targets ${all_targets} ${out_targets}) - -copy_if_different( - ${plugintest_release_src_dir} - "${CMAKE_CURRENT_BINARY_DIR}/RelWithDebInfo/llplugin/imageformats" - out_targets - ${plugintest_release_files} - ) -set(all_targets ${all_targets} ${out_targets}) - -# Debug config runtime files required for the plugins -set(plugins_debug_src_dir "${debug_libs_dir}") -set(plugins_debug_files - libeay32.dll - qtcored4.dll - qtguid4.dll - qtnetworkd4.dll - qtopengld4.dll - qtwebkitd4.dll - ssleay32.dll - ) -copy_if_different( - ${plugins_debug_src_dir} - "${CMAKE_CURRENT_BINARY_DIR}/Debug/llplugin" - out_targets - ${plugins_debug_files} - ) -set(all_targets ${all_targets} ${out_targets}) - -# Release & ReleaseDebInfo config runtime files required for the plugins -set(plugins_release_src_dir "${release_libs_dir}") -set(plugins_release_files - libeay32.dll - qtcore4.dll - qtgui4.dll - qtnetwork4.dll - qtopengl4.dll - qtwebkit4.dll - ssleay32.dll - ) -copy_if_different( - ${plugins_release_src_dir} - "${CMAKE_CURRENT_BINARY_DIR}/Release/llplugin" - out_targets - ${plugins_release_files} - ) -set(all_targets ${all_targets} ${out_targets}) - -copy_if_different( - ${plugins_release_src_dir} - "${CMAKE_CURRENT_BINARY_DIR}/RelWithDebInfo/llplugin" - out_targets - ${plugins_release_files} - ) -set(all_targets ${all_targets} ${out_targets}) - - -set(release_src_dir "${release_libs_dir}") -set(release_files - libhunspell.dll - libapr-1.dll - libaprutil-1.dll - libapriconv-1.dll - libeay32.dll - ssleay32.dll - libcollada14dom22.dll - glod.dll - ) - -if(WORD_SIZE EQUAL 32) - set(release_files ${release_files} - libtcmalloc_minimal.dll - ) -endif(WORD_SIZE EQUAL 32) - - -if(FMODEX) - if (WORD_SIZE EQUAL 32) - set(fmodex_dll_file "fmodex.dll") - else (WORD_SIZE EQUAL 32) - set(fmodex_dll_file "fmodex64.dll") - endif (WORD_SIZE EQUAL 32) - - find_path(FMODEX_BINARY_DIR "${fmodex_dll_file}" - "${release_src_dir}" - "${FMODEX_SDK_DIR}/api" - "${FMODEX_SDK_DIR}" - NO_DEFAULT_PATH - ) - - if(FMODEX_BINARY_DIR) - copy_if_different("${FMODEX_BINARY_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/Release" out_targets "${fmodex_dll_file}") - set(all_targets ${all_targets} ${out_targets}) - copy_if_different("${FMODEX_BINARY_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/RelWithDebInfo" out_targets "${fmodex_dll_file}") - set(all_targets ${all_targets} ${out_targets}) - copy_if_different("${FMODEX_BINARY_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/Debug" out_targets "${fmodex_dll_file}") - set(all_targets ${all_targets} ${out_targets}) - endif(FMODEX_BINARY_DIR) -endif(FMODEX) - -if(FMOD) - find_path(FMOD_BINARY_DIR fmod.dll - ${release_src_dir} - ${FMOD_SDK_DIR}/api - ${FMOD_SDK_DIR} - ) - -if(FMOD_BINARY_DIR) - copy_if_different("${FMOD_BINARY_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/Release" out_targets fmod.dll) - set(all_targets ${all_targets} ${out_targets}) - copy_if_different("${FMOD_BINARY_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/RelWithDebInfo" out_targets fmod.dll) - set(all_targets ${all_targets} ${out_targets}) - copy_if_different("${FMOD_BINARY_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/Debug" out_targets fmod.dll) - set(all_targets ${all_targets} ${out_targets}) - else(FMOD_BINARY_DIR) - list(APPEND release_files fmod.dll) #Required for compile. This will cause an error in copying binaries. - endif(FMOD_BINARY_DIR) -endif(FMOD) - -copy_if_different( - ${release_src_dir} - "${CMAKE_CURRENT_BINARY_DIR}/Release" - out_targets - ${release_files} - ) -set(all_targets ${all_targets} ${out_targets}) - -copy_if_different( - ${vivox_src_dir} - "${CMAKE_CURRENT_BINARY_DIR}/Release" - out_targets - ${vivox_files} - ) -set(all_targets ${all_targets} ${out_targets}) - -copy_if_different( - ${release_src_dir} - "${CMAKE_CURRENT_BINARY_DIR}/RelWithDebInfo" - out_targets - ${release_files} - ) -set(all_targets ${all_targets} ${out_targets}) - -copy_if_different( - ${vivox_src_dir} - "${CMAKE_CURRENT_BINARY_DIR}/RelWithDebInfo" - out_targets - ${vivox_files} - ) -set(all_targets ${all_targets} ${out_targets}) - -add_custom_target(copy_win_libs ALL - DEPENDS - ${all_targets} - ${release_appconfig_file} - ${relwithdebinfo_appconfig_file} - ${debug_appconfig_file} - ) -add_dependencies(copy_win_libs prepare) - diff --git a/indra/cmake/CopyWinLibs.cmake.in b/indra/cmake/CopyWinLibs.cmake.in new file mode 100644 index 000000000..91d5235a9 --- /dev/null +++ b/indra/cmake/CopyWinLibs.cmake.in @@ -0,0 +1,181 @@ +# -*- cmake -*- + +# The copy_win_libs folder contains file lists and a script used to +# copy dlls, exes and such needed to run the SecondLife from within +# VisualStudio. + +set(LIBS_PREBUILT_DIR "@LIBS_PREBUILT_DIR@") +set(LIBS_PREBUILT_LEGACY_DIR "@LIBS_PREBUILT_LEGACY_DIR@") +set(MSVC10 "@MSVC10@") +set(WORD_SIZE "@WORD_SIZE@") + +set(LIBS_RELEASE_DIR + ${LIBS_PREBUILT_DIR}/lib/release + ${LIBS_PREBUILT_LEGACY_DIR}/lib/release + ) +set(LIBS_DEBUG_DIR + ${LIBS_PREBUILT_DIR}/lib/debug + ${LIBS_PREBUILT_LEGACY_DIR}/lib/debug + ) + +function(copy_files paths names dest) + string(FIND ${dest} ${CUR_CONFIG} idx) + if(${idx} LESS 0) + return() + endif(${idx} LESS 0) + foreach(f ${names}) + foreach(p ${paths}) + set(from_file "${p}/${f}") + set(to_dest "${CMAKE_BINARY_DIR}/newview/${dest}") + if(EXISTS ${from_file}) + message("Copying ${from_file} to ${to_dest}") + if(NOT EXISTS ${to_dest}) + execute_process(COMMAND mkdir -p "${to_dest}") + endif(NOT EXISTS ${to_dest}) + execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${from_file} ${to_dest} RESULT_VARIABLE result) + if(${result}) + message(SEND_ERROR "Unsuccessful.") + endif(${result}) + set(found 1) + break() + endif(EXISTS ${from_file}) + endforeach(p) + if(NOT found) + message(SEND_ERROR "Failed to find library: ${f}") + endif(NOT found) + endforeach(f) +endfunction(copy_files) + +set(vivox_files + ca-bundle.crt + libsndfile-1.dll + ortp.dll + SLVoice.exe + vivoxoal.dll + vivoxplatform.dll + vivoxsdk.dll + zlib1.dll + ) +copy_files("${LIBS_RELEASE_DIR}" "${vivox_files}" "Release" ) +copy_files("${LIBS_RELEASE_DIR}" "${vivox_files}" "RelWithDebInfo") +copy_files("${LIBS_DEBUG_DIR}" "${vivox_files}" "Debug") + +set(release_files + libhunspell.dll + libapr-1.dll + libaprutil-1.dll + libapriconv-1.dll + libeay32.dll + ssleay32.dll + glod.dll + qtcore4.dll + ) +copy_files("${LIBS_RELEASE_DIR}" "${release_files}" "Release") +copy_files("${LIBS_RELEASE_DIR}" "${release_files}" "RelWithDebInfo") +copy_files("${LIBS_DEBUG_DIR}" "${release_files}" "Debug") + +if(MSVC10) + copy_files("${LIBS_DEBUG_DIR}" "libcollada14dom22-d.dll" "Debug") +endif(MSVC10) + +if(WORD_SIZE EQUAL 32) +set(release_files + libcollada14dom22.dll + libtcmalloc_minimal.dll + ) + copy_files("${LIBS_RELEASE_DIR}" "${release_files}" "Release") + copy_files("${LIBS_RELEASE_DIR}" "${release_files}" "RelWithDebInfo") +endif(WORD_SIZE EQUAL 32) + +set(plugins_release_files + libeay32.dll + qtcore4.dll + qtgui4.dll + qtnetwork4.dll + qtopengl4.dll + qtwebkit4.dll + ssleay32.dll + qtxmlpatterns4.dll + ) +copy_files("${LIBS_RELEASE_DIR}" "${plugins_release_files}" "Release/llplugin") +copy_files("${LIBS_RELEASE_DIR}" "${plugins_release_files}" "RelWithDebInfo/llplugin") +if(0) + copy_files("${LIBS_RELEASE_DIR}" "${plugin_release_files}" "../test_apps/llplugintest/Release") + copy_files("${LIBS_RELEASE_DIR}" "${plugin_release_files}" "../test_apps/llplugintest/RelWithDebInfo") +endif(0) + +# Debug config runtime files required for the plugins +set(plugins_debug_files + libeay32.dll + qtcored4.dll + qtguid4.dll + qtnetworkd4.dll + qtopengld4.dll + qtwebkitd4.dll + ssleay32.dll + qtxmlpatternsd4.dll + ) +copy_files("${LIBS_DEBUG_DIR}" "${plugins_debug_files}" "Debug/llplugin") +if(0) + copy_files("${LIBS_DEBUG_DIR}" "${plugins_debug_files}" "../test_apps/llplugintest/Debug") +endif(0) + +# Release & ReleaseDebInfo config runtime files required for the plugin test mule (Qt image format plugins) +set(plugin_image_release_files + qgif4.dll + qico4.dll + qjpeg4.dll + qmng4.dll + qsvg4.dll + qtiff4.dll + ) +copy_files("${LIBS_RELEASE_DIR}/imageformats" "${plugin_image_release_files}" "Release/llplugin/imageformats") +copy_files("${LIBS_RELEASE_DIR}/imageformats" "${plugin_image_release_files}" "RelWithDebInfo/llplugin/imageformats") +if(0) + copy_files("${LIBS_RELEASE_DIR}/imageformats" "${plugin_image_release_files}" "../test_apps/llplugintest/imageformats/Release") + copy_files("${LIBS_RELEASE_DIR}/imageformats" "${plugin_image_release_files}" "../test_apps/llplugintest/imageformats/RelWithDebInfo") +endif(0) + + +# Debug config runtime files required for the plugin test mule (Qt image format plugins) +set(plugin_image_debug_files + qgifd4.dll + qicod4.dll + qjpegd4.dll + qmngd4.dll + qsvgd4.dll + qtiffd4.dll + ) +copy_files("${LIBS_DEBUG_DIR}/imageformats" "${plugin_image_debug_files}" "Debug/llplugin/imageformats") +if(0) + copy_files("${LIBS_DEBUG_DIR}/imageformats" "${plugin_image_debug_files}" "../test_apps/llplugintest/imageformats/Debug") +endif(0) + +# Release & ReleaseDebInfo config runtime files required for the plugin test mule (Qt image format plugins) +set(plugin_codec_release_files + qcncodecs4.dll + qjpcodecs4.dll + qkrcodecs4.dll + qtwcodecs4.dll + ) +copy_files("${LIBS_RELEASE_DIR}/codecs" "${plugin_codec_release_files}" "Release/llplugin/codecs") +copy_files("${LIBS_RELEASE_DIR}/codecs" "${plugin_codec_release_files}" "RelWithDebInfo/llplugin/codecs") +if(0) + copy_files("${LIBS_RELEASE_DIR}/codecs" "${plugin_codec_release_files}" "../test_apps/llplugintest/codecs/Release") + copy_files("${LIBS_RELEASE_DIR}/codecs" "${plugin_codec_release_files}" "../test_apps/llplugintest/codecs/RelWithDebInfo") +endif(0) + +# Debug config runtime files required for the plugin test mule (Qt image format plugins) +set(plugin_codec_debug_files + qcncodecsd4.dll + qjpcodecsd4.dll + qkrcodecsd4.dll + qtwcodecsd4.dll + ) +copy_files("${LIBS_DEBUG_DIR}/codecs" "${plugin_codec_debug_files}" "Debug/llplugin/codecs") +if(0) + copy_files("${LIBS_DEBUG_DIR}/codecs" "${plugin_codec_debug_files}" "../test_apps/llplugintest/codecs/Debug") +endif(0) + + + diff --git a/indra/cmake/DBusGlib.cmake b/indra/cmake/DBusGlib.cmake index 05266eb9c..cb1b3a302 100644 --- a/indra/cmake/DBusGlib.cmake +++ b/indra/cmake/DBusGlib.cmake @@ -10,8 +10,9 @@ elseif (LINUX) use_prebuilt_binary(dbusglib) set(DBUSGLIB_FOUND ON FORCE BOOL) set(DBUSGLIB_INCLUDE_DIRS - ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include/dbus - ) + ${LIBS_PREBUILT_DIR}/include/dbus + ${LIBS_PREBUILT_LEGACY_DIR}/include/dbus + ) # We don't need to explicitly link against dbus-glib itself, because # the viewer probes for the system's copy at runtime. set(DBUSGLIB_LIBRARIES diff --git a/indra/cmake/DirectX.cmake b/indra/cmake/DirectX.cmake index 97a0bf910..56547bb7d 100644 --- a/indra/cmake/DirectX.cmake +++ b/indra/cmake/DirectX.cmake @@ -11,25 +11,32 @@ if (WINDOWS) set (DIRECTX_ARCHITECTURE x86) endif (WORD_SIZE EQUAL 32) + SET(program_files $ENV{ProgramW6432}) + if(NOT program_files) + SET(program_files $ENV{ProgramFiles}) + endif(NOT program_files) + SET(program_files_x86 "ProgramFiles(x86)") + SET(program_files_x86 $ENV{${program_files_x86}}) + find_path(DIRECTX_ROOT_DIR Include/dxdiag.h PATHS "$ENV{DXSDK_DIR}" - "$ENV{ProgramFiles}/Microsoft DirectX SDK (June 2010)" - "$ENV{ProgramFiles(x86)}/Microsoft DirectX SDK (June 2010)" - "$ENV{ProgramFiles}/Microsoft DirectX SDK (February 2010)" - "$ENV{ProgramFiles(x86)}/Microsoft DirectX SDK (February 2010)" - "$ENV{ProgramFiles}/Microsoft DirectX SDK (March 2009)" - "$ENV{ProgramFiles(x86)}/Microsoft DirectX SDK (March 2009)" - "$ENV{ProgramFiles}/Microsoft DirectX SDK (August 2008)" - "$ENV{ProgramFiles(x86)}/Microsoft DirectX SDK (August 2008)" - "$ENV{ProgramFiles}/Microsoft DirectX SDK (June 2008)" - "$ENV{ProgramFiles(x86)}/Microsoft DirectX SDK (June 2008)" - "$ENV{ProgramFiles}/Microsoft DirectX SDK (March 2008)" - "$ENV{ProgramFiles(x86)}/Microsoft DirectX SDK (March 2008)" - "$ENV{ProgramFiles}/Microsoft DirectX SDK (November 2007)" - "$ENV{ProgramFiles(x86)}/Microsoft DirectX SDK (November 2007)" - "$ENV{ProgramFiles}/Microsoft DirectX SDK (August 2007)" - "$ENV{ProgramFiles(x86)}/Microsoft DirectX SDK (August 2007)" + "${program_files}/Microsoft DirectX SDK (June 2010)" + "${program_files_x86}/Microsoft DirectX SDK (June 2010)" + "${program_files}/Microsoft DirectX SDK (February 2010)" + "${program_files_x86}/Microsoft DirectX SDK (February 2010)" + "${program_files}/Microsoft DirectX SDK (March 2009)" + "${program_files_x86}/Microsoft DirectX SDK (March 2009)" + "${program_files}/Microsoft DirectX SDK (August 2008)" + "${program_files_x86}/Microsoft DirectX SDK (August 2008)" + "${program_files}/Microsoft DirectX SDK (June 2008)" + "${program_files_x86}/Microsoft DirectX SDK (June 2008)" + "${program_files}/Microsoft DirectX SDK (March 2008)" + "${program_files_x86}/Microsoft DirectX SDK (March 2008)" + "${program_files}/Microsoft DirectX SDK (November 2007)" + "${program_files_x86}/Microsoft DirectX SDK (November 2007)" + "${program_files}/Microsoft DirectX SDK (August 2007)" + "${program_files_x86}/Microsoft DirectX SDK (August 2007)" ) if (DIRECTX_ROOT_DIR) @@ -38,10 +45,10 @@ if (WINDOWS) else (DIRECTX_ROOT_DIR) find_path (WIN_KIT_ROOT_DIR Include/um/windows.h PATHS - "$ENV{ProgramFiles}/Windows Kits/8.1" - "$ENV{ProgramFiles(x86)}/Windows Kits/8.1" - "$ENV{ProgramFiles}/Windows Kits/8.0" - "$ENV{ProgramFiles(x86)}/Windows Kits/8.0" + "${program_files}/Windows Kits/8.1" + "${program_files_x86}/Windows Kits/8.1" + "${program_files}/Windows Kits/8.0" + "${program_files_x86}/Windows Kits/8.0" ) find_path (WIN_KIT_LIB_DIR dxguid.lib diff --git a/indra/cmake/DownloadPrebuilt.cmake.in b/indra/cmake/DownloadPrebuilt.cmake.in index 7e4071d8a..5b67fedd4 100644 --- a/indra/cmake/DownloadPrebuilt.cmake.in +++ b/indra/cmake/DownloadPrebuilt.cmake.in @@ -2,7 +2,7 @@ # The top-level CMakeLists.txt configures packages and tool locations. set(packages "@PREBUILT_PACKAGES@") set(python "@PYTHON_EXECUTABLE@") -set(install_dir "@CMAKE_SOURCE_DIR@/..") +set(install_dir "@CMAKE_BINARY_DIR@/packages") set(scp "@SCP_EXECUTABLE@") set(scripts_dir "@SCRIPTS_DIR@") set(sentinel_dir "@CMAKE_BINARY_DIR@/prepare") @@ -20,7 +20,7 @@ foreach(package ${packages}) # This package is missing or out of date. message(STATUS "Obtaining${proprietary_message} prebuilt '${package}'") execute_process( - COMMAND ${python} install.py -p${prebuilt_type} --install-dir=${install_dir} ${scp_option} ${package} + COMMAND ${python} install.py -p${prebuilt_type} --install-dir=${install_dir} --installed-manifest=${install_dir}/installed.xml ${scp_option} ${package} WORKING_DIRECTORY ${scripts_dir} RESULT_VARIABLE result ) diff --git a/indra/cmake/ELFIO.cmake b/indra/cmake/ELFIO.cmake index fbde78311..8de2c36d4 100644 --- a/indra/cmake/ELFIO.cmake +++ b/indra/cmake/ELFIO.cmake @@ -8,7 +8,10 @@ if (STANDALONE) elseif (LINUX) use_prebuilt_binary(elfio) set(ELFIO_LIBRARIES ELFIO) - set(ELFIO_INCLUDE_DIR ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include) + set(ELFIO_INCLUDE_DIR + ${LIBS_PREBUILT_DIR}/include + ${LIBS_PREBUILT_LEGACY_DIR}/include + ) set(ELFIO_FOUND "YES") endif (STANDALONE) diff --git a/indra/cmake/EXPAT.cmake b/indra/cmake/EXPAT.cmake index 8a8f84526..bafe1a91e 100644 --- a/indra/cmake/EXPAT.cmake +++ b/indra/cmake/EXPAT.cmake @@ -9,9 +9,16 @@ if (STANDALONE) else (STANDALONE) use_prebuilt_binary(expat) if (WINDOWS) - set(EXPAT_LIBRARIES libexpatMT) + if (MSVC12) + set(EXPAT_LIBRARIES expat) + else (MSVC12) + set(EXPAT_LIBRARIES libexpatMT) + endif (MSVC12) else (WINDOWS) set(EXPAT_LIBRARIES expat) endif (WINDOWS) - set(EXPAT_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include) + set(EXPAT_INCLUDE_DIRS + ${LIBS_PREBUILT_DIR}/include + ${LIBS_PREBUILT_LEGACY_DIR}/include + ) endif (STANDALONE) diff --git a/indra/cmake/FMOD.cmake b/indra/cmake/FMOD.cmake deleted file mode 100644 index a2d9245ff..000000000 --- a/indra/cmake/FMOD.cmake +++ /dev/null @@ -1,52 +0,0 @@ -# -*- cmake -*- - -include(Linking) - -if(INSTALL_PROPRIETARY) - include(Prebuilt) - use_prebuilt_binary(fmod) -endif(INSTALL_PROPRIETARY) - -find_library(FMOD_LIBRARY - NAMES fmod fmodvc fmod-3.75 - PATHS - optimized ${ARCH_PREBUILT_DIRS_RELEASE} - debug ${ARCH_PREBUILT_DIRS_DEBUG} - ) - -if (NOT FMOD_LIBRARY) - set(FMOD_SDK_DIR CACHE PATH "Path to the FMOD SDK.") - if (FMOD_SDK_DIR) - find_library(FMOD_LIBRARY - NAMES fmodvc fmod-3.75 fmod - PATHS - ${FMOD_SDK_DIR}/api/lib - ${FMOD_SDK_DIR}/api - ${FMOD_SDK_DIR}/lib - ${FMOD_SDK_DIR} - ) - endif (FMOD_SDK_DIR) -endif (NOT FMOD_LIBRARY) - -find_path(FMOD_INCLUDE_DIR fmod.h - ${LIBS_PREBUILT_DIR}/include - ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include - ${FMOD_SDK_DIR}/api/inc - ${FMOD_SDK_DIR}/inc - ${FMOD_SDK_DIR} - ) - -if (FMOD_LIBRARY AND FMOD_INCLUDE_DIR) - set(FMOD ON CACHE BOOL "Use closed source FMOD sound library.") -else (FMOD_LIBRARY AND FMOD_INCLUDE_DIR) - set(FMOD_LIBRARY "") - set(FMOD_INCLUDE_DIR "") - if (FMOD) - message(STATUS "No support for FMOD audio (need to set FMOD_SDK_DIR?)") - endif (FMOD) - set(FMOD OFF CACHE BOOL "Use closed source FMOD sound library.") -endif (FMOD_LIBRARY AND FMOD_INCLUDE_DIR) - -if (FMOD) - message(STATUS "Building with FMOD audio support") -endif (FMOD) diff --git a/indra/cmake/FMODEX.cmake b/indra/cmake/FMODEX.cmake index f3425f1b2..ae95866c4 100644 --- a/indra/cmake/FMODEX.cmake +++ b/indra/cmake/FMODEX.cmake @@ -2,81 +2,115 @@ include(Linking) -if (NOT FMODEX_LIBRARY) - set(FMODEX_SDK_DIR CACHE PATH "Path to the FMOD Ex SDK.") - if (FMODEX_SDK_DIR) - if(WORD_SIZE EQUAL 32) - find_library(FMODEX_LIBRARY - fmodex_vc fmodexL_vc fmodex fmodexL - PATHS - "${FMODEX_SDK_DIR}/api/lib" - "${FMODEX_SDK_DIR}/api" - "${FMODEX_SDK_DIR}/lib" - "${FMODEX_SDK_DIR}" - ) - elseif(WORD_SIZE EQUAL 64) - find_library(FMODEX_LIBRARY - fmodex64_vc fmodexL64_vc fmodex64 fmodexL64 - PATHS - "${FMODEX_SDK_DIR}/api/lib" - "${FMODEX_SDK_DIR}/api" - "${FMODEX_SDK_DIR}/lib" - "${FMODEX_SDK_DIR}" - ) - endif(WORD_SIZE EQUAL 32) - endif(FMODEX_SDK_DIR) - if(WINDOWS AND NOT FMODEX_SDK_DIR) - GET_FILENAME_COMPONENT(FMODEX_PROG_DIR [HKEY_CURRENT_USER\\Software\\FMOD\ Programmers\ API\ Windows] ABSOLUTE CACHE) - if(WORD_SIZE EQUAL 32) - find_library(FMODEX_LIBRARY - fmodex_vc fmodexL_vc - PATHS - "${FMODEX_PROG_DIR}/api/lib" - "${FMODEX_PROG_DIR}/api" - "${FMODEX_PROG_DIR}" - ) - else(WORD_SIZE EQUAL 32) - find_library(FMODEX_LIBRARY - fmodex64_vc fmodexL64_vc - PATHS - "${FMODEX_PROG_DIR}/api/lib" - "${FMODEX_PROG_DIR}/api" - "${FMODEX_PROG_DIR}" - ) - endif(WORD_SIZE EQUAL 32) - if(FMODEX_LIBRARY) - message(STATUS "Found fmodex in ${FMODEX_PROG_DIR}") - set(FMODEX_SDK_DIR "${FMODEX_PROG_DIR}") - set(FMODEX_SDK_DIR "${FMODEX_PROG_DIR}" CACHE PATH "Path to the FMOD Ex SDK." FORCE) - endif(FMODEX_LIBRARY) - endif(WINDOWS AND NOT FMODEX_SDK_DIR) -endif (NOT FMODEX_LIBRARY) +if (FMODEX AND FMODSTUDIO) + message( FATAL_ERROR "You can not enable two FMOD variants at the same time." ) +endif (FMODEX AND FMODSTUDIO) -find_path(FMODEX_INCLUDE_DIR fmod.hpp - "${LIBS_PREBUILT_DIR}/include/fmodex" - "${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/fmodex" - "${FMODEX_SDK_DIR}/api/inc" - "${FMODEX_SDK_DIR}/inc" - "${FMODEX_SDK_DIR}" - ) +unset(FMOD_LIBRARY_RELEASE CACHE) +unset(FMOD_LIBRARY_DEBUG CACHE) +unset(FMOD_INCLUDE_DIR CACHE) -if(DARWIN) - set(FMODEX_ORIG_LIBRARY "${FMODEX_LIBRARY}") - set(FMODEX_LIBRARY "${CMAKE_CURRENT_BINARY_DIR}/libfmodex.dylib") -endif(DARWIN) +set(FMOD_EXTERNAL_LIB OFF) -if (FMODEX_LIBRARY AND FMODEX_INCLUDE_DIR) - set(FMODEX ON CACHE BOOL "Use closed source FMOD Ex sound library.") -else (FMODEX_LIBRARY AND FMODEX_INCLUDE_DIR) - set(FMODEX_LIBRARY "") - set(FMODEX_INCLUDE_DIR "") - if (FMODEX) - message(STATUS "No support for FMOD Ex audio (need to set FMODEX_SDK_DIR?)") - endif (FMODEX) - set(FMODEX OFF CACHE BOOL "Use closed source FMOD Ex sound library.") +if(STANDALONE OR WINDOWS) + if (NOT FMODEX_SDK_DIR AND WINDOWS) + GET_FILENAME_COMPONENT(REG_DIR [HKEY_CURRENT_USER\\Software\\FMOD\ Programmers\ API\ Windows] ABSOLUTE) + set(FMODEX_SDK_DIR ${REG_DIR} CACHE PATH "Path to the FMOD Ex SDK." FORCE) + endif (NOT FMODEX_SDK_DIR AND WINDOWS) + if(NOT FMODEX_SDK_DIR AND STANDALONE) + message(FATAL_ERROR "FMODEX_SDK_DIR not set!") + endif(NOT FMODEX_SDK_DIR AND STANDALONE) +endif(STANDALONE OR WINDOWS) + +if(FMODEX_SDK_DIR) + set(fmod_lib_paths "${FMODEX_SDK_DIR}/api" "${FMODEX_SDK_DIR}/api/lib" ) + set(fmod_inc_paths "${FMODEX_SDK_DIR}/api/inc") + + if(WINDOWS) + set(CMAKE_FIND_LIBRARY_SUFFIXES_OLD ${CMAKE_FIND_LIBRARY_SUFFIXES}) + set(CMAKE_FIND_LIBRARY_SUFFIXES .dll) + endif(WINDOWS) + if(WORD_SIZE EQUAL 64) + find_library(FMOD_LIBRARY_RELEASE fmodex64 PATHS ${fmod_lib_paths} NO_DEFAULT_PATH) + find_library(FMOD_LIBRARY_DEBUG fmodexL64 PATHS ${fmod_lib_paths} NO_DEFAULT_PATH) + else(WORD_SIZE EQUAL 64)#Check if CMAKE_FIND_LIBRARY_PREFIXES is set to 'lib' for darwin. + find_library(FMOD_LIBRARY_RELEASE fmodex PATHS ${fmod_lib_paths} NO_DEFAULT_PATH) + find_library(FMOD_LIBRARY_DEBUG fmodexL PATHS ${fmod_lib_paths} NO_DEFAULT_PATH) + endif(WORD_SIZE EQUAL 64) + if(WINDOWS) + set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES_OLD}) + if(WORD_SIZE EQUAL 64) + find_library(FMOD_LINK_LIBRARY_RELEASE fmodex64_vc PATHS ${fmod_lib_paths} NO_DEFAULT_PATH) + find_library(FMOD_LINK_LIBRARY_DEBUG fmodexL64_vc PATHS ${fmod_lib_paths} NO_DEFAULT_PATH) + else(WORD_SIZE EQUAL 64)#Check if CMAKE_FIND_LIBRARY_PREFIXES is set to 'lib' for darwin. + find_library(FMOD_LINK_LIBRARY_RELEASE fmodex_vc PATHS ${fmod_lib_paths} NO_DEFAULT_PATH) + find_library(FMOD_LINK_LIBRARY_DEBUG fmodexL_vc PATHS ${fmod_lib_paths} NO_DEFAULT_PATH) + endif(WORD_SIZE EQUAL 64) + else(WINDOWS) + set(FMOD_LINK_LIBRARY_RELEASE ${FMOD_LIBRARY_RELEASE}) + set(FMOD_LINK_LIBRARY_DEBUG ${FMOD_LIBRARY_DEBUG}) + endif(WINDOWS) + find_path(FMOD_INCLUDE_DIR fmod.hpp ${fmod_inc_paths}) + if(NOT FMOD_LIBRARY_RELEASE OR NOT FMOD_INCLUDE_DIR) + if(STANDALONE) + message(FATAL_ERROR "Provided FMODEX_SDK_DIR path not found '{$FMODEX_SDK_DIR}'") + else(STANDALONE) + message(STATUS "Provided FMODEX_SDK_DIR path not found '${FMODEX_SDK_DIR}'. Falling back to prebuilts") + endif(STANDALONE) + else(NOT FMOD_LIBRARY_RELEASE OR NOT FMOD_INCLUDE_DIR) + message(STATUS "Using system-provided FMOD Ex Libraries") + set(FMOD_EXTERNAL_LIB ON) + endif(NOT FMOD_LIBRARY_RELEASE OR NOT FMOD_INCLUDE_DIR) +endif (FMODEX_SDK_DIR) + +if (NOT FMOD_LIBRARY_RELEASE OR NOT FMOD_INCLUDE_DIR) + if(WINDOWS) + set(lib_suffix .dll) + elseif(DARWIN) + set(lib_suffix .dylib) + else(WINDOWS) + set(lib_suffix .so) + endif(WINDOWS) + if(WINDOWS) + if(WORD_SIZE EQUAL 64) + set(FMOD_LIBRARY_RELEASE ${LIBS_PREBUILT_DIR}/lib/release/fmodex64${lib_suffix}) + set(FMOD_LIBRARY_DEBUG ${LIBS_PREBUILT_DIR}/lib/debug/fmodexL64${lib_suffix}) + else(WORD_SIZE EQUAL 64) + set(FMOD_LIBRARY_RELEASE ${LIBS_PREBUILT_DIR}/lib/release/fmodex${lib_suffix}) + set(FMOD_LIBRARY_DEBUG ${LIBS_PREBUILT_DIR}/lib/debug/fmodexL${lib_suffix}) + endif(WORD_SIZE EQUAL 64) + else(WINDOWS) + if(WORD_SIZE EQUAL 64) + set(FMOD_LIBRARY_RELEASE ${LIBS_PREBUILT_DIR}/lib/release/libfmodex64${lib_suffix}) + set(FMOD_LIBRARY_DEBUG ${LIBS_PREBUILT_DIR}/lib/debug/libfmodex64L${lib_suffix}) + else(WORD_SIZE EQUAL 64) + set(FMOD_LIBRARY_RELEASE ${LIBS_PREBUILT_DIR}/lib/release/libfmodex${lib_suffix}) + set(FMOD_LIBRARY_DEBUG ${LIBS_PREBUILT_DIR}/lib/debug/libfmodexL${lib_suffix}) + endif(WORD_SIZE EQUAL 64) + endif(WINDOWS) + set(FMOD_LINK_LIBRARY_RELEASE ${FMOD_LIBRARY_RELEASE}) + set(FMOD_LINK_LIBRARY_DEBUG ${FMOD_LIBRARY_DEBUG}) + if(WINDOWS) + string(REPLACE ".dll" "_vc.lib" FMOD_LINK_LIBRARY_RELEASE ${FMOD_LIBRARY_RELEASE}) + string(REPLACE ".dll" "_vc.lib" FMOD_LINK_LIBRARY_DEBUG ${FMOD_LIBRARY_DEBUG}) + endif(WINDOWS) + use_prebuilt_binary(fmodex) + set(FMOD_INCLUDE_DIR + ${LIBS_PREBUILT_DIR}/include/fmodex) +endif(NOT FMOD_LIBRARY_RELEASE OR NOT FMOD_INCLUDE_DIR) + +if(FMOD_LIBRARY_RELEASE AND FMOD_INCLUDE_DIR) + set(FMOD ON) + if (NOT FMOD_LIBRARY_DEBUG) #Use release library in debug configuration if debug library is absent. + set(FMOD_LIBRARY_DEBUG ${FMOD_LIBRARY_RELEASE}) + endif (NOT FMOD_LIBRARY_DEBUG) +else (FMOD_LIBRARY_RELEASE AND FMOD_INCLUDE_DIR) + message(STATUS "No support for FMOD EX audio (need to set FMODEX_SDK_DIR?)") + set(FMOD OFF) set(FMODEX OFF) -endif (FMODEX_LIBRARY AND FMODEX_INCLUDE_DIR) +endif (FMOD_LIBRARY_RELEASE AND FMOD_INCLUDE_DIR) -if (FMODEX) +if (FMOD) message(STATUS "Building with FMOD Ex audio support") -endif (FMODEX) + set(LLSTARTUP_COMPILE_FLAGS "${LLSTARTUP_COMPILE_FLAGS} -DLL_FMODEX") +endif (FMOD) diff --git a/indra/cmake/FMODSTUDIO.cmake b/indra/cmake/FMODSTUDIO.cmake new file mode 100644 index 000000000..0939540f4 --- /dev/null +++ b/indra/cmake/FMODSTUDIO.cmake @@ -0,0 +1,112 @@ +# -*- cmake -*- + +include(Linking) + +if (FMODEX AND FMODSTUDIO) + message( FATAL_ERROR "You can not enable two FMOD variants at the same time." ) +endif (FMODEX AND FMODSTUDIO) + +unset(FMOD_LIBRARY_RELEASE CACHE) +unset(FMOD_LIBRARY_DEBUG CACHE) +unset(FMOD_INCLUDE_DIR CACHE) + +set(FMOD_EXTERNAL_LIB OFF) + +if(STANDALONE OR WINDOWS) + if (NOT FMODSTUDIO_SDK_DIR AND WINDOWS) + GET_FILENAME_COMPONENT(REG_DIR [HKEY_CURRENT_USER\\Software\\FMOD\ Studio\ API\ Windows] ABSOLUTE) + set(FMODSTUDIO_SDK_DIR ${REG_DIR} CACHE PATH "Path to the FMOD Studio SDK." FORCE) + endif (NOT FMODSTUDIO_SDK_DIR AND WINDOWS) + if(NOT FMODSTUDIO_SDK_DIR) + message(FATAL_ERROR "FMODSTUDIO_SDK_DIR not set!") + endif(NOT FMODSTUDIO_SDK_DIR) +endif(STANDALONE OR WINDOWS) + +if(FMODSTUDIO_SDK_DIR) + if(LINUX AND WORD_SIZE EQUAL 32) + set(fmod_lib_paths "${FMODSTUDIO_SDK_DIR}/api/lowlevel/lib/x86" ) + elseif(LINUX) + set(fmod_lib_paths "${FMODSTUDIO_SDK_DIR}/api/lowlevel/lib/x86_64") + else(LINUX AND WORD_SIZE EQUAL 32) + set(fmod_lib_paths "${FMODSTUDIO_SDK_DIR}/api/lowlevel/lib") + endif(LINUX AND WORD_SIZE EQUAL 32) + set(fmod_inc_paths "${FMODSTUDIO_SDK_DIR}/api/lowlevel/inc") + + if(WINDOWS) + set(CMAKE_FIND_LIBRARY_SUFFIXES_OLD ${CMAKE_FIND_LIBRARY_SUFFIXES}) + set(CMAKE_FIND_LIBRARY_SUFFIXES .dll) + endif(WINDOWS) + if(WORD_SIZE EQUAL 64 AND WINDOWS) + find_library(FMOD_LIBRARY_RELEASE fmod64 PATHS ${fmod_lib_paths} NO_DEFAULT_PATH) + find_library(FMOD_LIBRARY_DEBUG fmodL64 PATHS ${fmod_lib_paths} NO_DEFAULT_PATH) + else(WORD_SIZE EQUAL 64 AND WINDOWS)#Check if CMAKE_FIND_LIBRARY_PREFIXES is set to 'lib' for darwin. + find_library(FMOD_LIBRARY_RELEASE fmod PATHS ${fmod_lib_paths} NO_DEFAULT_PATH) + find_library(FMOD_LIBRARY_DEBUG fmodL PATHS ${fmod_lib_paths} NO_DEFAULT_PATH) + endif(WORD_SIZE EQUAL 64 AND WINDOWS) + if(WINDOWS) + set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES_OLD}) + string(REPLACE ".dll" "_vc.lib" FMOD_LINK_LIBRARY_RELEASE ${FMOD_LIBRARY_RELEASE}) + string(REPLACE ".dll" "_vc.lib" FMOD_LINK_LIBRARY_DEBUG ${FMOD_LIBRARY_DEBUG}) + else(WINDOWS) + set(FMOD_LINK_LIBRARY_RELEASE ${FMOD_LIBRARY_RELEASE}) + set(FMOD_LINK_LIBRARY_DEBUG ${FMOD_LIBRARY_DEBUG}) + endif(WINDOWS) + find_path(FMOD_INCLUDE_DIR fmod.hpp ${fmod_inc_paths}) + if(NOT FMOD_LIBRARY_RELEASE OR NOT FMOD_INCLUDE_DIR) + if(STANDALONE) + message(FATAL_ERROR "Provided FMODSTUDIO_SDK_DIR path not found '{$FMODSTUDIO_SDK_DIR}'") + else(STANDALONE) + message(STATUS "Provided FMODSTUDIO_SDK_DIR path not found '${FMODSTUDIO_SDK_DIR}'. Falling back to prebuilts") + endif(STANDALONE) + else(NOT FMOD_LIBRARY_RELEASE OR NOT FMOD_INCLUDE_DIR) + message(STATUS "Using system-provided FMOD Studio Libraries") + set(FMOD_EXTERNAL_LIB ON) + endif(NOT FMOD_LIBRARY_RELEASE OR NOT FMOD_INCLUDE_DIR) +endif (FMODSTUDIO_SDK_DIR) + +if (NOT FMOD_LIBRARY_RELEASE OR NOT FMOD_INCLUDE_DIR) + if(WINDOWS) + set(lib_suffix .dll) + elseif(DARWIN) + set(lib_suffix .dylib) + else(WINDOWS) + set(lib_suffix .so) + endif(WINDOWS) + if(WINDOWS) + if(WORD_SIZE EQUAL 64) + set(FMOD_LIBRARY_RELEASE ${LIBS_PREBUILT_DIR}/lib/release/fmod64${lib_suffix}) + set(FMOD_LIBRARY_DEBUG ${LIBS_PREBUILT_DIR}/lib/debug/fmodL64${lib_suffix}) + else(WORD_SIZE EQUAL 64) + set(FMOD_LIBRARY_RELEASE ${LIBS_PREBUILT_DIR}/lib/release/fmod${lib_suffix}) + set(FMOD_LIBRARY_DEBUG ${LIBS_PREBUILT_DIR}/lib/debug/fmodL${lib_suffix}) + endif(WORD_SIZE EQUAL 64) + else(WINDOWS) + set(FMOD_LIBRARY_RELEASE ${LIBS_PREBUILT_DIR}/lib/release/libfmod${lib_suffix}) + set(FMOD_LIBRARY_DEBUG ${LIBS_PREBUILT_DIR}/lib/debug/libfmodL${lib_suffix}) + endif(WINDOWS) + set(FMOD_LINK_LIBRARY_RELEASE ${FMOD_LIBRARY_RELEASE}) + set(FMOD_LINK_LIBRARY_DEBUG ${FMOD_LIBRARY_DEBUG}) + if(WINDOWS) + string(REPLACE ".dll" "_vc.lib" FMOD_LINK_LIBRARY_RELEASE ${FMOD_LIBRARY_RELEASE}) + string(REPLACE ".dll" "_vc.lib" FMOD_LINK_LIBRARY_DEBUG ${FMOD_LIBRARY_DEBUG}) + endif(WINDOWS) + use_prebuilt_binary(fmodstudio) + set(FMOD_INCLUDE_DIR + ${LIBS_PREBUILT_DIR}/include/fmodstudio) +endif(NOT FMOD_LIBRARY_RELEASE OR NOT FMOD_INCLUDE_DIR) + +if(FMOD_LIBRARY_RELEASE AND FMOD_INCLUDE_DIR) + set(FMOD ON) + if (NOT FMOD_LIBRARY_DEBUG) #Use release library in debug configuration if debug library is absent. + set(FMOD_LIBRARY_DEBUG ${FMOD_LIBRARY_RELEASE}) + endif (NOT FMOD_LIBRARY_DEBUG) +else (FMOD_LIBRARY_RELEASE AND FMOD_INCLUDE_DIR) + message(STATUS "No support for FMOD Studio audio (need to set FMODSTUDIO_SDK_DIR?)") + set(FMOD OFF) + set(FMODSTUDIO OFF) +endif (FMOD_LIBRARY_RELEASE AND FMOD_INCLUDE_DIR) + +if (FMOD) + message(STATUS "Building with FMOD Studio audio support") + set(LLSTARTUP_COMPILE_FLAGS "${LLSTARTUP_COMPILE_FLAGS} -DLL_FMODSTUDIO") +endif (FMOD) diff --git a/indra/cmake/FreeType.cmake b/indra/cmake/FreeType.cmake index e9d4d8093..5cca587cf 100644 --- a/indra/cmake/FreeType.cmake +++ b/indra/cmake/FreeType.cmake @@ -7,12 +7,17 @@ if (STANDALONE) pkg_check_modules(FREETYPE REQUIRED freetype2) else (STANDALONE) use_prebuilt_binary(freetype) - if (LINUX) + if(MSVC12) set(FREETYPE_INCLUDE_DIRS - ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include) - else (LINUX) - set(FREETYPE_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include) - endif (LINUX) + ${LIBS_PREBUILT_DIR}/include/freetype2 + ${LIBS_PREBUILT_LEGACY_DIR}/include/freetype2 + ) + else(MSVC12) + set(FREETYPE_INCLUDE_DIRS + ${LIBS_PREBUILT_DIR}/include + ${LIBS_PREBUILT_LEGACY_DIR}/include + ) + endif (MSVC12) set(FREETYPE_LIBRARIES freetype) endif (STANDALONE) diff --git a/indra/cmake/GLOD.cmake b/indra/cmake/GLOD.cmake index e46a72c86..d688db2fe 100644 --- a/indra/cmake/GLOD.cmake +++ b/indra/cmake/GLOD.cmake @@ -8,6 +8,9 @@ if (STANDALONE) include(FindGLOD) else (STANDALONE) use_prebuilt_binary(GLOD) - set(GLOD_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include) + set(GLOD_INCLUDE_DIRS + ${LIBS_PREBUILT_DIR}/include + ${LIBS_PREBUILT_LEGACY_DIR}/include + ) set(GLOD_LIBRARIES glod) endif (STANDALONE) diff --git a/indra/cmake/GStreamer010Plugin.cmake b/indra/cmake/GStreamer010Plugin.cmake index 90ed35c81..9fdf60eba 100644 --- a/indra/cmake/GStreamer010Plugin.cmake +++ b/indra/cmake/GStreamer010Plugin.cmake @@ -16,10 +16,13 @@ else (STANDALONE) set(GSTREAMER010_FOUND ON FORCE BOOL) set(GSTREAMER010_PLUGINS_BASE_FOUND ON FORCE BOOL) set(GSTREAMER010_INCLUDE_DIRS - ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include/gstreamer-0.10 - ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include/glib-2.0 - ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include/libxml2 - ) + ${LIBS_PREBUILT_DIR}/include/gstreamer-0.10 + ${LIBS_PREBUILT_DIR}/includeg/lib-2.0 + ${LIBS_PREBUILT_DIR}/include/libxml2 + ${LIBS_PREBUILT_LEGACY_DIR}/include/gstreamer-0.10 + ${LIBS_PREBUILT_LEGACY_DIR}/include/glib-2.0 + ${LIBS_PREBUILT_LEGACY_DIR}/include/libxml2 + ) endif (STANDALONE) diff --git a/indra/cmake/GoogleBreakpad.cmake b/indra/cmake/GoogleBreakpad.cmake index 69e54ee1b..de899a462 100644 --- a/indra/cmake/GoogleBreakpad.cmake +++ b/indra/cmake/GoogleBreakpad.cmake @@ -17,5 +17,10 @@ else (STANDALONE) endif (WINDOWS) # yes, this does look dumb, no, it's not incorrect # I think it's incorrect: the second one should go --Aleric - set(BREAKPAD_INCLUDE_DIRECTORIES "${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include/google_breakpad" "${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include/google_breakpad/google_breakpad") + set(BREAKPAD_INCLUDE_DIRECTORIES + ${LIBS_PREBUILT_DIR}/include/google_breakpad + ${LIBS_PREBUILT_LEGACY_DIR}/include/google_breakpad + ${LIBS_PREBUILT_DIR}/include/google_breakpad/google_breakpad + ${LIBS_PREBUILT_LEGACY_DIR}/include/google_breakpad/google_breakpad + ) endif (STANDALONE) diff --git a/indra/cmake/GooglePerfTools.cmake b/indra/cmake/GooglePerfTools.cmake index d92c39ded..49ff3f5eb 100644 --- a/indra/cmake/GooglePerfTools.cmake +++ b/indra/cmake/GooglePerfTools.cmake @@ -25,7 +25,9 @@ else (STANDALONE) set(TCMALLOC_LIBRARIES tcmalloc_minimal) endif() set(GOOGLE_PERFTOOLS_INCLUDE_DIR - ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include) + ${LIBS_PREBUILT_DIR}/include + ${LIBS_PREBUILT_LEGACY_DIR}/include + ) endif (LINUX) endif (STANDALONE) diff --git a/indra/cmake/Hunspell.cmake b/indra/cmake/Hunspell.cmake index 363f061b5..3ea97afdf 100644 --- a/indra/cmake/Hunspell.cmake +++ b/indra/cmake/Hunspell.cmake @@ -6,7 +6,10 @@ if (STANDALONE) else (STANDALONE) use_prebuilt_binary(hunspell) - set(HUNSPELL_INCLUDE_DIR ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include/hunspell) + set(HUNSPELL_INCLUDE_DIR + ${LIBS_PREBUILT_DIR}/include/hunspell + ${LIBS_PREBUILT_LEGACY_DIR}/include/hunspell + ) if (LINUX OR DARWIN) set(HUNSPELL_LIBRARY hunspell-1.3) diff --git a/indra/cmake/JPEG.cmake b/indra/cmake/JPEG.cmake index 5c55aedbb..2fe1beb51 100644 --- a/indra/cmake/JPEG.cmake +++ b/indra/cmake/JPEG.cmake @@ -13,11 +13,14 @@ else (STANDALONE) set(JPEG_LIBRARIES jpeg) elseif (DARWIN) set(JPEG_LIBRARIES - optimized ${ARCH_PREBUILT_DIRS_RELEASE}/libjpeg.a - debug ${ARCH_PREBUILT_DIRS_DEBUG}/libjpeg.a + debug libjpeg.a + optimized libjpeg.a ) elseif (WINDOWS) set(JPEG_LIBRARIES jpeglib) endif (LINUX) - set(JPEG_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include) + set(JPEG_INCLUDE_DIRS + ${LIBS_PREBUILT_DIR}/include + ${LIBS_PREBUILT_LEGACY_DIR}/include + ) endif (STANDALONE) diff --git a/indra/cmake/JsonCpp.cmake b/indra/cmake/JsonCpp.cmake index 499089843..3ab859d4d 100644 --- a/indra/cmake/JsonCpp.cmake +++ b/indra/cmake/JsonCpp.cmake @@ -10,13 +10,22 @@ if (STANDALONE) else (STANDALONE) use_prebuilt_binary(jsoncpp) if (WINDOWS) - set(JSONCPP_LIBRARIES - debug json_vc${MSVC_SUFFIX}d - optimized json_vc${MSVC_SUFFIX}) + if(MSVC12) + set(JSONCPP_LIBRARIES + debug json_vc${MSVC_SUFFIX}debug_libmt.lib + optimized json_vc${MSVC_SUFFIX}_libmt) + else(MSVC12) + set(JSONCPP_LIBRARIES + debug json_vc${MSVC_SUFFIX}d + optimized json_vc${MSVC_SUFFIX}) + endif(MSVC12) elseif (DARWIN) set(JSONCPP_LIBRARIES json_linux-gcc-4.0.1_libmt) elseif (LINUX) set(JSONCPP_LIBRARIES jsoncpp) endif (WINDOWS) - set(JSONCPP_INCLUDE_DIR ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include/jsoncpp) + set(JSONCPP_INCLUDE_DIR + ${LIBS_PREBUILT_DIR}/include/jsoncpp + ${LIBS_PREBUILT_LEGACY_DIR}/include/jsoncpp + ) endif (STANDALONE) diff --git a/indra/cmake/LLAddBuildTest.cmake b/indra/cmake/LLAddBuildTest.cmake index 3d42088bc..290db9f22 100644 --- a/indra/cmake/LLAddBuildTest.cmake +++ b/indra/cmake/LLAddBuildTest.cmake @@ -87,7 +87,7 @@ MACRO(ADD_BUILD_TEST_INTERNAL name parent libraries source_files) ${libraries} ) - GET_TARGET_PROPERTY(TEST_EXE ${name}_test LOCATION) + SET(TEST_EXE $) SET(TEST_OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${name}_test_ok.txt) IF ("${wrapper}" STREQUAL "") diff --git a/indra/cmake/LLSharedLibs.cmake b/indra/cmake/LLSharedLibs.cmake index 14dd67f32..982b2d3f7 100644 --- a/indra/cmake/LLSharedLibs.cmake +++ b/indra/cmake/LLSharedLibs.cmake @@ -1,17 +1,13 @@ # ll_deploy_sharedlibs_command # target_exe: the cmake target of the executable for which the shared libs will be deployed. macro(ll_deploy_sharedlibs_command target_exe) - get_target_property(TARGET_LOCATION ${target_exe} LOCATION) - get_filename_component(OUTPUT_PATH ${TARGET_LOCATION} PATH) + SET(OUTPUT_PATH $) if(DARWIN) SET_TEST_PATH(SEARCH_DIRS) get_target_property(IS_BUNDLE ${target_exe} MACOSX_BUNDLE) if(IS_BUNDLE) # If its a bundle the exe is not in the target location, this should find it. - get_filename_component(TARGET_FILE ${TARGET_LOCATION} NAME) - set(OUTPUT_PATH ${TARGET_LOCATION}.app/Contents/MacOS) - set(TARGET_LOCATION ${OUTPUT_PATH}/${TARGET_FILE}) set(OUTPUT_PATH ${OUTPUT_PATH}/../Resources) endif(IS_BUNDLE) elseif(WINDOWS) @@ -26,7 +22,7 @@ macro(ll_deploy_sharedlibs_command target_exe) TARGET ${target_exe} POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS - "-DBIN_NAME=\"${TARGET_LOCATION}\"" + "-DBIN_NAME=\"$\"" "-DSEARCH_DIRS=\"${SEARCH_DIRS}\"" "-DDST_PATH=\"${OUTPUT_PATH}\"" "-P" @@ -42,7 +38,8 @@ macro(ll_stage_sharedlib DSO_TARGET) # Also this directory is shared with RunBuildTest.cmake, y'know, for the tests. set_target_properties(${DSO_TARGET} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${SHARED_LIB_STAGING_DIR}) if(NOT WINDOWS) - get_target_property(DSO_PATH ${DSO_TARGET} LOCATION) + + SET(DSO_PATH $) get_filename_component(DSO_FILE ${DSO_PATH} NAME) if(DARWIN) set(SHARED_LIB_STAGING_DIR_CONFIG ${SHARED_LIB_STAGING_DIR}/${CMAKE_CFG_INTDIR}/Resources) diff --git a/indra/cmake/LLWindow.cmake b/indra/cmake/LLWindow.cmake index a46d9c592..c5de9d269 100644 --- a/indra/cmake/LLWindow.cmake +++ b/indra/cmake/LLWindow.cmake @@ -17,7 +17,10 @@ else (STANDALONE) use_prebuilt_binary(mesa) use_prebuilt_binary(SDL) set (SDL_FOUND TRUE) - set (SDL_INCLUDE_DIR ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}) + set (SDL_INCLUDE_DIR + ${LIBS_PREBUILT_DIR}/include + ${LIBS_PREBUILT_LEGACY_DIR}/include + ) if(WORD_SIZE EQUAL 64) set (SDL_LIBRARY SDL) else(WORD_SIZE EQUAL 64) diff --git a/indra/cmake/Linking.cmake b/indra/cmake/Linking.cmake index e7bc897c9..a0ce0f6f1 100644 --- a/indra/cmake/Linking.cmake +++ b/indra/cmake/Linking.cmake @@ -5,26 +5,35 @@ set(${CMAKE_CURRENT_LIST_FILE}_INCLUDED "YES") include(Variables) if (NOT STANDALONE) - set(ARCH_PREBUILT_DIRS ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/lib) - set(ARCH_PREBUILT_DIRS_RELEASE ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/lib/release) - set(ARCH_PREBUILT_DIRS_DEBUG ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/lib/debug) + + if(CMAKE_BUILD_TYPE) + string(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_LOWER) + endif(CMAKE_BUILD_TYPE) if(WINDOWS OR ${CMAKE_GENERATOR} MATCHES "Xcode") # the cmake xcode and VS generators implicitly append ${CMAKE_CFG_INTDIR} to the library paths for us # fortunately both windows and darwin are case insensitive filesystems so this works. - set(ARCH_PREBUILT_LINK_DIRS "${ARCH_PREBUILT_DIRS}") + set(ARCH_PREBUILT_LINK_DIRS + ${LIBS_PREBUILT_DIR}/lib + ${LIBS_PREBUILT_LEGACY_DIR}/lib + ) else(WINDOWS OR ${CMAKE_GENERATOR} MATCHES "Xcode") # else block is for linux and any other makefile based generators - string(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_LOWER) - set(ARCH_PREBUILT_LINK_DIRS ${ARCH_PREBUILT_DIRS}/${CMAKE_BUILD_TYPE_LOWER}) + set(ARCH_PREBUILT_LINK_DIRS + ${LIBS_PREBUILT_DIR}/lib/${CMAKE_BUILD_TYPE_LOWER} + ${LIBS_PREBUILT_LEGACY_DIR}/lib/${CMAKE_BUILD_TYPE_LOWER} + ) endif(WINDOWS OR ${CMAKE_GENERATOR} MATCHES "Xcode") - if (NOT "${CMAKE_BUILD_TYPE}" STREQUAL "Release") + if (NOT "${CMAKE_BUILD_TYPE_LOWER}" STREQUAL "release") # When we're building something other than Release, append the # packages/lib/release directory to deal with autobuild packages that don't # provide (e.g.) lib/debug libraries. - list(APPEND ARCH_PREBUILT_LINK_DIRS ${ARCH_PREBUILT_DIRS_RELEASE}) - endif (NOT "${CMAKE_BUILD_TYPE}" STREQUAL "Release") + list(APPEND ARCH_PREBUILT_LINK_DIRS + ${LIBS_PREBUILT_DIR}/lib/release + ${LIBS_PREBUILT_LEGACY_DIR}/lib/release + ) + endif (NOT "${CMAKE_BUILD_TYPE_LOWER}" STREQUAL "release") endif (NOT STANDALONE) link_directories(${ARCH_PREBUILT_LINK_DIRS}) @@ -37,7 +46,7 @@ else (LINUX) set(PTHREAD_LIBRARY "") endif (LINUX) -if (WINDOWS) +if (WINDOWS) set(WINDOWS_LIBRARIES advapi32 shell32 diff --git a/indra/cmake/NDOF.cmake b/indra/cmake/NDOF.cmake index a4e210405..d7fb4e686 100644 --- a/indra/cmake/NDOF.cmake +++ b/indra/cmake/NDOF.cmake @@ -15,7 +15,10 @@ else (STANDALONE) set(NDOF_LIBRARY ndofdev) endif (WINDOWS) - set(NDOF_INCLUDE_DIR ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include/ndofdev) + set(NDOF_INCLUDE_DIR + ${LIBS_PREBUILT_DIR}/include/ndofdev + ${LIBS_PREBUILT_LEGACY_DIR}/include/ndofdev + ) set(NDOF_FOUND 1) endif (STANDALONE) diff --git a/indra/cmake/OPENAL.cmake b/indra/cmake/OPENAL.cmake index d5ab802d9..39ab8210d 100644 --- a/indra/cmake/OPENAL.cmake +++ b/indra/cmake/OPENAL.cmake @@ -2,6 +2,7 @@ include(Linking) include(Prebuilt) +if(NOT FMOD) if (LINUX) set(OPENAL ON CACHE BOOL "Enable OpenAL") else (LINUX) @@ -21,9 +22,14 @@ if (OPENAL) openal alut ) - set(OPENAL_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include) + set(OPENAL_INCLUDE_DIRS + ${LIBS_PREBUILT_DIR}/include + ${LIBS_PREBUILT_LEGACY_DIR}/include + ) endif (OPENAL) if (OPENAL) message(STATUS "Building with OpenAL audio support") + set(LLSTARTUP_COMPILE_FLAGS "${LLSTARTUP_COMPILE_FLAGS} -DLL_OPENAL") endif (OPENAL) +endif(NOT FMOD) diff --git a/indra/cmake/OpenGL.cmake b/indra/cmake/OpenGL.cmake index 0bfc1a359..abf908f23 100644 --- a/indra/cmake/OpenGL.cmake +++ b/indra/cmake/OpenGL.cmake @@ -3,5 +3,8 @@ include(Prebuilt) if (NOT (STANDALONE OR DARWIN)) use_prebuilt_binary(glext) - set(GLEXT_INCLUDE_DIR ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include) + set(GLEXT_INCLUDE_DIR + ${LIBS_PREBUILT_DIR}/include + ${LIBS_PREBUILT_LEGACY_DIR}/include + ) endif (NOT (STANDALONE OR DARWIN)) diff --git a/indra/cmake/OpenSSL.cmake b/indra/cmake/OpenSSL.cmake index 51532054c..d363e6af3 100644 --- a/indra/cmake/OpenSSL.cmake +++ b/indra/cmake/OpenSSL.cmake @@ -13,7 +13,10 @@ else (STANDALONE OR USE_SYSTEM_OPENSSL) else (WINDOWS) set(OPENSSL_LIBRARIES ssl) endif (WINDOWS) - set(OPENSSL_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include) + set(OPENSSL_INCLUDE_DIRS + ${LIBS_PREBUILT_DIR}/include + ${LIBS_PREBUILT_LEGACY_DIR}/include + ) endif (STANDALONE OR USE_SYSTEM_OPENSSL) if (LINUX) diff --git a/indra/cmake/PNG.cmake b/indra/cmake/PNG.cmake index 7312156fc..fb71c3067 100644 --- a/indra/cmake/PNG.cmake +++ b/indra/cmake/PNG.cmake @@ -8,9 +8,12 @@ if (STANDALONE) include(FindPNG) else (STANDALONE) use_prebuilt_binary(libpng) - set(PNG_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include/) if (WINDOWS) - set(PNG_LIBRARIES libpng15) + if(MSVC12) + set(PNG_LIBRARIES libpng16) + else(MSVC12) + set(PNG_LIBRARIES libpng15) + endif(MSVC12) elseif(DARWIN) set(PNG_LIBRARIES png15) else(LINUX) @@ -31,7 +34,17 @@ else (STANDALONE) # set(PNG_PRELOAD_ARCHIVES -Wl,--whole-archive png16 -Wl,--no-whole-archive) set(PNG_LIBRARIES png16) - set(PNG_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include/libpng16) endif () endif() + if (WINDOWS) + set(PNG_INCLUDE_DIRS + ${LIBS_PREBUILT_DIR}/include/${PNG_LIBRARIES} + ${LIBS_PREBUILT_LEGACY_DIR}/include/${PNG_LIBRARIES} + ) + else (WINDOWS) + set(PNG_INCLUDE_DIRS + ${LIBS_PREBUILT_DIR}/include/lib${PNG_LIBRARIES} + ${LIBS_PREBUILT_LEGACY_DIR}/include/lib${PNG_LIBRARIES} + ) + endif (WINDOWS) endif (STANDALONE) diff --git a/indra/cmake/PulseAudio.cmake b/indra/cmake/PulseAudio.cmake index dafdd4163..62e2bf9b2 100644 --- a/indra/cmake/PulseAudio.cmake +++ b/indra/cmake/PulseAudio.cmake @@ -13,8 +13,9 @@ if (PULSEAUDIO) use_prebuilt_binary(pulseaudio) set(PULSEAUDIO_FOUND ON FORCE BOOL) set(PULSEAUDIO_INCLUDE_DIRS - ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include - ) + ${LIBS_PREBUILT_DIR}/include + ${LIBS_PREBUILT_LEGACY_DIR}/include + ) # We don't need to explicitly link against pulseaudio itself, because # the viewer probes for the system's copy at runtime. set(PULSEAUDIO_LIBRARIES diff --git a/indra/cmake/QuickTimePlugin.cmake b/indra/cmake/QuickTimePlugin.cmake index cb54e287a..171213d42 100644 --- a/indra/cmake/QuickTimePlugin.cmake +++ b/indra/cmake/QuickTimePlugin.cmake @@ -9,18 +9,29 @@ if (DARWIN) include(CMakeFindFrameworks) find_library(QUICKTIME_LIBRARY QuickTime) elseif (WINDOWS AND WORD_SIZE EQUAL 32) - set(QUICKTIME_SDK_DIR "$ENV{PROGRAMFILES}/QuickTime SDK" + SET(program_files "ProgramFiles(x86)") + SET(program_files $ENV{${program_files}}) + if(NOT program_files) + SET(program_files $ENV{ProgramW6432}) + endif(NOT program_files) + if(NOT program_files) + SET(program_files $ENV{ProgramFiles}) + endif(NOT program_files) + + set(QUICKTIME_SDK_DIR "${program_files}/QuickTime SDK" CACHE PATH "Location of the QuickTime SDK.") find_library(DEBUG_QUICKTIME_LIBRARY qtmlclient PATHS - ${ARCH_PREBUILT_DIRS_DEBUG} + ${LIBS_PREBUILT_DIR}/lib/debug + ${LIBS_PREBUILT_LEGACY_DIR}/lib/debug "${QUICKTIME_SDK_DIR}\\libraries" ) find_library(RELEASE_QUICKTIME_LIBRARY qtmlclient PATHS - ${ARCH_PREBUILT_DIRS_RELEASE} + ${LIBS_PREBUILT_DIR}/lib/release + ${LIBS_PREBUILT_LEGACY_DIR}/lib/release "${QUICKTIME_SDK_DIR}\\libraries" ) @@ -33,7 +44,8 @@ elseif (WINDOWS AND WORD_SIZE EQUAL 32) endif (DEBUG_QUICKTIME_LIBRARY AND RELEASE_QUICKTIME_LIBRARY) include_directories( - ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include/quicktime + ${LIBS_PREBUILT_DIR}/include/quicktime + ${LIBS_PREBUILT_LEGACY_DIR}/include/quicktime "${QUICKTIME_SDK_DIR}\\CIncludes" ) endif (DARWIN) diff --git a/indra/cmake/UI.cmake b/indra/cmake/UI.cmake index 679b5bf3a..697ac4288 100644 --- a/indra/cmake/UI.cmake +++ b/indra/cmake/UI.cmake @@ -55,12 +55,18 @@ else (STANDALONE) endif (LINUX) include_directories ( - ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include - ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include/cairo - ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include/pixman-1 + ${LIBS_PREBUILT_DIR}/packages/include + ${LIBS_PREBUILT_DIR}/packages/include/cairo + ${LIBS_PREBUILT_DIR}/packages/include/pixman-1 + ${LIBS_PREBUILT_LEGACY_DIR}/include + ${LIBS_PREBUILT_LEGACY_DIR}/include/cairo + ${LIBS_PREBUILT_LEGACY_DIR}/include/pixman-1 ) foreach(include ${${LL_ARCH}_INCLUDES}) - include_directories(${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include/${include}) + include_directories( + ${LIBS_PREBUILT_DIR}/include/${include} + ${LIBS_PREBUILT_LEGACY_DIR}/include/${include} + ) endforeach(include) endif (STANDALONE) diff --git a/indra/cmake/UnixInstall.cmake b/indra/cmake/UnixInstall.cmake index 630999d80..f566aad3d 100644 --- a/indra/cmake/UnixInstall.cmake +++ b/indra/cmake/UnixInstall.cmake @@ -11,6 +11,6 @@ if (INSTALL) set(APP_BIN_DIR bin) endif(NOT APP_BIN_DIR) if(NOT APP_SHARE_DIR) - set(APP_SHARE_DIR share/secondlife-${viewer_VERSION}) + set(APP_SHARE_DIR share/secondlife-${${ROOT_PROJECT_NAME}_VERSION}) endif(NOT APP_SHARE_DIR) endif (INSTALL) diff --git a/indra/cmake/Variables.cmake b/indra/cmake/Variables.cmake index a8df1d307..5b9890d5b 100644 --- a/indra/cmake/Variables.cmake +++ b/indra/cmake/Variables.cmake @@ -32,9 +32,6 @@ set(DISABLE_TCMALLOC OFF CACHE BOOL "Disable linkage of TCMalloc. (64bit builds set(LL_TESTS OFF CACHE BOOL "Build and run unit and integration tests (disable for build timing runs to reduce variation)") set(DISABLE_FATAL_WARNINGS TRUE CACHE BOOL "Set this to FALSE to enable fatal warnings.") -set(LIBS_PREBUILT_DIR ${CMAKE_SOURCE_DIR}/../libraries CACHE PATH - "Location of prebuilt libraries.") - if (${CMAKE_SYSTEM_NAME} MATCHES "Windows") set(WINDOWS ON BOOL FORCE) if (WORD_SIZE EQUAL 32) @@ -154,6 +151,12 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") set(LL_ARCH_DIR universal-darwin) endif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") +set(LIBS_PREBUILT_DIR ${CMAKE_BINARY_DIR}/packages CACHE PATH + "Location of prebuilt libraries.") + +set(LIBS_PREBUILT_LEGACY_DIR ${CMAKE_BINARY_DIR}/packages/libraries/${LL_ARCH_DIR} CACHE PATH + "Legacy location of prebuilt libraries.") + if (WINDOWS AND WORD_SIZE EQUAL 32) set(PREBUILT_TYPE windows) elseif (WINDOWS AND WORD_SIZE EQUAL 64) diff --git a/indra/cmake/WebKitLibPlugin.cmake b/indra/cmake/WebKitLibPlugin.cmake index 7a6305f22..8551aa163 100644 --- a/indra/cmake/WebKitLibPlugin.cmake +++ b/indra/cmake/WebKitLibPlugin.cmake @@ -32,8 +32,8 @@ if (WINDOWS) ) elseif (DARWIN) set(WEBKIT_PLUGIN_LIBRARIES - optimized ${ARCH_PREBUILT_DIRS_RELEASE}/libllqtwebkit.dylib - debug ${ARCH_PREBUILT_DIRS_DEBUG}/libllqtwebkit.dylib + debug libllqtwebkit.dylib + optimized libllqtwebkit.dylib ) elseif (LINUX) if (STANDALONE) diff --git a/indra/cmake/XmlRpcEpi.cmake b/indra/cmake/XmlRpcEpi.cmake index cbfe1e16f..2c93fd20c 100644 --- a/indra/cmake/XmlRpcEpi.cmake +++ b/indra/cmake/XmlRpcEpi.cmake @@ -9,5 +9,8 @@ if (STANDALONE) else (STANDALONE) use_prebuilt_binary(xmlrpc-epi) set(XMLRPCEPI_LIBRARIES xmlrpc-epi) - set(XMLRPCEPI_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include) + set(XMLRPCEPI_INCLUDE_DIRS + ${LIBS_PREBUILT_DIR}/include + ${LIBS_PREBUILT_LEGACY_DIR}/include + ) endif (STANDALONE) diff --git a/indra/cmake/ZLIB.cmake b/indra/cmake/ZLIB.cmake index c133248be..3384c55ee 100644 --- a/indra/cmake/ZLIB.cmake +++ b/indra/cmake/ZLIB.cmake @@ -17,6 +17,9 @@ else (STANDALONE) set(ZLIB_LIBRARIES z) endif (WINDOWS) if (WINDOWS OR LINUX) - set(ZLIB_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include/zlib) + set(ZLIB_INCLUDE_DIRS + ${LIBS_PREBUILT_DIR}/include/zlib + ${LIBS_PREBUILT_LEGACY_DIR}/include/zlib + ) endif (WINDOWS OR LINUX) endif (STANDALONE) diff --git a/indra/develop.py b/indra/develop.py index d3a77ae07..add325c41 100755 --- a/indra/develop.py +++ b/indra/develop.py @@ -41,6 +41,7 @@ import shutil import socket import sys import commands +import shlex class CommandError(Exception): pass @@ -111,11 +112,15 @@ class PlatformSetup(object): def build_dirs(self): '''Return the top-level directories in which builds occur. - This can return more than one directory, e.g. if doing a 32-bit viewer and server build on Linux.''' - return ['build-' + self.platform()] + if(os.path.basename(os.path.normpath(os.getcwd())) == 'indra'): + prefix = '../' + else: + prefix = '' + + return [prefix+'build-' + self.platform()] def cmake_commandline(self, src_dir, build_dir, opts, simple): '''Return the command line to run cmake with.''' @@ -275,9 +280,7 @@ class LinuxSetup(UnixSetup): return 'linux' def build_dirs(self): - platform_build = '%s-%s' % (self.platform(), self.build_type.lower()) - - return ['viewer-' + platform_build] + return [PlatformSetup.build_dirs(self)[0]+'-'+self.build_type.lower()] def cmake_commandline(self, src_dir, build_dir, opts, simple): args = dict( @@ -399,6 +402,12 @@ class DarwinSetup(UnixSetup): else: return UnixSetup.arch(self) + def build_dirs(self): + if(self.generator == 'Xcode'): + return PlatformSetup.build_dirs(self) + else: + return [PlatformSetup.build_dirs(self)[0]+'-'+self.build_type.lower()] + def cmake_commandline(self, src_dir, build_dir, opts, simple): args = dict( dir=src_dir, @@ -408,15 +417,17 @@ class DarwinSetup(UnixSetup): word_size=self.word_size, unattended=self.unattended, project_name=self.project_name, - universal=self.universal, - type=self.build_type.upper(), + universal='', + type='', ) + if(self.generator != 'Xcode'): + args['type'] = '-DCMAKE_BUILD_TYPE=%s' % self.build_type.upper() if self.universal == 'ON': args['universal'] = '-DCMAKE_OSX_ARCHITECTURES:STRING=\'i386;ppc\'' #if simple: # return 'cmake %(opts)s %(dir)r' % args return ('cmake -G %(generator)r ' - '-DCMAKE_BUILD_TYPE:STRING=%(type)s ' + '%(type)s ' '-DSTANDALONE:BOOL=%(standalone)s ' '-DUNATTENDED:BOOL=%(unattended)s ' '-DWORD_SIZE:STRING=%(word_size)s ' @@ -425,6 +436,18 @@ class DarwinSetup(UnixSetup): '%(opts)s %(dir)r' % args) def run_build(self, opts, targets): + if(self.generator != 'Xcode'): + if targets: + targets = ' '.join(targets) + else: + targets = 'all' + + for d in self.build_dirs(): + cmd = 'make -C %r %s %s' % (d, ' '.join(opts), targets) + print 'Running %r' % cmd + self.run(cmd) + return + cwd = getcwd() if targets: targets = ' '.join(['-target ' + repr(t) for t in targets]) @@ -447,14 +470,14 @@ class WindowsSetup(PlatformSetup): 'gen' : r'Visual Studio 10', 'ver' : r'10.0' }, - 'vc110' : { - 'gen' : r'Visual Studio 11', - 'ver' : r'11.0' + 'vc120' : { + 'gen' : r'Visual Studio 12', + 'ver' : r'12.0' } } gens['vs2010'] = gens['vc100'] - gens['vs2012'] = gens['vc110'] + gens['vs2013'] = gens['vc120'] search_path = r'C:\windows' exe_suffixes = ('.exe', '.bat', '.com') @@ -497,14 +520,24 @@ class WindowsSetup(PlatformSetup): generator = property(_get_generator, _set_generator) + def get_gen_str(self, gen): + if gen is None: + gen = self._generator + return self.gens[gen.lower()]['ver'] + def os(self): return 'win32' def build_dirs(self): - if self.word_size == 64: - return ['build-' + self.generator + '-Win64'] + if(os.path.basename(os.path.normpath(os.getcwd())) == 'indra'): + prefix = '../' else: - return ['build-' + self.generator] + prefix = '' + + if self.word_size == 64: + return [prefix+'build-' + self.generator + '-Win64'] + else: + return [prefix+'build-' + self.generator] def cmake_commandline(self, src_dir, build_dir, opts, simple): args = dict( @@ -525,7 +558,7 @@ class WindowsSetup(PlatformSetup): '-DSTANDALONE:BOOL=%(standalone)s ' '-DUNATTENDED:BOOL=%(unattended)s ' '-DWORD_SIZE:STRING=%(word_size)s ' - '-DROOT_PROJECT_NAME:STRING=%(project_name)s ' + '-DROOT_PROJECT_NAME:STRING=\"%(project_name)s\" ' '%(opts)s "%(dir)s"' % args) def get_HKLM_registry_value(self, key_str, value_str): @@ -537,34 +570,53 @@ class WindowsSetup(PlatformSetup): return value def find_visual_studio(self, gen=None): - if gen is None: - gen = self._generator - gen = gen.lower() + gen = self.get_gen_str(gen) value_str = (r'EnvironmentDirectory') key_str = (r'SOFTWARE\Microsoft\VisualStudio\%s\Setup\VS' % - self.gens[gen]['ver']) + gen) print ('Reading VS environment from HKEY_LOCAL_MACHINE\%s\%s' % (key_str, value_str)) try: return self.get_HKLM_registry_value(key_str, value_str) except WindowsError, err: key_str = (r'SOFTWARE\Wow6432Node\Microsoft\VisualStudio\%s\Setup\VS' % - self.gens[gen]['ver']) + gen) try: return self.get_HKLM_registry_value(key_str, value_str) except: print >> sys.stderr, "Didn't find ", self.gens[gen]['gen'] return '' - + + def find_msbuild(self, gen=None): + gen = self.get_gen_str(gen) + + key_str = (r'SOFTWARE\Microsoft\MSBuild\ToolsVersions\12.0') + + print ('Checking MSBuild support for vs ver = %s' % gen) + if not self.get_HKLM_registry_value(key_str+'\\'+gen, "VCTargetsPath"): + return (None, None) + print ('Reading MSBuild location from HKEY_LOCAL_MACHINE\%s\MSBuildToolsPath' % + key_str) + print key_str + try: + return (self.get_HKLM_registry_value(key_str, 'MSBuildToolsPath'), gen) + except WindowsError, err: + key_str = (r'SOFTWARE\Wow6432Node\Microsoft\MSBuild\ToolsVersions\%s' % + gen) + + try: + return (self.get_HKLM_registry_value(key_str, 'MSBuildToolsPath'), gen) + except WindowsError, err: + print 'Didn\'t find msbuild' + return (None, None) + def find_visual_studio_express(self, gen=None): - if gen is None: - gen = self._generator - gen = gen.lower() + gen = self.get_gen_str(gen) try: import _winreg key_str = (r'SOFTWARE\Microsoft\VCEXpress\%s\Setup\VC' % - self.gens[gen]['ver']) + gen) value_str = (r'ProductDir') print ('Reading VS environment from HKEY_LOCAL_MACHINE\%s\%s' % (key_str, value_str)) @@ -576,17 +628,15 @@ class WindowsSetup(PlatformSetup): print 'Found: %s' % value return value except WindowsError, err: - print >> sys.stderr, "Didn't find ", self.gens[gen]['gen'] + print >> sys.stderr, "Didn't find ", gen return '' def find_visual_studio_express_single(self, gen=None): - if gen is None: - gen = self._generator - gen = gen.lower() + gen = self.get_gen_str(gen) try: import _winreg key_str = (r'SOFTWARE\Microsoft\VCEXpress\%s_Config\Setup\VC' % - self.gens[gen]['ver']) + gen) value_str = (r'ProductDir') print ('Reading VS environment from HKEY_CURRENT_USER\%s\%s' % (key_str, value_str)) @@ -598,7 +648,7 @@ class WindowsSetup(PlatformSetup): print 'Found: %s' % value return value except WindowsError, err: - print >> sys.stderr, "Didn't find ", self.gens[gen]['gen'] + print >> sys.stderr, "Didn't find ", gen return '' def get_build_cmd(self): @@ -607,7 +657,7 @@ class WindowsSetup(PlatformSetup): if self.gens[self.generator]['ver'] in [ r'8.0', r'9.0' ]: config = '\"%s|Win32\"' % config - return "buildconsole %s.sln /build %s" % (self.project_name, config) + return "buildconsole \"%s.sln\" /build %s" % (self.project_name, config), None environment = self.find_visual_studio() if environment == '': environment = self.find_visual_studio_express() @@ -622,16 +672,23 @@ class WindowsSetup(PlatformSetup): print >> sys.stderr, "\nPlease see https://wiki.secondlife.com/wiki/Microsoft_Visual_Studio#Extra_steps_for_Visual_Studio_Express_editions for Visual Studio Express specific information" exit(0) + msbuild_dir, tool_ver = self.find_msbuild() + + if msbuild_dir is not None and tool_ver is not None: + return ('\"%smsbuild.exe\" \"%s.sln\" /p:configuration=%s /p:VisualStudioVersion=%s' % + (msbuild_dir, self.project_name, self.build_type, tool_ver)), True + # devenv.com is CLI friendly, devenv.exe... not so much. - return ('"%sdevenv.com" %s.sln /build %s' % - (self.find_visual_studio(), self.project_name, self.build_type)) + return ('"%sdevenv.com" \"%s.sln\" /build %s' % + (self.find_visual_studio(), self.project_name, self.build_type)), None def run(self, command, name=None): '''Run a program. If the program fails, raise an exception.''' - ret = os.system(command) + ret = os.system('\"'+command+'\"') if ret: if name is None: - name = command.split(None, 1)[0] + name = os.path.normpath(shlex.split(command.encode('utf8'),posix=False)[0].strip('"')) + path = self.find_in_path(name) if not path: ret = 'was not found' @@ -657,10 +714,15 @@ class WindowsSetup(PlatformSetup): if prev_build == self.build_type: # Only run vstool if the build type has changed. continue - vstool_cmd = (os.path.join('tools','vstool','VSTool.exe') + - ' --solution ' + - os.path.join(build_dir,'Singularity.sln') + - ' --config ' + self.build_type + + + if(os.path.basename(os.path.normpath(os.getcwd())) == 'indra'): + tool_path = os.path.join('tools','vstool','VSTool.exe') + else: + tool_path = os.path.join('indra','tools','vstool','VSTool.exe') + vstool_cmd = (tool_path + + ' --solution \"' + + os.path.join(build_dir,'%s.sln' % self.project_name) + + '\" --config ' + self.build_type + ' --startup secondlife-bin') print 'Running vstool %r in %r' % (vstool_cmd, getcwd()) self.run(vstool_cmd) @@ -668,16 +730,21 @@ class WindowsSetup(PlatformSetup): def run_build(self, opts, targets): cwd = getcwd() - build_cmd = self.get_build_cmd() + build_cmd, msbuild = self.get_build_cmd() for d in self.build_dirs(): try: os.chdir(d) if targets: - for t in targets: - cmd = '%s /project %s %s' % (build_cmd, t, ' '.join(opts)) + if msbuild: + cmd = '%s /target:%s %s' % (build_cmd, ';'.join(targets), ' '.join(opts)) print 'Running build(targets) %r in %r' % (cmd, d) self.run(cmd) + else: + for t in targets: + cmd = '%s /project %s %s' % (build_cmd, t, ' '.join(opts)) + print 'Running build(targets) %r in %r' % (cmd, d) + self.run(cmd) else: cmd = '%s %s' % (build_cmd, ' '.join(opts)) print 'Running build %r in %r' % (cmd, d) @@ -748,10 +815,12 @@ Commands: Command-options for "configure": We use cmake variables to change the build configuration. -DPACKAGE:BOOL=ON Create "package" target to make installers - -DLOCALIZESETUP:BOOL=ON Create one win_setup target per supported language -DLL_TESTS:BOOL=OFF Don't generate unit test projects -DEXAMPLEPLUGIN:BOOL=OFF Don't generate example plugin project -DDISABLE_TCMALLOC:BOOL=ON Disable linkage of TCMalloc. (64bit builds automatically disable TCMalloc) + -DRELEASE_CRASH_REPORTING:BOOL=ON Enable Google Breakpad crash reporting + -DFMODSTUDIO:BOOL=ON Use FMOD Studio audio libraries + -DFMODEX:BOOL=ON Use FMOD Ex audio libraries Examples: Set up a Visual Studio 2010 project with "package" target: diff --git a/indra/lib/python/indra/__init__.py b/indra/lib/python/indra/__init__.py index 9daab3480..0c5053cf4 100644 --- a/indra/lib/python/indra/__init__.py +++ b/indra/lib/python/indra/__init__.py @@ -2,19 +2,24 @@ @file __init__.py @brief Initialization file for the indra module. -$LicenseInfo:firstyear=2006&license=internal$ +$LicenseInfo:firstyear=2006&license=viewerlgpl$ +Second Life Viewer Source Code +Copyright (C) 2006-2010, Linden Research, Inc. -Copyright (c) 2006-2009, Linden Research, Inc. +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; +version 2.1 of the License only. -The following source code is PROPRIETARY AND CONFIDENTIAL. Use of -this source code is governed by the Linden Lab Source Code Disclosure -Agreement ("Agreement") previously entered between you and Linden -Lab. By accessing, using, copying, modifying or distributing this -software, you acknowledge that you have been informed of your -obligations under the Agreement and agree to abide by those obligations. +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. -ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO -WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, -COMPLETENESS OR PERFORMANCE. +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA $/LicenseInfo$ """ diff --git a/indra/lib/python/indra/base/cllsd_test.py b/indra/lib/python/indra/base/cllsd_test.py index 3af59e741..1f06898ff 100644 --- a/indra/lib/python/indra/base/cllsd_test.py +++ b/indra/lib/python/indra/base/cllsd_test.py @@ -1,3 +1,25 @@ +#!/usr/bin/python +## +## $LicenseInfo:firstyear=2011&license=viewerlgpl$ +## Second Life Viewer Source Code +## Copyright (C) 2011, Linden Research, Inc. +## +## This library is free software; you can redistribute it and/or +## modify it under the terms of the GNU Lesser General Public +## License as published by the Free Software Foundation; +## version 2.1 of the License only. +## +## This library is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## Lesser General Public License for more details. +## +## You should have received a copy of the GNU Lesser General Public +## License along with this library; if not, write to the Free Software +## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +## +## Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA +## $/LicenseInfo$ from indra.base import llsd, lluuid from datetime import datetime import cllsd @@ -10,7 +32,7 @@ values = ( '&<>', u'\u81acj', llsd.uri('http://foo<'), - lluuid.LLUUID(), + lluuid.UUID(), llsd.LLSD(['thing']), 1, myint(31337), diff --git a/indra/lib/python/indra/base/lllog.py b/indra/lib/python/indra/base/lllog.py deleted file mode 100644 index 31000fcb9..000000000 --- a/indra/lib/python/indra/base/lllog.py +++ /dev/null @@ -1,72 +0,0 @@ -"""\ -@file lllog.py -@brief Logging for event processing - -$LicenseInfo:firstyear=2008&license=mit$ - -Copyright (c) 2008-2009, Linden Research, Inc. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -$/LicenseInfo$ -""" - -from indra.base.llsd import format_notation - -try: - import syslog -except ImportError: - # Windows - import sys - - class syslog(object): - _logfp = sys.stderr - - def syslog(msg): - _logfp.write(msg) - if not msg.endswith('\n'): - _logfp.write('\n') - - syslog = staticmethod(syslog) - -class Logger(object): - def __init__(self, name='indra'): - self._sequence = 0 - try: - syslog.openlog(name, syslog.LOG_CONS | syslog.LOG_PID, - syslog.LOG_LOCAL0) - except AttributeError: - # No syslog module on Windows - pass - - def next(self): - self._sequence += 1 - return self._sequence - - def log(self, msg, llsd): - payload = 'INFO: log: LLLOGMESSAGE (%d) %s %s' % (self.next(), msg, - format_notation(llsd)) - syslog.syslog(payload) - -_logger = None - -def log(msg, llsd): - global _logger - if _logger is None: - _logger = Logger() - _logger.log(msg, llsd) diff --git a/indra/lib/python/indra/base/llsd.py b/indra/lib/python/indra/base/llsd.py index 9534d5935..4527b115f 100644 --- a/indra/lib/python/indra/base/llsd.py +++ b/indra/lib/python/indra/base/llsd.py @@ -72,8 +72,11 @@ BOOL_FALSE = ('0', '0.0', 'false', '') def format_datestr(v): - """ Formats a datetime object into the string format shared by xml and notation serializations.""" - return v.isoformat() + 'Z' + """ Formats a datetime or date object into the string format shared by xml and notation serializations.""" + if hasattr(v, 'microsecond'): + return v.isoformat() + 'Z' + else: + return v.strftime('%Y-%m-%dT%H:%M:%SZ') def parse_datestr(datestr): """Parses a datetime object from the string format shared by xml and notation serializations.""" @@ -183,6 +186,7 @@ class LLSDXMLFormatter(object): unicode : self.STRING, uri : self.URI, datetime.datetime : self.DATE, + datetime.date : self.DATE, list : self.ARRAY, tuple : self.ARRAY, types.GeneratorType : self.ARRAY, @@ -234,7 +238,7 @@ class LLSDXMLFormatter(object): def MAP(self, v): return self.elt( 'map', - ''.join(["%s%s" % (self.elt('key', key), self.generate(value)) + ''.join(["%s%s" % (self.elt('key', self.xml_esc(str(key))), self.generate(value)) for key, value in v.items()])) typeof = type @@ -347,6 +351,7 @@ class LLSDNotationFormatter(object): unicode : self.STRING, uri : self.URI, datetime.datetime : self.DATE, + datetime.date : self.DATE, list : self.ARRAY, tuple : self.ARRAY, types.GeneratorType : self.ARRAY, @@ -924,12 +929,13 @@ def _format_binary_recurse(something): (type(something), something)) -def parse_binary(something): - header = '\n' - if not something.startswith(header): - raise LLSDParseError('LLSD binary encoding header not found') - return LLSDBinaryParser().parse(something[len(header):]) - +def parse_binary(binary): + if binary.startswith(''): + just_binary = binary.split('\n', 1)[1] + else: + just_binary = binary + return LLSDBinaryParser().parse(just_binary) + def parse_xml(something): try: return to_python(fromstring(something)[0]) diff --git a/indra/lib/python/indra/base/lluuid.py b/indra/lib/python/indra/base/lluuid.py index cff190087..7413ffe10 100644 --- a/indra/lib/python/indra/base/lluuid.py +++ b/indra/lib/python/indra/base/lluuid.py @@ -28,13 +28,12 @@ $/LicenseInfo$ import random, socket, string, time, re import uuid - -# *HACK: Necessary for python 2.4. Consider replacing this code wart -# after python >=2.5 has deployed everywhere. 2009-10-05 try: + # Python 2.6 from hashlib import md5 except ImportError: - from md5 import md5 + # Python 2.5 and earlier + from md5 import new as md5 def _int2binstr(i,l): s='' @@ -73,7 +72,7 @@ class UUID(object): ip = '' try: ip = socket.gethostbyname(socket.gethostname()) - except(socket.gaierror): + except(socket.gaierror, socket.error): # no ip address, so just default to somewhere in 10.x.x.x ip = '10' for i in range(3): @@ -164,7 +163,7 @@ class UUID(object): def setFromMemoryDump(self, gdb_string): """ We expect to get gdb_string as four hex units. eg: - 0x147d54db 0xc34b3f1b 0x714f989b 0x0a892fd2 + 0x147d54db 0xc34b3f1b 0x714f989b 0x0a892fd2 Which will be translated to: db547d14-1b3f4bc3-9b984f71-d22f890a Returns self. @@ -188,7 +187,7 @@ class UUID(object): def getAsString(self): """ Return a different string representation of the form - AAAAAAAA-AAAABBBB-BBBBBBBB-BBCCCCCC (a 128-bit number in hex) + AAAAAAAA-AAAABBBB-BBBBBBBB-BBCCCCCC (a 128-bit number in hex) where A=network address, B=timestamp, C=random. """ i1 = _binstr2int(self._bits[0:4]) @@ -234,7 +233,7 @@ NULL = UUID() def printTranslatedMemory(four_hex_uints): """ We expect to get the string as four hex units. eg: - 0x147d54db 0xc34b3f1b 0x714f989b 0x0a892fd2 + 0x147d54db 0xc34b3f1b 0x714f989b 0x0a892fd2 Which will be translated to: db547d14-1b3f4bc3-9b984f71-d22f890a """ diff --git a/indra/lib/python/indra/base/metrics.py b/indra/lib/python/indra/base/metrics.py index 8f2a85cf0..ff8380265 100644 --- a/indra/lib/python/indra/base/metrics.py +++ b/indra/lib/python/indra/base/metrics.py @@ -29,25 +29,93 @@ $/LicenseInfo$ """ import sys -from indra.base import llsd +try: + import syslog +except ImportError: + # Windows + import sys + class syslog(object): + # wrap to a lame syslog for windows + _logfp = sys.stderr + def syslog(msg): + _logfp.write(msg) + if not msg.endswith('\n'): + _logfp.write('\n') + syslog = staticmethod(syslog) -_sequence_id = 0 +from indra.base.llsd import format_notation -def record_metrics(table, stats, dest=None): +def record_metrics(table, stats): "Write a standard metrics log" - _log("LLMETRICS", table, stats, dest) + _log("LLMETRICS", table, stats) -def record_event(table, data, dest=None): +def record_event(table, data): "Write a standard logmessage log" - _log("LLLOGMESSAGE", table, data, dest) + _log("LLLOGMESSAGE", table, data) -def _log(header, table, data, dest): +def set_destination(dest): + """Set the destination of metrics logs for this process. + + If you do not call this function prior to calling a logging + method, that function will open sys.stdout as a destination. + Attempts to set dest to None will throw a RuntimeError. + @param dest a file-like object which will be the destination for logs.""" if dest is None: - # do this check here in case sys.stdout changes at some - # point. as a default parameter, it will never be - # re-evaluated. - dest = sys.stdout + raise RuntimeError("Attempt to unset metrics destination.") + global _destination + _destination = dest + +def destination(): + """Get the destination of the metrics logs for this process. + Returns None if no destination is set""" + global _destination + return _destination + +class SysLogger(object): + "A file-like object which writes to syslog." + def __init__(self, ident='indra', logopt = None, facility = None): + try: + if logopt is None: + logopt = syslog.LOG_CONS | syslog.LOG_PID + if facility is None: + facility = syslog.LOG_LOCAL0 + syslog.openlog(ident, logopt, facility) + import atexit + atexit.register(syslog.closelog) + except AttributeError: + # No syslog module on Windows + pass + + def write(str): + syslog.syslog(str) + write = staticmethod(write) + + def flush(): + pass + flush = staticmethod(flush) + +# +# internal API +# +_sequence_id = 0 +_destination = None + +def _next_id(): global _sequence_id - print >>dest, header, "(" + str(_sequence_id) + ")", - print >>dest, table, llsd.format_notation(data) + next = _sequence_id _sequence_id += 1 + return next + +def _dest(): + global _destination + if _destination is None: + # this default behavior is documented in the metrics functions above. + _destination = sys.stdout + return _destination + +def _log(header, table, data): + log_line = "%s (%d) %s %s" \ + % (header, _next_id(), table, format_notation(data)) + dest = _dest() + dest.write(log_line) + dest.flush() diff --git a/indra/lib/python/indra/ipc/servicebuilder.py b/indra/lib/python/indra/ipc/servicebuilder.py index 04ccee765..0a0ce2b4e 100644 --- a/indra/lib/python/indra/ipc/servicebuilder.py +++ b/indra/lib/python/indra/ipc/servicebuilder.py @@ -39,6 +39,12 @@ except: pass _g_builder = None +def _builder(): + global _g_builder + if _g_builder is None: + _g_builder = ServiceBuilder() + return _g_builder + def build(name, context={}, **kwargs): """ Convenience method for using a global, singleton, service builder. Pass arguments either via a dict or via python keyword arguments, or both! @@ -56,6 +62,11 @@ def build(name, context={}, **kwargs): _g_builder = ServiceBuilder() return _g_builder.buildServiceURL(name, context, **kwargs) +def build_path(name, context={}, **kwargs): + context = context.copy() # shouldn't modify the caller's dictionary + context.update(kwargs) + return _builder().buildPath(name, context) + class ServiceBuilder(object): def __init__(self, services_definition = services_config): """\ @@ -73,12 +84,21 @@ class ServiceBuilder(object): continue if isinstance(service_builder, dict): # We will be constructing several builders - for name, builder in service_builder.items(): + for name, builder in service_builder.iteritems(): full_builder_name = service['name'] + '-' + name self.builders[full_builder_name] = builder else: self.builders[service['name']] = service_builder + def buildPath(self, name, context): + """\ + @brief given the environment on construction, return a service path. + @param name The name of the service. + @param context A dict of name value lookups for the service. + @returns Returns the + """ + return russ.format(self.builders[name], context) + def buildServiceURL(self, name, context={}, **kwargs): """\ @brief given the environment on construction, return a service URL. @@ -108,7 +128,7 @@ def on_in(query_name, host_key, schema_key): @param schema_key Logical name of destination schema. Will be looked up in indra.xml. """ - host_name = config.get(host_key) - schema_name = config.get(schema_key) - return '/'.join( ('on', host_name, 'in', schema_name, query_name.lstrip('/')) ) + return "on/config:%s/in/config:%s/%s" % (host_key.strip('/'), + schema_key.strip('/'), + query_name.lstrip('/')) diff --git a/indra/lib/python/indra/ipc/siesta.py b/indra/lib/python/indra/ipc/siesta.py index b206f181c..d867e7153 100644 --- a/indra/lib/python/indra/ipc/siesta.py +++ b/indra/lib/python/indra/ipc/siesta.py @@ -1,3 +1,32 @@ +"""\ +@file siesta.py +@brief A tiny llsd based RESTful web services framework + +$LicenseInfo:firstyear=2008&license=mit$ + +Copyright (c) 2008, Linden Research, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +$/LicenseInfo$ +""" + +from indra.base import config from indra.base import llsd from webob import exc import webob @@ -37,11 +66,11 @@ def mime_type(content_type): return content_type.split(';', 1)[0].strip().lower() class BodyLLSD(object): - '''Give a webob Request or Response an llsd property. + '''Give a webob Request or Response an llsd based "content" property. - Getting the llsd property parses the body, and caches the result. + Getting the content property parses the body, and caches the result. - Setting the llsd property formats a payload, and the body property + Setting the content property formats a payload, and the body property is set.''' def _llsd__get(self): @@ -80,7 +109,7 @@ class BodyLLSD(object): if hasattr(self, '_llsd'): del self._llsd - llsd = property(_llsd__get, _llsd__set, _llsd__del) + content = property(_llsd__get, _llsd__set, _llsd__del) class Response(webob.Response, BodyLLSD): @@ -114,10 +143,10 @@ class Request(webob.Request, BodyLLSD): Sensible content type and accept headers are used by default. - Setting the llsd property also sets the body. Getting the llsd + Setting the content property also sets the body. Getting the content property parses the body if necessary. - If you set the body property directly, the llsd property will be + If you set the body property directly, the content property will be deleted.''' default_content_type = 'application/llsd+xml' @@ -149,11 +178,11 @@ class Request(webob.Request, BodyLLSD): body = property(webob.Request._body__get, _body__set, webob.Request._body__del, webob.Request._body__get.__doc__) - def create_response(self, llsd=None, status='200 OK', + def create_response(self, content=None, status='200 OK', conditional_response=webob.NoDefault): resp = self.ResponseClass(status=status, request=self, conditional_response=conditional_response) - resp.llsd = llsd + resp.content = content return resp def curl(self): @@ -196,12 +225,18 @@ llsd_formatters = { 'application/xml': llsd.format_xml, } +formatter_qualities = ( + ('application/llsd+xml', 1.0), + ('application/llsd+notation', 0.5), + ('application/llsd+binary', 0.4), + ('application/xml', 0.3), + ('application/json', 0.2), + ) def formatter_for_mime_type(mime_type): '''Return a formatter that encodes to the given MIME type. The result is a pair of function and MIME type.''' - try: return llsd_formatters[mime_type], mime_type except KeyError: @@ -214,21 +249,19 @@ def formatter_for_request(req): '''Return a formatter that encodes to the preferred type of the client. The result is a pair of function and actual MIME type.''' - - for ctype in req.accept.best_matches('application/llsd+xml'): - try: - return llsd_formatters[ctype], ctype - except KeyError: - pass - else: + ctype = req.accept.best_match(formatter_qualities) + try: + return llsd_formatters[ctype], ctype + except KeyError: raise exc.HTTPNotAcceptable().exception def wsgi_adapter(func, environ, start_response): '''Adapt a Siesta callable to act as a WSGI application.''' - + # Process the request as appropriate. try: req = Request(environ) + #print req.urlvars resp = func(req, **req.urlvars) if not isinstance(resp, webob.Response): try: @@ -281,7 +314,8 @@ def llsd_class(cls): allowed = [m for m in http11_methods if hasattr(instance, 'handle_' + m.lower())] raise exc.HTTPMethodNotAllowed( - headers={'Allowed': ', '.join(allowed)}).exception + headers={'Allow': ', '.join(allowed)}).exception + #print "kwargs: ", kwargs return handler(req, **kwargs) def replacement(environ, start_response): @@ -336,7 +370,7 @@ def curl(reqs): route_re = re.compile(r''' \{ # exact character "{" - (\w+) # variable name (restricted to a-z, 0-9, _) + (\w*) # "config" or variable (restricted to a-z, 0-9, _) (?:([:~])([^}]+))? # optional :type or ~regex part \} # exact character "}" ''', re.VERBOSE) @@ -344,27 +378,37 @@ route_re = re.compile(r''' predefined_regexps = { 'uuid': r'[a-f0-9][a-f0-9-]{31,35}', 'int': r'\d+', + 'host': r'[a-z0-9][a-z0-9\-\.]*', } def compile_route(route): fp = StringIO() last_pos = 0 for match in route_re.finditer(route): + #print "matches: ", match.groups() fp.write(re.escape(route[last_pos:match.start()])) var_name = match.group(1) sep = match.group(2) expr = match.group(3) - if expr: - if sep == ':': - expr = predefined_regexps[expr] - # otherwise, treat what follows '~' as a regexp + if var_name == 'config': + expr = re.escape(str(config.get(var_name))) else: - expr = '[^/]+' - expr = '(?P<%s>%s)' % (var_name, expr) + if expr: + if sep == ':': + expr = predefined_regexps[expr] + # otherwise, treat what follows '~' as a regexp + else: + expr = '[^/]+' + if var_name != '': + expr = '(?P<%s>%s)' % (var_name, expr) + else: + expr = '(%s)' % (expr,) fp.write(expr) last_pos = match.end() fp.write(re.escape(route[last_pos:])) - return '^%s$' % fp.getvalue() + compiled_route = '^%s$' % fp.getvalue() + #print route, "->", compiled_route + return compiled_route class Router(object): '''WSGI routing class. Parses a URL and hands off a request to @@ -372,21 +416,43 @@ class Router(object): responds with a 404.''' def __init__(self): - self.routes = [] - self.paths = [] + self._new_routes = [] + self._routes = [] + self._paths = [] def add(self, route, app, methods=None): - self.paths.append(route) - self.routes.append((re.compile(compile_route(route)), app, - methods and dict.fromkeys(methods))) + self._new_routes.append((route, app, methods)) + + def _create_routes(self): + for route, app, methods in self._new_routes: + self._paths.append(route) + self._routes.append( + (re.compile(compile_route(route)), + app, + methods and dict.fromkeys(methods))) + self._new_routes = [] def __call__(self, environ, start_response): + # load up the config from the config file. Only needs to be + # done once per interpreter. This is the entry point of all + # siesta applications, so this is where we trap it. + _conf = config.get_config() + if _conf is None: + import os.path + fname = os.path.join( + environ.get('ll.config_dir', '/local/linden/etc'), + 'indra.xml') + config.load(fname) + + # proceed with handling the request + self._create_routes() path_info = environ['PATH_INFO'] request_method = environ['REQUEST_METHOD'] allowed = [] - for regex, app, methods in self.routes: + for regex, app, methods in self._routes: m = regex.match(path_info) if m: + #print "groupdict:",m.groupdict() if not methods or request_method in methods: environ['paste.urlvars'] = m.groupdict() return app(environ, start_response) @@ -396,7 +462,7 @@ class Router(object): allowed = dict.fromkeys(allows).keys() allowed.sort() resp = exc.HTTPMethodNotAllowed( - headers={'Allowed': ', '.join(allowed)}) + headers={'Allow': ', '.join(allowed)}) else: resp = exc.HTTPNotFound() return resp(environ, start_response) diff --git a/indra/lib/python/indra/util/llmanifest.py b/indra/lib/python/indra/util/llmanifest.py index 625d1456f..0059faa2e 100644 --- a/indra/lib/python/indra/util/llmanifest.py +++ b/indra/lib/python/indra/util/llmanifest.py @@ -280,13 +280,14 @@ class LLManifest(object): self.file_list = [] self.excludes = [] self.actions = [] - self.src_prefix = [args['source']] - self.artwork_prefix = [args['artwork']] - self.build_prefix = [args['build']] - self.dst_prefix = [args['dest']] + self.src_prefix = list([args['source']]) + self.artwork_prefix = list([args['artwork']]) + self.build_prefix = list([args['build']]) + self.alt_build_prefix = list([args['build']]) + self.dst_prefix = list([args['dest']]) self.created_paths = [] self.package_name = "Unknown" - + def default_grid(self): return self.args.get('grid', None) == '' def default_channel(self): @@ -310,7 +311,7 @@ class LLManifest(object): in the file list by path().""" self.excludes.append(glob) - def prefix(self, src='', build=None, dst=None): + def prefix(self, src='', build=None, dst=None, alt_build=None): """ Pushes a prefix onto the stack. Until end_prefix is called, all relevant method calls (esp. to path()) will prefix paths with the entire prefix stack. Source and destination @@ -321,10 +322,15 @@ class LLManifest(object): dst = src if build is None: build = src + if alt_build is None: + alt_build = build + self.src_prefix.append(src) self.artwork_prefix.append(src) self.build_prefix.append(build) self.dst_prefix.append(dst) + self.alt_build_prefix.append(alt_build) + return True # so that you can wrap it in an if to get indentation def end_prefix(self, descr=None): @@ -337,25 +343,30 @@ class LLManifest(object): src = self.src_prefix.pop() artwork = self.artwork_prefix.pop() build = self.build_prefix.pop() + alt_build_prefix = self.alt_build_prefix.pop() dst = self.dst_prefix.pop() if descr and not(src == descr or build == descr or dst == descr): raise ValueError, "End prefix '" + descr + "' didn't match '" +src+ "' or '" +dst + "'" def get_src_prefix(self): """ Returns the current source prefix.""" - return os.path.join(*self.src_prefix) + return os.path.relpath(os.path.normpath(os.path.join(*self.src_prefix))) def get_artwork_prefix(self): """ Returns the current artwork prefix.""" - return os.path.join(*self.artwork_prefix) + return os.path.relpath(os.path.normpath(os.path.join(*self.artwork_prefix))) def get_build_prefix(self): """ Returns the current build prefix.""" - return os.path.join(*self.build_prefix) + return os.path.relpath(os.path.normpath(os.path.join(*self.build_prefix))) + + def get_alt_build_prefix(self): + """ Returns the current alternate source prefix.""" + return os.path.relpath(os.path.normpath(os.path.join(*self.alt_build_prefix))) def get_dst_prefix(self): """ Returns the current destination prefix.""" - return os.path.join(*self.dst_prefix) + return os.path.relpath(os.path.normpath(os.path.join(*self.dst_prefix))) def src_path_of(self, relpath): """Returns the full path to a file or directory specified @@ -372,22 +383,6 @@ class LLManifest(object): relative to the destination directory.""" return os.path.join(self.get_dst_prefix(), relpath) - def ensure_src_dir(self, reldir): - """Construct the path for a directory relative to the - source path, and ensures that it exists. Returns the - full path.""" - path = os.path.join(self.get_src_prefix(), reldir) - self.cmakedirs(path) - return path - - def ensure_dst_dir(self, reldir): - """Construct the path for a directory relative to the - destination path, and ensures that it exists. Returns the - full path.""" - path = os.path.join(self.get_dst_prefix(), reldir) - self.cmakedirs(path) - return path - def run_command(self, command): """ Runs an external command, and returns the output. Raises an exception if the command reurns a nonzero status code. For @@ -484,29 +479,30 @@ class LLManifest(object): if method is not None: method(src, dst) self.file_list.append([src, dst]) - return 1 + return [dst] else: sys.stdout.write(" (excluding %r, %r)" % (src, dst)) sys.stdout.flush() - return 0 + return [] def process_directory(self, src, dst): if not self.includes(src, dst): sys.stdout.write(" (excluding %r, %r)" % (src, dst)) sys.stdout.flush() - return 0 + return [] names = os.listdir(src) self.cmakedirs(dst) errors = [] + found_files = [] count = 0 for name in names: srcname = os.path.join(src, name) dstname = os.path.join(dst, name) if os.path.isdir(srcname): - count += self.process_directory(srcname, dstname) + found_files.extend(self.process_directory(srcname, dstname)) else: - count += self.process_file(srcname, dstname) - return count + found_files.extend(self.process_file(srcname, dstname)) + return found_files def includes(self, src, dst): if src: @@ -586,25 +582,11 @@ class LLManifest(object): if os.path.exists(f): return f # didn't find it, return last item in list - if len(list) > 0: + if list: return list[-1] else: return None - def contents_of_tar(self, src_tar, dst_dir): - """ Extracts the contents of the tarfile (specified - relative to the source prefix) into the directory - specified relative to the destination directory.""" - self.check_file_exists(src_tar) - tf = tarfile.open(self.src_path_of(src_tar), 'r') - for member in tf.getmembers(): - tf.extract(member, self.ensure_dst_dir(dst_dir)) - # TODO get actions working on these dudes, perhaps we should extract to a temporary directory and then process_directory on it? - self.file_list.append([src_tar, - self.dst_path_of(os.path.join(dst_dir,member.name))]) - tf.close() - - def wildcard_regex(self, src_glob, dst_glob): src_re = re.escape(src_glob) src_re = src_re.replace('\*', '([-a-zA-Z0-9._ ]*)') @@ -615,12 +597,6 @@ class LLManifest(object): i = i+1 return re.compile(src_re), dst_temp - def check_file_exists(self, path): - if not os.path.exists(path) and not os.path.islink(path): - raise RuntimeError("Path %s doesn't exist" % ( - os.path.normpath(os.path.join(os.getcwd(), path)),)) - - wildcard_pattern = re.compile('\*') def expand_globs(self, src, dst): src_list = glob.glob(src) @@ -630,40 +606,61 @@ class LLManifest(object): d = src_re.sub(d_template, s.replace('\\', '/')) yield os.path.normpath(s), os.path.normpath(d) + def path2basename(self, path, file): + """ + It is a common idiom to write: + self.path(os.path.join(somedir, somefile), somefile) + + So instead you can write: + self.path2basename(somedir, somefile) + + Note that this is NOT the same as: + self.path(os.path.join(somedir, somefile)) + + which is the same as: + temppath = os.path.join(somedir, somefile) + self.path(temppath, temppath) + """ + return self.path(os.path.join(path, file), file) + def path(self, src, dst=None): - sys.stdout.write("Processing %s => %s ... " % (src, dst)) sys.stdout.flush() if src == None: raise RuntimeError("No source file, dst is " + dst) if dst == None: dst = src dst = os.path.join(self.get_dst_prefix(), dst) + sys.stdout.write("Processing %s => %s ... " % (src, dst)) count = 0 is_glob = False + found_files = [] - # look under each prefix for matching paths - paths = set([os.path.join(self.get_src_prefix(), src), - os.path.join(self.get_artwork_prefix(), src), - os.path.join(self.get_build_prefix(), src)]) + # look under each prefix for matching paths. Paths are normalized so './../blah' will match '../blah/../blah/' + paths = set([os.path.normpath(os.path.join(self.get_src_prefix(), src)), + os.path.normpath(os.path.join(self.get_artwork_prefix(), src)), + os.path.normpath(os.path.join(self.get_build_prefix(), src)), + os.path.normpath(os.path.join(self.get_alt_build_prefix(), src))] + ) for path in paths: if self.wildcard_pattern.search(path): is_glob = True for s,d in self.expand_globs(path, dst): assert(s != d) - count += self.process_file(s, d) + found_files.extend(self.process_file(s, d)) else: # if it's a directory, recurse through it if os.path.isdir(path): - count += self.process_directory(path, dst) + found_files.extend(self.process_directory(path, dst)) elif os.path.exists(path): - count += self.process_file(path, dst) + found_files.extend(self.process_file(path, dst)) # if we're specifying a single path (not a glob), # we should error out if it doesn't exist - if count == 0 and not is_glob: + if not found_files and not is_glob: raise RuntimeError("No files match %s\n" % str(paths)) - print "%d files" % count + print "%d files" % len(found_files) + return found_files def do(self, *actions): self.actions = actions diff --git a/indra/lib/python/indra/util/llperformance.py b/indra/lib/python/indra/util/llperformance.py index 7c52730b5..57dd64de3 100755 --- a/indra/lib/python/indra/util/llperformance.py +++ b/indra/lib/python/indra/util/llperformance.py @@ -1,4 +1,28 @@ -#!/usr/bin/python +#!/usr/bin/env python +"""\ +@file llperformance.py + +$LicenseInfo:firstyear=2010&license=viewerlgpl$ +Second Life Viewer Source Code +Copyright (C) 2010-2011, Linden Research, Inc. + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; +version 2.1 of the License only. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA +$/LicenseInfo$ +""" # ------------------------------------------------ # Sim metrics utility functions. diff --git a/indra/lib/python/indra/util/llsubprocess.py b/indra/lib/python/indra/util/llsubprocess.py index c4c40739e..7e0e115d1 100644 --- a/indra/lib/python/indra/util/llsubprocess.py +++ b/indra/lib/python/indra/util/llsubprocess.py @@ -90,6 +90,17 @@ all the output, and get the result. child.tochild.close() result = child.poll() if result != -1: + # At this point, the child process has exited and result + # is the return value from the process. Between the time + # we called select() and poll() the process may have + # exited so read all the data left on the child process + # stdout and stderr. + last = child.fromchild.read() + if last: + out.append(last) + last = child.childerr.read() + if last: + err.append(last) child.tochild.close() child.fromchild.close() child.childerr.close() diff --git a/indra/lib/python/indra/util/llversion.py b/indra/lib/python/indra/util/llversion.py deleted file mode 100644 index 770b861dd..000000000 --- a/indra/lib/python/indra/util/llversion.py +++ /dev/null @@ -1,95 +0,0 @@ -"""@file llversion.py -@brief Utility for parsing llcommon/llversion${server}.h - for the version string and channel string - Utility that parses svn info for branch and revision - -$LicenseInfo:firstyear=2006&license=mit$ - -Copyright (c) 2006-2009, Linden Research, Inc. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -$/LicenseInfo$ -""" - -import re, sys, os, commands - -# Methods for gathering version information from -# llversionviewer.h and llversionserver.h - -def get_src_root(): - indra_lib_python_indra_path = os.path.dirname(__file__) - return os.path.abspath(os.path.realpath(indra_lib_python_indra_path + "/../../../../../")) - -def get_version_file_contents(version_type): - filepath = get_src_root() + '/indra/llcommon/llversion%s.h' % version_type - file = open(filepath,"r") - file_str = file.read() - file.close() - return file_str - -def get_version(version_type): - file_str = get_version_file_contents(version_type) - m = re.search('const S32 LL_VERSION_MAJOR = (\d+);', file_str) - VER_MAJOR = m.group(1) - m = re.search('const S32 LL_VERSION_MINOR = (\d+);', file_str) - VER_MINOR = m.group(1) - m = re.search('const S32 LL_VERSION_PATCH = (\d+);', file_str) - VER_PATCH = m.group(1) - m = re.search('const S32 LL_VERSION_BUILD = (\d+);', file_str) - VER_BUILD = m.group(1) - version = "%(VER_MAJOR)s.%(VER_MINOR)s.%(VER_PATCH)s.%(VER_BUILD)s" % locals() - return version - -def get_channel(version_type): - file_str = get_version_file_contents(version_type) - m = re.search('const char \* const LL_CHANNEL = "(.+)";', file_str) - return m.group(1) - -def get_viewer_version(): - return get_version('viewer') - -def get_server_version(): - return get_version('server') - -def get_viewer_channel(): - return get_channel('viewer') - -def get_server_channel(): - return get_channel('server') - -# Methods for gathering subversion information -def get_svn_status_matching(regular_expression): - # Get the subversion info from the working source tree - status, output = commands.getstatusoutput('svn info %s' % get_src_root()) - m = regular_expression.search(output) - if not m: - print "Failed to parse svn info output, resultfollows:" - print output - raise Exception, "No matching svn status in "+src_root - return m.group(1) - -def get_svn_branch(): - branch_re = re.compile('URL: (\S+)') - return get_svn_status_matching(branch_re) - -def get_svn_revision(): - last_rev_re = re.compile('Last Changed Rev: (\d+)') - return get_svn_status_matching(last_rev_re) - - diff --git a/indra/lib/python/indra/util/named_query.py b/indra/lib/python/indra/util/named_query.py index 192e59275..6bf956107 100644 --- a/indra/lib/python/indra/util/named_query.py +++ b/indra/lib/python/indra/util/named_query.py @@ -40,7 +40,6 @@ from indra.base import llsd from indra.base import config DEBUG = False - NQ_FILE_SUFFIX = config.get('named-query-file-suffix', '.nq') NQ_FILE_SUFFIX_LEN = len(NQ_FILE_SUFFIX) @@ -52,6 +51,11 @@ def _init_g_named_manager(sql_dir = None): This function is intended entirely for testing purposes, because it's tricky to control the config from inside a test.""" + global NQ_FILE_SUFFIX + NQ_FILE_SUFFIX = config.get('named-query-file-suffix', '.nq') + global NQ_FILE_SUFFIX_LEN + NQ_FILE_SUFFIX_LEN = len(NQ_FILE_SUFFIX) + if sql_dir is None: sql_dir = config.get('named-query-base-dir') @@ -65,11 +69,11 @@ def _init_g_named_manager(sql_dir = None): _g_named_manager = NamedQueryManager( os.path.abspath(os.path.realpath(sql_dir))) -def get(name): +def get(name, schema = None): "Get the named query object to be used to perform queries" if _g_named_manager is None: _init_g_named_manager() - return _g_named_manager.get(name) + return _g_named_manager.get(name).for_schema(schema) def sql(connection, name, params): # use module-global NamedQuery object to perform default substitution @@ -280,7 +284,10 @@ class NamedQuery(object): So, we need a vendor (or extention) for LIKE_STRING. Anyone want to write it?""" - utf8_value = unicode(value, "utf-8") + if isinstance(value, unicode): + utf8_value = value + else: + utf8_value = unicode(value, "utf-8") esc_list = [] remove_chars = set(u"%_") for glyph in utf8_value: @@ -317,6 +324,8 @@ class NamedQuery(object): def for_schema(self, db_name): "Look trough the alternates and return the correct query" + if db_name is None: + return self try: return self._alternative[db_name] except KeyError, e: @@ -341,21 +350,21 @@ class NamedQuery(object): cursor = connection.cursor(MySQLdb.cursors.DictCursor) else: cursor = connection.cursor() - - statement = self.sql(connection, params) + + full_query, params = self._construct_sql(params) if DEBUG: - print "SQL:", statement - rows = cursor.execute(statement) - + print "SQL:", self.sql(connection, params) + rows = cursor.execute(full_query, params) + # *NOTE: the expect_rows argument is a very cheesy way to get some # validation on the result set. If you want to add more expectation - # logic, do something more object-oriented and flexible. Or use an ORM. + # logic, do something more object-oriented and flexible. Or use an ORM. if(self._return_as_map): expect_rows = 1 if expect_rows is not None and rows != expect_rows: cursor.close() - raise ExpectationFailed("Statement expected %s rows, got %s. Sql: %s" % ( - expect_rows, rows, statement)) + raise ExpectationFailed("Statement expected %s rows, got %s. Sql: '%s' %s" % ( + expect_rows, rows, full_query, params)) # convert to dicts manually if we're not using a dictcursor if use_dictcursor: @@ -381,11 +390,9 @@ class NamedQuery(object): return result_set[0] return result_set - def sql(self, connection, params): - """ Generates an SQL statement from the named query document - and a dictionary of parameters. - - """ + def _construct_sql(self, params): + """ Returns a query string and a dictionary of parameters, + suitable for directly passing to the execute() method.""" self.refresh() # build the query from the options available and the params @@ -431,10 +438,23 @@ class NamedQuery(object): new_params[self._build_integer_key(key)] = int(params[key]) params.update(new_params) + return full_query, params + + def sql(self, connection, params): + """ Generates an SQL statement from the named query document + and a dictionary of parameters. + + *NOTE: Only use for debugging, because it uses the + non-standard MySQLdb 'literal' method. + """ + if not DEBUG: + import warnings + warnings.warn("Don't use named_query.sql() when not debugging. Used on %s" % self._location) # do substitution using the mysql (non-standard) 'literal' # function to do the escaping. - sql = full_query % connection.literal(params) - return sql + full_query, params = self._construct_sql(params) + return full_query % connection.literal(params) + def refresh(self): """ Refresh self from the file on the filesystem. diff --git a/indra/lib/python/indra/util/simperf_oprof_interface.py b/indra/lib/python/indra/util/simperf_oprof_interface.py index c8d0f7475..547d2f998 100755 --- a/indra/lib/python/indra/util/simperf_oprof_interface.py +++ b/indra/lib/python/indra/util/simperf_oprof_interface.py @@ -3,20 +3,27 @@ @file simperf_oprof_interface.py @brief Manage OProfile data collection on a host -$LicenseInfo:firstyear=2008&license=internal$ +$LicenseInfo:firstyear=2008&license=mit$ Copyright (c) 2008-2009, Linden Research, Inc. -The following source code is PROPRIETARY AND CONFIDENTIAL. Use of -this source code is governed by the Linden Lab Source Code Disclosure -Agreement ("Agreement") previously entered between you and Linden -Lab. By accessing, using, copying, modifying or distributing this -software, you acknowledge that you have been informed of your -obligations under the Agreement and agree to abide by those obligations. +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: -ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO -WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, -COMPLETENESS OR PERFORMANCE. +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. $/LicenseInfo$ """ diff --git a/indra/lib/python/indra/util/simperf_proc_interface.py b/indra/lib/python/indra/util/simperf_proc_interface.py index 62a63fa87..de061f68c 100755 --- a/indra/lib/python/indra/util/simperf_proc_interface.py +++ b/indra/lib/python/indra/util/simperf_proc_interface.py @@ -1,4 +1,31 @@ -#!/usr/bin/python +#!/usr/bin/env python +"""\ +@file simperf_proc_interface.py +@brief Utility to extract log messages from *..llsd files containing performance statistics. + +$LicenseInfo:firstyear=2008&license=mit$ + +Copyright (c) 2008-2009, Linden Research, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +$/LicenseInfo$ +""" # ---------------------------------------------------- # Utility to extract log messages from *..llsd diff --git a/indra/lib/python/indra/util/test_win32_manifest.py b/indra/lib/python/indra/util/test_win32_manifest.py new file mode 100644 index 000000000..0532cb006 --- /dev/null +++ b/indra/lib/python/indra/util/test_win32_manifest.py @@ -0,0 +1,146 @@ +#!/usr/bin/env python +"""\ +@file test_win32_manifest.py +@brief Test an assembly binding version and uniqueness in a windows dll or exe. + +$LicenseInfo:firstyear=2009&license=viewerlgpl$ +Second Life Viewer Source Code +Copyright (C) 2009-2011, Linden Research, Inc. + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; +version 2.1 of the License only. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA +$/LicenseInfo$ +""" +import sys, os +import tempfile +from xml.dom.minidom import parse + +class AssemblyTestException(Exception): + pass + +class NoManifestException(AssemblyTestException): + pass + +class MultipleBindingsException(AssemblyTestException): + pass + +class UnexpectedVersionException(AssemblyTestException): + pass + +class NoMatchingAssemblyException(AssemblyTestException): + pass + +def get_HKLM_registry_value(key_str, value_str): + import _winreg + reg = _winreg.ConnectRegistry(None, _winreg.HKEY_LOCAL_MACHINE) + key = _winreg.OpenKey(reg, key_str) + value = _winreg.QueryValueEx(key, value_str)[0] + #print 'Found: %s' % value + return value + +def find_vc_dir(): + supported_versions = (r'8.0', r'9.0') + supported_products = (r'VisualStudio', r'VCExpress') + value_str = (r'ProductDir') + + for product in supported_products: + for version in supported_versions: + key_str = (r'SOFTWARE\Microsoft\%s\%s\Setup\VC' % + (product, version)) + try: + return get_HKLM_registry_value(key_str, value_str) + except WindowsError, err: + x64_key_str = (r'SOFTWARE\Wow6432Node\Microsoft\VisualStudio\%s\Setup\VS' % + version) + try: + return get_HKLM_registry_value(x64_key_str, value_str) + except: + print >> sys.stderr, "Didn't find MS %s version %s " % (product,version) + + raise + +def find_mt_path(): + vc_dir = find_vc_dir() + mt_path = '\"%sbin\\mt.exe\"' % vc_dir + return mt_path + +def test_assembly_binding(src_filename, assembly_name, assembly_ver): + print "checking %s dependency %s..." % (src_filename, assembly_name) + + (tmp_file_fd, tmp_file_name) = tempfile.mkstemp(suffix='.xml') + tmp_file = os.fdopen(tmp_file_fd) + tmp_file.close() + + mt_path = find_mt_path() + resource_id = "" + if os.path.splitext(src_filename)[1].lower() == ".dll": + resource_id = ";#2" + system_call = '%s -nologo -inputresource:%s%s -out:%s > NUL' % (mt_path, src_filename, resource_id, tmp_file_name) + print "Executing: %s" % system_call + mt_result = os.system(system_call) + if mt_result == 31: + print "No manifest found in %s" % src_filename + raise NoManifestException() + + manifest_dom = parse(tmp_file_name) + nodes = manifest_dom.getElementsByTagName('assemblyIdentity') + + versions = list() + for node in nodes: + if node.getAttribute('name') == assembly_name: + versions.append(node.getAttribute('version')) + + if len(versions) == 0: + print "No matching assemblies found in %s" % src_filename + raise NoMatchingAssemblyException() + + elif len(versions) > 1: + print "Multiple bindings to %s found:" % assembly_name + print versions + print + raise MultipleBindingsException(versions) + + elif versions[0] != assembly_ver: + print "Unexpected version found for %s:" % assembly_name + print "Wanted %s, found %s" % (assembly_ver, versions[0]) + print + raise UnexpectedVersionException(assembly_ver, versions[0]) + + os.remove(tmp_file_name) + + print "SUCCESS: %s OK!" % src_filename + print + +if __name__ == '__main__': + + print + print "Running test_win32_manifest.py..." + + usage = 'test_win32_manfest ' + + try: + src_filename = sys.argv[1] + assembly_name = sys.argv[2] + assembly_ver = sys.argv[3] + except: + print "Usage:" + print usage + print + raise + + test_assembly_binding(src_filename, assembly_name, assembly_ver) + + diff --git a/indra/lib/python/uuid.py b/indra/lib/python/uuid.py index 1c86c761b..0bc21a35f 100644 --- a/indra/lib/python/uuid.py +++ b/indra/lib/python/uuid.py @@ -45,13 +45,6 @@ Typical usage: This module works with Python 2.3 or higher.""" -# *HACK: Necessary for python 2.4. Consider replacing this code wart -# after python >=2.5 has deployed everywhere. 2009-10-05 -try: - from hashlib import md5 -except ImportError: - from md5 import md5 - __author__ = 'Ka-Ping Yee ' __date__ = '$Date: 2006/06/12 23:15:40 $'.split()[1].replace('/', '-') __version__ = '$Revision: 1.30 $'.split()[1] @@ -453,6 +446,13 @@ def uuid1(node=None, clock_seq=None): def uuid3(namespace, name): """Generate a UUID from the MD5 hash of a namespace UUID and a name.""" + try: + # Python 2.6 + from hashlib import md5 + except ImportError: + # Python 2.5 and earlier + from md5 import new as md5 + hash = md5(namespace.bytes + name).digest() return UUID(bytes=hash[:16], version=3) diff --git a/indra/libhacd/hacdRaycastMesh.cpp b/indra/libhacd/hacdRaycastMesh.cpp index 2f84bbc11..28e1325a1 100644 --- a/indra/libhacd/hacdRaycastMesh.cpp +++ b/indra/libhacd/hacdRaycastMesh.cpp @@ -17,6 +17,10 @@ #include #include #include "hacdManifoldMesh.h" + +#if _MSC_VER >= 1800 +#include +#endif namespace HACD { bool BBox::Raycast(const Vec3 & origin, const Vec3 & dir, Float & distMin) const diff --git a/indra/llappearance/llavatarjoint.h b/indra/llappearance/llavatarjoint.h index fec91503c..e4da9bb9a 100644 --- a/indra/llappearance/llavatarjoint.h +++ b/indra/llappearance/llavatarjoint.h @@ -127,6 +127,16 @@ public: LLAvatarJointCollisionVolume(); virtual ~LLAvatarJointCollisionVolume() {}; + void* operator new(size_t size) + { + return ll_aligned_malloc_16(size); + } + + void operator delete(void* ptr) + { + ll_aligned_free_16(ptr); + } + /*virtual*/ BOOL inheritScale() { return TRUE; } /*virtual*/ U32 render( F32 pixelArea, BOOL first_pass = TRUE, BOOL is_dummy = FALSE ); diff --git a/indra/llappearance/llpolymorph.h b/indra/llappearance/llpolymorph.h index f1ecef881..b00fef4ac 100644 --- a/indra/llappearance/llpolymorph.h +++ b/indra/llappearance/llpolymorph.h @@ -163,6 +163,16 @@ public: LLPolyMorphTarget(LLPolyMesh *poly_mesh); ~LLPolyMorphTarget(); + void* operator new(size_t size) + { + return ll_aligned_malloc_16(size); + } + + void operator delete(void* ptr) + { + ll_aligned_free_16(ptr); + } + // Special: These functions are overridden by child classes LLPolyMorphTargetInfo* getInfo() const { return (LLPolyMorphTargetInfo*)mInfo; } // This sets mInfo and calls initialization functions diff --git a/indra/llaudio/CMakeLists.txt b/indra/llaudio/CMakeLists.txt index 22d814e03..25970a99a 100644 --- a/indra/llaudio/CMakeLists.txt +++ b/indra/llaudio/CMakeLists.txt @@ -5,25 +5,21 @@ project(llaudio) include(00-Common) include(Audio) include(LLAudio) +if (FMODSTUDIO) + include(FMODSTUDIO) +endif (FMODSTUDIO) if (FMODEX) include(FMODEX) - set(FMOD OFF) endif (FMODEX) -if (NOT FMODEX) - include(FMOD) -endif (NOT FMODEX) include(OPENAL) include(LLCommon) include(LLMath) include(LLMessage) include(LLVFS) -if (FMODEX) - include_directories(${FMODEX_INCLUDE_DIR}) -endif(FMODEX) -if(FMOD) +if (FMOD) include_directories(${FMOD_INCLUDE_DIR}) -endif (FMOD) +endif(FMOD) include_directories( ${LLAUDIO_INCLUDE_DIRS} @@ -58,6 +54,20 @@ set(llaudio_HEADER_FILES llwindgen.h ) +if (FMODSTUDIO) + list(APPEND llaudio_SOURCE_FILES + llaudioengine_fmodstudio.cpp + lllistener_fmodstudio.cpp + llstreamingaudio_fmodstudio.cpp + ) + + list(APPEND llaudio_HEADER_FILES + llaudioengine_fmodstudio.h + lllistener_fmodstudio.h + llstreamingaudio_fmodstudio.h + ) +endif (FMODSTUDIO) + if (FMODEX) list(APPEND llaudio_SOURCE_FILES llaudioengine_fmodex.cpp @@ -71,26 +81,6 @@ if (FMODEX) llstreamingaudio_fmodex.h ) endif (FMODEX) -if (FMOD) - list(APPEND llaudio_SOURCE_FILES - llaudioengine_fmod.cpp - lllistener_fmod.cpp - llstreamingaudio_fmod.cpp - ) - - list(APPEND llaudio_HEADER_FILES - llaudioengine_fmod.h - lllistener_fmod.h - llstreamingaudio_fmod.h - ) - - if (LINUX) - if (${CXX_VERSION} MATCHES "4.[23]") - set_source_files_properties(llaudioengine_fmod.cpp - COMPILE_FLAGS -Wno-error=write-strings) - endif (${CXX_VERSION} MATCHES "4.[23]") - endif (LINUX) -endif (FMOD) if (OPENAL) list(APPEND llaudio_SOURCE_FILES diff --git a/indra/llaudio/llaudioengine.cpp b/indra/llaudio/llaudioengine.cpp index 6be8a8042..99e151f12 100644 --- a/indra/llaudio/llaudioengine.cpp +++ b/indra/llaudio/llaudioengine.cpp @@ -174,6 +174,9 @@ void LLAudioEngine::shutdown() delete mBuffers[i]; mBuffers[i] = NULL; } + + delete mStreamingAudioImpl; + mStreamingAudioImpl = NULL; } diff --git a/indra/llaudio/llaudioengine_fmod.cpp b/indra/llaudio/llaudioengine_fmod.cpp deleted file mode 100644 index 01beaa9d5..000000000 --- a/indra/llaudio/llaudioengine_fmod.cpp +++ /dev/null @@ -1,789 +0,0 @@ -/** - * @file audioengine_fmod.cpp - * @brief Implementation of LLAudioEngine class abstracting the audio support as a FMOD 3D implementation - * - * $LicenseInfo:firstyear=2002&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#include "linden_common.h" - -#include "llstreamingaudio.h" -#include "llstreamingaudio_fmod.h" - -#include "llaudioengine_fmod.h" -#include "lllistener_fmod.h" - -#include "llerror.h" -#include "llmath.h" -#include "llrand.h" - -#include "fmod.h" -#include "fmod_errors.h" -#include "lldir.h" -#include "llapr.h" - -#include "sound_ids.h" - - -extern "C" { - void * F_CALLBACKAPI windCallback(void *originalbuffer, void *newbuffer, int length, void* userdata); -} - - -LLAudioEngine_FMOD::LLAudioEngine_FMOD() -{ - mInited = false; - mWindGen = NULL; - mWindDSP = NULL; -} - - -LLAudioEngine_FMOD::~LLAudioEngine_FMOD() -{ -} - - -bool LLAudioEngine_FMOD::init(const S32 num_channels, void* userdata) -{ - LLAudioEngine::init(num_channels, userdata); - - // Reserve one extra channel for the http stream. - if (!FSOUND_SetMinHardwareChannels(num_channels + 1)) - { - LL_WARNS("AppInit") << "FMOD::init[0](), error: " << FMOD_ErrorString(FSOUND_GetError()) << LL_ENDL; - } - - LL_DEBUGS("AppInit") << "LLAudioEngine_FMOD::init() initializing FMOD" << LL_ENDL; - - F32 version = FSOUND_GetVersion(); - if (version < FMOD_VERSION) - { - LL_WARNS("AppInit") << "Error : You are using the wrong FMOD version (" << version - << ")! You should be using FMOD " << FMOD_VERSION << LL_ENDL; - //return false; - } - - U32 fmod_flags = 0x0; - -#if LL_WINDOWS - // Windows needs to know which window is frontmost. - // This must be called before FSOUND_Init() per the FMOD docs. - // This could be used to let FMOD handle muting when we lose focus, - // but we don't actually want to do that because we want to distinguish - // between minimized and not-focused states. - if (!FSOUND_SetHWND(userdata)) - { - LL_WARNS("AppInit") << "Error setting FMOD window: " - << FMOD_ErrorString(FSOUND_GetError()) << LL_ENDL; - return false; - } - // Play audio when we don't have focus. - // (For example, IM client on top of us.) - // This means we also try to play audio when minimized, - // so we manually handle muting in that case. JC - fmod_flags |= FSOUND_INIT_GLOBALFOCUS; - fmod_flags |= FSOUND_INIT_DSOUND_HRTF_FULL; -#endif - -#if LL_LINUX - // initialize the FMOD engine - - // This is a hack to use only FMOD's basic FPU mixer - // when the LL_VALGRIND environmental variable is set, - // otherwise valgrind will fall over on FMOD's MMX detection - if (getenv("LL_VALGRIND")) /*Flawfinder: ignore*/ - { - LL_INFOS("AppInit") << "Pacifying valgrind in FMOD init." << LL_ENDL; - FSOUND_SetMixer(FSOUND_MIXER_QUALITY_FPU); - } - - // If we don't set an output method, Linux FMOD always - // decides on OSS and fails otherwise. So we'll manually - // try ESD, then OSS, then ALSA. - // Why this order? See SL-13250, but in short, OSS emulated - // on top of ALSA is ironically more reliable than raw ALSA. - // Ack, and ESD has more reliable failure modes - but has worse - // latency - than all of them, so wins for now. - bool audio_ok = false; - - if (!audio_ok) - { - if (NULL == getenv("LL_BAD_FMOD_ESD")) /*Flawfinder: ignore*/ - { - LL_DEBUGS("AppInit") << "Trying ESD audio output..." << LL_ENDL; - if(FSOUND_SetOutput(FSOUND_OUTPUT_ESD) && - FSOUND_Init(44100, num_channels, fmod_flags)) - { - LL_DEBUGS("AppInit") << "ESD audio output initialized OKAY" - << LL_ENDL; - audio_ok = true; - } else { - LL_WARNS("AppInit") << "ESD audio output FAILED to initialize: " - << FMOD_ErrorString(FSOUND_GetError()) << LL_ENDL; - } - } else { - LL_DEBUGS("AppInit") << "ESD audio output SKIPPED" << LL_ENDL; - } - } - if (!audio_ok) - { - if (NULL == getenv("LL_BAD_FMOD_OSS")) /*Flawfinder: ignore*/ - { - LL_DEBUGS("AppInit") << "Trying OSS audio output..." << LL_ENDL; - if(FSOUND_SetOutput(FSOUND_OUTPUT_OSS) && - FSOUND_Init(44100, num_channels, fmod_flags)) - { - LL_DEBUGS("AppInit") << "OSS audio output initialized OKAY" << LL_ENDL; - audio_ok = true; - } else { - LL_WARNS("AppInit") << "OSS audio output FAILED to initialize: " - << FMOD_ErrorString(FSOUND_GetError()) << LL_ENDL; - } - } else { - LL_DEBUGS("AppInit") << "OSS audio output SKIPPED" << LL_ENDL; - } - } - if (!audio_ok) - { - if (NULL == getenv("LL_BAD_FMOD_ALSA")) /*Flawfinder: ignore*/ - { - LL_DEBUGS("AppInit") << "Trying ALSA audio output..." << LL_ENDL; - if(FSOUND_SetOutput(FSOUND_OUTPUT_ALSA) && - FSOUND_Init(44100, num_channels, fmod_flags)) - { - LL_DEBUGS("AppInit") << "ALSA audio output initialized OKAY" << LL_ENDL; - audio_ok = true; - } else { - LL_WARNS("AppInit") << "ALSA audio output FAILED to initialize: " - << FMOD_ErrorString(FSOUND_GetError()) << LL_ENDL; - } - } else { - LL_DEBUGS("AppInit") << "OSS audio output SKIPPED" << LL_ENDL; - } - } - if (!audio_ok) - { - LL_WARNS("AppInit") << "Overall audio init failure." << LL_ENDL; - return false; - } - - // On Linux, FMOD causes a SIGPIPE for some netstream error - // conditions (an FMOD bug); ignore SIGPIPE so it doesn't crash us. - // NOW FIXED in FMOD 3.x since 2006-10-01. - //signal(SIGPIPE, SIG_IGN); - - // We're interested in logging which output method we - // ended up with, for QA purposes. - switch (FSOUND_GetOutput()) - { - case FSOUND_OUTPUT_NOSOUND: LL_DEBUGS("AppInit") << "Audio output: NoSound" << LL_ENDL; break; - case FSOUND_OUTPUT_OSS: LL_DEBUGS("AppInit") << "Audio output: OSS" << LL_ENDL; break; - case FSOUND_OUTPUT_ESD: LL_DEBUGS("AppInit") << "Audio output: ESD" << LL_ENDL; break; - case FSOUND_OUTPUT_ALSA: LL_DEBUGS("AppInit") << "Audio output: ALSA" << LL_ENDL; break; - default: LL_INFOS("AppInit") << "Audio output: Unknown!" << LL_ENDL; break; - }; - -#else // LL_LINUX - - // initialize the FMOD engine - if (!FSOUND_Init(44100, num_channels, fmod_flags)) - { - LL_WARNS("AppInit") << "Error initializing FMOD: " - << FMOD_ErrorString(FSOUND_GetError()) << LL_ENDL; - return false; - } - -#endif - - // set up our favourite FMOD-native streaming audio implementation if none has already been added - if (!getStreamingAudioImpl()) // no existing implementation added - setStreamingAudioImpl(new LLStreamingAudio_FMOD()); - - LL_DEBUGS("AppInit") << "LLAudioEngine_FMOD::init() FMOD initialized correctly" << LL_ENDL; - - mInited = true; - - return true; -} - - -std::string LLAudioEngine_FMOD::getDriverName(bool verbose) -{ - if (verbose) - { - F32 version = FSOUND_GetVersion(); - return llformat("FMOD version %f", version); - } - else - { - return "FMOD"; - } -} - - -void LLAudioEngine_FMOD::allocateListener(void) -{ - mListenerp = (LLListener *) new LLListener_FMOD(); - if (!mListenerp) - { - llwarns << "Listener creation failed" << llendl; - } -} - - -void LLAudioEngine_FMOD::shutdown() -{ - if (mWindDSP) - { - FSOUND_DSP_SetActive(mWindDSP,false); - FSOUND_DSP_Free(mWindDSP); - } - - stopInternetStream(); - - LLAudioEngine::shutdown(); - - llinfos << "LLAudioEngine_FMOD::shutdown() closing FMOD" << llendl; - FSOUND_Close(); - llinfos << "LLAudioEngine_FMOD::shutdown() done closing FMOD" << llendl; - - delete mListenerp; - mListenerp = NULL; -} - - -LLAudioBuffer * LLAudioEngine_FMOD::createBuffer() -{ - return new LLAudioBufferFMOD(); -} - - -LLAudioChannel * LLAudioEngine_FMOD::createChannel() -{ - return new LLAudioChannelFMOD(); -} - - -bool LLAudioEngine_FMOD::initWind() -{ - if (!mWindGen) - { - bool enable; - - switch (FSOUND_GetMixer()) - { - case FSOUND_MIXER_MMXP5: - case FSOUND_MIXER_MMXP6: - case FSOUND_MIXER_QUALITY_MMXP5: - case FSOUND_MIXER_QUALITY_MMXP6: - enable = (typeid(MIXBUFFERFORMAT) == typeid(S16)); - break; - case FSOUND_MIXER_BLENDMODE: - enable = (typeid(MIXBUFFERFORMAT) == typeid(S32)); - break; - case FSOUND_MIXER_QUALITY_FPU: - enable = (typeid(MIXBUFFERFORMAT) == typeid(F32)); - break; - default: - // FSOUND_GetMixer() does not return a valid mixer type on Darwin - LL_INFOS("AppInit") << "Unknown FMOD mixer type, assuming default" << LL_ENDL; - enable = true; - break; - } - - if (enable) - { - mWindGen = new LLWindGen(FSOUND_GetOutputRate()); - } - else - { - LL_WARNS("AppInit") << "Incompatible FMOD mixer type, wind noise disabled" << LL_ENDL; - } - } - - mNextWindUpdate = 0.0; - - if (mWindGen && !mWindDSP) - { - mWindDSP = FSOUND_DSP_Create(&windCallback, FSOUND_DSP_DEFAULTPRIORITY_CLEARUNIT + 20, mWindGen); - } - if (mWindDSP) - { - FSOUND_DSP_SetActive(mWindDSP, true); - return true; - } - - return false; -} - - -void LLAudioEngine_FMOD::cleanupWind() -{ - if (mWindDSP) - { - FSOUND_DSP_SetActive(mWindDSP, false); - FSOUND_DSP_Free(mWindDSP); - mWindDSP = NULL; - } - - delete mWindGen; - mWindGen = NULL; -} - - -//----------------------------------------------------------------------- -void LLAudioEngine_FMOD::updateWind(LLVector3 wind_vec, F32 camera_height_above_water) -{ - LLVector3 wind_pos; - F64 pitch; - F64 center_freq; - - if (!mEnableWind) - { - return; - } - - if (mWindUpdateTimer.checkExpirationAndReset(LL_WIND_UPDATE_INTERVAL)) - { - - // wind comes in as Linden coordinate (+X = forward, +Y = left, +Z = up) - // need to convert this to the conventional orientation DS3D and OpenAL use - // where +X = right, +Y = up, +Z = backwards - - wind_vec.setVec(-wind_vec.mV[1], wind_vec.mV[2], -wind_vec.mV[0]); - - // cerr << "Wind update" << endl; - - pitch = 1.0 + mapWindVecToPitch(wind_vec); - center_freq = 80.0 * pow(pitch,2.5*(mapWindVecToGain(wind_vec)+1.0)); - - mWindGen->mTargetFreq = (F32)center_freq; - mWindGen->mTargetGain = (F32)mapWindVecToGain(wind_vec) * mMaxWindGain; - mWindGen->mTargetPanGainR = (F32)mapWindVecToPan(wind_vec); - } -} - -/* -//----------------------------------------------------------------------- -void LLAudioEngine_FMOD::setSourceMinDistance(U16 source_num, F64 distance) -{ - if (!mInited) - { - return; - } - if (mBuffer[source_num]) - { - mMinDistance[source_num] = (F32) distance; - if (!FSOUND_Sample_SetMinMaxDistance(mBuffer[source_num],mMinDistance[source_num], mMaxDistance[source_num])) - { - llwarns << "FMOD::setSourceMinDistance(" << source_num << "), error: " << FMOD_ErrorString(FSOUND_GetError()) << llendl; - } - } -} - -//----------------------------------------------------------------------- -void LLAudioEngine_FMOD::setSourceMaxDistance(U16 source_num, F64 distance) -{ - if (!mInited) - { - return; - } - if (mBuffer[source_num]) - { - mMaxDistance[source_num] = (F32) distance; - if (!FSOUND_Sample_SetMinMaxDistance(mBuffer[source_num],mMinDistance[source_num], mMaxDistance[source_num])) - { - llwarns << "FMOD::setSourceMaxDistance(" << source_num << "), error: " << FMOD_ErrorString(FSOUND_GetError()) << llendl; - } - } -} - -//----------------------------------------------------------------------- -void LLAudioEngine_FMOD::get3DParams(S32 source_num, S32 *volume, S32 *freq, S32 *inside, S32 *outside, LLVector3 *orient, S32 *out_volume, F32 *min_dist, F32 *max_dist) -{ - *volume = 0; - *freq = 0; - *inside = 0; - *outside = 0; - *orient = LLVector3::zero; - *out_volume = 0; - *min_dist = 0.f; - *max_dist = 0.f; -} - -*/ - - -//----------------------------------------------------------------------- -void LLAudioEngine_FMOD::setInternalGain(F32 gain) -{ - if (!mInited) - { - return; - } - - gain = llclamp( gain, 0.0f, 1.0f ); - FSOUND_SetSFXMasterVolume( llround( 255.0f * gain ) ); - - LLStreamingAudioInterface *saimpl = getStreamingAudioImpl(); - if ( saimpl ) - { - // fmod likes its streaming audio channel gain re-asserted after - // master volume change. - saimpl->setGain(saimpl->getGain()); - } -} - -// -// LLAudioChannelFMOD implementation -// - -LLAudioChannelFMOD::LLAudioChannelFMOD() : LLAudioChannel(), mChannelID(0), mLastSamplePos(0) -{ -} - - -LLAudioChannelFMOD::~LLAudioChannelFMOD() -{ - cleanup(); -} - - -bool LLAudioChannelFMOD::updateBuffer() -{ - if (LLAudioChannel::updateBuffer()) - { - // Base class update returned true, which means that we need to actually - // set up the channel for a different buffer. - - LLAudioBufferFMOD *bufferp = (LLAudioBufferFMOD *)mCurrentSourcep->getCurrentBuffer(); - - // Grab the FMOD sample associated with the buffer - FSOUND_SAMPLE *samplep = bufferp->getSample(); - if (!samplep) - { - // This is bad, there should ALWAYS be a sample associated with a legit - // buffer. - llerrs << "No FMOD sample!" << llendl; - return false; - } - - - // Actually play the sound. Start it off paused so we can do all the necessary - // setup. - mChannelID = FSOUND_PlaySoundEx(FSOUND_FREE, samplep, FSOUND_DSP_GetSFXUnit(), true); - - //llinfos << "Setting up channel " << std::hex << mChannelID << std::dec << llendl; - } - - // If we have a source for the channel, we need to update its gain. - if (mCurrentSourcep) - { - // SJB: warnings can spam and hurt framerate, disabling - if (!FSOUND_SetVolume(mChannelID, llround(getSecondaryGain() * mCurrentSourcep->getGain() * 255.0f))) - { -// llwarns << "LLAudioChannelFMOD::updateBuffer error: " << FMOD_ErrorString(FSOUND_GetError()) << llendl; - } - - if (!FSOUND_SetLoopMode(mChannelID, mCurrentSourcep->isLoop() ? FSOUND_LOOP_NORMAL : FSOUND_LOOP_OFF)) - { -// llwarns << "Channel " << mChannelID << "Source ID: " << mCurrentSourcep->getID() -// << " at " << mCurrentSourcep->getPositionGlobal() << llendl; -// llwarns << "LLAudioChannelFMOD::updateBuffer error: " << FMOD_ErrorString(FSOUND_GetError()) << llendl; - } - } - - return true; -} - - -void LLAudioChannelFMOD::update3DPosition() -{ - if (!mChannelID) - { - // We're not actually a live channel (i.e., we're not playing back anything) - return; - } - - LLAudioBufferFMOD *bufferp = (LLAudioBufferFMOD *)mCurrentBufferp; - if (!bufferp) - { - // We don't have a buffer associated with us (should really have been picked up - // by the above if. - return; - } - - if (mCurrentSourcep->isAmbient()) - { - // Ambient sound, don't need to do any positional updates. - bufferp->set3DMode(false); - } - else - { - // Localized sound. Update the position and velocity of the sound. - bufferp->set3DMode(true); - - LLVector3 float_pos; - float_pos.setVec(mCurrentSourcep->getPositionGlobal()); - if (!FSOUND_3D_SetAttributes(mChannelID, float_pos.mV, mCurrentSourcep->getVelocity().mV)) - { - LL_DEBUGS("FMOD") << "LLAudioChannelFMOD::update3DPosition error: " << FMOD_ErrorString(FSOUND_GetError()) << LL_ENDL; - } - } -} - - -void LLAudioChannelFMOD::updateLoop() -{ - if (!mChannelID) - { - // May want to clear up the loop/sample counters. - return; - } - - // - // Hack: We keep track of whether we looped or not by seeing when the - // sample position looks like it's going backwards. Not reliable; may - // yield false negatives. - // - U32 cur_pos = FSOUND_GetCurrentPosition(mChannelID); - if (cur_pos < (U32)mLastSamplePos) - { - mLoopedThisFrame = true; - } - mLastSamplePos = cur_pos; -} - - -void LLAudioChannelFMOD::cleanup() -{ - LLAudioChannel::cleanup(); - if (!mChannelID) - { - //llinfos << "Aborting cleanup with no channelID." << llendl; - return; - } - - //llinfos << "Cleaning up channel: " << mChannelID << llendl; - if (!FSOUND_StopSound(mChannelID)) - { - LL_DEBUGS("FMOD") << "LLAudioChannelFMOD::cleanup error: " << FMOD_ErrorString(FSOUND_GetError()) << llendl; - } - - mChannelID = 0; - mLastSamplePos = 0; -} - - -void LLAudioChannelFMOD::play() -{ - if (!mChannelID) - { - llwarns << "Playing without a channelID, aborting" << llendl; - return; - } - - if(!FSOUND_IsPaused(mChannelID)) - { - FSOUND_SetPaused(mChannelID, true); - FSOUND_SetCurrentPosition(mChannelID, 0); - } - - if (!FSOUND_SetPaused(mChannelID, false)) - { - llwarns << "LLAudioChannelFMOD::play error: " << FMOD_ErrorString(FSOUND_GetError()) << llendl; - } - getSource()->setPlayedOnce(true); -} - - -void LLAudioChannelFMOD::playSynced(LLAudioChannel *channelp) -{ - LLAudioChannelFMOD *fmod_channelp = (LLAudioChannelFMOD*)channelp; - if (!(fmod_channelp->mChannelID && mChannelID)) - { - // Don't have channels allocated to both the master and the slave - return; - } - - U32 position = FSOUND_GetCurrentPosition(fmod_channelp->mChannelID) % mCurrentBufferp->getLength(); - // Try to match the position of our sync master - if (!FSOUND_SetCurrentPosition(mChannelID, position)) - { - llwarns << "LLAudioChannelFMOD::playSynced unable to set current position" << llendl; - } - - // Start us playing - play(); -} - - -bool LLAudioChannelFMOD::isPlaying() -{ - if (!mChannelID) - { - return false; - } - - return FSOUND_IsPlaying(mChannelID) && (!FSOUND_GetPaused(mChannelID)); -} - - - -// -// LLAudioBufferFMOD implementation -// - - -LLAudioBufferFMOD::LLAudioBufferFMOD() : LLAudioBuffer() -{ - mSamplep = NULL; -} - - -LLAudioBufferFMOD::~LLAudioBufferFMOD() -{ - if (mSamplep) - { - // Clean up the associated FMOD sample if it exists. - FSOUND_Sample_Free(mSamplep); - mSamplep = NULL; - } -} - - -bool LLAudioBufferFMOD::loadWAV(const std::string& filename) -{ - // Try to open a wav file from disk. This will eventually go away, as we don't - // really want to block doing this. - if (filename.empty()) - { - // invalid filename, abort. - return false; - } - - if (!LLAPRFile::isExist(filename, LL_APR_RPB)) - { - // File not found, abort. - return false; - } - - if (mSamplep) - { - // If there's already something loaded in this buffer, clean it up. - FSOUND_Sample_Free(mSamplep); - mSamplep = NULL; - } - - // Load up the wav file into an fmod sample -#if LL_WINDOWS - // MikeS. - Loading the sound file manually and then handing it over to FMOD, - // since FMOD uses posix IO internally, - // which doesn't work with unicode file paths. - LLFILE* sound_file = LLFile::fopen(filename,"rb"); /* Flawfinder: ignore */ - if (sound_file) - { - fseek(sound_file,0,SEEK_END); - U32 file_length = ftell(sound_file); //Find the length of the file by seeking to the end and getting the offset - size_t read_count; - fseek(sound_file,0,SEEK_SET); //Seek back to the beginning - char* buffer = new char[file_length]; - llassert(buffer); - read_count = fread((void*)buffer,file_length,1,sound_file);//Load it.. - if(ferror(sound_file)==0 && (read_count == 1)){//No read error, and we got 1 chunk of our size... - unsigned int mode_flags = FSOUND_LOOP_NORMAL | FSOUND_LOADMEMORY; - //FSOUND_16BITS | FSOUND_MONO | FSOUND_LOADMEMORY | FSOUND_LOOP_NORMAL; - mSamplep = FSOUND_Sample_Load(FSOUND_UNMANAGED, buffer, mode_flags , 0, file_length); - } - delete[] buffer; - fclose(sound_file); - } -#else - mSamplep = FSOUND_Sample_Load(FSOUND_UNMANAGED, filename.c_str(), FSOUND_LOOP_NORMAL, 0, 0); -#endif - - if (!mSamplep) - { - // We failed to load the file for some reason. - llwarns << "Could not load data '" << filename << "': " - << FMOD_ErrorString(FSOUND_GetError()) << llendl; - - // - // If we EVER want to load wav files provided by end users, we need - // to rethink this! - // - // file is probably corrupt - remove it. - LLFile::remove(filename); - return false; - } - - // Everything went well, return true - return true; -} - - -U32 LLAudioBufferFMOD::getLength() -{ - if (!mSamplep) - { - return 0; - } - - return FSOUND_Sample_GetLength(mSamplep); -} - - -void LLAudioBufferFMOD::set3DMode(bool use3d) -{ - U16 current_mode = FSOUND_Sample_GetMode(mSamplep); - - if (use3d) - { - if (!FSOUND_Sample_SetMode(mSamplep, (current_mode & (~FSOUND_2D)))) - { - llwarns << "LLAudioBufferFMOD::set3DMode error: " << FMOD_ErrorString(FSOUND_GetError()) << llendl; - } - } - else - { - if (!FSOUND_Sample_SetMode(mSamplep, current_mode | FSOUND_2D)) - { - llwarns << "LLAudioBufferFMOD::set3DMode error: " << FMOD_ErrorString(FSOUND_GetError()) << llendl; - } - } -} - - -void * F_CALLBACKAPI windCallback(void *originalbuffer, void *newbuffer, int length, void* userdata) -{ - // originalbuffer = fmod's original mixbuffer. - // newbuffer = the buffer passed from the previous DSP unit. - // length = length in samples at this mix time. - // userdata = user parameter passed through in FSOUND_DSP_Create. - - LLWindGen *windgen = - (LLWindGen *)userdata; - - newbuffer = windgen->windGenerate((LLAudioEngine_FMOD::MIXBUFFERFORMAT *)newbuffer, length); - - return newbuffer; -} diff --git a/indra/llaudio/llaudioengine_fmod.h b/indra/llaudio/llaudioengine_fmod.h deleted file mode 100644 index 4582a5d57..000000000 --- a/indra/llaudio/llaudioengine_fmod.h +++ /dev/null @@ -1,124 +0,0 @@ -/** - * @file audioengine_fmod.h - * @brief Definition of LLAudioEngine class abstracting the audio - * support as a FMOD 3D implementation - * - * $LicenseInfo:firstyear=2002&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#ifndef LL_AUDIOENGINE_FMOD_H -#define LL_AUDIOENGINE_FMOD_H - -#include "llaudioengine.h" -#include "lllistener_fmod.h" -#include "llwindgen.h" - -#include "fmod.h" - -class LLAudioStreamManagerFMOD; - -class LLAudioEngine_FMOD : public LLAudioEngine -{ -public: - LLAudioEngine_FMOD(); - virtual ~LLAudioEngine_FMOD(); - - // initialization/startup/shutdown - virtual bool init(const S32 num_channels, void *user_data); - virtual std::string getDriverName(bool verbose); - virtual void allocateListener(); - - virtual void shutdown(); - - /*virtual*/ bool initWind(); - /*virtual*/ void cleanupWind(); - - /*virtual*/void updateWind(LLVector3 direction, F32 camera_height_above_water); - -#if LL_DARWIN - typedef S32 MIXBUFFERFORMAT; -#else - typedef S16 MIXBUFFERFORMAT; -#endif - -protected: - /*virtual*/ LLAudioBuffer *createBuffer(); // Get a free buffer, or flush an existing one if you have to. - /*virtual*/ LLAudioChannel *createChannel(); // Create a new audio channel. - - /*virtual*/ void setInternalGain(F32 gain); -protected: - static signed char F_CALLBACKAPI callbackMetaData(char* name, char* value, void* userdata); - - //F32 mMinDistance[MAX_BUFFERS]; - //F32 mMaxDistance[MAX_BUFFERS]; - - bool mInited; - - // On Windows, userdata is the HWND of the application window. - void* mUserData; - - LLWindGen *mWindGen; - FSOUND_DSPUNIT *mWindDSP; -}; - - -class LLAudioChannelFMOD : public LLAudioChannel -{ -public: - LLAudioChannelFMOD(); - virtual ~LLAudioChannelFMOD(); - -protected: - /*virtual*/ void play(); - /*virtual*/ void playSynced(LLAudioChannel *channelp); - /*virtual*/ void cleanup(); - /*virtual*/ bool isPlaying(); - - /*virtual*/ bool updateBuffer(); - /*virtual*/ void update3DPosition(); - /*virtual*/ void updateLoop(); - -protected: - int mChannelID; - S32 mLastSamplePos; -}; - - -class LLAudioBufferFMOD : public LLAudioBuffer -{ -public: - LLAudioBufferFMOD(); - virtual ~LLAudioBufferFMOD(); - - /*virtual*/ bool loadWAV(const std::string& filename); - /*virtual*/ U32 getLength(); - friend class LLAudioChannelFMOD; - - void set3DMode(bool use3d); -protected: - FSOUND_SAMPLE *getSample() { return mSamplep; } -protected: - FSOUND_SAMPLE *mSamplep; -}; - - -#endif // LL_AUDIOENGINE_FMOD_H diff --git a/indra/llaudio/llaudioengine_fmodex.cpp b/indra/llaudio/llaudioengine_fmodex.cpp index 972725171..8b71012ba 100644 --- a/indra/llaudio/llaudioengine_fmodex.cpp +++ b/indra/llaudio/llaudioengine_fmodex.cpp @@ -285,7 +285,7 @@ bool LLAudioEngine_FMODEX::init(const S32 num_channels, void* userdata) return false; #endif - U32 version; + U32 version = 0; FMOD_RESULT result; LL_DEBUGS("AppInit") << "LLAudioEngine_FMODEX::init() initializing FMOD" << LL_ENDL; @@ -321,10 +321,6 @@ bool LLAudioEngine_FMODEX::init(const S32 num_channels, void* userdata) if(mEnableProfiler) { fmod_flags |= FMOD_INIT_ENABLE_PROFILE; - mSystem->createChannelGroup("None", &mChannelGroups[AUDIO_TYPE_NONE]); - mSystem->createChannelGroup("SFX", &mChannelGroups[AUDIO_TYPE_SFX]); - mSystem->createChannelGroup("UI", &mChannelGroups[AUDIO_TYPE_UI]); - mSystem->createChannelGroup("Ambient", &mChannelGroups[AUDIO_TYPE_AMBIENT]); } #if LL_LINUX @@ -335,7 +331,7 @@ bool LLAudioEngine_FMODEX::init(const S32 num_channels, void* userdata) if (NULL == getenv("LL_BAD_FMOD_PULSEAUDIO")) /*Flawfinder: ignore*/ { LL_DEBUGS("AppInit") << "Trying PulseAudio audio output..." << LL_ENDL; - if(mSystem->setOutput(FMOD_OUTPUTTYPE_PULSEAUDIO) == FMOD_OK && + if((result = mSystem->setOutput(FMOD_OUTPUTTYPE_PULSEAUDIO)) == FMOD_OK && (result = mSystem->init(num_channels + 2, fmod_flags, 0)) == FMOD_OK) { LL_DEBUGS("AppInit") << "PulseAudio output initialized OKAY" << LL_ENDL; @@ -356,7 +352,7 @@ bool LLAudioEngine_FMODEX::init(const S32 num_channels, void* userdata) if (NULL == getenv("LL_BAD_FMOD_ALSA")) /*Flawfinder: ignore*/ { LL_DEBUGS("AppInit") << "Trying ALSA audio output..." << LL_ENDL; - if(mSystem->setOutput(FMOD_OUTPUTTYPE_ALSA) == FMOD_OK && + if((result = mSystem->setOutput(FMOD_OUTPUTTYPE_ALSA)) == FMOD_OK && (result = mSystem->init(num_channels + 2, fmod_flags, 0)) == FMOD_OK) { LL_DEBUGS("AppInit") << "ALSA audio output initialized OKAY" << LL_ENDL; @@ -377,7 +373,7 @@ bool LLAudioEngine_FMODEX::init(const S32 num_channels, void* userdata) if (NULL == getenv("LL_BAD_FMOD_OSS")) /*Flawfinder: ignore*/ { LL_DEBUGS("AppInit") << "Trying OSS audio output..." << LL_ENDL; - if(mSystem->setOutput(FMOD_OUTPUTTYPE_OSS) == FMOD_OK && + if((result = mSystem->setOutput(FMOD_OUTPUTTYPE_OSS)) == FMOD_OK && (result = mSystem->init(num_channels + 2, fmod_flags, 0)) == FMOD_OK) { LL_DEBUGS("AppInit") << "OSS audio output initialized OKAY" << LL_ENDL; @@ -402,20 +398,22 @@ bool LLAudioEngine_FMODEX::init(const S32 num_channels, void* userdata) // We're interested in logging which output method we // ended up with, for QA purposes. FMOD_OUTPUTTYPE output_type; - mSystem->getOutput(&output_type); - switch (output_type) + if(!Check_FMOD_Error(mSystem->getOutput(&output_type), "FMOD::System::getOutput")) { - case FMOD_OUTPUTTYPE_NOSOUND: - LL_INFOS("AppInit") << "Audio output: NoSound" << LL_ENDL; break; - case FMOD_OUTPUTTYPE_PULSEAUDIO: - LL_INFOS("AppInit") << "Audio output: PulseAudio" << LL_ENDL; break; - case FMOD_OUTPUTTYPE_ALSA: - LL_INFOS("AppInit") << "Audio output: ALSA" << LL_ENDL; break; - case FMOD_OUTPUTTYPE_OSS: - LL_INFOS("AppInit") << "Audio output: OSS" << LL_ENDL; break; - default: - LL_INFOS("AppInit") << "Audio output: Unknown!" << LL_ENDL; break; - }; + switch (output_type) + { + case FMOD_OUTPUTTYPE_NOSOUND: + LL_INFOS("AppInit") << "Audio output: NoSound" << LL_ENDL; break; + case FMOD_OUTPUTTYPE_PULSEAUDIO: + LL_INFOS("AppInit") << "Audio output: PulseAudio" << LL_ENDL; break; + case FMOD_OUTPUTTYPE_ALSA: + LL_INFOS("AppInit") << "Audio output: ALSA" << LL_ENDL; break; + case FMOD_OUTPUTTYPE_OSS: + LL_INFOS("AppInit") << "Audio output: OSS" << LL_ENDL; break; + default: + LL_INFOS("AppInit") << "Audio output: Unknown!" << LL_ENDL; break; + }; + } #else // LL_LINUX // initialize the FMOD engine @@ -437,6 +435,14 @@ bool LLAudioEngine_FMODEX::init(const S32 num_channels, void* userdata) return false; #endif + if (mEnableProfiler) + { + Check_FMOD_Error(mSystem->createChannelGroup("None", &mChannelGroups[AUDIO_TYPE_NONE]), "FMOD::System::createChannelGroup"); + Check_FMOD_Error(mSystem->createChannelGroup("SFX", &mChannelGroups[AUDIO_TYPE_SFX]), "FMOD::System::createChannelGroup"); + Check_FMOD_Error(mSystem->createChannelGroup("UI", &mChannelGroups[AUDIO_TYPE_UI]), "FMOD::System::createChannelGroup"); + Check_FMOD_Error(mSystem->createChannelGroup("Ambient", &mChannelGroups[AUDIO_TYPE_AMBIENT]), "FMOD::System::createChannelGroup"); + } + // set up our favourite FMOD-native streaming audio implementation if none has already been added if (!getStreamingAudioImpl()) // no existing implementation added setStreamingAudioImpl(new LLStreamingAudio_FMODEX(mSystem)); @@ -447,35 +453,40 @@ bool LLAudioEngine_FMODEX::init(const S32 num_channels, void* userdata) unsigned int r_bufferlength; char r_name[256]; FMOD_SPEAKERMODE speaker_mode; - mSystem->getDSPBufferSize(&r_bufferlength, &r_numbuffers); - mSystem->getSoftwareFormat(&r_samplerate, NULL, &r_channels, NULL, NULL, &r_bits); - mSystem->getDriverInfo(0, r_name, 255, 0); - mSystem->getSpeakerMode(&speaker_mode); - std::string speaker_mode_str = "unknown"; - switch(speaker_mode) + if (!Check_FMOD_Error(mSystem->getDSPBufferSize(&r_bufferlength, &r_numbuffers), "FMOD::System::getDSPBufferSize") && + !Check_FMOD_Error(mSystem->getSoftwareFormat(&r_samplerate, NULL, &r_channels, NULL, NULL, &r_bits), "FMOD::System::getSoftwareFormat") && + !Check_FMOD_Error(mSystem->getDriverInfo(0, r_name, 255, 0), "FMOD::System::getDriverInfo") && + !Check_FMOD_Error(mSystem->getSpeakerMode(&speaker_mode), "FMOD::System::getSpeakerMode")) { - #define SPEAKER_MODE_CASE(MODE) case MODE: speaker_mode_str = #MODE; break; - SPEAKER_MODE_CASE(FMOD_SPEAKERMODE_RAW) - SPEAKER_MODE_CASE(FMOD_SPEAKERMODE_MONO) - SPEAKER_MODE_CASE(FMOD_SPEAKERMODE_STEREO) - SPEAKER_MODE_CASE(FMOD_SPEAKERMODE_QUAD) - SPEAKER_MODE_CASE(FMOD_SPEAKERMODE_SURROUND) - SPEAKER_MODE_CASE(FMOD_SPEAKERMODE_5POINT1) - SPEAKER_MODE_CASE(FMOD_SPEAKERMODE_7POINT1) - SPEAKER_MODE_CASE(FMOD_SPEAKERMODE_SRS5_1_MATRIX) - SPEAKER_MODE_CASE(FMOD_SPEAKERMODE_MYEARS) - default:; - #undef SPEAKER_MODE_CASE + std::string speaker_mode_str = "unknown"; + switch(speaker_mode) + { + #define SPEAKER_MODE_CASE(MODE) case MODE: speaker_mode_str = #MODE; break; + SPEAKER_MODE_CASE(FMOD_SPEAKERMODE_RAW) + SPEAKER_MODE_CASE(FMOD_SPEAKERMODE_MONO) + SPEAKER_MODE_CASE(FMOD_SPEAKERMODE_STEREO) + SPEAKER_MODE_CASE(FMOD_SPEAKERMODE_QUAD) + SPEAKER_MODE_CASE(FMOD_SPEAKERMODE_SURROUND) + SPEAKER_MODE_CASE(FMOD_SPEAKERMODE_5POINT1) + SPEAKER_MODE_CASE(FMOD_SPEAKERMODE_7POINT1) + SPEAKER_MODE_CASE(FMOD_SPEAKERMODE_SRS5_1_MATRIX) + SPEAKER_MODE_CASE(FMOD_SPEAKERMODE_MYEARS) + default:; + #undef SPEAKER_MODE_CASE + } + + r_name[255] = '\0'; + int latency = 1000.0 * r_bufferlength * r_numbuffers /r_samplerate; + + LL_INFOS("AppInit") << "FMOD device: "<< r_name << "\n" + << "Output mode: "<< speaker_mode_str << "\n" + << "FMOD Ex parameters: " << r_samplerate << " Hz * " << r_channels << " * " <close(); + Check_FMOD_Error(mSystem->close(), "FMOD::System::close"); LL_INFOS("AudioImpl") << "LLAudioEngine_FMODEX::shutdown() Requesting FMOD Ex system release" << LL_ENDL; - mSystem->release(); + Check_FMOD_Error(mSystem->release(), "FMOD::System::release"); } LL_INFOS("AudioImpl") << "LLAudioEngine_FMODEX::shutdown() done closing FMOD Ex" << LL_ENDL; @@ -544,30 +553,27 @@ bool LLAudioEngine_FMODEX::initWind() { mNextWindUpdate = 0.0; - if (!mWindDSP) - { - FMOD_DSP_DESCRIPTION dspdesc; - memset(&dspdesc, 0, sizeof(FMOD_DSP_DESCRIPTION)); //Set everything to zero - strncpy(dspdesc.name,"Wind Unit", sizeof(dspdesc.name)); //Set name to "Wind Unit" - dspdesc.channels=2; - dspdesc.read = &windCallback; //Assign callback. - if(Check_FMOD_Error(mSystem->createDSP(&dspdesc, &mWindDSP), "FMOD::createDSP")) - return false; + cleanupWind(); - if(mWindGen) - delete mWindGen; + + FMOD_DSP_DESCRIPTION dspdesc; + memset(&dspdesc, 0, sizeof(FMOD_DSP_DESCRIPTION)); //Set everything to zero + strncpy(dspdesc.name,"Wind Unit", sizeof(dspdesc.name)); //Set name to "Wind Unit" + dspdesc.channels=2; + dspdesc.read = &windCallback; //Assign callback. + if(Check_FMOD_Error(mSystem->createDSP(&dspdesc, &mWindDSP), "FMOD::createDSP") || !mWindDSP) + return false; - float frequency = 44100; - mWindDSP->getDefaults(&frequency,0,0,0); + float frequency = 44100; + if (!Check_FMOD_Error(mWindDSP->getDefaults(&frequency,0,0,0), "FMOD::DSP::getDefaults")) + { mWindGen = new LLWindGen((U32)frequency); - mWindDSP->setUserData((void*)mWindGen); + if (!Check_FMOD_Error(mWindDSP->setUserData((void*)mWindGen), "FMOD::DSP::setUserData") && + !Check_FMOD_Error(mSystem->playDSP(FMOD_CHANNEL_FREE, mWindDSP, false, 0), "FMOD::System::playDSP")) + return true; //Success } - if (mWindDSP) - { - mSystem->playDSP(FMOD_CHANNEL_FREE, mWindDSP, false, 0); - return true; - } + cleanupWind(); return false; } @@ -576,8 +582,8 @@ void LLAudioEngine_FMODEX::cleanupWind() { if (mWindDSP) { - mWindDSP->remove(); - mWindDSP->release(); + Check_FMOD_Error(mWindDSP->remove(), "FMOD::DSP::remove"); + Check_FMOD_Error(mWindDSP->release(), "FMOD::DSP::release"); mWindDSP = NULL; } @@ -629,8 +635,8 @@ void LLAudioEngine_FMODEX::setInternalGain(F32 gain) gain = llclamp( gain, 0.0f, 1.0f ); FMOD::ChannelGroup *master_group; - mSystem->getMasterChannelGroup(&master_group); - + if(Check_FMOD_Error(mSystem->getMasterChannelGroup(&master_group), "FMOD::System::getMasterChannelGroup")) + return; master_group->setVolume(gain); LLStreamingAudioInterface *saimpl = getStreamingAudioImpl(); @@ -1013,10 +1019,9 @@ FMOD_RESULT F_CALLBACK windCallback(FMOD_DSP_STATE *dsp_state, float *originalbu FMOD::DSP *thisdsp = (FMOD::DSP *)dsp_state->instance; thisdsp->getUserData((void **)&windgen); - S32 channels, configwidth, configheight; - thisdsp->getInfo(0, 0, &channels, &configwidth, &configheight); - windgen->windGenerate((LLAudioEngine_FMODEX::MIXBUFFERFORMAT *)newbuffer, length); + if (windgen) + windgen->windGenerate((LLAudioEngine_FMODEX::MIXBUFFERFORMAT *)newbuffer, length); return FMOD_OK; } diff --git a/indra/llaudio/llaudioengine_fmodex.h b/indra/llaudio/llaudioengine_fmodex.h index 18b4d61a8..fe93d8c48 100644 --- a/indra/llaudio/llaudioengine_fmodex.h +++ b/indra/llaudio/llaudioengine_fmodex.h @@ -35,7 +35,7 @@ #define LL_AUDIOENGINE_FMODEX_H #include "llaudioengine.h" -#include "lllistener_fmod.h" +#include "lllistener_fmodex.h" #include "llwindgen.h" //Stubs diff --git a/indra/llaudio/llaudioengine_fmodstudio.cpp b/indra/llaudio/llaudioengine_fmodstudio.cpp new file mode 100644 index 000000000..93541d3de --- /dev/null +++ b/indra/llaudio/llaudioengine_fmodstudio.cpp @@ -0,0 +1,1002 @@ +/** + * @file audioengine_FMODSTUDIO.cpp + * @brief Implementation of LLAudioEngine class abstracting the audio support as a FMOD 3D implementation + * + * $LicenseInfo:firstyear=2002&license=viewergpl$ + * + * Copyright (c) 2002-2009, Linden Research, Inc. + * + * Second Life Viewer Source Code + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab. Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. + * + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. + * $/LicenseInfo$ + */ + +#include "linden_common.h" + +#include "llstreamingaudio.h" +#include "llstreamingaudio_fmodstudio.h" + +#include "llaudioengine_fmodstudio.h" +#include "lllistener_fmodstudio.h" + +#include "llerror.h" +#include "llmath.h" +#include "llrand.h" + +#include "fmod.hpp" +#include "fmod_errors.h" +#include "lldir.h" +#include "llapr.h" + +#include "sound_ids.h" + +#include + +#if LL_WINDOWS //Some ugly code to make missing fmod.dll not cause a fatal error. +#define WIN32_LEAN_AND_MEAN +#include "windows.h" +#include +#pragma comment(lib, "delayimp.lib") + +bool attemptDelayLoad() +{ + __try + { +#if defined(_WIN64) + if( FAILED( __HrLoadAllImportsForDll( "fmod64.dll" ) ) ) + return false; +#else + if( FAILED( __HrLoadAllImportsForDll( "fmod.dll" ) ) ) + return false; +#endif + } + __except( EXCEPTION_EXECUTE_HANDLER ) + { + return false; + } + return true; +} +#endif + +static bool sVerboseDebugging = false; + +FMOD_RESULT F_CALLBACK windCallback(FMOD_DSP_STATE *dsp_state, float *inbuffer, float *outbuffer, unsigned int length, int inchannels, int *outchannels); + +FMOD::ChannelGroup *LLAudioEngine_FMODSTUDIO::mChannelGroups[LLAudioEngine::AUDIO_TYPE_COUNT] = {0}; + +//This class is designed to keep track of all sound<->channel assocations. +//Used to verify validity of sound and channel pointers, as well as catch cases were sounds +//are released with active channels still attached. +class CFMODSoundChecks +{ + typedef std::map > active_sounds_t; + typedef std::set dead_sounds_t; + typedef std::map active_channels_t; + typedef std::map dead_channels_t; + + active_sounds_t mActiveSounds; + dead_sounds_t mDeadSounds; + active_channels_t mActiveChannels; + dead_channels_t mDeadChannels; +public: + enum STATUS + { + ACTIVE, + DEAD, + UNKNOWN + }; + STATUS getPtrStatus(LLAudioChannel* channel) + { + if(!channel) + return UNKNOWN; + return getPtrStatus(dynamic_cast(channel)->mChannelp); + } + STATUS getPtrStatus(LLAudioBuffer* sound) + { + if(!sound) + return UNKNOWN; + return getPtrStatus(dynamic_cast(sound)->mSoundp); + } + STATUS getPtrStatus(FMOD::Channel* channel) + { + if(!channel) + return UNKNOWN; + else if(mActiveChannels.find(channel) != mActiveChannels.end()) + return ACTIVE; + else if(mDeadChannels.find(channel) != mDeadChannels.end()) + return DEAD; + return UNKNOWN; + } + STATUS getPtrStatus(FMOD::Sound* sound) + { + if(!sound) + return UNKNOWN; + if(mActiveSounds.find(sound) != mActiveSounds.end()) + return ACTIVE; + else if(mDeadSounds.find(sound) != mDeadSounds.end()) + return DEAD; + return UNKNOWN; + } + void addNewSound(FMOD::Sound* sound) + { + assertActiveState(sound,true,false); + + mDeadSounds.erase(sound); + mActiveSounds.insert(std::make_pair(sound,std::set())); + } + void removeSound(FMOD::Sound* sound) + { + assertActiveState(sound,true); + + active_sounds_t::const_iterator it = mActiveSounds.find(sound); + llassert(it != mActiveSounds.end()); + if(it != mActiveSounds.end()) + { + if(!it->second.empty()) + { + LL_WARNS("AudioImpl") << "Removing sound " << sound << " with attached channels: \n"; + for(std::set::iterator it2 = it->second.begin(); it2 != it->second.end();++it2) + { + switch(getPtrStatus(*it2)) + { + case ACTIVE: + LL_CONT << " Channel " << *it2 << " ACTIVE\n"; + break; + case DEAD: + LL_CONT << " Channel " << *it2 << " DEAD\n"; + break; + default: + LL_CONT << " Channel " << *it2 << " UNKNOWN\n"; + } + } + LL_CONT << LL_ENDL; + } + llassert(it->second.empty()); + mDeadSounds.insert(sound); + mActiveSounds.erase(sound); + } + } + void addNewChannelToSound(FMOD::Sound* sound,FMOD::Channel* channel) + { + assertActiveState(sound,true); + assertActiveState(channel,true,false); + + mActiveSounds[sound].insert(channel); + mActiveChannels.insert(std::make_pair(channel,sound)); + } + void removeChannel(FMOD::Channel* channel) + { + assertActiveState(channel,true); + + active_channels_t::const_iterator it = mActiveChannels.find(channel); + llassert(it != mActiveChannels.end()); + if(it != mActiveChannels.end()) + { +#ifdef SHOW_ASSERT + STATUS status = getPtrStatus(it->second); + llassert(status != DEAD); + llassert(status != UNKNOWN); +#endif + + active_sounds_t::iterator it2 = mActiveSounds.find(it->second); + llassert(it2 != mActiveSounds.end()); + if(it2 != mActiveSounds.end()) + { + it2->second.erase(channel); + } + mDeadChannels.insert(*it); + mActiveChannels.erase(channel); + } + } + + template + void assertActiveState(T ptr, bool try_log=false, bool active=true) + { +#ifndef SHOW_ASSERT + if(try_log && sVerboseDebugging) +#endif + { + CFMODSoundChecks::STATUS chan = getPtrStatus(ptr); + if(try_log && sVerboseDebugging) + { + if(active) + { + if(chan == CFMODSoundChecks::DEAD) + LL_WARNS("AudioImpl") << __FUNCTION__ << ": Using unexpectedly dead " << typeid(T*).name() << " " << ptr << LL_ENDL; + else if(chan == CFMODSoundChecks::UNKNOWN) + LL_WARNS("AudioImpl") << __FUNCTION__ << ": Using unexpectedly unknown " << typeid(T*).name() << " " << ptr << LL_ENDL; + } + else if(chan == CFMODSoundChecks::ACTIVE) + LL_WARNS("AudioImpl") << __FUNCTION__ << ": Using unexpectedly active " << typeid(T*).name() << " " << ptr << LL_ENDL; + } + llassert( active == (chan == CFMODSoundChecks::ACTIVE) ); + } + } +} gSoundCheck; + +LLAudioEngine_FMODSTUDIO::LLAudioEngine_FMODSTUDIO(bool enable_profiler, bool verbose_debugging) +{ + sVerboseDebugging = verbose_debugging; + mInited = false; + mWindGen = NULL; + mWindDSP = NULL; + mSystem = NULL; + mEnableProfiler = enable_profiler; +} + + +LLAudioEngine_FMODSTUDIO::~LLAudioEngine_FMODSTUDIO() +{ +} + + +inline bool Check_FMOD_Error(FMOD_RESULT result, const char *string) +{ + if(result == FMOD_OK) + return false; + LL_WARNS("AudioImpl") << string << " Error: " << FMOD_ErrorString(result) << LL_ENDL; + return true; +} + +void* F_STDCALL decode_alloc(unsigned int size, FMOD_MEMORY_TYPE type, const char *sourcestr) +{ + if(type & FMOD_MEMORY_STREAM_DECODE) + { + LL_INFOS("AudioImpl") << "Decode buffer size: " << size << LL_ENDL; + } + else if(type & FMOD_MEMORY_STREAM_FILE) + { + LL_INFOS("AudioImpl") << "Stream buffer size: " << size << LL_ENDL; + } + return new char[size]; +} +void* F_STDCALL decode_realloc(void *ptr, unsigned int size, FMOD_MEMORY_TYPE type, const char *sourcestr) +{ + memset(ptr,0,size); + return ptr; +} +void F_STDCALL decode_dealloc(void *ptr, FMOD_MEMORY_TYPE type, const char *sourcestr) +{ + delete[] (char*)ptr; +} + +bool LLAudioEngine_FMODSTUDIO::init(const S32 num_channels, void* userdata) +{ + +#if LL_WINDOWS + if(!attemptDelayLoad()) + return false; +#endif + + U32 version = 0; + FMOD_RESULT result; + + LL_DEBUGS("AppInit") << "LLAudioEngine_FMODSTUDIO::init() initializing FMOD" << LL_ENDL; + + //result = FMOD::Memory_Initialize(NULL, 0, &decode_alloc, &decode_realloc, &decode_dealloc, FMOD_MEMORY_STREAM_DECODE | FMOD_MEMORY_STREAM_FILE); + //if(Check_FMOD_Error(result, "FMOD::Memory_Initialize")) + // return false; + + result = FMOD::System_Create(&mSystem); + if(Check_FMOD_Error(result, "FMOD::System_Create")) + return false; + + //will call LLAudioEngine_FMODSTUDIO::allocateListener, which needs a valid mSystem pointer. + LLAudioEngine::init(num_channels, userdata); + + result = mSystem->getVersion(&version); + Check_FMOD_Error(result, "FMOD::System::getVersion"); + + if (version < FMOD_VERSION) + { + LL_WARNS("AppInit") << "Error : You are using the wrong FMOD Studio version (" << version + << ")! You should be using FMOD Studio" << FMOD_VERSION << LL_ENDL; + } + + // In this case, all sounds, PLUS wind and stream will be software. + result = mSystem->setSoftwareChannels(num_channels + 2); + Check_FMOD_Error(result,"FMOD::System::setSoftwareChannels"); + + U32 fmod_flags = FMOD_INIT_NORMAL | FMOD_INIT_3D_RIGHTHANDED | FMOD_INIT_THREAD_UNSAFE; + if(mEnableProfiler) + { + fmod_flags |= FMOD_INIT_PROFILE_ENABLE; + } + +#if LL_LINUX + bool audio_ok = false; + + if (!audio_ok) + { + if (NULL == getenv("LL_BAD_FMOD_PULSEAUDIO")) /*Flawfinder: ignore*/ + { + LL_DEBUGS("AppInit") << "Trying PulseAudio audio output..." << LL_ENDL; + if((result = mSystem->setOutput(FMOD_OUTPUTTYPE_PULSEAUDIO)) == FMOD_OK && + (result = mSystem->init(num_channels + 2, fmod_flags, 0)) == FMOD_OK) + { + LL_DEBUGS("AppInit") << "PulseAudio output initialized OKAY" << LL_ENDL; + audio_ok = true; + } + else + { + Check_FMOD_Error(result, "PulseAudio audio output FAILED to initialize"); + } + } + else + { + LL_DEBUGS("AppInit") << "PulseAudio audio output SKIPPED" << LL_ENDL; + } + } + if (!audio_ok) + { + if (NULL == getenv("LL_BAD_FMOD_ALSA")) /*Flawfinder: ignore*/ + { + LL_DEBUGS("AppInit") << "Trying ALSA audio output..." << LL_ENDL; + if((result = mSystem->setOutput(FMOD_OUTPUTTYPE_ALSA)) == FMOD_OK && + (result = mSystem->init(num_channels + 2, fmod_flags, 0)) == FMOD_OK) + { + LL_DEBUGS("AppInit") << "ALSA audio output initialized OKAY" << LL_ENDL; + audio_ok = true; + } + else + { + Check_FMOD_Error(result, "ALSA audio output FAILED to initialize"); + } + } + else + { + LL_DEBUGS("AppInit") << "ALSA audio output SKIPPED" << LL_ENDL; + } + } + if (!audio_ok) + { + LL_WARNS("AppInit") << "Overall audio init failure." << LL_ENDL; + return false; + } + + // We're interested in logging which output method we + // ended up with, for QA purposes. + FMOD_OUTPUTTYPE output_type; + if(!Check_FMOD_Error(mSystem->getOutput(&output_type), "FMOD::System::getOutput")) + { + switch (output_type) + { + case FMOD_OUTPUTTYPE_NOSOUND: + LL_INFOS("AppInit") << "Audio output: NoSound" << LL_ENDL; break; + case FMOD_OUTPUTTYPE_PULSEAUDIO: + LL_INFOS("AppInit") << "Audio output: PulseAudio" << LL_ENDL; break; + case FMOD_OUTPUTTYPE_ALSA: + LL_INFOS("AppInit") << "Audio output: ALSA" << LL_ENDL; break; + default: + LL_INFOS("AppInit") << "Audio output: Unknown!" << LL_ENDL; break; + }; + } +#else // LL_LINUX + + // initialize the FMOD engine + result = mSystem->init( num_channels + 2, fmod_flags, 0); + if (result == FMOD_ERR_OUTPUT_CREATEBUFFER) + { + /* + Ok, the speaker mode selected isn't supported by this soundcard. Switch it + back to stereo... + */ + result = mSystem->setSoftwareFormat(44100, FMOD_SPEAKERMODE_STEREO, 0); + Check_FMOD_Error(result,"Error falling back to stereo mode"); + /* + ... and re-init. + */ + result = mSystem->init( num_channels + 2, fmod_flags, 0); + } + if(Check_FMOD_Error(result, "Error initializing FMOD Studio")) + return false; +#endif + + if (mEnableProfiler) + { + Check_FMOD_Error(mSystem->createChannelGroup("None", &mChannelGroups[AUDIO_TYPE_NONE]), "FMOD::System::createChannelGroup"); + Check_FMOD_Error(mSystem->createChannelGroup("SFX", &mChannelGroups[AUDIO_TYPE_SFX]), "FMOD::System::createChannelGroup"); + Check_FMOD_Error(mSystem->createChannelGroup("UI", &mChannelGroups[AUDIO_TYPE_UI]), "FMOD::System::createChannelGroup"); + Check_FMOD_Error(mSystem->createChannelGroup("Ambient", &mChannelGroups[AUDIO_TYPE_AMBIENT]), "FMOD::System::createChannelGroup"); + } + + // set up our favourite FMOD-native streaming audio implementation if none has already been added + if (!getStreamingAudioImpl()) // no existing implementation added + setStreamingAudioImpl(new LLStreamingAudio_FMODSTUDIO(mSystem)); + + LL_INFOS("AppInit") << "LLAudioEngine_FMODSTUDIO::init() FMOD Studio initialized correctly" << LL_ENDL; + + int r_numbuffers, r_samplerate; + unsigned int r_bufferlength; + char r_name[256]; + FMOD_SPEAKERMODE speaker_mode; + if (!Check_FMOD_Error(mSystem->getDSPBufferSize(&r_bufferlength, &r_numbuffers), "FMOD::System::getDSPBufferSize") && + !Check_FMOD_Error(mSystem->getSoftwareFormat(&r_samplerate, &speaker_mode, NULL), "FMOD::System::getSoftwareFormat") && + !Check_FMOD_Error(mSystem->getDriverInfo(0, r_name, 255, NULL, NULL, &speaker_mode, NULL), "FMOD::System::getDriverInfo")) + { + std::string speaker_mode_str = "unknown"; + switch(speaker_mode) + { + #define SPEAKER_MODE_CASE(MODE) case MODE: speaker_mode_str = #MODE; break; + SPEAKER_MODE_CASE(FMOD_SPEAKERMODE_RAW) + SPEAKER_MODE_CASE(FMOD_SPEAKERMODE_MONO) + SPEAKER_MODE_CASE(FMOD_SPEAKERMODE_STEREO) + SPEAKER_MODE_CASE(FMOD_SPEAKERMODE_QUAD) + SPEAKER_MODE_CASE(FMOD_SPEAKERMODE_SURROUND) + SPEAKER_MODE_CASE(FMOD_SPEAKERMODE_5POINT1) + SPEAKER_MODE_CASE(FMOD_SPEAKERMODE_7POINT1) + default:; + #undef SPEAKER_MODE_CASE + } + + r_name[255] = '\0'; + int latency = 1000.0 * r_bufferlength * r_numbuffers /r_samplerate; + + LL_INFOS("AppInit") << "FMOD device: "<< r_name << "\n" + << "Output mode: "<< speaker_mode_str << "\n" + << "FMOD Studio parameters: " << r_samplerate << " Hz * " <<" bit\n" + << "\tbuffer " << r_bufferlength << " * " << r_numbuffers << " (" << latency <<"ms)" << LL_ENDL; + } + else + { + LL_WARNS("AppInit") << "Failed to retrieve FMOD device info!" << LL_ENDL; + } + mInited = true; + + return true; +} + + +std::string LLAudioEngine_FMODSTUDIO::getDriverName(bool verbose) +{ + llassert_always(mSystem); + if (verbose) + { + U32 version; + if(!Check_FMOD_Error(mSystem->getVersion(&version), "FMOD::System::getVersion")) + { + return llformat("FMOD Studio %1x.%02x.%02x", version >> 16, version >> 8 & 0x000000FF, version & 0x000000FF); + } + } + return "FMODEx"; +} + + +void LLAudioEngine_FMODSTUDIO::allocateListener(void) +{ + mListenerp = (LLListener *) new LLListener_FMODSTUDIO(mSystem); + if (!mListenerp) + { + LL_WARNS("AudioImpl") << "Listener creation failed" << LL_ENDL; + } +} + + +void LLAudioEngine_FMODSTUDIO::shutdown() +{ + LL_INFOS("AudioImpl") << "About to LLAudioEngine::shutdown()" << LL_ENDL; + LLAudioEngine::shutdown(); + + LL_INFOS("AudioImpl") << "LLAudioEngine_FMODSTUDIO::shutdown() closing FMOD Studio" << LL_ENDL; + if ( mSystem ) // speculative fix for MAINT-2657 + { + LL_INFOS("AudioImpl") << "LLAudioEngine_FMODSTUDIO::shutdown() Requesting FMOD Studio system closure" << LL_ENDL; + Check_FMOD_Error(mSystem->close(), "FMOD::System::close"); + LL_INFOS("AudioImpl") << "LLAudioEngine_FMODSTUDIO::shutdown() Requesting FMOD Studio system release" << LL_ENDL; + Check_FMOD_Error(mSystem->release(), "FMOD::System::release"); + } + LL_INFOS("AudioImpl") << "LLAudioEngine_FMODSTUDIO::shutdown() done closing FMOD Studio" << LL_ENDL; + + delete mListenerp; + mListenerp = NULL; +} + + +LLAudioBuffer * LLAudioEngine_FMODSTUDIO::createBuffer() +{ + return new LLAudioBufferFMODSTUDIO(mSystem); +} + + +LLAudioChannel * LLAudioEngine_FMODSTUDIO::createChannel() +{ + return new LLAudioChannelFMODSTUDIO(mSystem); +} + +bool LLAudioEngine_FMODSTUDIO::initWind() +{ + mNextWindUpdate = 0.0; + + cleanupWind(); + + FMOD_DSP_DESCRIPTION dspdesc; + memset(&dspdesc, 0, sizeof(FMOD_DSP_DESCRIPTION)); //Set everything to zero + dspdesc.pluginsdkversion = FMOD_PLUGIN_SDK_VERSION; + strncpy(dspdesc.name,"Wind Unit", sizeof(dspdesc.name)); //Set name to "Wind Unit" + dspdesc.numoutputbuffers = 1; + dspdesc.read = &windCallback; //Assign callback. + if (Check_FMOD_Error(mSystem->createDSP(&dspdesc, &mWindDSP), "FMOD::createDSP") || !mWindDSP) + return false; + + int frequency = 44100; + if (!Check_FMOD_Error(mSystem->getSoftwareFormat(&frequency, NULL, NULL), "FMOD::System::getSoftwareFormat")) + { + mWindGen = new LLWindGen((U32)frequency); + FMOD_SPEAKERMODE mode; + if (!Check_FMOD_Error(mWindDSP->setUserData((void*)mWindGen), "FMOD::DSP::setUserData") && + !Check_FMOD_Error(mSystem->playDSP(mWindDSP, NULL, false, 0), "FMOD::System::playDSP") && + !Check_FMOD_Error(mSystem->getSoftwareFormat(NULL, &mode, NULL), "FMOD::System::getSoftwareFormat") && + !Check_FMOD_Error(mWindDSP->setChannelFormat(FMOD_CHANNELMASK_STEREO, 2, mode), "FMOD::DSP::setChannelFormat")) + return true; //Success + } + + cleanupWind(); + return false; +} + + +void LLAudioEngine_FMODSTUDIO::cleanupWind() +{ + if (mWindDSP) + { + FMOD::ChannelGroup* mastergroup = NULL; + if (!Check_FMOD_Error(mSystem->getMasterChannelGroup(&mastergroup), "FMOD::System::getMasterChannelGroup") && mastergroup) + Check_FMOD_Error(mastergroup->removeDSP(mWindDSP), "FMOD::ChannelGroup::removeDSP"); + Check_FMOD_Error(mWindDSP->release(), "FMOD::DSP::release"); + mWindDSP = NULL; + } + + delete mWindGen; + mWindGen = NULL; +} + + +//----------------------------------------------------------------------- +void LLAudioEngine_FMODSTUDIO::updateWind(LLVector3 wind_vec, F32 camera_height_above_water) +{ + LLVector3 wind_pos; + F64 pitch; + F64 center_freq; + + if (!mEnableWind) + { + return; + } + + if (mWindUpdateTimer.checkExpirationAndReset(LL_WIND_UPDATE_INTERVAL)) + { + + // wind comes in as Linden coordinate (+X = forward, +Y = left, +Z = up) + // need to convert this to the conventional orientation DS3D and OpenAL use + // where +X = right, +Y = up, +Z = backwards + + wind_vec.setVec(-wind_vec.mV[1], wind_vec.mV[2], -wind_vec.mV[0]); + + // cerr << "Wind update" << endl; + + pitch = 1.0 + mapWindVecToPitch(wind_vec); + center_freq = 80.0 * pow(pitch,2.5*(mapWindVecToGain(wind_vec)+1.0)); + + mWindGen->mTargetFreq = (F32)center_freq; + mWindGen->mTargetGain = (F32)mapWindVecToGain(wind_vec) * mMaxWindGain; + mWindGen->mTargetPanGainR = (F32)mapWindVecToPan(wind_vec); + } +} + +//----------------------------------------------------------------------- +void LLAudioEngine_FMODSTUDIO::setInternalGain(F32 gain) +{ + if (!mInited) + { + return; + } + + gain = llclamp( gain, 0.0f, 1.0f ); + + FMOD::ChannelGroup *master_group; + if(Check_FMOD_Error(mSystem->getMasterChannelGroup(&master_group), "FMOD::System::getMasterChannelGroup")) + return; + + master_group->setVolume(gain); + + LLStreamingAudioInterface *saimpl = getStreamingAudioImpl(); + if ( saimpl ) + { + // fmod likes its streaming audio channel gain re-asserted after + // master volume change. + saimpl->setGain(saimpl->getGain()); + } +} + +// +// LLAudioChannelFMODSTUDIO implementation +// + +LLAudioChannelFMODSTUDIO::LLAudioChannelFMODSTUDIO(FMOD::System *system) : LLAudioChannel(), mSystemp(system), mChannelp(NULL), mLastSamplePos(0) +{ +} + + +LLAudioChannelFMODSTUDIO::~LLAudioChannelFMODSTUDIO() +{ + if(sVerboseDebugging) + LL_DEBUGS("AudioImpl") << "Destructing Audio Channel. mChannelp = " << mChannelp << LL_ENDL; + + cleanup(); +} + +static FMOD_RESULT F_CALLBACK channel_callback(FMOD_CHANNELCONTROL *channel, FMOD_CHANNELCONTROL_TYPE controltype, FMOD_CHANNELCONTROL_CALLBACK_TYPE callbacktype, void *commanddata1, void *commanddata2) +{ + if (controltype == FMOD_CHANNELCONTROL_CHANNEL && + callbacktype == FMOD_CHANNELCONTROL_CALLBACK_END) + { + FMOD::Channel* chan = reinterpret_cast(channel); + LLAudioChannelFMODSTUDIO* audio_channel = NULL; + chan->getUserData((void**)&audio_channel); + if(audio_channel) + { + audio_channel->onRelease(); + } + } + return FMOD_OK; +} + +void LLAudioChannelFMODSTUDIO::onRelease() +{ + llassert(mChannelp); + if(sVerboseDebugging) + LL_DEBUGS("AudioImpl") << "Fmod signaled channel release for channel " << mChannelp << LL_ENDL; + gSoundCheck.removeChannel(mChannelp); + mChannelp = NULL; //Null out channel here so cleanup doesn't try to redundantly stop it. + cleanup(); +} + +bool LLAudioChannelFMODSTUDIO::updateBuffer() +{ + if (LLAudioChannel::updateBuffer()) + { + // Base class update returned true, which means the channel buffer was changed, and not is null. + + // Grab the FMOD sample associated with the buffer + FMOD::Sound *soundp = ((LLAudioBufferFMODSTUDIO*)mCurrentBufferp)->getSound(); + if (!soundp) + { + // This is bad, there should ALWAYS be a sound associated with a legit + // buffer. + LL_ERRS("AudioImpl") << "No FMOD sound!" << LL_ENDL; + return false; + } + + // Actually play the sound. Start it off paused so we can do all the necessary + // setup. + if(!mChannelp) + { + FMOD_RESULT result = getSystem()->playSound(soundp, NULL, true, &mChannelp); + Check_FMOD_Error(result, "FMOD::System::playSound"); + if(result == FMOD_OK) + { + if(sVerboseDebugging) + LL_DEBUGS("AudioImpl") << "Created channel " << mChannelp << " for sound " << soundp << LL_ENDL; + + gSoundCheck.addNewChannelToSound(soundp,mChannelp); + mChannelp->setCallback(&channel_callback); + mChannelp->setUserData(this); + } + } + } + + // If we have a source for the channel, we need to update its gain. + if (mCurrentSourcep && mChannelp) + { + FMOD_RESULT result; + + gSoundCheck.assertActiveState(this); + result = mChannelp->setVolume(getSecondaryGain() * mCurrentSourcep->getGain()); + Check_FMOD_Error(result, "FMOD::Channel::setVolume"); + result = mChannelp->setMode(mCurrentSourcep->isLoop() ? FMOD_LOOP_NORMAL : FMOD_LOOP_OFF); + Check_FMOD_Error(result, "FMOD::Channel::setMode"); + } + + return true; +} + + +void LLAudioChannelFMODSTUDIO::update3DPosition() +{ + if (!mChannelp) + { + // We're not actually a live channel (i.e., we're not playing back anything) + return; + } + + LLAudioBufferFMODSTUDIO *bufferp = (LLAudioBufferFMODSTUDIO *)mCurrentBufferp; + if (!bufferp) + { + // We don't have a buffer associated with us (should really have been picked up + // by the above if. + return; + } + + gSoundCheck.assertActiveState(this); + + if (mCurrentSourcep->isAmbient()) + { + // Ambient sound, don't need to do any positional updates. + set3DMode(false); + } + else + { + // Localized sound. Update the position and velocity of the sound. + set3DMode(true); + + LLVector3 float_pos; + float_pos.setVec(mCurrentSourcep->getPositionGlobal()); + FMOD_RESULT result = mChannelp->set3DAttributes((FMOD_VECTOR*)float_pos.mV, (FMOD_VECTOR*)mCurrentSourcep->getVelocity().mV); + Check_FMOD_Error(result, "FMOD::Channel::set3DAttributes"); + } +} + + +void LLAudioChannelFMODSTUDIO::updateLoop() +{ + if (!mChannelp) + { + // May want to clear up the loop/sample counters. + return; + } + + gSoundCheck.assertActiveState(this); + + // + // Hack: We keep track of whether we looped or not by seeing when the + // sample position looks like it's going backwards. Not reliable; may + // yield false negatives. + // + U32 cur_pos; + Check_FMOD_Error(mChannelp->getPosition(&cur_pos,FMOD_TIMEUNIT_PCMBYTES),"FMOD::Channel::getPosition"); + + if (cur_pos < (U32)mLastSamplePos) + { + mLoopedThisFrame = true; + } + mLastSamplePos = cur_pos; +} + + +void LLAudioChannelFMODSTUDIO::cleanup() +{ + LLAudioChannel::cleanup(); + + if (!mChannelp) + { + llassert(mCurrentBufferp == NULL); + //LL_INFOS("AudioImpl") << "Aborting cleanup with no channel handle." << LL_ENDL; + return; + } + + if(sVerboseDebugging) + LL_DEBUGS("AudioImpl") << "Stopping channel " << mChannelp << LL_ENDL; + + gSoundCheck.removeChannel(mChannelp); + mChannelp->setCallback(NULL); + Check_FMOD_Error(mChannelp->stop(),"FMOD::Channel::stop"); + + mChannelp = NULL; + mLastSamplePos = 0; +} + + +void LLAudioChannelFMODSTUDIO::play() +{ + if (!mChannelp) + { + LL_WARNS("AudioImpl") << "Playing without a channel handle, aborting" << LL_ENDL; + return; + } + + gSoundCheck.assertActiveState(this,true); + + bool paused=true; + Check_FMOD_Error(mChannelp->getPaused(&paused), "FMOD::Channel::getPaused"); + if(!paused) + { + Check_FMOD_Error(mChannelp->setPaused(true), "FMOD::Channel::setPaused"); + Check_FMOD_Error(mChannelp->setPosition(0,FMOD_TIMEUNIT_PCMBYTES), "FMOD::Channel::setPosition"); + } + Check_FMOD_Error(mChannelp->setPaused(false), "FMOD::Channel::setPaused"); + + if(sVerboseDebugging) + LL_DEBUGS("AudioImpl") << "Playing channel " << mChannelp << LL_ENDL; + + getSource()->setPlayedOnce(true); + + if(LLAudioEngine_FMODSTUDIO::mChannelGroups[getSource()->getType()]) + Check_FMOD_Error(mChannelp->setChannelGroup(LLAudioEngine_FMODSTUDIO::mChannelGroups[getSource()->getType()]),"FMOD::Channel::setChannelGroup"); +} + + +void LLAudioChannelFMODSTUDIO::playSynced(LLAudioChannel *channelp) +{ + LLAudioChannelFMODSTUDIO *fmod_channelp = (LLAudioChannelFMODSTUDIO*)channelp; + if (!(fmod_channelp->mChannelp && mChannelp)) + { + // Don't have channels allocated to both the master and the slave + return; + } + + gSoundCheck.assertActiveState(this,true); + + U32 cur_pos; + if(Check_FMOD_Error(fmod_channelp->mChannelp->getPosition(&cur_pos,FMOD_TIMEUNIT_PCMBYTES), "Unable to retrieve current position")) + return; + + cur_pos %= mCurrentBufferp->getLength(); + + // Try to match the position of our sync master + Check_FMOD_Error(mChannelp->setPosition(cur_pos,FMOD_TIMEUNIT_PCMBYTES),"Unable to set current position"); + + // Start us playing + play(); +} + + +bool LLAudioChannelFMODSTUDIO::isPlaying() +{ + if (!mChannelp) + { + return false; + } + + gSoundCheck.assertActiveState(this); + + bool paused, playing; + Check_FMOD_Error(mChannelp->getPaused(&paused),"FMOD::Channel::getPaused"); + Check_FMOD_Error(mChannelp->isPlaying(&playing),"FMOD::Channel::isPlaying"); + return !paused && playing; +} + + +// +// LLAudioChannelFMODSTUDIO implementation +// + + +LLAudioBufferFMODSTUDIO::LLAudioBufferFMODSTUDIO(FMOD::System *system) : LLAudioBuffer(), mSystemp(system), mSoundp(NULL) +{ +} + + +LLAudioBufferFMODSTUDIO::~LLAudioBufferFMODSTUDIO() +{ + if(mSoundp) + { + if(sVerboseDebugging) + LL_DEBUGS("AudioImpl") << "Release sound " << mSoundp << LL_ENDL; + + gSoundCheck.removeSound(mSoundp); + Check_FMOD_Error(mSoundp->release(),"FMOD::Sound::Release"); + mSoundp = NULL; + } +} + + +bool LLAudioBufferFMODSTUDIO::loadWAV(const std::string& filename) +{ + // Try to open a wav file from disk. This will eventually go away, as we don't + // really want to block doing this. + if (filename.empty()) + { + // invalid filename, abort. + return false; + } + + if (!LLAPRFile::isExist(filename, LL_APR_RPB)) + { + // File not found, abort. + return false; + } + + if (mSoundp) + { + gSoundCheck.removeSound(mSoundp); + // If there's already something loaded in this buffer, clean it up. + Check_FMOD_Error(mSoundp->release(),"FMOD::Sound::release"); + mSoundp = NULL; + } + + FMOD_MODE base_mode = FMOD_LOOP_NORMAL; + FMOD_CREATESOUNDEXINFO exinfo; + memset(&exinfo,0,sizeof(exinfo)); + exinfo.cbsize = sizeof(exinfo); + exinfo.suggestedsoundtype = FMOD_SOUND_TYPE_WAV; //Hint to speed up loading. + // Load up the wav file into an fmod sample + FMOD_RESULT result = getSystem()->createSound(filename.c_str(), base_mode, &exinfo, &mSoundp); + if (result != FMOD_OK) + { + // We failed to load the file for some reason. + LL_WARNS("AudioImpl") << "Could not load data '" << filename << "': " << FMOD_ErrorString(result) << LL_ENDL; + + // + // If we EVER want to load wav files provided by end users, we need + // to rethink this! + // + // file is probably corrupt - remove it. + LLFile::remove(filename); + return false; + } + + gSoundCheck.addNewSound(mSoundp); + + // Everything went well, return true + return true; +} + + +U32 LLAudioBufferFMODSTUDIO::getLength() +{ + if (!mSoundp) + { + return 0; + } + + gSoundCheck.assertActiveState(this); + U32 length; + Check_FMOD_Error(mSoundp->getLength(&length, FMOD_TIMEUNIT_PCMBYTES),"FMOD::Sound::getLength"); + return length; +} + + +void LLAudioChannelFMODSTUDIO::set3DMode(bool use3d) +{ + gSoundCheck.assertActiveState(this); + + FMOD_MODE current_mode; + if(Check_FMOD_Error(mChannelp->getMode(¤t_mode),"FMOD::Channel::getMode")) + return; + FMOD_MODE new_mode = current_mode; + new_mode &= ~(use3d ? FMOD_2D : FMOD_3D); + new_mode |= use3d ? FMOD_3D : FMOD_2D; + + if(current_mode != new_mode) + { + Check_FMOD_Error(mChannelp->setMode(new_mode),"FMOD::Channel::setMode"); + } +} + + +FMOD_RESULT F_CALLBACK windCallback(FMOD_DSP_STATE *dsp_state, float *inbuffer, float *outbuffer, unsigned int length, int inchannels, int *outchannels) +{ + // inbuffer = incomming data. + // newbuffer = outgoing data. AKA this DSP's output. + // length = length in samples at this mix time. True buffer size, in bytes, would be (length * sizeof(float) * inchannels). + // userdata = user-provided data attached this DSP via FMOD::DSP::setUserData. + + LLWindGen *windgen; + FMOD::DSP *thisdsp = (FMOD::DSP *)dsp_state->instance; + + thisdsp->getUserData((void **)&windgen); + + if (windgen) + windgen->windGenerate((LLAudioEngine_FMODSTUDIO::MIXBUFFERFORMAT *)outbuffer, length); + + return FMOD_OK; +} diff --git a/indra/llaudio/llaudioengine_fmodstudio.h b/indra/llaudio/llaudioengine_fmodstudio.h new file mode 100644 index 000000000..730a702a1 --- /dev/null +++ b/indra/llaudio/llaudioengine_fmodstudio.h @@ -0,0 +1,139 @@ +/** + * @file audioengine_FMODSTUDIO.h + * @brief Definition of LLAudioEngine class abstracting the audio + * support as a FMOD Studio 3D implementation + * + * $LicenseInfo:firstyear=2002&license=viewergpl$ + * + * Copyright (c) 2002-2009, Linden Research, Inc. + * + * Second Life Viewer Source Code + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab. Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. + * + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. + * $/LicenseInfo$ + */ + +#ifndef LL_AUDIOENGINE_FMODSTUDIO_H +#define LL_AUDIOENGINE_FMODSTUDIO_H + +#include "llaudioengine.h" +#include "lllistener_fmodstudio.h" +#include "llwindgen.h" + +//Stubs +class LLAudioStreamManagerFMODSTUDIO; +namespace FMOD +{ + class System; + class Channel; + class ChannelGroup; + class Sound; + class DSP; +} + +//Interfaces +class LLAudioEngine_FMODSTUDIO : public LLAudioEngine +{ +public: + LLAudioEngine_FMODSTUDIO(bool enable_profiler, bool verbose_debugging); + virtual ~LLAudioEngine_FMODSTUDIO(); + + // initialization/startup/shutdown + virtual bool init(const S32 num_channels, void *user_data); + virtual std::string getDriverName(bool verbose); + virtual void allocateListener(); + + virtual void shutdown(); + + /*virtual*/ bool initWind(); + /*virtual*/ void cleanupWind(); + + /*virtual*/void updateWind(LLVector3 direction, F32 camera_height_above_water); + + typedef F32 MIXBUFFERFORMAT; + + FMOD::System *getSystem() const {return mSystem;} +protected: + /*virtual*/ LLAudioBuffer *createBuffer(); // Get a free buffer, or flush an existing one if you have to. + /*virtual*/ LLAudioChannel *createChannel(); // Create a new audio channel. + + /*virtual*/ void setInternalGain(F32 gain); + + bool mInited; + + LLWindGen *mWindGen; + + FMOD::DSP *mWindDSP; + FMOD::System *mSystem; + bool mEnableProfiler; + +public: + static FMOD::ChannelGroup *mChannelGroups[LLAudioEngine::AUDIO_TYPE_COUNT]; +}; + + +class LLAudioChannelFMODSTUDIO : public LLAudioChannel +{ +public: + LLAudioChannelFMODSTUDIO(FMOD::System *audioengine); + virtual ~LLAudioChannelFMODSTUDIO(); + void onRelease(); +protected: + /*virtual*/ void play(); + /*virtual*/ void playSynced(LLAudioChannel *channelp); + /*virtual*/ void cleanup(); + /*virtual*/ bool isPlaying(); + + /*virtual*/ bool updateBuffer(); + /*virtual*/ void update3DPosition(); + /*virtual*/ void updateLoop(); + + void set3DMode(bool use3d); +protected: + FMOD::System *getSystem() const {return mSystemp;} + FMOD::System *mSystemp; + FMOD::Channel *mChannelp; + S32 mLastSamplePos; + + friend class CFMODSoundChecks; +}; + + +class LLAudioBufferFMODSTUDIO : public LLAudioBuffer +{ +public: + LLAudioBufferFMODSTUDIO(FMOD::System *audioengine); + virtual ~LLAudioBufferFMODSTUDIO(); + + /*virtual*/ bool loadWAV(const std::string& filename); + /*virtual*/ U32 getLength(); + friend class LLAudioChannelFMODSTUDIO; +protected: + FMOD::System *getSystem() const {return mSystemp;} + FMOD::System *mSystemp; + FMOD::Sound *getSound() const{ return mSoundp; } + FMOD::Sound *mSoundp; + + friend class CFMODSoundChecks; +}; + + +#endif // LL_AUDIOENGINE_FMODSTUDIO_H diff --git a/indra/llaudio/lllistener_fmod.cpp b/indra/llaudio/lllistener_fmod.cpp deleted file mode 100644 index 0138f4345..000000000 --- a/indra/llaudio/lllistener_fmod.cpp +++ /dev/null @@ -1,125 +0,0 @@ -/** - * @file listener_fmod.cpp - * @brief implementation of LISTENER class abstracting the audio - * support as a FMOD 3D implementation (windows only) - * - * $LicenseInfo:firstyear=2002&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#include "linden_common.h" -#include "llaudioengine.h" -#include "lllistener_fmod.h" -#include "fmod.h" - -//----------------------------------------------------------------------- -// constructor -//----------------------------------------------------------------------- -LLListener_FMOD::LLListener_FMOD() -{ - init(); -} - -//----------------------------------------------------------------------- -LLListener_FMOD::~LLListener_FMOD() -{ -} - -//----------------------------------------------------------------------- -void LLListener_FMOD::init(void) -{ - // do inherited - LLListener::init(); - mDopplerFactor = 1.0f; - mRolloffFactor = 1.0f; -} - -//----------------------------------------------------------------------- -void LLListener_FMOD::translate(LLVector3 offset) -{ - LLListener::translate(offset); - - FSOUND_3D_Listener_SetAttributes(mPosition.mV, NULL, mListenAt.mV[0],mListenAt.mV[1],mListenAt.mV[2], mListenUp.mV[0],mListenUp.mV[1],mListenUp.mV[2]); -} - -//----------------------------------------------------------------------- -void LLListener_FMOD::setPosition(LLVector3 pos) -{ - LLListener::setPosition(pos); - - FSOUND_3D_Listener_SetAttributes(pos.mV, NULL, mListenAt.mV[0],mListenAt.mV[1],mListenAt.mV[2], mListenUp.mV[0],mListenUp.mV[1],mListenUp.mV[2]); -} - -//----------------------------------------------------------------------- -void LLListener_FMOD::setVelocity(LLVector3 vel) -{ - LLListener::setVelocity(vel); - - FSOUND_3D_Listener_SetAttributes(NULL, vel.mV, mListenAt.mV[0],mListenAt.mV[1],mListenAt.mV[2], mListenUp.mV[0],mListenUp.mV[1],mListenUp.mV[2]); -} - -//----------------------------------------------------------------------- -void LLListener_FMOD::orient(LLVector3 up, LLVector3 at) -{ - LLListener::orient(up, at); - - // Welcome to the transition between right and left - // (coordinate systems, that is) - // Leaving the at vector alone results in a L/R reversal - // since DX is left-handed and we (LL, OpenGL, OpenAL) are right-handed - at = -at; - - FSOUND_3D_Listener_SetAttributes(NULL, NULL, at.mV[0],at.mV[1],at.mV[2], up.mV[0],up.mV[1],up.mV[2]); -} - -//----------------------------------------------------------------------- -void LLListener_FMOD::commitDeferredChanges() -{ - FSOUND_Update(); -} - - -void LLListener_FMOD::setRolloffFactor(F32 factor) -{ - mRolloffFactor = factor; - FSOUND_3D_SetRolloffFactor(factor); -} - - -F32 LLListener_FMOD::getRolloffFactor() -{ - return mRolloffFactor; -} - - -void LLListener_FMOD::setDopplerFactor(F32 factor) -{ - mDopplerFactor = factor; - FSOUND_3D_SetDopplerFactor(factor); -} - - -F32 LLListener_FMOD::getDopplerFactor() -{ - return mDopplerFactor; -} - - diff --git a/indra/llaudio/lllistener_fmod.h b/indra/llaudio/lllistener_fmod.h deleted file mode 100644 index 818da05d5..000000000 --- a/indra/llaudio/lllistener_fmod.h +++ /dev/null @@ -1,58 +0,0 @@ -/** - * @file listener_fmod.h - * @brief Description of LISTENER class abstracting the audio support - * as an FMOD 3D implementation (windows and Linux) - * - * $LicenseInfo:firstyear=2002&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#ifndef LL_LISTENER_FMOD_H -#define LL_LISTENER_FMOD_H - -#include "lllistener.h" - -class LLListener_FMOD : public LLListener -{ - public: - LLListener_FMOD(); - virtual ~LLListener_FMOD(); - virtual void init(); - - virtual void translate(LLVector3 offset); - virtual void setPosition(LLVector3 pos); - virtual void setVelocity(LLVector3 vel); - virtual void orient(LLVector3 up, LLVector3 at); - virtual void commitDeferredChanges(); - - virtual void setDopplerFactor(F32 factor); - virtual F32 getDopplerFactor(); - virtual void setRolloffFactor(F32 factor); - virtual F32 getRolloffFactor(); - - protected: - F32 mDopplerFactor; - F32 mRolloffFactor; -}; - -#endif - - diff --git a/indra/llaudio/lllistener_fmodstudio.cpp b/indra/llaudio/lllistener_fmodstudio.cpp new file mode 100644 index 000000000..e2074ce2d --- /dev/null +++ b/indra/llaudio/lllistener_fmodstudio.cpp @@ -0,0 +1,135 @@ +/** + * @file listener_fmodstudio.cpp + * @brief implementation of LISTENER class abstracting the audio + * support as a FMOD 3D implementation (windows only) + * + * $LicenseInfo:firstyear=2002&license=viewergpl$ + * + * Copyright (c) 2002-2009, Linden Research, Inc. + * + * Second Life Viewer Source Code + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab. Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. + * + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. + * $/LicenseInfo$ + */ + +#include "linden_common.h" +#include "llaudioengine.h" +#include "lllistener_fmodstudio.h" +#include "fmod.hpp" + +//----------------------------------------------------------------------- +// constructor +//----------------------------------------------------------------------- +LLListener_FMODSTUDIO::LLListener_FMODSTUDIO(FMOD::System *system) +{ + mSystem = system; + init(); +} + +//----------------------------------------------------------------------- +LLListener_FMODSTUDIO::~LLListener_FMODSTUDIO() +{ +} + +//----------------------------------------------------------------------- +void LLListener_FMODSTUDIO::init(void) +{ + // do inherited + LLListener::init(); + mDopplerFactor = 1.0f; + mRolloffFactor = 1.0f; +} + +//----------------------------------------------------------------------- +void LLListener_FMODSTUDIO::translate(LLVector3 offset) +{ + LLListener::translate(offset); + + mSystem->set3DListenerAttributes(0, (FMOD_VECTOR*)mPosition.mV, NULL, (FMOD_VECTOR*)mListenAt.mV, (FMOD_VECTOR*)mListenUp.mV); +} + +//----------------------------------------------------------------------- +void LLListener_FMODSTUDIO::setPosition(LLVector3 pos) +{ + LLListener::setPosition(pos); + + mSystem->set3DListenerAttributes(0, (FMOD_VECTOR*)mPosition.mV, NULL, (FMOD_VECTOR*)mListenAt.mV, (FMOD_VECTOR*)mListenUp.mV); +} + +//----------------------------------------------------------------------- +void LLListener_FMODSTUDIO::setVelocity(LLVector3 vel) +{ + LLListener::setVelocity(vel); + + mSystem->set3DListenerAttributes(0, NULL, (FMOD_VECTOR*)mVelocity.mV, (FMOD_VECTOR*)mListenAt.mV, (FMOD_VECTOR*)mListenUp.mV); +} + +//----------------------------------------------------------------------- +void LLListener_FMODSTUDIO::orient(LLVector3 up, LLVector3 at) +{ + LLListener::orient(up, at); + + mSystem->set3DListenerAttributes(0, NULL, NULL, (FMOD_VECTOR*)at.mV, (FMOD_VECTOR*)up.mV); +} + +//----------------------------------------------------------------------- +void LLListener_FMODSTUDIO::commitDeferredChanges() +{ + mSystem->update(); +} + + +void LLListener_FMODSTUDIO::setRolloffFactor(F32 factor) +{ + //An internal FMODEx optimization skips 3D updates if there have not been changes to the 3D sound environment. + //Sadly, a change in rolloff is not accounted for, thus we must touch the listener properties as well. + //In short: Changing the position ticks a dirtyflag inside fmodstudio, which makes it not skip 3D processing next update call. + if(mRolloffFactor != factor) + { + LLVector3 pos = mVelocity - LLVector3(0.f,0.f,.1f); + mSystem->set3DListenerAttributes(0, (FMOD_VECTOR*)pos.mV, NULL, NULL, NULL); + mSystem->set3DListenerAttributes(0, (FMOD_VECTOR*)mVelocity.mV, NULL, NULL, NULL); + } + mRolloffFactor = factor; + mSystem->set3DSettings(mDopplerFactor, 1.f, mRolloffFactor); +} + + +F32 LLListener_FMODSTUDIO::getRolloffFactor() +{ + return mRolloffFactor; +} + + +void LLListener_FMODSTUDIO::setDopplerFactor(F32 factor) +{ + mDopplerFactor = factor; + mSystem->set3DSettings(mDopplerFactor, 1.f, mRolloffFactor); +} + + +F32 LLListener_FMODSTUDIO::getDopplerFactor() +{ + return mDopplerFactor; +} + + diff --git a/indra/llaudio/lllistener_fmodstudio.h b/indra/llaudio/lllistener_fmodstudio.h new file mode 100644 index 000000000..516f4eae8 --- /dev/null +++ b/indra/llaudio/lllistener_fmodstudio.h @@ -0,0 +1,71 @@ +/** + * @file listener_fmodstudio.h + * @brief Description of LISTENER class abstracting the audio support + * as an FMOD Studio 3D implementation (windows and Linux) + * + * $LicenseInfo:firstyear=2002&license=viewergpl$ + * + * Copyright (c) 2002-2009, Linden Research, Inc. + * + * Second Life Viewer Source Code + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab. Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. + * + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. + * $/LicenseInfo$ + */ + +#ifndef LL_LISTENER_FMODSTUDIO_H +#define LL_LISTENER_FMODSTUDIO_H + +#include "lllistener.h" + +//Stubs +namespace FMOD +{ + class System; +} + +//Interfaces +class LLListener_FMODSTUDIO : public LLListener +{ + public: + LLListener_FMODSTUDIO(FMOD::System *system); + virtual ~LLListener_FMODSTUDIO(); + virtual void init(); + + virtual void translate(LLVector3 offset); + virtual void setPosition(LLVector3 pos); + virtual void setVelocity(LLVector3 vel); + virtual void orient(LLVector3 up, LLVector3 at); + virtual void commitDeferredChanges(); + + virtual void setDopplerFactor(F32 factor); + virtual F32 getDopplerFactor(); + virtual void setRolloffFactor(F32 factor); + virtual F32 getRolloffFactor(); + protected: + FMOD::System *mSystem; + F32 mDopplerFactor; + F32 mRolloffFactor; +}; + +#endif + + diff --git a/indra/llaudio/llstreamingaudio_fmod.cpp b/indra/llaudio/llstreamingaudio_fmod.cpp deleted file mode 100644 index 4036b8df6..000000000 --- a/indra/llaudio/llstreamingaudio_fmod.cpp +++ /dev/null @@ -1,385 +0,0 @@ -/** - * @file streamingaudio_fmod.cpp - * @brief LLStreamingAudio_FMOD implementation - * - * $LicenseInfo:firstyear=2009&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#include "linden_common.h" - -#include "llmath.h" - -#include "fmod.h" -#include "fmod_errors.h" - -#include "llstreamingaudio_fmod.h" - - -class LLAudioStreamManagerFMOD -{ -public: - LLAudioStreamManagerFMOD(const std::string& url); - int startStream(); - bool stopStream(); // Returns true if the stream was successfully stopped. - bool ready(); - - const std::string& getURL() { return mInternetStreamURL; } - - int getOpenState(); - - FSOUND_STREAM* getStream() { return mInternetStream; } -protected: - FSOUND_STREAM* mInternetStream; - bool mReady; - - std::string mInternetStreamURL; -}; - - - -//--------------------------------------------------------------------------- -// Internet Streaming -//--------------------------------------------------------------------------- -LLStreamingAudio_FMOD::LLStreamingAudio_FMOD() : - mCurrentInternetStreamp(NULL), - mFMODInternetStreamChannel(-1), - mGain(1.0f), - mMetaData(NULL) -{ - // Number of milliseconds of audio to buffer for the audio card. - // Must be larger than the usual Second Life frame stutter time. - FSOUND_Stream_SetBufferSize(200); - - // Here's where we set the size of the network buffer and some buffering - // parameters. In this case we want a network buffer of 16k, we want it - // to prebuffer 40% of that when we first connect, and we want it - // to rebuffer 80% of that whenever we encounter a buffer underrun. - - // Leave the net buffer properties at the default. - //FSOUND_Stream_Net_SetBufferProperties(20000, 40, 80); -} - - -LLStreamingAudio_FMOD::~LLStreamingAudio_FMOD() -{ - // nothing interesting/safe to do. -} - -signed char F_CALLBACKAPI MetaDataCallback(char *name, char *value, void *userdata) -{ - std::string szName(name); - if(szName == "TITLE" || szName=="TIT2" || szName=="Title") - (*(LLSD*)userdata)["TITLE"] = value; - if(szName == "ARTIST" || szName=="TPE1" || szName =="WM/AlbumTitle") - (*(LLSD*)userdata)["ARTIST"] = value; - else - (*(LLSD*)userdata)[std::string(name)] = value; - return true; -} - -void LLStreamingAudio_FMOD::start(const std::string& url) -{ - //if (!mInited) - //{ - // llwarns << "startInternetStream before audio initialized" << llendl; - // return; - //} - - // "stop" stream but don't clear url, etc. in case url == mInternetStreamURL - stop(); - - if (!url.empty()) - { - llinfos << "Starting internet stream: " << url << llendl; - mCurrentInternetStreamp = new LLAudioStreamManagerFMOD(url); - mURL = url; - if(mCurrentInternetStreamp->getStream()) - { - mMetaData = new LLSD; - } - } - else - { - llinfos << "Set internet stream to null" << llendl; - mURL.clear(); - } -} - - -void LLStreamingAudio_FMOD::update() -{ - // Kill dead internet streams, if possible - std::list::iterator iter; - for (iter = mDeadStreams.begin(); iter != mDeadStreams.end();) - { - LLAudioStreamManagerFMOD *streamp = *iter; - if (streamp->stopStream()) - { - llinfos << "Closed dead stream" << llendl; - delete streamp; - mDeadStreams.erase(iter++); - } - else - { - iter++; - } - } - - // Don't do anything if there are no streams playing - if (!mCurrentInternetStreamp) - { - return; - } - - int open_state = mCurrentInternetStreamp->getOpenState(); - - if (!open_state) - { - // Stream is live - - // start the stream if it's ready - if (mFMODInternetStreamChannel < 0) - { - mFMODInternetStreamChannel = mCurrentInternetStreamp->startStream(); - - if (mFMODInternetStreamChannel != -1) - { - // Reset volume to previously set volume - setGain(getGain()); - FSOUND_SetPaused(mFMODInternetStreamChannel, false); - if(mCurrentInternetStreamp->getStream() && mMetaData) - { - FSOUND_Stream_Net_SetMetadataCallback(mCurrentInternetStreamp->getStream(),&MetaDataCallback, mMetaData); - } - } - } - } - - switch(open_state) - { - default: - case 0: - // success - break; - case -1: - // stream handle is invalid - llwarns << "InternetStream - invalid handle" << llendl; - stop(); - return; - case -2: - // opening - break; - case -3: - // failed to open, file not found, perhaps - llwarns << "InternetStream - failed to open" << llendl; - stop(); - return; - case -4: - // connecting - break; - case -5: - // buffering - break; - } - -} - -void LLStreamingAudio_FMOD::stop() -{ - if(mMetaData) - { - if(mCurrentInternetStreamp && mCurrentInternetStreamp->getStream()) - FSOUND_Stream_Net_SetMetadataCallback(mCurrentInternetStreamp->getStream(),NULL,NULL); - delete mMetaData; - mMetaData = NULL; - } - if (mFMODInternetStreamChannel != -1) - { - FSOUND_SetPaused(mFMODInternetStreamChannel, true); - FSOUND_SetPriority(mFMODInternetStreamChannel, 0); - mFMODInternetStreamChannel = -1; - } - - if (mCurrentInternetStreamp) - { - llinfos << "Stopping internet stream: " << mCurrentInternetStreamp->getURL() << llendl; - if (mCurrentInternetStreamp->stopStream()) - { - delete mCurrentInternetStreamp; - } - else - { - llwarns << "Pushing stream to dead list: " << mCurrentInternetStreamp->getURL() << llendl; - mDeadStreams.push_back(mCurrentInternetStreamp); - } - mCurrentInternetStreamp = NULL; - //mURL.clear(); - } -} - -void LLStreamingAudio_FMOD::pause(int pauseopt) -{ - if (pauseopt < 0) - { - pauseopt = mCurrentInternetStreamp ? 1 : 0; - } - - if (pauseopt) - { - if (mCurrentInternetStreamp) - { - stop(); - } - } - else - { - start(getURL()); - } -} - - -// A stream is "playing" if it has been requested to start. That -// doesn't necessarily mean audio is coming out of the speakers. -int LLStreamingAudio_FMOD::isPlaying() -{ - if (mCurrentInternetStreamp) - { - return 1; // Active and playing - } - else if (!mURL.empty()) - { - return 2; // "Paused" - } - else - { - return 0; - } -} - - -F32 LLStreamingAudio_FMOD::getGain() -{ - return mGain; -} - - -std::string LLStreamingAudio_FMOD::getURL() -{ - return mURL; -} - - -void LLStreamingAudio_FMOD::setGain(F32 vol) -{ - mGain = vol; - - if (mFMODInternetStreamChannel != -1) - { - vol = llclamp(vol * vol, 0.f, 1.f); - int vol_int = llround(vol * 255.f); - FSOUND_SetVolumeAbsolute(mFMODInternetStreamChannel, vol_int); - } -} - - -/////////////////////////////////////////////////////// -// manager of possibly-multiple internet audio streams - -LLAudioStreamManagerFMOD::LLAudioStreamManagerFMOD(const std::string& url) : - mInternetStream(NULL), - mReady(false) -{ - mInternetStreamURL = url; - mInternetStream = FSOUND_Stream_Open(url.c_str(), FSOUND_NORMAL | FSOUND_NONBLOCKING, 0, 0); - if (!mInternetStream) - { - llwarns << "Couldn't open fmod stream, error " - << FMOD_ErrorString(FSOUND_GetError()) - << llendl; - mReady = false; - return; - } - - mReady = true; -} - -int LLAudioStreamManagerFMOD::startStream() -{ - // We need a live and opened stream before we try and play it. - if (!mInternetStream || getOpenState()) - { - llwarns << "No internet stream to start playing!" << llendl; - return -1; - } - - // Make sure the stream is set to 2D mode. - FSOUND_Stream_SetMode(mInternetStream, FSOUND_2D); - - return FSOUND_Stream_PlayEx(FSOUND_FREE, mInternetStream, NULL, true); -} - -bool LLAudioStreamManagerFMOD::stopStream() -{ - if (mInternetStream) - { - int read_percent = 0; - int status = 0; - int bitrate = 0; - unsigned int flags = 0x0; - FSOUND_Stream_Net_GetStatus(mInternetStream, &status, &read_percent, &bitrate, &flags); - - bool close = true; - switch (status) - { - case FSOUND_STREAM_NET_CONNECTING: - close = false; - break; - case FSOUND_STREAM_NET_NOTCONNECTED: - case FSOUND_STREAM_NET_BUFFERING: - case FSOUND_STREAM_NET_READY: - case FSOUND_STREAM_NET_ERROR: - default: - close = true; - } - - if (close) - { - FSOUND_Stream_Close(mInternetStream); - mInternetStream = NULL; - return true; - } - else - { - return false; - } - } - else - { - return true; - } -} - -int LLAudioStreamManagerFMOD::getOpenState() -{ - int open_state = FSOUND_Stream_GetOpenState(mInternetStream); - return open_state; -} diff --git a/indra/llaudio/llstreamingaudio_fmod.h b/indra/llaudio/llstreamingaudio_fmod.h deleted file mode 100644 index 4bb65c54d..000000000 --- a/indra/llaudio/llstreamingaudio_fmod.h +++ /dev/null @@ -1,68 +0,0 @@ -/** - * @file streamingaudio_fmod.h - * @author Tofu Linden - * @brief Definition of LLStreamingAudio_FMOD implementation - * - * $LicenseInfo:firstyear=2009&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#ifndef LL_STREAMINGAUDIO_FMOD_H -#define LL_STREAMINGAUDIO_FMOD_H - -#include "stdtypes.h" // from llcommon - -#include "llstreamingaudio.h" - -class LLAudioStreamManagerFMOD; - -class LLStreamingAudio_FMOD : public LLStreamingAudioInterface -{ - public: - LLStreamingAudio_FMOD(); - /*virtual*/ ~LLStreamingAudio_FMOD(); - - /*virtual*/ void start(const std::string& url); - /*virtual*/ void stop(); - /*virtual*/ void pause(int pause); - /*virtual*/ void update(); - /*virtual*/ int isPlaying(); - /*virtual*/ void setGain(F32 vol); - /*virtual*/ F32 getGain(); - /*virtual*/ std::string getURL(); - - /*virtual*/ bool supportsMetaData(){return true;} - /*virtual*/ const LLSD *getMetaData(){return mMetaData;} //return NULL if not playing. - /*virtual*/ bool supportsWaveData(){return false;} - /*virtual*/ bool getWaveData(float* arr, S32 count, S32 stride = 1){return false;} -private: - LLAudioStreamManagerFMOD *mCurrentInternetStreamp; - int mFMODInternetStreamChannel; - std::list mDeadStreams; - - std::string mURL; - F32 mGain; - - LLSD *mMetaData; -}; - - -#endif // LL_STREAMINGAUDIO_FMOD_H diff --git a/indra/llaudio/llstreamingaudio_fmodex.cpp b/indra/llaudio/llstreamingaudio_fmodex.cpp index be5888aa5..0716e09d5 100644 --- a/indra/llaudio/llstreamingaudio_fmodex.cpp +++ b/indra/llaudio/llstreamingaudio_fmodex.cpp @@ -39,6 +39,13 @@ #include "llstreamingaudio_fmodex.h" +inline bool Check_FMOD_Error(FMOD_RESULT result, const char *string) +{ + if (result == FMOD_OK) + return false; + LL_WARNS("AudioImpl") << string << " Error: " << FMOD_ErrorString(result) << LL_ENDL; + return true; +} class LLAudioStreamManagerFMODEX { @@ -50,7 +57,7 @@ public: const std::string& getURL() { return mInternetStreamURL; } - FMOD_OPENSTATE getOpenState(unsigned int* percentbuffered=NULL, bool* starving=NULL, bool* diskbusy=NULL); + FMOD_RESULT getOpenState(FMOD_OPENSTATE& openstate, unsigned int* percentbuffered=NULL, bool* starving=NULL, bool* diskbusy=NULL); protected: FMOD::System* mSystem; FMOD::Channel* mStreamChannel; @@ -72,11 +79,14 @@ LLStreamingAudio_FMODEX::LLStreamingAudio_FMODEX(FMOD::System *system) : mGain(1.0f), mMetaData(NULL) { + FMOD_RESULT result; + // Number of milliseconds of audio to buffer for the audio card. // Must be larger than the usual Second Life frame stutter time. const U32 buffer_seconds = 10; //sec const U32 estimated_bitrate = 128; //kbit/sec - mSystem->setStreamBufferSize(estimated_bitrate * buffer_seconds * 128/*bytes/kbit*/, FMOD_TIMEUNIT_RAWBYTES); + result = mSystem->setStreamBufferSize(estimated_bitrate * buffer_seconds * 128/*bytes/kbit*/, FMOD_TIMEUNIT_RAWBYTES); + Check_FMOD_Error(result, "FMOD::System::setStreamBufferSize"); // Here's where we set the size of the network buffer and some buffering // parameters. In this case we want a network buffer of 16k, we want it @@ -90,7 +100,13 @@ LLStreamingAudio_FMODEX::LLStreamingAudio_FMODEX(FMOD::System *system) : LLStreamingAudio_FMODEX::~LLStreamingAudio_FMODEX() { - // nothing interesting/safe to do. + stop(); + for (U32 i = 0; i < 100; ++i) + { + if (releaseDeadStreams()) + break; + ms_sleep(10); + } } @@ -169,24 +185,7 @@ std::string utf16input_to_utf8(char* input, U32 len, utf_endian_type_t type) void LLStreamingAudio_FMODEX::update() { - // Kill dead internet streams, if possible - std::list::iterator iter; - for (iter = mDeadStreams.begin(); iter != mDeadStreams.end();) - { - LLAudioStreamManagerFMODEX *streamp = *iter; - if (streamp->stopStream()) - { - llinfos << "Closed dead stream" << llendl; - delete streamp; - mDeadStreams.erase(iter++); - } - else - { - iter++; - } - } - - if(!mDeadStreams.empty()) + if (!releaseDeadStreams()) { llassert_always(mCurrentInternetStreamp == NULL); return; @@ -211,9 +210,15 @@ void LLStreamingAudio_FMODEX::update() unsigned int progress; bool starving; bool diskbusy; - FMOD_OPENSTATE open_state = mCurrentInternetStreamp->getOpenState(&progress, &starving, &diskbusy); + FMOD_OPENSTATE open_state; + FMOD_RESULT res = mCurrentInternetStreamp->getOpenState(open_state, &progress, &starving, &diskbusy); - if (open_state == FMOD_OPENSTATE_READY) + if (res != FMOD_OK || open_state == FMOD_OPENSTATE_ERROR) + { + stop(); + return; + } + else if (open_state == FMOD_OPENSTATE_READY) { // Stream is live @@ -223,14 +228,9 @@ void LLStreamingAudio_FMODEX::update() { // Reset volume to previously set volume setGain(getGain()); - mFMODInternetStreamChannelp->setPaused(false); + Check_FMOD_Error(mFMODInternetStreamChannelp->setPaused(false), "FMOD::Channel::setPaused"); } } - else if(open_state == FMOD_OPENSTATE_ERROR) - { - stop(); - return; - } if(mFMODInternetStreamChannelp) { @@ -266,7 +266,7 @@ void LLStreamingAudio_FMODEX::update() if (!LLStringUtil::compareInsensitive(name, "Sample Rate Change")) { llinfos << "Stream forced changing sample rate to " << *((float *)tag.data) << llendl; - mFMODInternetStreamChannelp->setFrequency(*((float *)tag.data)); + Check_FMOD_Error(mFMODInternetStreamChannelp->setFrequency(*((float *)tag.data)), "FMOD::Channel::setFrequency"); } continue; default: @@ -289,6 +289,8 @@ void LLStreamingAudio_FMODEX::update() case(FMOD_TAGDATATYPE_STRING): { std::string out = rawstr_to_utf8(std::string((char*)tag.data,tag.datalen)); + if (out.length() && out[out.size() - 1] == 0) + out.erase(out.size() - 1); (*mMetaData)[name]=out; llinfos << tag.name << "(RAW): " << out << llendl; } @@ -299,6 +301,8 @@ void LLStreamingAudio_FMODEX::update() if (tag.datalen > 3 && ((char*)tag.data)[0] == 0xEF && ((char*)tag.data)[1] == 0xBB && ((char*)tag.data)[2] == 0xBF) offs = 3; std::string out((char*)tag.data + offs, tag.datalen - offs); + if (out.length() && out[out.size() - 1] == 0) + out.erase(out.size() - 1); (*mMetaData)[name] = out; llinfos << tag.name << "(UTF8): " << out << llendl; } @@ -306,6 +310,8 @@ void LLStreamingAudio_FMODEX::update() case(FMOD_TAGDATATYPE_STRING_UTF16): { std::string out = utf16input_to_utf8((char*)tag.data, tag.datalen, UTF16); + if (out.length() && out[out.size() - 1] == 0) + out.erase(out.size() - 1); (*mMetaData)[name] = out; llinfos << tag.name << "(UTF16): " << out << llendl; } @@ -313,6 +319,8 @@ void LLStreamingAudio_FMODEX::update() case(FMOD_TAGDATATYPE_STRING_UTF16BE): { std::string out = utf16input_to_utf8((char*)tag.data, tag.datalen, UTF16BE); + if (out.length() && out[out.size() - 1] == 0) + out.erase(out.size() - 1); (*mMetaData)[name] = out; llinfos << tag.name << "(UTF16BE): " << out << llendl; } @@ -324,18 +332,17 @@ void LLStreamingAudio_FMODEX::update() if(starving) { bool paused = false; - mFMODInternetStreamChannelp->getPaused(&paused); - if(!paused) + if (mFMODInternetStreamChannelp->getPaused(&paused) == FMOD_OK && !paused) { llinfos << "Stream starvation detected! Pausing stream until buffer nearly full." << llendl; llinfos << " (diskbusy="<setPaused(true); + Check_FMOD_Error(mFMODInternetStreamChannelp->setPaused(true), "FMOD::Channel::setPaused"); } } else if(progress > 80) { - mFMODInternetStreamChannelp->setPaused(false); + Check_FMOD_Error(mFMODInternetStreamChannelp->setPaused(false), "FMOD::Channel::setPaused"); } } } @@ -352,8 +359,8 @@ void LLStreamingAudio_FMODEX::stop() } if (mFMODInternetStreamChannelp) { - mFMODInternetStreamChannelp->setPaused(true); - mFMODInternetStreamChannelp->setPriority(0); + Check_FMOD_Error(mFMODInternetStreamChannelp->setPaused(true), "FMOD::Channel::setPaused"); + Check_FMOD_Error(mFMODInternetStreamChannelp->setPriority(0), "FMOD::Channel::setPriority"); mFMODInternetStreamChannelp = NULL; } @@ -434,7 +441,7 @@ void LLStreamingAudio_FMODEX::setGain(F32 vol) { vol = llclamp(vol * vol, 0.f, 1.f); //should vol be squared here? - mFMODInternetStreamChannelp->setVolume(vol); + Check_FMOD_Error(mFMODInternetStreamChannelp->setVolume(vol), "FMOD::Channel::setVolume"); } } @@ -444,8 +451,8 @@ void LLStreamingAudio_FMODEX::setGain(F32 vol) return false; bool muted=false; - mFMODInternetStreamChannelp->getMute(&muted); - if(muted) + FMOD_RESULT res = mFMODInternetStreamChannelp->getMute(&muted); + if(res != FMOD_OK || muted) return false; static std::vector local_array(count); //Have to have an extra buffer to mix channels. Bleh. @@ -498,7 +505,8 @@ LLAudioStreamManagerFMODEX::LLAudioStreamManagerFMODEX(FMOD::System *system, con FMOD::Channel *LLAudioStreamManagerFMODEX::startStream() { // We need a live and opened stream before we try and play it. - if (!mInternetStream || getOpenState() != FMOD_OPENSTATE_READY) + FMOD_OPENSTATE open_state; + if (getOpenState(open_state) != FMOD_OK || open_state != FMOD_OPENSTATE_READY) { llwarns << "No internet stream to start playing!" << llendl; return NULL; @@ -507,7 +515,7 @@ FMOD::Channel *LLAudioStreamManagerFMODEX::startStream() if(mStreamChannel) return mStreamChannel; //Already have a channel for this stream. - mSystem->playSound(FMOD_CHANNEL_FREE, mInternetStream, true, &mStreamChannel); + Check_FMOD_Error(mSystem->playSound(FMOD_CHANNEL_FREE, mInternetStream, true, &mStreamChannel), "FMOD::System::playSound"); return mStreamChannel; } @@ -516,17 +524,17 @@ bool LLAudioStreamManagerFMODEX::stopStream() if (mInternetStream) { bool close = true; - switch (getOpenState()) + FMOD_OPENSTATE open_state; + if (getOpenState(open_state) == FMOD_OK) { - case FMOD_OPENSTATE_CONNECTING: - close = false; - break; - /*case FSOUND_STREAM_NET_NOTCONNECTED: - case FSOUND_STREAM_NET_BUFFERING: - case FSOUND_STREAM_NET_READY: - case FSOUND_STREAM_NET_ERROR:*/ - default: - close = true; + switch (open_state) + { + case FMOD_OPENSTATE_CONNECTING: + close = false; + break; + default: + close = true; + } } if (close && mInternetStream->release() == FMOD_OK) @@ -546,19 +554,43 @@ bool LLAudioStreamManagerFMODEX::stopStream() } } -FMOD_OPENSTATE LLAudioStreamManagerFMODEX::getOpenState(unsigned int* percentbuffered, bool* starving, bool* diskbusy) +FMOD_RESULT LLAudioStreamManagerFMODEX::getOpenState(FMOD_OPENSTATE& state, unsigned int* percentbuffered, bool* starving, bool* diskbusy) { - FMOD_OPENSTATE state; - mInternetStream->getOpenState(&state,percentbuffered,starving,diskbusy); - return state; + if (!mInternetStream) + return FMOD_ERR_INVALID_HANDLE; + FMOD_RESULT result = mInternetStream->getOpenState(&state, percentbuffered, starving, diskbusy); + Check_FMOD_Error(result, "FMOD::Sound::getOpenState"); + return result; } void LLStreamingAudio_FMODEX::setBufferSizes(U32 streambuffertime, U32 decodebuffertime) { - mSystem->setStreamBufferSize(streambuffertime/1000*128*128, FMOD_TIMEUNIT_RAWBYTES); + Check_FMOD_Error(mSystem->setStreamBufferSize(streambuffertime / 1000 * 128 * 128, FMOD_TIMEUNIT_RAWBYTES), "FMOD::System::setStreamBufferSize"); FMOD_ADVANCEDSETTINGS settings; memset(&settings,0,sizeof(settings)); settings.cbsize=sizeof(settings); settings.defaultDecodeBufferSize = decodebuffertime;//ms - mSystem->setAdvancedSettings(&settings); + Check_FMOD_Error(mSystem->setAdvancedSettings(&settings), "FMOD::System::setAdvancedSettings"); } + +bool LLStreamingAudio_FMODEX::releaseDeadStreams() +{ + // Kill dead internet streams, if possible + std::list::iterator iter; + for (iter = mDeadStreams.begin(); iter != mDeadStreams.end();) + { + LLAudioStreamManagerFMODEX *streamp = *iter; + if (streamp->stopStream()) + { + llinfos << "Closed dead stream" << llendl; + delete streamp; + mDeadStreams.erase(iter++); + } + else + { + iter++; + } + } + + return mDeadStreams.empty(); +} \ No newline at end of file diff --git a/indra/llaudio/llstreamingaudio_fmodex.h b/indra/llaudio/llstreamingaudio_fmodex.h index 8e8bb2da6..15a4af931 100644 --- a/indra/llaudio/llstreamingaudio_fmodex.h +++ b/indra/llaudio/llstreamingaudio_fmodex.h @@ -70,6 +70,8 @@ class LLStreamingAudio_FMODEX : public LLStreamingAudioInterface /*virtual*/ bool supportsAdjustableBufferSizes(){return true;} /*virtual*/ void setBufferSizes(U32 streambuffertime, U32 decodebuffertime); private: + bool releaseDeadStreams(); + FMOD::System *mSystem; LLAudioStreamManagerFMODEX *mCurrentInternetStreamp; diff --git a/indra/llaudio/llstreamingaudio_fmodstudio.cpp b/indra/llaudio/llstreamingaudio_fmodstudio.cpp new file mode 100644 index 000000000..5a530c557 --- /dev/null +++ b/indra/llaudio/llstreamingaudio_fmodstudio.cpp @@ -0,0 +1,675 @@ +/** + * @file streamingaudio_fmodstudio.cpp + * @brief LLStreamingAudio_FMODSTUDIO implementation + * + * $LicenseInfo:firstyear=2009&license=viewergpl$ + * + * Copyright (c) 2009, Linden Research, Inc. + * + * Second Life Viewer Source Code + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab. Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. + * + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. + * $/LicenseInfo$ + */ + +#include "linden_common.h" + +#include "llmath.h" +#include "llthread.h" + +#include "fmod.hpp" +#include "fmod_errors.h" + +#include "llstreamingaudio_fmodstudio.h" + +inline bool Check_FMOD_Error(FMOD_RESULT result, const char *string) +{ + if (result == FMOD_OK) + return false; + LL_WARNS("AudioImpl") << string << " Error: " << FMOD_ErrorString(result) << LL_ENDL; + return true; +} + +class LLAudioStreamManagerFMODSTUDIO +{ +public: + LLAudioStreamManagerFMODSTUDIO(FMOD::System *system, FMOD::ChannelGroup *group, const std::string& url); + FMOD::Channel* startStream(); + bool stopStream(); // Returns true if the stream was successfully stopped. + bool ready(); + + const std::string& getURL() { return mInternetStreamURL; } + + FMOD_RESULT getOpenState(FMOD_OPENSTATE& openstate, unsigned int* percentbuffered = NULL, bool* starving = NULL, bool* diskbusy = NULL); +protected: + FMOD::System* mSystem; + FMOD::Channel* mStreamChannel; + FMOD::Sound* mInternetStream; + FMOD::ChannelGroup* mChannelGroup; + bool mReady; + + std::string mInternetStreamURL; +}; + +LLGlobalMutex gWaveDataMutex; //Just to be extra strict. +const U32 WAVE_BUFFER_SIZE = 1024; +U32 gWaveBufferMinSize = 0; +F32 gWaveDataBuffer[WAVE_BUFFER_SIZE] = { 0.f }; +U32 gWaveDataBufferSize = 0; + +FMOD_RESULT F_CALLBACK waveDataCallback(FMOD_DSP_STATE *dsp_state, float *inbuffer, float *outbuffer, unsigned int length, int inchannels, int *outchannels) +{ + if (!length || !inchannels) + return FMOD_OK; + memcpy(outbuffer, inbuffer, length * inchannels * sizeof(float)); + + static std::vector local_buf; + if (local_buf.size() < length) + local_buf.resize(length, 0.f); + + for (U32 i = 0; i < length; ++i) + { + F32 total = 0.f; + for (S32 j = 0; j < inchannels; ++j) + { + total += inbuffer[i*inchannels + j]; + } + local_buf[i] = total / inchannels; + } + + { + LLMutexLock lock(gWaveDataMutex); + + for (U32 i = length; i > 0; --i) + { + if (++gWaveDataBufferSize > WAVE_BUFFER_SIZE) + { + if (gWaveBufferMinSize) + memcpy(gWaveDataBuffer + WAVE_BUFFER_SIZE - gWaveBufferMinSize, gWaveDataBuffer, gWaveBufferMinSize * sizeof(float)); + gWaveDataBufferSize = 1 + gWaveBufferMinSize; + } + gWaveDataBuffer[WAVE_BUFFER_SIZE - gWaveDataBufferSize] = local_buf[i - 1]; + } + } + + return FMOD_OK; +} + +//--------------------------------------------------------------------------- +// Internet Streaming +//--------------------------------------------------------------------------- +LLStreamingAudio_FMODSTUDIO::LLStreamingAudio_FMODSTUDIO(FMOD::System *system) : + mSystem(system), + mCurrentInternetStreamp(NULL), + mFMODInternetStreamChannelp(NULL), + mGain(1.0f), + mMetaData(NULL), + mStreamGroup(NULL), + mStreamDSP(NULL) +{ + FMOD_RESULT result; + + // Number of milliseconds of audio to buffer for the audio card. + // Must be larger than the usual Second Life frame stutter time. + const U32 buffer_seconds = 10; //sec + const U32 estimated_bitrate = 128; //kbit/sec + result = mSystem->setStreamBufferSize(estimated_bitrate * buffer_seconds * 128/*bytes/kbit*/, FMOD_TIMEUNIT_RAWBYTES); + Check_FMOD_Error(result, "FMOD::System::setStreamBufferSize"); + + // Here's where we set the size of the network buffer and some buffering + // parameters. In this case we want a network buffer of 16k, we want it + // to prebuffer 40% of that when we first connect, and we want it + // to rebuffer 80% of that whenever we encounter a buffer underrun. + + // Leave the net buffer properties at the default. + //FSOUND_Stream_Net_SetBufferProperties(20000, 40, 80); + + Check_FMOD_Error(mSystem->createChannelGroup("stream", &mStreamGroup), "FMOD::System::createChannelGroup"); + + FMOD_DSP_DESCRIPTION dspdesc; + memset(&dspdesc, 0, sizeof(FMOD_DSP_DESCRIPTION)); //Zero out everything + dspdesc.pluginsdkversion = FMOD_PLUGIN_SDK_VERSION; + strncpy(dspdesc.name, "Waveform", sizeof(dspdesc.name)); + dspdesc.numoutputbuffers = 1; + dspdesc.read = &waveDataCallback; //Assign callback. + + Check_FMOD_Error(system->createDSP(&dspdesc, &mStreamDSP), "FMOD::System::createDSP"); +} + + +LLStreamingAudio_FMODSTUDIO::~LLStreamingAudio_FMODSTUDIO() +{ + stop(); + for (U32 i = 0; i < 100; ++i) + { + if (releaseDeadStreams()) + break; + ms_sleep(10); + } + + cleanupWaveData(); +} + + +void LLStreamingAudio_FMODSTUDIO::start(const std::string& url) +{ + //if (!mInited) + //{ + // llwarns << "startInternetStream before audio initialized" << llendl; + // return; + //} + + // "stop" stream but don't clear url, etc. in case url == mInternetStreamURL + stop(); + + if (!url.empty()) + { + if(mDeadStreams.empty()) + { + llinfos << "Starting internet stream: " << url << llendl; + mCurrentInternetStreamp = new LLAudioStreamManagerFMODSTUDIO(mSystem, mStreamGroup, url); + mURL = url; + mMetaData = new LLSD; + } + else + { + llinfos << "Deferring stream load until buffer release: " << url << llendl; + mPendingURL = url; + } + } + else + { + llinfos << "Set internet stream to null" << llendl; + mURL.clear(); + } +} + +enum utf_endian_type_t +{ + UTF16LE, + UTF16BE, + UTF16 +}; + +std::string utf16input_to_utf8(char* input, U32 len, utf_endian_type_t type) +{ + if (type == UTF16) + { + type = UTF16BE; //Default + if (len > 2) + { + //Parse and strip BOM. + if ((input[0] == 0xFE && input[1] == 0xFF) || + (input[0] == 0xFF && input[1] == 0xFE)) + { + input += 2; + len -= 2; + type = input[0] == 0xFE ? UTF16BE : UTF16LE; + } + } + } + llutf16string out_16((U16*)input, len / 2); + if (len % 2) + { + out_16.push_back((input)[len - 1] << 8); + } + if (type == UTF16BE) + { + for (llutf16string::iterator i = out_16.begin(); i < out_16.end(); ++i) + { + llutf16string::value_type v = *i; + *i = ((v & 0x00FF) << 8) | ((v & 0xFF00) >> 8); + } + } + return utf16str_to_utf8str(out_16); +} + +void LLStreamingAudio_FMODSTUDIO::update() +{ + if (!releaseDeadStreams()) + { + llassert_always(mCurrentInternetStreamp == NULL); + return; + } + + if(!mPendingURL.empty()) + { + llassert_always(mCurrentInternetStreamp == NULL); + llinfos << "Starting internet stream: " << mPendingURL << llendl; + mCurrentInternetStreamp = new LLAudioStreamManagerFMODSTUDIO(mSystem,mStreamGroup, mPendingURL); + mURL = mPendingURL; + mMetaData = new LLSD; + mPendingURL.clear(); + } + + // Don't do anything if there are no streams playing + if (!mCurrentInternetStreamp) + { + return; + } + + unsigned int progress; + bool starving; + bool diskbusy; + FMOD_OPENSTATE open_state; + FMOD_RESULT result = mCurrentInternetStreamp->getOpenState(open_state, &progress, &starving, &diskbusy); + + if (result != FMOD_OK || open_state == FMOD_OPENSTATE_ERROR) + { + stop(); + return; + } + else if (open_state == FMOD_OPENSTATE_READY) + { + // Stream is live + + // start the stream if it's ready + if (!mFMODInternetStreamChannelp && + (mFMODInternetStreamChannelp = mCurrentInternetStreamp->startStream())) + { + // Reset volume to previously set volume + setGain(getGain()); + if (mStreamDSP) + { + Check_FMOD_Error(mFMODInternetStreamChannelp->addDSP(FMOD_CHANNELCONTROL_DSP_TAIL, mStreamDSP), "FMOD::Channel::addDSP"); + } + Check_FMOD_Error(mFMODInternetStreamChannelp->setPaused(false), "FMOD::Channel::setPaused"); + } + } + + + if(mFMODInternetStreamChannelp) + { + if(!mMetaData) + mMetaData = new LLSD; + + FMOD::Sound *sound = NULL; + + if(mFMODInternetStreamChannelp->getCurrentSound(&sound) == FMOD_OK && sound) + { + FMOD_TAG tag; + S32 tagcount, dirtytagcount; + if(sound->getNumTags(&tagcount, &dirtytagcount) == FMOD_OK && dirtytagcount) + { + mMetaData->clear(); + + for(S32 i = 0; i < tagcount; ++i) + { + if(sound->getTag(NULL, i, &tag)!=FMOD_OK) + continue; + std::string name = tag.name; + switch(tag.type) //Crappy tag translate table. + { + case(FMOD_TAGTYPE_ID3V2): + if (!LLStringUtil::compareInsensitive(name, "TIT2")) name = "TITLE"; + else if(name == "TPE1") name = "ARTIST"; + break; + case(FMOD_TAGTYPE_ASF): + if (!LLStringUtil::compareInsensitive(name, "Title")) name = "TITLE"; + else if (!LLStringUtil::compareInsensitive(name, "WM/AlbumArtist")) name = "ARTIST"; + break; + case(FMOD_TAGTYPE_FMOD): + if (!LLStringUtil::compareInsensitive(name, "Sample Rate Change")) + { + llinfos << "Stream forced changing sample rate to " << *((float *)tag.data) << llendl; + Check_FMOD_Error(mFMODInternetStreamChannelp->setFrequency(*((float *)tag.data)), "FMOD::Channel::setFrequency"); + } + continue; + default: + if (!LLStringUtil::compareInsensitive(name, "TITLE") || + !LLStringUtil::compareInsensitive(name, "ARTIST")) + LLStringUtil::toUpper(name); + break; + } + + switch(tag.datatype) + { + case(FMOD_TAGDATATYPE_INT): + (*mMetaData)[name]=*(LLSD::Integer*)(tag.data); + llinfos << tag.name << ": " << *(int*)(tag.data) << llendl; + break; + case(FMOD_TAGDATATYPE_FLOAT): + (*mMetaData)[name]=*(LLSD::Float*)(tag.data); + llinfos << tag.name << ": " << *(float*)(tag.data) << llendl; + break; + case(FMOD_TAGDATATYPE_STRING): + { + std::string out = rawstr_to_utf8(std::string((char*)tag.data,tag.datalen)); + if (out.length() && out[out.size() - 1] == 0) + out.erase(out.size() - 1); + (*mMetaData)[name]=out; + llinfos << tag.name << "(RAW): " << out << llendl; + } + break; + case(FMOD_TAGDATATYPE_STRING_UTF8) : + { + U8 offs = 0; + if (tag.datalen > 3 && ((char*)tag.data)[0] == 0xEF && ((char*)tag.data)[1] == 0xBB && ((char*)tag.data)[2] == 0xBF) + offs = 3; + std::string out((char*)tag.data + offs, tag.datalen - offs); + if (out.length() && out[out.size() - 1] == 0) + out.erase(out.size() - 1); + (*mMetaData)[name] = out; + llinfos << tag.name << "(UTF8): " << out << llendl; + } + break; + case(FMOD_TAGDATATYPE_STRING_UTF16): + { + std::string out = utf16input_to_utf8((char*)tag.data, tag.datalen, UTF16); + if (out.length() && out[out.size() - 1] == 0) + out.erase(out.size() - 1); + (*mMetaData)[name] = out; + llinfos << tag.name << "(UTF16): " << out << llendl; + } + break; + case(FMOD_TAGDATATYPE_STRING_UTF16BE): + { + std::string out = utf16input_to_utf8((char*)tag.data, tag.datalen, UTF16BE); + if (out.length() && out[out.size() - 1] == 0) + out.erase(out.size() - 1); + (*mMetaData)[name] = out; + llinfos << tag.name << "(UTF16BE): " << out << llendl; + } + default: + break; + } + } + } + if(starving) + { + bool paused = false; + if (mFMODInternetStreamChannelp->getPaused(&paused) == FMOD_OK && !paused) + { + llinfos << "Stream starvation detected! Pausing stream until buffer nearly full." << llendl; + llinfos << " (diskbusy="<setPaused(true), "FMOD::Channel::setPaused"); + } + } + else if(progress > 80) + { + Check_FMOD_Error(mFMODInternetStreamChannelp->setPaused(false), "FMOD::Channel::setPaused"); + } + } + } +} + +void LLStreamingAudio_FMODSTUDIO::stop() +{ + mPendingURL.clear(); + + if(mMetaData) + { + delete mMetaData; + mMetaData = NULL; + } + + if (mFMODInternetStreamChannelp) + { + Check_FMOD_Error(mFMODInternetStreamChannelp->setPaused(true), "FMOD::Channel::setPaused"); + Check_FMOD_Error(mFMODInternetStreamChannelp->setPriority(0), "FMOD::Channel::setPriority"); + if (mStreamDSP) + { + Check_FMOD_Error(mFMODInternetStreamChannelp->removeDSP(mStreamDSP), "FMOD::Channel::removeDSP"); + } + mFMODInternetStreamChannelp = NULL; + } + + if (mCurrentInternetStreamp) + { + llinfos << "Stopping internet stream: " << mCurrentInternetStreamp->getURL() << llendl; + if (mCurrentInternetStreamp->stopStream()) + { + delete mCurrentInternetStreamp; + } + else + { + llwarns << "Pushing stream to dead list: " << mCurrentInternetStreamp->getURL() << llendl; + mDeadStreams.push_back(mCurrentInternetStreamp); + } + mCurrentInternetStreamp = NULL; + //mURL.clear(); + } +} + +void LLStreamingAudio_FMODSTUDIO::pause(int pauseopt) +{ + if (pauseopt < 0) + { + pauseopt = mCurrentInternetStreamp ? 1 : 0; + } + + if (pauseopt) + { + if (mCurrentInternetStreamp) + { + stop(); + } + } + else + { + start(getURL()); + } +} + + +// A stream is "playing" if it has been requested to start. That +// doesn't necessarily mean audio is coming out of the speakers. +int LLStreamingAudio_FMODSTUDIO::isPlaying() +{ + if (mCurrentInternetStreamp) + { + return 1; // Active and playing + } + else if (!mURL.empty() || !mPendingURL.empty()) + { + return 2; // "Paused" + } + else + { + return 0; + } +} + + +F32 LLStreamingAudio_FMODSTUDIO::getGain() +{ + return mGain; +} + + +std::string LLStreamingAudio_FMODSTUDIO::getURL() +{ + return mURL; +} + + +void LLStreamingAudio_FMODSTUDIO::setGain(F32 vol) +{ + mGain = vol; + + if (mFMODInternetStreamChannelp) + { + vol = llclamp(vol * vol, 0.f, 1.f); //should vol be squared here? + + Check_FMOD_Error(mFMODInternetStreamChannelp->setVolume(vol), "FMOD::Channel::setVolume"); + } +} + +/*virtual*/ bool LLStreamingAudio_FMODSTUDIO::getWaveData(float* arr, S32 count, S32 stride/*=1*/) +{ + if (count > (WAVE_BUFFER_SIZE / 2)) + LL_ERRS("AudioImpl") << "Count=" << count << " exceeds WAVE_BUFFER_SIZE/2=" << WAVE_BUFFER_SIZE << LL_ENDL; + + if(!mFMODInternetStreamChannelp || !mCurrentInternetStreamp) + return false; + + bool muted = false; + FMOD_RESULT res = mFMODInternetStreamChannelp->getMute(&muted); + if(res != FMOD_OK || muted) + return false; + { + U32 buff_size; + { + LLMutexLock lock(gWaveDataMutex); + gWaveBufferMinSize = count; + buff_size = gWaveDataBufferSize; + if (!buff_size) + return false; + memcpy(arr, gWaveDataBuffer + WAVE_BUFFER_SIZE - buff_size, llmin(U32(count), buff_size) * sizeof(float)); + } + if (buff_size < U32(count)) + memset(arr + buff_size, 0, (count - buff_size) * sizeof(float)); + } + return true; +} + +/////////////////////////////////////////////////////// +// manager of possibly-multiple internet audio streams + +LLAudioStreamManagerFMODSTUDIO::LLAudioStreamManagerFMODSTUDIO(FMOD::System *system, FMOD::ChannelGroup *group, const std::string& url) : + mSystem(system), + mStreamChannel(NULL), + mInternetStream(NULL), + mChannelGroup(group), + mReady(false) +{ + mInternetStreamURL = url; + + FMOD_RESULT result = mSystem->createStream(url.c_str(), FMOD_2D | FMOD_NONBLOCKING | FMOD_IGNORETAGS, 0, &mInternetStream); + + if (result!= FMOD_OK) + { + llwarns << "Couldn't open fmod stream, error " + << FMOD_ErrorString(result) + << llendl; + mReady = false; + return; + } + + mReady = true; +} + +FMOD::Channel *LLAudioStreamManagerFMODSTUDIO::startStream() +{ + // We need a live and opened stream before we try and play it. + FMOD_OPENSTATE open_state; + if (getOpenState(open_state) != FMOD_OK || open_state != FMOD_OPENSTATE_READY) + { + llwarns << "No internet stream to start playing!" << llendl; + return NULL; + } + + if(mStreamChannel) + return mStreamChannel; //Already have a channel for this stream. + + Check_FMOD_Error(mSystem->playSound(mInternetStream, mChannelGroup, true, &mStreamChannel), "FMOD::System::playSound"); + return mStreamChannel; +} + +bool LLAudioStreamManagerFMODSTUDIO::stopStream() +{ + if (mInternetStream) + { + bool close = true; + FMOD_OPENSTATE open_state; + if (getOpenState(open_state) == FMOD_OK) + { + switch (open_state) + { + case FMOD_OPENSTATE_CONNECTING: + close = false; + break; + default: + close = true; + } + } + + if (close && mInternetStream->release() == FMOD_OK) + { + mStreamChannel = NULL; + mInternetStream = NULL; + return true; + } + else + { + return false; + } + } + else + { + return true; + } +} + +FMOD_RESULT LLAudioStreamManagerFMODSTUDIO::getOpenState(FMOD_OPENSTATE& state, unsigned int* percentbuffered, bool* starving, bool* diskbusy) +{ + if (!mInternetStream) + return FMOD_ERR_INVALID_HANDLE; + FMOD_RESULT result = mInternetStream->getOpenState(&state, percentbuffered, starving, diskbusy); + Check_FMOD_Error(result, "FMOD::Sound::getOpenState"); + return result; +} + +void LLStreamingAudio_FMODSTUDIO::setBufferSizes(U32 streambuffertime, U32 decodebuffertime) +{ + Check_FMOD_Error(mSystem->setStreamBufferSize(streambuffertime / 1000 * 128 * 128, FMOD_TIMEUNIT_RAWBYTES), "FMOD::System::setStreamBufferSize"); + FMOD_ADVANCEDSETTINGS settings; + memset(&settings,0,sizeof(settings)); + settings.cbSize=sizeof(settings); + settings.defaultDecodeBufferSize = decodebuffertime;//ms + Check_FMOD_Error(mSystem->setAdvancedSettings(&settings), "FMOD::System::setAdvancedSettings"); +} + +bool LLStreamingAudio_FMODSTUDIO::releaseDeadStreams() +{ + // Kill dead internet streams, if possible + std::list::iterator iter; + for (iter = mDeadStreams.begin(); iter != mDeadStreams.end();) + { + LLAudioStreamManagerFMODSTUDIO *streamp = *iter; + if (streamp->stopStream()) + { + llinfos << "Closed dead stream" << llendl; + delete streamp; + mDeadStreams.erase(iter++); + } + else + { + iter++; + } + } + + return mDeadStreams.empty(); +} + +void LLStreamingAudio_FMODSTUDIO::cleanupWaveData() +{ + if (mStreamGroup) + { + Check_FMOD_Error(mStreamGroup->release(), "FMOD::ChannelGroup::release"); + mStreamGroup = NULL; + } + + if(mStreamDSP) + Check_FMOD_Error(mStreamDSP->release(), "FMOD::DSP::release"); + mStreamDSP = NULL; +} \ No newline at end of file diff --git a/indra/llaudio/llstreamingaudio_fmodstudio.h b/indra/llaudio/llstreamingaudio_fmodstudio.h new file mode 100644 index 000000000..bb4a77e42 --- /dev/null +++ b/indra/llaudio/llstreamingaudio_fmodstudio.h @@ -0,0 +1,97 @@ +/** + * @file streamingaudio_fmodstudio.h + * @author Tofu Linden + * @brief Definition of LLStreamingAudio_FMODSTUDIO implementation + * + * $LicenseInfo:firstyear=2009&license=viewergpl$ + * + * Copyright (c) 2009, Linden Research, Inc. + * + * Second Life Viewer Source Code + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab. Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. + * + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. + * $/LicenseInfo$ + */ + +#ifndef LL_STREAMINGAUDIO_FMODSTUDIO_H +#define LL_STREAMINGAUDIO_FMODSTUDIO_H + +#include "stdtypes.h" // from llcommon + +#include "llstreamingaudio.h" +#include "lltimer.h" + +//Stubs +class LLAudioStreamManagerFMODSTUDIO; +namespace FMOD +{ + class System; + class Channel; + class ChannelGroup; + class ChannelGroup; + class DSP; +} + +//Interfaces +class LLStreamingAudio_FMODSTUDIO : public LLStreamingAudioInterface +{ + public: + LLStreamingAudio_FMODSTUDIO(FMOD::System *system); + /*virtual*/ ~LLStreamingAudio_FMODSTUDIO(); + + /*virtual*/ void start(const std::string& url); + /*virtual*/ void stop(); + /*virtual*/ void pause(int pause); + /*virtual*/ void update(); + /*virtual*/ int isPlaying(); + /*virtual*/ void setGain(F32 vol); + /*virtual*/ F32 getGain(); + /*virtual*/ std::string getURL(); + + /*virtual*/ bool supportsMetaData(){return true;} + /*virtual*/ const LLSD *getMetaData(){return mMetaData;} //return NULL if not playing. + /*virtual*/ bool supportsWaveData(){return true;} + /*virtual*/ bool getWaveData(float* arr, S32 count, S32 stride = 1); + /*virtual*/ bool supportsAdjustableBufferSizes(){return true;} + /*virtual*/ void setBufferSizes(U32 streambuffertime, U32 decodebuffertime); + +private: + bool releaseDeadStreams(); + void cleanupWaveData(); + + FMOD::System *mSystem; + + LLAudioStreamManagerFMODSTUDIO *mCurrentInternetStreamp; + FMOD::Channel *mFMODInternetStreamChannelp; + std::list mDeadStreams; + + std::string mURL; + std::string mPendingURL; + F32 mGain; + + LLSD *mMetaData; + + FMOD::ChannelGroup* mStreamGroup; + FMOD::DSP* mStreamDSP; +}; + + +#endif // LL_STREAMINGAUDIO_FMOD_H diff --git a/indra/llcharacter/lleditingmotion.h b/indra/llcharacter/lleditingmotion.h index bc95ff682..b06d2b774 100644 --- a/indra/llcharacter/lleditingmotion.h +++ b/indra/llcharacter/lleditingmotion.h @@ -58,6 +58,16 @@ public: // Destructor virtual ~LLEditingMotion(); + void* operator new(size_t size) + { + return ll_aligned_malloc_16(size); + } + + void operator delete(void* ptr) + { + ll_aligned_free_16(ptr); + } + public: //------------------------------------------------------------------------- // functions to support MotionController and MotionRegistry diff --git a/indra/llcharacter/llkeyframemotion.cpp b/indra/llcharacter/llkeyframemotion.cpp index 711ac21e5..4be835dce 100644 --- a/indra/llcharacter/llkeyframemotion.cpp +++ b/indra/llcharacter/llkeyframemotion.cpp @@ -1111,7 +1111,7 @@ void LLKeyframeMotion::applyConstraint(JointConstraint* constraint, F32 time, U8 LLVector3 source_to_target = target_pos - keyframe_source_pos; - S32 max_iteration_count = llround(clamp_rescale( + S32 max_iteration_count = llmath::llround(clamp_rescale( mCharacter->getPixelArea(), MAX_PIXEL_AREA_CONSTRAINTS, MIN_PIXEL_AREA_CONSTRAINTS, diff --git a/indra/llcharacter/llkeyframestandmotion.h b/indra/llcharacter/llkeyframestandmotion.h index 346df97f0..c3a9ddd22 100644 --- a/indra/llcharacter/llkeyframestandmotion.h +++ b/indra/llcharacter/llkeyframestandmotion.h @@ -53,6 +53,16 @@ public: // Destructor virtual ~LLKeyframeStandMotion(); + void* operator new(size_t size) + { + return ll_aligned_malloc_16(size); + } + + void operator delete(void* ptr) + { + ll_aligned_free_16(ptr); + } + public: //------------------------------------------------------------------------- // functions to support MotionController and MotionRegistry diff --git a/indra/llcharacter/llmotioncontroller.cpp b/indra/llcharacter/llmotioncontroller.cpp index d12b3ddb6..2764405e5 100644 --- a/indra/llcharacter/llmotioncontroller.cpp +++ b/indra/llcharacter/llmotioncontroller.cpp @@ -876,12 +876,12 @@ void LLMotionController::updateMotions(bool force_update) // // This old code is nonsense. - //S32 quantum_count = llmax(0, llround((update_time - time_interval) / mTimeStep)) + 1; + //S32 quantum_count = llmax(0, llmath::llround((update_time - time_interval) / mTimeStep)) + 1; // (update_time - time_interval) / mTimeStep is an integer! We need llround to get rid of floating point errors, not llfloor. - // Moreover, just rounding off to the nearest integer with llround(update_time / mTimeStep) makes a lot more sense: + // Moreover, just rounding off to the nearest integer with llmath::llround(update_time / mTimeStep) makes a lot more sense: // it is the best we can do to get as close to what we should draw as possible. // However, mAnimTime may only be incremented; therefore make sure of that with the llmax. - S32 quantum_count = llmax(llround(update_time / mTimeStep), llceil(mAnimTime / mTimeStep)); + S32 quantum_count = llmax(llmath::llround(update_time / mTimeStep), llceil(mAnimTime / mTimeStep)); // if (quantum_count == mTimeStepCount) { diff --git a/indra/llcharacter/llpose.h b/indra/llcharacter/llpose.h index 2b976b219..63c0fdde4 100644 --- a/indra/llcharacter/llpose.h +++ b/indra/llcharacter/llpose.h @@ -96,6 +96,16 @@ protected: public: LLJointStateBlender(); ~LLJointStateBlender(); + void* operator new(size_t size) + { + return ll_aligned_malloc_16(size); + } + + void operator delete(void* ptr) + { + ll_aligned_free_16(ptr); + } + void blendJointStates(BOOL apply_now = TRUE); BOOL addJointState(const LLPointer& joint_state, S32 priority, BOOL additive_blend); void interpolate(F32 u); diff --git a/indra/llcommon/llerror.cpp b/indra/llcommon/llerror.cpp index 4155885d8..10921d421 100644 --- a/indra/llcommon/llerror.cpp +++ b/indra/llcommon/llerror.cpp @@ -108,7 +108,7 @@ namespace { mFile.close(); } - bool okay() { return mFile; } + bool okay() { return !!mFile; } virtual bool wantsTime() { return true; } diff --git a/indra/llcommon/lleventcoro.h b/indra/llcommon/lleventcoro.h index a42af63b6..b451092bf 100644 --- a/indra/llcommon/lleventcoro.h +++ b/indra/llcommon/lleventcoro.h @@ -67,7 +67,7 @@ public: LLEventPumpOrPumpName() {} operator LLEventPump& () const { return *mPump; } LLEventPump& getPump() const { return *mPump; } - operator bool() const { return mPump; } + operator bool() const { return !!mPump; } bool operator!() const { return ! mPump; } private: diff --git a/indra/llcommon/llstl.h b/indra/llcommon/llstl.h index fdd2f7f22..bd129e8a3 100644 --- a/indra/llcommon/llstl.h +++ b/indra/llcommon/llstl.h @@ -296,7 +296,7 @@ inline void vector_shrink_to_fit(std::vector& invec) #if defined(LL_WINDOWS) || __cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X) && __GNUC_MINOR__ >= 5) invec.shrink_to_fit(); #else - invec(invec.begin(), invec.end()).swap(invec); + std::vector(invec).swap(invec); #endif } diff --git a/indra/llcommon/llthread.h b/indra/llcommon/llthread.h index 8dee66b34..62e36c2e4 100644 --- a/indra/llcommon/llthread.h +++ b/indra/llcommon/llthread.h @@ -27,12 +27,16 @@ #ifndef LL_LLTHREAD_H #define LL_LLTHREAD_H -#define USE_BOOST_MUTEX +#if !defined(_MSC_VER) || _MSC_VER >= 1700 +#define USE_BOOST_MUTEX 1 +#endif + +#define IS_LLCOMMON_INLINE (!LL_COMMON_LINK_SHARED || defined(llcommon_EXPORTS)) #if LL_GNUC // Needed for is_main_thread() when compiling with optimization (relwithdebinfo). // It doesn't hurt to just always specify it though. -#pragma interface +//#pragma interface #endif #include "llapp.h" @@ -188,7 +192,7 @@ protected: //Prefer boost over stl over windows over apr. -#if defined(USE_BOOST_MUTEX) && (BOOST_VERSION >= 103400) //condition_variable_any was added in boost 1.34 +#if USE_BOOST_MUTEX && (BOOST_VERSION >= 103400) //condition_variable_any was added in boost 1.34 //Define BOOST_SYSTEM_NO_DEPRECATED to avoid system_category() and generic_category() dependencies, as those won't be exported. #define BOOST_SYSTEM_NO_DEPRECATED #include @@ -268,7 +272,12 @@ public: { if (inc_lock_if_recursive()) return; + +#if IS_LLCOMMON_INLINE if (AIThreadID::in_main_thread_inline() && LLApp::isRunning()) +#else + if (AIThreadID::in_main_thread() && LLApp::isRunning()) +#endif { if (!LLMutexImpl::try_lock()) { @@ -279,7 +288,11 @@ public: { LLMutexImpl::lock(); } +#if IS_LLCOMMON_INLINE mLockingThread.reset_inline(); +#else + mLockingThread.reset(); +#endif } void unlock() @@ -302,7 +315,11 @@ public: return true; if (!LLMutexImpl::try_lock()) return false; +#if IS_LLCOMMON_INLINE mLockingThread.reset_inline(); +#else + mLockingThread.reset(); +#endif return true; } @@ -321,7 +338,11 @@ public: // Returns true if locked by this thread. bool isSelfLocked() const { +#if IS_LLCOMMON_INLINE return mLockingThread.equals_current_thread_inline(); +#else + return mLockingThread.equals_current_thread(); +#endif } #ifdef NEEDS_MUTEX_IMPL @@ -426,16 +447,20 @@ public: {} ~LLCondition() {} - void LL_COMMON_API wait() + void wait() { +#if IS_LLCOMMON_INLINE if (AIThreadID::in_main_thread_inline()) +#else + if (AIThreadID::in_main_thread()) +#endif wait_main(); else LLConditionVariableImpl::wait(*this); } void signal() { LLConditionVariableImpl::notify_one(); } void broadcast() { LLConditionVariableImpl::notify_all(); } private: - void wait_main(); //Cannot be inline. Uses internal fasttimer. + LL_COMMON_API void wait_main(); //Cannot be inline. Uses internal fasttimer. }; class LLMutexLock @@ -646,7 +671,7 @@ public: void unref() { llassert(mRef > 0); - if (!--mRef) delete this; + if (--mRef == 0) delete this; } S32 getNumRefs() const { diff --git a/indra/llimage/llimage.cpp b/indra/llimage/llimage.cpp index 2e0531263..18258ad3a 100644 --- a/indra/llimage/llimage.cpp +++ b/indra/llimage/llimage.cpp @@ -1178,13 +1178,13 @@ void LLImageRaw::copyLineScaled( U8* in, U8* out, S32 in_pixel_len, S32 out_pixe a *= norm_factor; // skip conditional S32 t4 = x * out_pixel_step * components; - out[t4 + 0] = U8(llround(r)); + out[t4 + 0] = U8(llmath::llround(r)); if (components >= 2) - out[t4 + 1] = U8(llround(g)); + out[t4 + 1] = U8(llmath::llround(g)); if (components >= 3) - out[t4 + 2] = U8(llround(b)); + out[t4 + 2] = U8(llmath::llround(b)); if( components == 4) - out[t4 + 3] = U8(llround(a)); + out[t4 + 3] = U8(llmath::llround(a)); } } } @@ -1259,10 +1259,10 @@ void LLImageRaw::compositeRowScaled4onto3( U8* in, U8* out, S32 in_pixel_len, S3 b *= norm_factor; a *= norm_factor; - in_scaled_r = U8(llround(r)); - in_scaled_g = U8(llround(g)); - in_scaled_b = U8(llround(b)); - in_scaled_a = U8(llround(a)); + in_scaled_r = U8(llmath::llround(r)); + in_scaled_g = U8(llmath::llround(g)); + in_scaled_b = U8(llmath::llround(b)); + in_scaled_a = U8(llmath::llround(a)); } if( in_scaled_a ) diff --git a/indra/llimage/llpngwrapper.h b/indra/llimage/llpngwrapper.h index 7aeb1a09c..410583024 100644 --- a/indra/llimage/llpngwrapper.h +++ b/indra/llimage/llpngwrapper.h @@ -30,8 +30,12 @@ #include #else // Workaround for wrongly packaged prebuilt. +#if _MSC_VER >= 1800 +#include +#else #include "libpng15/png.h" #endif +#endif #include "llimage.h" class LLPngWrapper diff --git a/indra/llmath/llmath.h b/indra/llmath/llmath.h index 2908405ea..5009a1c4f 100644 --- a/indra/llmath/llmath.h +++ b/indra/llmath/llmath.h @@ -174,6 +174,7 @@ inline S32 lltrunc( F32 f ) inline S32 lltrunc( F64 f ) { + return (S32)f; } @@ -204,64 +205,35 @@ inline S32 llceil( F32 f ) } -#ifndef BOGUS_ROUND -// Use this round. Does an arithmetic round (0.5 always rounds up) -inline S32 llround(const F32 val) +namespace llmath { - return llfloor(val + 0.5f); -} - -#else // BOGUS_ROUND -// Old llround implementation - does banker's round (toward nearest even in the case of a 0.5. -// Not using this because we don't have a consistent implementation on both platforms, use -// llfloor(val + 0.5f), which is consistent on all platforms. -inline S32 llround(const F32 val) -{ - #if LL_WINDOWS - // Note: assumes that the floating point control word is set to rounding mode (the default) - S32 ret_val; - _asm fld val - _asm fistp ret_val; - return ret_val; - #elif LL_LINUX - // Note: assumes that the floating point control word is set - // to rounding mode (the default) - S32 ret_val; - __asm__ __volatile__( "flds %1 \n\t" - "fistpl %0 \n\t" - : "=m" (ret_val) - : "m" (val) ); - return ret_val; - #else - return llfloor(val + 0.5f); - #endif -} - -// A fast arithmentic round on intel, from Laurent de Soras http://ldesoras.free.fr -inline int round_int(double x) -{ - const float round_to_nearest = 0.5f; - int i; - __asm + // Use this round. Does an arithmetic round (0.5 always rounds up) + inline S32 llround(const F32 val) { - fld x - fadd st, st (0) - fadd round_to_nearest - fistp i - sar i, 1 +#if __cplusplus >= 201103L || _MSC_VER >= 1800 + return S32(std::round(val)); +#else + return llfloor(val + 0.5f); +#endif } - return (i); -} -#endif // BOGUS_ROUND -inline F32 llround( F32 val, F32 nearest ) -{ - return F32(floor(val * (1.0f / nearest) + 0.5f)) * nearest; -} + inline F32 llround(F32 val, F32 nearest) + { +#if __cplusplus >= 201103L || _MSC_VER >= 1800 + return F32(std::round(val * (1.0f / nearest))) * nearest; +#else + return F32(floor(val * (1.0f / nearest) + 0.5f)) * nearest; +#endif + } -inline F64 llround( F64 val, F64 nearest ) -{ - return F64(floor(val * (1.0 / nearest) + 0.5)) * nearest; + inline F64 llround(F64 val, F64 nearest) + { +#if __cplusplus >= 201103L || _MSC_VER >= 1800 + return F64(std::round(val * (1.0 / nearest))) * nearest; +#else + return F64(floor(val * (1.0 / nearest) + 0.5)) * nearest; +#endif + } } // these provide minimum peak error @@ -309,7 +281,7 @@ const S32 LL_SHIFT_AMOUNT = 16; //16.16 fixed point represe #define LL_MAN_INDEX 1 #endif -/* Deprecated: use llround(), lltrunc(), or llfloor() instead +/* Deprecated: use llmath::llround(), lltrunc(), or llfloor() instead // ================================================================================================ // Real2Int // ================================================================================================ @@ -351,7 +323,7 @@ static union #define LL_EXP_A (1048576 * OO_LN2) // use 1512775 for integer #define LL_EXP_C (60801) // this value of C good for -4 < y < 4 -#define LL_FAST_EXP(y) (LLECO.n.i = llround(F32(LL_EXP_A*(y))) + (1072693248 - LL_EXP_C), LLECO.d) +#define LL_FAST_EXP(y) (LLECO.n.i = llmath::llround(F32(LL_EXP_A*(y))) + (1072693248 - LL_EXP_C), LLECO.d) @@ -370,8 +342,8 @@ inline F32 snap_to_sig_figs(F32 foo, S32 sig_figs) bar *= 10.f; } - //F32 new_foo = (F32)llround(foo * bar); - // the llround() implementation sucks. Don't us it. + //F32 new_foo = (F32)llmath::llround(foo * bar); + // the llmath::llround() implementation sucks. Don't us it. F32 sign = (foo > 0.f) ? 1.f : -1.f; F32 new_foo = F32( S64(foo * bar + sign * 0.5f)); diff --git a/indra/llmath/llquantize.h b/indra/llmath/llquantize.h index dd0cf2941..6df9c1fb4 100644 --- a/indra/llmath/llquantize.h +++ b/indra/llmath/llquantize.h @@ -52,7 +52,7 @@ inline U16 F32_to_U16_ROUND(F32 val, F32 lower, F32 upper) val /= (upper - lower); // round the value. Sreturn the U16 - return (U16)(llround(val*U16MAX)); + return (U16)(llmath::llround(val*U16MAX)); } @@ -92,7 +92,7 @@ inline U8 F32_to_U8_ROUND(F32 val, F32 lower, F32 upper) val /= (upper - lower); // return the rounded U8 - return (U8)(llround(val*U8MAX)); + return (U8)(llmath::llround(val*U8MAX)); } diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp index 3b5b2f148..25697eef6 100644 --- a/indra/llmath/llvolume.cpp +++ b/indra/llmath/llvolume.cpp @@ -560,7 +560,7 @@ void LLProfile::genNGon(const LLProfileParams& params, S32 sides, F32 offset, F3 // Scale to have size "match" scale. Compensates to get object to generally fill bounding box. - S32 total_sides = llround(sides / ang_scale); // Total number of sides all around + S32 total_sides = llmath::llround(sides / ang_scale); // Total number of sides all around if (total_sides < 8) { diff --git a/indra/llmath/v4color.cpp b/indra/llmath/v4color.cpp index 9131befd8..6b771c3ad 100644 --- a/indra/llmath/v4color.cpp +++ b/indra/llmath/v4color.cpp @@ -125,10 +125,10 @@ LLColor4 LLColor4::cyan6(0.2f, 0.6f, 0.6f, 1.0f); LLColor4::operator const LLColor4U() const { return LLColor4U( - (U8)llclampb(llround(mV[VRED]*255.f)), - (U8)llclampb(llround(mV[VGREEN]*255.f)), - (U8)llclampb(llround(mV[VBLUE]*255.f)), - (U8)llclampb(llround(mV[VALPHA]*255.f))); + (U8)llclampb(llmath::llround(mV[VRED]*255.f)), + (U8)llclampb(llmath::llround(mV[VGREEN]*255.f)), + (U8)llclampb(llmath::llround(mV[VBLUE]*255.f)), + (U8)llclampb(llmath::llround(mV[VALPHA]*255.f))); } LLColor4::LLColor4(const LLColor3 &vec, F32 a) diff --git a/indra/llmath/v4coloru.h b/indra/llmath/v4coloru.h index fa1295441..5040f0710 100644 --- a/indra/llmath/v4coloru.h +++ b/indra/llmath/v4coloru.h @@ -353,10 +353,10 @@ inline LLColor4U LLColor4U::multAll(const F32 k) { // Round to nearest return LLColor4U( - (U8)llround(mV[VX] * k), - (U8)llround(mV[VY] * k), - (U8)llround(mV[VZ] * k), - (U8)llround(mV[VW] * k)); + (U8)llmath::llround(mV[VX] * k), + (U8)llmath::llround(mV[VY] * k), + (U8)llmath::llround(mV[VZ] * k), + (U8)llmath::llround(mV[VW] * k)); } /* inline LLColor4U operator*(const LLColor4U &a, U8 k) @@ -471,7 +471,7 @@ void LLColor4U::setVecScaleClamp(const LLColor4& color) color_scale_factor /= max_color; } const S32 MAX_COLOR = 255; - S32 r = llround(color.mV[0] * color_scale_factor); + S32 r = llmath::llround(color.mV[0] * color_scale_factor); if (r > MAX_COLOR) { r = MAX_COLOR; @@ -482,7 +482,7 @@ void LLColor4U::setVecScaleClamp(const LLColor4& color) } mV[0] = r; - S32 g = llround(color.mV[1] * color_scale_factor); + S32 g = llmath::llround(color.mV[1] * color_scale_factor); if (g > MAX_COLOR) { g = MAX_COLOR; @@ -493,7 +493,7 @@ void LLColor4U::setVecScaleClamp(const LLColor4& color) } mV[1] = g; - S32 b = llround(color.mV[2] * color_scale_factor); + S32 b = llmath::llround(color.mV[2] * color_scale_factor); if (b > MAX_COLOR) { b = MAX_COLOR; @@ -505,7 +505,7 @@ void LLColor4U::setVecScaleClamp(const LLColor4& color) mV[2] = b; // Alpha shouldn't be scaled, just clamped... - S32 a = llround(color.mV[3] * MAX_COLOR); + S32 a = llmath::llround(color.mV[3] * MAX_COLOR); if (a > MAX_COLOR) { a = MAX_COLOR; @@ -527,7 +527,7 @@ void LLColor4U::setVecScaleClamp(const LLColor3& color) } const S32 MAX_COLOR = 255; - S32 r = llround(color.mV[0] * color_scale_factor); + S32 r = llmath::llround(color.mV[0] * color_scale_factor); if (r > MAX_COLOR) { r = MAX_COLOR; @@ -539,7 +539,7 @@ void LLColor4U::setVecScaleClamp(const LLColor3& color) } mV[0] = r; - S32 g = llround(color.mV[1] * color_scale_factor); + S32 g = llmath::llround(color.mV[1] * color_scale_factor); if (g > MAX_COLOR) { g = MAX_COLOR; @@ -551,7 +551,7 @@ void LLColor4U::setVecScaleClamp(const LLColor3& color) } mV[1] = g; - S32 b = llround(color.mV[2] * color_scale_factor); + S32 b = llmath::llround(color.mV[2] * color_scale_factor); if (b > MAX_COLOR) { b = MAX_COLOR; diff --git a/indra/llmessage/aicurlprivate.h b/indra/llmessage/aicurlprivate.h index fe1ab864c..cd0bdd963 100644 --- a/indra/llmessage/aicurlprivate.h +++ b/indra/llmessage/aicurlprivate.h @@ -466,7 +466,7 @@ class BufferedCurlEasyRequest : public CurlEasyRequest { // Return true when prepRequest was already called and the object has not been // invalidated as a result of calling aborted(). - bool isValid(void) const { return mResponder; } + bool isValid(void) const { return !!mResponder; } // Return the capability type of this request. AICapabilityType capability_type(void) const { llassert(mCapabilityType != number_of_capability_types); return mCapabilityType; } diff --git a/indra/llmessage/llregionhandle.h b/indra/llmessage/llregionhandle.h index c77794e4b..d0c29c54c 100644 --- a/indra/llmessage/llregionhandle.h +++ b/indra/llmessage/llregionhandle.h @@ -73,7 +73,7 @@ inline BOOL to_region_handle(const F32 x_pos, const F32 y_pos, U64 *region_handl } else { - x_int = (U32)llround(x_pos); + x_int = (U32)llmath::llround(x_pos); } if (y_pos < 0.f) { @@ -82,7 +82,7 @@ inline BOOL to_region_handle(const F32 x_pos, const F32 y_pos, U64 *region_handl } else { - y_int = (U32)llround(y_pos); + y_int = (U32)llmath::llround(y_pos); } *region_handle = to_region_handle(x_int, y_int); return TRUE; diff --git a/indra/llmessage/llthrottle.cpp b/indra/llmessage/llthrottle.cpp index 64ebd51fe..b28b9a944 100644 --- a/indra/llmessage/llthrottle.cpp +++ b/indra/llmessage/llthrottle.cpp @@ -391,7 +391,7 @@ BOOL LLThrottleGroup::dynamicAdjust() } mBitsSentThisPeriod[i] = 0; - total += llround(mBitsSentHistory[i]); + total += llmath::llround(mBitsSentHistory[i]); } // Look for busy channels diff --git a/indra/llmessage/message.cpp b/indra/llmessage/message.cpp index b06751886..03ad0d9d1 100644 --- a/indra/llmessage/message.cpp +++ b/indra/llmessage/message.cpp @@ -2765,7 +2765,7 @@ void LLMessageSystem::dumpReceiveCounts() if (mt->mReceiveCount > 0) { LL_INFOS("Messaging") << "Num: " << std::setw(3) << mt->mReceiveCount << " Bytes: " << std::setw(6) << mt->mReceiveBytes - << " Invalid: " << std::setw(3) << mt->mReceiveInvalid << " " << mt->mName << " " << llround(100 * mt->mDecodeTimeThisFrame / mReceiveTime) << "%" << llendl; + << " Invalid: " << std::setw(3) << mt->mReceiveInvalid << " " << mt->mName << " " << llmath::llround(100 * mt->mDecodeTimeThisFrame / mReceiveTime) << "%" << llendl; } } } diff --git a/indra/llplugin/llpluginmessagepipe.cpp b/indra/llplugin/llpluginmessagepipe.cpp index a00cd63e6..cbe3f1226 100644 --- a/indra/llplugin/llpluginmessagepipe.cpp +++ b/indra/llplugin/llpluginmessagepipe.cpp @@ -120,10 +120,11 @@ LLPluginMessagePipe::~LLPluginMessagePipe() bool LLPluginMessagePipe::addMessage(const std::string &message) { // queue the message for later output - LLMutexLock lock(&mOutputMutex); + //LLMutexLock lock(&mOutputMutex); + mOutputMutex.lock(); mOutput += message; mOutput += MESSAGE_DELIMITER; // message separator - + mOutputMutex.unlock(); return true; } diff --git a/indra/llprimitive/llmaterial.cpp b/indra/llprimitive/llmaterial.cpp index cf4c645cf..bfe8301a7 100644 --- a/indra/llprimitive/llmaterial.cpp +++ b/indra/llprimitive/llmaterial.cpp @@ -119,18 +119,18 @@ LLSD LLMaterial::asLLSD() const LLSD material_data; material_data[MATERIALS_CAP_NORMAL_MAP_FIELD] = mNormalID; - material_data[MATERIALS_CAP_NORMAL_MAP_OFFSET_X_FIELD] = llround(mNormalOffsetX * MATERIALS_MULTIPLIER); - material_data[MATERIALS_CAP_NORMAL_MAP_OFFSET_Y_FIELD] = llround(mNormalOffsetY * MATERIALS_MULTIPLIER); - material_data[MATERIALS_CAP_NORMAL_MAP_REPEAT_X_FIELD] = llround(mNormalRepeatX * MATERIALS_MULTIPLIER); - material_data[MATERIALS_CAP_NORMAL_MAP_REPEAT_Y_FIELD] = llround(mNormalRepeatY * MATERIALS_MULTIPLIER); - material_data[MATERIALS_CAP_NORMAL_MAP_ROTATION_FIELD] = llround(mNormalRotation * MATERIALS_MULTIPLIER); + material_data[MATERIALS_CAP_NORMAL_MAP_OFFSET_X_FIELD] = llmath::llround(mNormalOffsetX * MATERIALS_MULTIPLIER); + material_data[MATERIALS_CAP_NORMAL_MAP_OFFSET_Y_FIELD] = llmath::llround(mNormalOffsetY * MATERIALS_MULTIPLIER); + material_data[MATERIALS_CAP_NORMAL_MAP_REPEAT_X_FIELD] = llmath::llround(mNormalRepeatX * MATERIALS_MULTIPLIER); + material_data[MATERIALS_CAP_NORMAL_MAP_REPEAT_Y_FIELD] = llmath::llround(mNormalRepeatY * MATERIALS_MULTIPLIER); + material_data[MATERIALS_CAP_NORMAL_MAP_ROTATION_FIELD] = llmath::llround(mNormalRotation * MATERIALS_MULTIPLIER); material_data[MATERIALS_CAP_SPECULAR_MAP_FIELD] = mSpecularID; - material_data[MATERIALS_CAP_SPECULAR_MAP_OFFSET_X_FIELD] = llround(mSpecularOffsetX * MATERIALS_MULTIPLIER); - material_data[MATERIALS_CAP_SPECULAR_MAP_OFFSET_Y_FIELD] = llround(mSpecularOffsetY * MATERIALS_MULTIPLIER); - material_data[MATERIALS_CAP_SPECULAR_MAP_REPEAT_X_FIELD] = llround(mSpecularRepeatX * MATERIALS_MULTIPLIER); - material_data[MATERIALS_CAP_SPECULAR_MAP_REPEAT_Y_FIELD] = llround(mSpecularRepeatY * MATERIALS_MULTIPLIER); - material_data[MATERIALS_CAP_SPECULAR_MAP_ROTATION_FIELD] = llround(mSpecularRotation * MATERIALS_MULTIPLIER); + material_data[MATERIALS_CAP_SPECULAR_MAP_OFFSET_X_FIELD] = llmath::llround(mSpecularOffsetX * MATERIALS_MULTIPLIER); + material_data[MATERIALS_CAP_SPECULAR_MAP_OFFSET_Y_FIELD] = llmath::llround(mSpecularOffsetY * MATERIALS_MULTIPLIER); + material_data[MATERIALS_CAP_SPECULAR_MAP_REPEAT_X_FIELD] = llmath::llround(mSpecularRepeatX * MATERIALS_MULTIPLIER); + material_data[MATERIALS_CAP_SPECULAR_MAP_REPEAT_Y_FIELD] = llmath::llround(mSpecularRepeatY * MATERIALS_MULTIPLIER); + material_data[MATERIALS_CAP_SPECULAR_MAP_ROTATION_FIELD] = llmath::llround(mSpecularRotation * MATERIALS_MULTIPLIER); material_data[MATERIALS_CAP_SPECULAR_COLOR_FIELD] = mSpecularLightColor.getValue(); material_data[MATERIALS_CAP_SPECULAR_EXP_FIELD] = mSpecularLightExponent; diff --git a/indra/llprimitive/llprimitive.cpp b/indra/llprimitive/llprimitive.cpp index bdf15cb94..e9b7b2f42 100644 --- a/indra/llprimitive/llprimitive.cpp +++ b/indra/llprimitive/llprimitive.cpp @@ -1142,12 +1142,12 @@ BOOL LLPrimitive::packTEMessage(LLMessageSystem *mesgsys) const const LLTextureEntry* te = getTE(face_index); scale_s[face_index] = (F32) te->mScaleS; scale_t[face_index] = (F32) te->mScaleT; - offset_s[face_index] = (S16) llround((llclamp(te->mOffsetS,-1.0f,1.0f) * (F32)0x7FFF)) ; - offset_t[face_index] = (S16) llround((llclamp(te->mOffsetT,-1.0f,1.0f) * (F32)0x7FFF)) ; - image_rot[face_index] = (S16) llround(((fmod(te->mRotation, F_TWO_PI)/F_TWO_PI) * TEXTURE_ROTATION_PACK_FACTOR)); + offset_s[face_index] = (S16) llmath::llround((llclamp(te->mOffsetS,-1.0f,1.0f) * (F32)0x7FFF)) ; + offset_t[face_index] = (S16) llmath::llround((llclamp(te->mOffsetT,-1.0f,1.0f) * (F32)0x7FFF)) ; + image_rot[face_index] = (S16) llmath::llround(((fmod(te->mRotation, F_TWO_PI)/F_TWO_PI) * TEXTURE_ROTATION_PACK_FACTOR)); bump[face_index] = te->getBumpShinyFullbright(); media_flags[face_index] = te->getMediaTexGen(); - glow[face_index] = (U8) llround((llclamp(te->getGlow(), 0.0f, 1.0f) * (F32)0xFF)); + glow[face_index] = (U8) llmath::llround((llclamp(te->getGlow(), 0.0f, 1.0f) * (F32)0xFF)); // Directly sending material_ids is not safe! memcpy(&material_data[face_index*16],getTE(face_index)->getMaterialID().get(),16); /* Flawfinder: ignore */ @@ -1227,12 +1227,12 @@ BOOL LLPrimitive::packTEMessage(LLDataPacker &dp) const const LLTextureEntry* te = getTE(face_index); scale_s[face_index] = (F32) te->mScaleS; scale_t[face_index] = (F32) te->mScaleT; - offset_s[face_index] = (S16) llround((llclamp(te->mOffsetS,-1.0f,1.0f) * (F32)0x7FFF)) ; - offset_t[face_index] = (S16) llround((llclamp(te->mOffsetT,-1.0f,1.0f) * (F32)0x7FFF)) ; - image_rot[face_index] = (S16) llround(((fmod(te->mRotation, F_TWO_PI)/F_TWO_PI) * TEXTURE_ROTATION_PACK_FACTOR)); + offset_s[face_index] = (S16) llmath::llround((llclamp(te->mOffsetS,-1.0f,1.0f) * (F32)0x7FFF)) ; + offset_t[face_index] = (S16) llmath::llround((llclamp(te->mOffsetT,-1.0f,1.0f) * (F32)0x7FFF)) ; + image_rot[face_index] = (S16) llmath::llround(((fmod(te->mRotation, F_TWO_PI)/F_TWO_PI) * TEXTURE_ROTATION_PACK_FACTOR)); bump[face_index] = te->getBumpShinyFullbright(); media_flags[face_index] = te->getMediaTexGen(); - glow[face_index] = (U8) llround((llclamp(te->getGlow(), 0.0f, 1.0f) * (F32)0xFF)); + glow[face_index] = (U8) llmath::llround((llclamp(te->getGlow(), 0.0f, 1.0f) * (F32)0xFF)); // Directly sending material_ids is not safe! memcpy(&material_data[face_index*16],getTE(face_index)->getMaterialID().get(),16); /* Flawfinder: ignore */ diff --git a/indra/llprimitive/llvolumemessage.cpp b/indra/llprimitive/llvolumemessage.cpp index 273ed1b7e..53f035fc3 100644 --- a/indra/llprimitive/llvolumemessage.cpp +++ b/indra/llprimitive/llvolumemessage.cpp @@ -58,13 +58,13 @@ bool LLVolumeMessage::packProfileParams( tempU8 = params->getCurveType(); mesgsys->addU8Fast(_PREHASH_ProfileCurve, tempU8); - tempU16 = (U16) llround( params->getBegin() / CUT_QUANTA); + tempU16 = (U16) llmath::llround( params->getBegin() / CUT_QUANTA); mesgsys->addU16Fast(_PREHASH_ProfileBegin, tempU16); - tempU16 = 50000 - (U16) llround(params->getEnd() / CUT_QUANTA); + tempU16 = 50000 - (U16) llmath::llround(params->getEnd() / CUT_QUANTA); mesgsys->addU16Fast(_PREHASH_ProfileEnd, tempU16); - tempU16 = (U16) llround(params->getHollow() / HOLLOW_QUANTA); + tempU16 = (U16) llmath::llround(params->getHollow() / HOLLOW_QUANTA); mesgsys->addU16Fast(_PREHASH_ProfileHollow, tempU16); return true; @@ -86,13 +86,13 @@ bool LLVolumeMessage::packProfileParams( tempU8 = params->getCurveType(); dp.packU8(tempU8, "Curve"); - tempU16 = (U16) llround( params->getBegin() / CUT_QUANTA); + tempU16 = (U16) llmath::llround( params->getBegin() / CUT_QUANTA); dp.packU16(tempU16, "Begin"); - tempU16 = 50000 - (U16) llround(params->getEnd() / CUT_QUANTA); + tempU16 = 50000 - (U16) llmath::llround(params->getEnd() / CUT_QUANTA); dp.packU16(tempU16, "End"); - tempU16 = (U16) llround(params->getHollow() / HOLLOW_QUANTA); + tempU16 = (U16) llmath::llround(params->getHollow() / HOLLOW_QUANTA); dp.packU16(tempU16, "Hollow"); return true; } @@ -223,46 +223,46 @@ bool LLVolumeMessage::packPathParams( U8 curve = params->getCurveType(); mesgsys->addU8Fast(_PREHASH_PathCurve, curve); - U16 begin = (U16) llround(params->getBegin() / CUT_QUANTA); + U16 begin = (U16) llmath::llround(params->getBegin() / CUT_QUANTA); mesgsys->addU16Fast(_PREHASH_PathBegin, begin); - U16 end = 50000 - (U16) llround(params->getEnd() / CUT_QUANTA); + U16 end = 50000 - (U16) llmath::llround(params->getEnd() / CUT_QUANTA); mesgsys->addU16Fast(_PREHASH_PathEnd, end); // Avoid truncation problem with direct F32->U8 cast. // (e.g., (U8) (0.50 / 0.01) = (U8) 49.9999999 = 49 not 50. - U8 pack_scale_x = 200 - (U8) llround(params->getScaleX() / SCALE_QUANTA); + U8 pack_scale_x = 200 - (U8) llmath::llround(params->getScaleX() / SCALE_QUANTA); mesgsys->addU8Fast(_PREHASH_PathScaleX, pack_scale_x ); - U8 pack_scale_y = 200 - (U8) llround(params->getScaleY() / SCALE_QUANTA); + U8 pack_scale_y = 200 - (U8) llmath::llround(params->getScaleY() / SCALE_QUANTA); mesgsys->addU8Fast(_PREHASH_PathScaleY, pack_scale_y ); - U8 pack_shear_x = (U8) llround(params->getShearX() / SHEAR_QUANTA); + U8 pack_shear_x = (U8) llmath::llround(params->getShearX() / SHEAR_QUANTA); mesgsys->addU8Fast(_PREHASH_PathShearX, pack_shear_x ); - U8 pack_shear_y = (U8) llround(params->getShearY() / SHEAR_QUANTA); + U8 pack_shear_y = (U8) llmath::llround(params->getShearY() / SHEAR_QUANTA); mesgsys->addU8Fast(_PREHASH_PathShearY, pack_shear_y ); - S8 twist = (S8) llround(params->getTwist() / SCALE_QUANTA); + S8 twist = (S8) llmath::llround(params->getTwist() / SCALE_QUANTA); mesgsys->addS8Fast(_PREHASH_PathTwist, twist); - S8 twist_begin = (S8) llround(params->getTwistBegin() / SCALE_QUANTA); + S8 twist_begin = (S8) llmath::llround(params->getTwistBegin() / SCALE_QUANTA); mesgsys->addS8Fast(_PREHASH_PathTwistBegin, twist_begin); - S8 radius_offset = (S8) llround(params->getRadiusOffset() / SCALE_QUANTA); + S8 radius_offset = (S8) llmath::llround(params->getRadiusOffset() / SCALE_QUANTA); mesgsys->addS8Fast(_PREHASH_PathRadiusOffset, radius_offset); - S8 taper_x = (S8) llround(params->getTaperX() / TAPER_QUANTA); + S8 taper_x = (S8) llmath::llround(params->getTaperX() / TAPER_QUANTA); mesgsys->addS8Fast(_PREHASH_PathTaperX, taper_x); - S8 taper_y = (S8) llround(params->getTaperY() / TAPER_QUANTA); + S8 taper_y = (S8) llmath::llround(params->getTaperY() / TAPER_QUANTA); mesgsys->addS8Fast(_PREHASH_PathTaperY, taper_y); - U8 revolutions = (U8) llround( (params->getRevolutions() - 1.0f) / REV_QUANTA); + U8 revolutions = (U8) llmath::llround( (params->getRevolutions() - 1.0f) / REV_QUANTA); mesgsys->addU8Fast(_PREHASH_PathRevolutions, revolutions); - S8 skew = (S8) llround(params->getSkew() / SCALE_QUANTA); + S8 skew = (S8) llmath::llround(params->getSkew() / SCALE_QUANTA); mesgsys->addS8Fast(_PREHASH_PathSkew, skew); return true; @@ -280,46 +280,46 @@ bool LLVolumeMessage::packPathParams( U8 curve = params->getCurveType(); dp.packU8(curve, "Curve"); - U16 begin = (U16) llround(params->getBegin() / CUT_QUANTA); + U16 begin = (U16) llmath::llround(params->getBegin() / CUT_QUANTA); dp.packU16(begin, "Begin"); - U16 end = 50000 - (U16) llround(params->getEnd() / CUT_QUANTA); + U16 end = 50000 - (U16) llmath::llround(params->getEnd() / CUT_QUANTA); dp.packU16(end, "End"); // Avoid truncation problem with direct F32->U8 cast. // (e.g., (U8) (0.50 / 0.01) = (U8) 49.9999999 = 49 not 50. - U8 pack_scale_x = 200 - (U8) llround(params->getScaleX() / SCALE_QUANTA); + U8 pack_scale_x = 200 - (U8) llmath::llround(params->getScaleX() / SCALE_QUANTA); dp.packU8(pack_scale_x, "ScaleX"); - U8 pack_scale_y = 200 - (U8) llround(params->getScaleY() / SCALE_QUANTA); + U8 pack_scale_y = 200 - (U8) llmath::llround(params->getScaleY() / SCALE_QUANTA); dp.packU8(pack_scale_y, "ScaleY"); - S8 pack_shear_x = (S8) llround(params->getShearX() / SHEAR_QUANTA); + S8 pack_shear_x = (S8) llmath::llround(params->getShearX() / SHEAR_QUANTA); dp.packU8(*(U8 *)&pack_shear_x, "ShearX"); - S8 pack_shear_y = (S8) llround(params->getShearY() / SHEAR_QUANTA); + S8 pack_shear_y = (S8) llmath::llround(params->getShearY() / SHEAR_QUANTA); dp.packU8(*(U8 *)&pack_shear_y, "ShearY"); - S8 twist = (S8) llround(params->getTwist() / SCALE_QUANTA); + S8 twist = (S8) llmath::llround(params->getTwist() / SCALE_QUANTA); dp.packU8(*(U8 *)&twist, "Twist"); - S8 twist_begin = (S8) llround(params->getTwistBegin() / SCALE_QUANTA); + S8 twist_begin = (S8) llmath::llround(params->getTwistBegin() / SCALE_QUANTA); dp.packU8(*(U8 *)&twist_begin, "TwistBegin"); - S8 radius_offset = (S8) llround(params->getRadiusOffset() / SCALE_QUANTA); + S8 radius_offset = (S8) llmath::llround(params->getRadiusOffset() / SCALE_QUANTA); dp.packU8(*(U8 *)&radius_offset, "RadiusOffset"); - S8 taper_x = (S8) llround(params->getTaperX() / TAPER_QUANTA); + S8 taper_x = (S8) llmath::llround(params->getTaperX() / TAPER_QUANTA); dp.packU8(*(U8 *)&taper_x, "TaperX"); - S8 taper_y = (S8) llround(params->getTaperY() / TAPER_QUANTA); + S8 taper_y = (S8) llmath::llround(params->getTaperY() / TAPER_QUANTA); dp.packU8(*(U8 *)&taper_y, "TaperY"); - U8 revolutions = (U8) llround( (params->getRevolutions() - 1.0f) / REV_QUANTA); + U8 revolutions = (U8) llmath::llround( (params->getRevolutions() - 1.0f) / REV_QUANTA); dp.packU8(*(U8 *)&revolutions, "Revolutions"); - S8 skew = (S8) llround(params->getSkew() / SCALE_QUANTA); + S8 skew = (S8) llmath::llround(params->getSkew() / SCALE_QUANTA); dp.packU8(*(U8 *)&skew, "Skew"); return true; diff --git a/indra/llrender/llfontfreetype.cpp b/indra/llrender/llfontfreetype.cpp index 30b0ed429..f2839bb67 100644 --- a/indra/llrender/llfontfreetype.cpp +++ b/indra/llrender/llfontfreetype.cpp @@ -184,8 +184,8 @@ BOOL LLFontFreetype::loadFace(const std::string& filename, const F32 point_size, mDescender = -mFTFace->descender * pixels_per_unit; mLineHeight = mFTFace->height * pixels_per_unit; - S32 max_char_width = llround(0.5f + (x_max - x_min)); - S32 max_char_height = llround(0.5f + (y_max - y_min)); + S32 max_char_width = llmath::llround(0.5f + (x_max - x_min)); + S32 max_char_height = llmath::llround(0.5f + (y_max - y_min)); mFontBitmapCachep->init(components, max_char_width, max_char_height); diff --git a/indra/llrender/llfontgl.cpp b/indra/llrender/llfontgl.cpp index 31d48f2ab..4c03726b7 100644 --- a/indra/llrender/llfontgl.cpp +++ b/indra/llrender/llfontgl.cpp @@ -230,10 +230,10 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons case LEFT: break; case RIGHT: - cur_x -= llmin(scaled_max_pixels, llround(getWidthF32(wstr.c_str(), begin_offset, length) * sScaleX)); + cur_x -= llmin(scaled_max_pixels, llmath::llround(getWidthF32(wstr.c_str(), begin_offset, length) * sScaleX)); break; case HCENTER: - cur_x -= llmin(scaled_max_pixels, llround(getWidthF32(wstr.c_str(), begin_offset, length) * sScaleX)) / 2; + cur_x -= llmin(scaled_max_pixels, llmath::llround(getWidthF32(wstr.c_str(), begin_offset, length) * sScaleX)) / 2; break; default: break; @@ -242,7 +242,7 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons cur_render_y = cur_y; cur_render_x = cur_x; - F32 start_x = (F32)llround(cur_x); + F32 start_x = (F32)llmath::llround(cur_x); const LLFontBitmapCache* font_bitmap_cache = mFontFreetype->getFontBitmapCache(); @@ -256,12 +256,12 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons if (use_ellipses && halign == LEFT) { // check for too long of a string - S32 string_width = llround(getWidthF32(wstr.c_str(), begin_offset, max_chars) * sScaleX); + S32 string_width = llmath::llround(getWidthF32(wstr.c_str(), begin_offset, max_chars) * sScaleX); if (string_width > scaled_max_pixels) { // use four dots for ellipsis width to generate padding const LLWString dots(utf8str_to_wstring(std::string("...."))); - scaled_max_pixels = llmax(0, scaled_max_pixels - llround(getWidthF32(dots.c_str()))); + scaled_max_pixels = llmax(0, scaled_max_pixels - llmath::llround(getWidthF32(dots.c_str()))); draw_ellipses = TRUE; } } @@ -308,8 +308,8 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons gGL.getTexUnit(0)->bind(ext_image); // snap origin to whole screen pixel - const F32 ext_x = (F32)llround(cur_render_x + (EXT_X_BEARING * sScaleX)); - const F32 ext_y = (F32)llround(cur_render_y + (EXT_Y_BEARING * sScaleY + mFontFreetype->getAscenderHeight() - mFontFreetype->getLineHeight())); + const F32 ext_x = (F32)llmath::llround(cur_render_x + (EXT_X_BEARING * sScaleX)); + const F32 ext_y = (F32)llmath::llround(cur_render_y + (EXT_Y_BEARING * sScaleY + mFontFreetype->getAscenderHeight() - mFontFreetype->getLineHeight())); LLRectf uv_rect(0.f, 1.f, 1.f, 0.f); LLRectf screen_rect(ext_x, ext_y + ext_height, ext_x + ext_width, ext_y); @@ -398,10 +398,10 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons (fgi->mXBitmapOffset + fgi->mWidth) * inv_width, (fgi->mYBitmapOffset - PAD_UVY) * inv_height); // snap glyph origin to whole screen pixel - LLRectf screen_rect((F32)llround(cur_render_x + (F32)fgi->mXBearing), - (F32)llround(cur_render_y + (F32)fgi->mYBearing), - (F32)llround(cur_render_x + (F32)fgi->mXBearing) + (F32)fgi->mWidth, - (F32)llround(cur_render_y + (F32)fgi->mYBearing) - (F32)fgi->mHeight); + LLRectf screen_rect((F32)llmath::llround(cur_render_x + (F32)fgi->mXBearing), + (F32)llmath::llround(cur_render_y + (F32)fgi->mYBearing), + (F32)llmath::llround(cur_render_x + (F32)fgi->mXBearing) + (F32)fgi->mWidth, + (F32)llmath::llround(cur_render_y + (F32)fgi->mYBearing) - (F32)fgi->mHeight); if (glyph_count >= GLYPH_BATCH_SIZE) { @@ -432,8 +432,8 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons // Must do this to cur_x, not just to cur_render_x, otherwise you // will squish sub-pixel kerned characters too close together. // For example, "CCCCC" looks bad. - cur_x = (F32)llround(cur_x); - //cur_y = (F32)llround(cur_y); + cur_x = (F32)llmath::llround(cur_x); + //cur_y = (F32)llmath::llround(cur_y); cur_render_x = cur_x; cur_render_y = cur_y; @@ -523,7 +523,7 @@ F32 LLFontGL::getDescenderHeight() const F32 LLFontGL::getLineHeight() const { - return (F32)llround(mFontFreetype->getLineHeight() / sScaleY); + return (F32)llmath::llround(mFontFreetype->getLineHeight() / sScaleY); } S32 LLFontGL::getWidth(const std::string& utf8text) const @@ -546,7 +546,7 @@ S32 LLFontGL::getWidth(const std::string& utf8text, const S32 begin_offset, cons S32 LLFontGL::getWidth(const llwchar* wchars, const S32 begin_offset, const S32 max_chars, BOOL use_embedded) const { F32 width = getWidthF32(wchars, begin_offset, max_chars, use_embedded); - return llround(width); + return llmath::llround(width); } F32 LLFontGL::getWidthF32(const std::string& utf8text) const @@ -620,7 +620,7 @@ F32 LLFontGL::getWidthF32(const llwchar* wchars, const S32 begin_offset, const S cur_x += mFontFreetype->getXKerning(fgi, next_glyph); } // Round after kerning. - cur_x = (F32)llround(cur_x); + cur_x = (F32)llmath::llround(cur_x); } } @@ -749,7 +749,7 @@ S32 LLFontGL::maxDrawableChars(const llwchar* wchars, F32 max_pixels, S32 max_ch } } // Round after kerning. - cur_x = (F32)llround(cur_x); + cur_x = (F32)llmath::llround(cur_x); drawn_x = cur_x; } @@ -837,7 +837,7 @@ S32 LLFontGL::firstDrawableChar(const llwchar* wchars, F32 max_pixels, S32 text_ } // Round after kerning. - total_width = (F32)llround(total_width); + total_width = (F32)llmath::llround(total_width); } if (drawable_chars == 0) @@ -929,7 +929,7 @@ S32 LLFontGL::charFromPixelOffset(const llwchar* wchars, const S32 begin_offset, // Round after kerning. - cur_x = (F32)llround(cur_x); + cur_x = (F32)llmath::llround(cur_x); } diff --git a/indra/llrender/llpostprocess.cpp b/indra/llrender/llpostprocess.cpp index 18be01d24..4a2ad8302 100644 --- a/indra/llrender/llpostprocess.cpp +++ b/indra/llrender/llpostprocess.cpp @@ -637,8 +637,8 @@ void LLPostProcess::drawOrthoQuad(QuadType type) mVBO->getTexCoord1Strider(uv2); float offs[2] = { - llround(((float) rand() / (float) RAND_MAX) * (float)NOISE_SIZE)/float(NOISE_SIZE), - llround(((float) rand() / (float) RAND_MAX) * (float)NOISE_SIZE)/float(NOISE_SIZE) }; + llmath::llround(((float) rand() / (float) RAND_MAX) * (float)NOISE_SIZE)/float(NOISE_SIZE), + llmath::llround(((float) rand() / (float) RAND_MAX) * (float)NOISE_SIZE)/float(NOISE_SIZE) }; float scale[2] = { (float)mScreenWidth * mNoiseTextureScale, (float)mScreenHeight * mNoiseTextureScale }; diff --git a/indra/llrender/llrender2dutils.cpp b/indra/llrender/llrender2dutils.cpp index 7ab223f4d..f8b54ee68 100644 --- a/indra/llrender/llrender2dutils.cpp +++ b/indra/llrender/llrender2dutils.cpp @@ -401,8 +401,8 @@ void gl_draw_scaled_image_with_border(S32 x, S32 y, S32 width, S32 height, LLTex F32 image_width = image->getWidth(0); F32 image_height = image->getHeight(0); - S32 image_natural_width = llround(image_width * uv_width); - S32 image_natural_height = llround(image_height * uv_height); + S32 image_natural_width = llmath::llround(image_width * uv_width); + S32 image_natural_height = llmath::llround(image_height * uv_height); LLRectf draw_center_rect( uv_center_rect.mLeft * image_width, uv_center_rect.mTop * image_height, @@ -421,10 +421,10 @@ void gl_draw_scaled_image_with_border(S32 x, S32 y, S32 width, S32 height, LLTex F32 shrink_scale = 1.f - llmax(shrink_width_ratio, shrink_height_ratio); - draw_center_rect.mLeft = llround(ui_translation.mV[VX] + (F32)draw_center_rect.mLeft * shrink_scale * ui_scale.mV[VX]); - draw_center_rect.mTop = llround(ui_translation.mV[VY] + lerp((F32)height, (F32)draw_center_rect.mTop, shrink_scale) * ui_scale.mV[VY]); - draw_center_rect.mRight = llround(ui_translation.mV[VX] + lerp((F32)width, (F32)draw_center_rect.mRight, shrink_scale) * ui_scale.mV[VX]); - draw_center_rect.mBottom = llround(ui_translation.mV[VY] + (F32)draw_center_rect.mBottom * shrink_scale * ui_scale.mV[VY]); + draw_center_rect.mLeft = llmath::llround(ui_translation.mV[VX] + (F32)draw_center_rect.mLeft * shrink_scale * ui_scale.mV[VX]); + draw_center_rect.mTop = llmath::llround(ui_translation.mV[VY] + lerp((F32)height, (F32)draw_center_rect.mTop, shrink_scale) * ui_scale.mV[VY]); + draw_center_rect.mRight = llmath::llround(ui_translation.mV[VX] + lerp((F32)width, (F32)draw_center_rect.mRight, shrink_scale) * ui_scale.mV[VX]); + draw_center_rect.mBottom = llmath::llround(ui_translation.mV[VY] + (F32)draw_center_rect.mBottom * shrink_scale * ui_scale.mV[VY]); } LLRectf draw_outer_rect(ui_translation.mV[VX], @@ -664,8 +664,8 @@ void gl_draw_scaled_rotated_image(S32 x, S32 y, S32 width, S32 height, F32 degre ui_translation.mV[VY] += y; ui_translation.scaleVec(ui_scale); S32 index = 0; - S32 scaled_width = llround(width * ui_scale.mV[VX]); - S32 scaled_height = llround(height * ui_scale.mV[VY]); + S32 scaled_width = llmath::llround(width * ui_scale.mV[VX]); + S32 scaled_height = llmath::llround(height * ui_scale.mV[VY]); uv[index] = LLVector2(uv_rect.mRight, uv_rect.mTop); pos[index].set(ui_translation.mV[VX] + scaled_width, ui_translation.mV[VY] + scaled_height, 0.f); diff --git a/indra/llrender/lluiimage.cpp b/indra/llrender/lluiimage.cpp index da122425c..7aa750756 100644 --- a/indra/llrender/lluiimage.cpp +++ b/indra/llrender/lluiimage.cpp @@ -115,13 +115,13 @@ void LLUIImage::drawBorder(S32 x, S32 y, S32 width, S32 height, const LLColor4& S32 LLUIImage::getWidth() const { // return clipped dimensions of actual image area - return llround((F32)mImage->getWidth(0) * mClipRegion.getWidth()); + return llmath::llround((F32)mImage->getWidth(0) * mClipRegion.getWidth()); } S32 LLUIImage::getHeight() const { // return clipped dimensions of actual image area - return llround((F32)mImage->getHeight(0) * mClipRegion.getHeight()); + return llmath::llround((F32)mImage->getHeight(0) * mClipRegion.getHeight()); } S32 LLUIImage::getTextureWidth() const diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp index 1b9add0a4..ed318c473 100644 --- a/indra/llui/llbutton.cpp +++ b/indra/llui/llbutton.cpp @@ -536,8 +536,8 @@ void LLButton::getOverlayImageSize(S32& overlay_width, S32& overlay_height) overlay_height = mImageOverlay->getHeight(); F32 scale_factor = llmin((F32)getRect().getWidth() / (F32)overlay_width, (F32)getRect().getHeight() / (F32)overlay_height, 1.f); - overlay_width = llround((F32)overlay_width * scale_factor); - overlay_height = llround((F32)overlay_height * scale_factor); + overlay_width = llmath::llround((F32)overlay_width * scale_factor); + overlay_height = llmath::llround((F32)overlay_height * scale_factor); } @@ -696,7 +696,7 @@ void LLButton::draw() if (hasFocus()) { F32 lerp_amt = gFocusMgr.getFocusFlashAmt(); - drawBorder(imagep, gFocusMgr.getFocusColor() % alpha, llround(lerp(1.f, 3.f, lerp_amt))); + drawBorder(imagep, gFocusMgr.getFocusColor() % alpha, llmath::llround(lerp(1.f, 3.f, lerp_amt))); } if (use_glow_effect) @@ -981,7 +981,7 @@ void LLButton::resize(LLUIString label) { S32 overlay_width = mImageOverlay->getWidth(); F32 scale_factor = (getRect().getHeight() - (mImageOverlayBottomPad + mImageOverlayTopPad)) / (F32)mImageOverlay->getHeight(); - overlay_width = llround((F32)overlay_width * scale_factor); + overlay_width = llmath::llround((F32)overlay_width * scale_factor); switch(mImageOverlayAlignment) { diff --git a/indra/llui/llcheckboxctrl.cpp b/indra/llui/llcheckboxctrl.cpp index ada81b639..caf81cd14 100644 --- a/indra/llui/llcheckboxctrl.cpp +++ b/indra/llui/llcheckboxctrl.cpp @@ -83,7 +83,7 @@ LLCheckBoxCtrl::LLCheckBoxCtrl(const std::string& name, const LLRect& rect, // Label (add a little space to make sure text actually renders) const S32 FUDGE = 10; S32 text_width = mFont->getWidth( label ) + FUDGE; - S32 text_height = llround(mFont->getLineHeight()); + S32 text_height = llmath::llround(mFont->getLineHeight()); LLRect label_rect; label_rect.setOriginAndSize( LLCHECKBOXCTRL_HPAD + LLCHECKBOXCTRL_BTN_SIZE + LLCHECKBOXCTRL_SPACING, @@ -187,7 +187,7 @@ void LLCheckBoxCtrl::reshape(S32 width, S32 height, BOOL called_from_parent) //stretch or shrink bounding rectangle of label when rebuilding UI at new scale const S32 FUDGE = 10; S32 text_width = mFont->getWidth( mLabel->getText() ) + FUDGE; - S32 text_height = llround(mFont->getLineHeight()); + S32 text_height = llmath::llround(mFont->getLineHeight()); LLRect label_rect; label_rect.setOriginAndSize( LLCHECKBOXCTRL_HPAD + LLCHECKBOXCTRL_BTN_SIZE + LLCHECKBOXCTRL_SPACING, diff --git a/indra/llui/lldraghandle.cpp b/indra/llui/lldraghandle.cpp index 33f1a1a1c..de5cbbe7a 100644 --- a/indra/llui/lldraghandle.cpp +++ b/indra/llui/lldraghandle.cpp @@ -247,7 +247,7 @@ void LLDragHandleTop::reshapeTitleBox() S32 title_width = font->getWidth( getTitleBox()->getText() ) + TITLE_PAD; if (getMaxTitleWidth() > 0) title_width = llmin(title_width, getMaxTitleWidth()); - S32 title_height = llround(font->getLineHeight()); + S32 title_height = llmath::llround(font->getLineHeight()); LLRect title_rect; title_rect.setLeftTopAndSize( LEFT_PAD, diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp index e3da1a9d6..f226af189 100644 --- a/indra/llui/llfloater.cpp +++ b/indra/llui/llfloater.cpp @@ -1449,7 +1449,7 @@ void LLFloater::draw() } gl_drop_shadow(left, top, right, bottom, shadow_color, - llround(shadow_offset)); + llmath::llround(shadow_offset)); // No transparent windows in simple UI if (isBackgroundOpaque()) @@ -1614,16 +1614,16 @@ void LLFloater::updateButtons() btn_rect.setLeftTopAndSize( LLPANEL_BORDER_WIDTH, getRect().getHeight() - CLOSE_BOX_FROM_TOP - (LLFLOATER_CLOSE_BOX_SIZE + 1) * button_count, - llround((F32)LLFLOATER_CLOSE_BOX_SIZE * mButtonScale), - llround((F32)LLFLOATER_CLOSE_BOX_SIZE * mButtonScale)); + llmath::llround((F32)LLFLOATER_CLOSE_BOX_SIZE * mButtonScale), + llmath::llround((F32)LLFLOATER_CLOSE_BOX_SIZE * mButtonScale)); } else { btn_rect.setLeftTopAndSize( getRect().getWidth() - LLPANEL_BORDER_WIDTH - (LLFLOATER_CLOSE_BOX_SIZE + 1) * button_count, getRect().getHeight() - CLOSE_BOX_FROM_TOP, - llround((F32)LLFLOATER_CLOSE_BOX_SIZE * mButtonScale), - llround((F32)LLFLOATER_CLOSE_BOX_SIZE * mButtonScale)); + llmath::llround((F32)LLFLOATER_CLOSE_BOX_SIZE * mButtonScale), + llmath::llround((F32)LLFLOATER_CLOSE_BOX_SIZE * mButtonScale)); } mButtons[i]->setRect(btn_rect); @@ -1650,16 +1650,16 @@ void LLFloater::buildButtons() btn_rect.setLeftTopAndSize( LLPANEL_BORDER_WIDTH, getRect().getHeight() - CLOSE_BOX_FROM_TOP - (LLFLOATER_CLOSE_BOX_SIZE + 1) * (i + 1), - llround(LLFLOATER_CLOSE_BOX_SIZE * mButtonScale), - llround(LLFLOATER_CLOSE_BOX_SIZE * mButtonScale)); + llmath::llround(LLFLOATER_CLOSE_BOX_SIZE * mButtonScale), + llmath::llround(LLFLOATER_CLOSE_BOX_SIZE * mButtonScale)); } else { btn_rect.setLeftTopAndSize( getRect().getWidth() - LLPANEL_BORDER_WIDTH - (LLFLOATER_CLOSE_BOX_SIZE + 1) * (i + 1), getRect().getHeight() - CLOSE_BOX_FROM_TOP, - llround(LLFLOATER_CLOSE_BOX_SIZE * mButtonScale), - llround(LLFLOATER_CLOSE_BOX_SIZE * mButtonScale)); + llmath::llround(LLFLOATER_CLOSE_BOX_SIZE * mButtonScale), + llmath::llround(LLFLOATER_CLOSE_BOX_SIZE * mButtonScale)); } LLButton* buttonp = new LLButton( diff --git a/indra/llui/llfocusmgr.h b/indra/llui/llfocusmgr.h index 7e5e50dfb..fd09bf55f 100644 --- a/indra/llui/llfocusmgr.h +++ b/indra/llui/llfocusmgr.h @@ -94,7 +94,7 @@ public: F32 getFocusTime() const { return mFocusFlashTimer.getElapsedTimeF32(); } F32 getFocusFlashAmt() const; - S32 getFocusFlashWidth() const { return llround(lerp(1.f, 3.f, getFocusFlashAmt())); } + S32 getFocusFlashWidth() const { return llmath::llround(lerp(1.f, 3.f, getFocusFlashAmt())); } LLColor4 getFocusColor() const; void triggerFocusFlash(); BOOL getAppHasFocus() const { return mAppHasFocus; } diff --git a/indra/llui/lllayoutstack.cpp b/indra/llui/lllayoutstack.cpp index db3921460..b3efdf5d9 100644 --- a/indra/llui/lllayoutstack.cpp +++ b/indra/llui/lllayoutstack.cpp @@ -122,7 +122,7 @@ F32 LLLayoutPanel::getVisibleAmount() const S32 LLLayoutPanel::getLayoutDim() const { - return llround((F32)((mOrientation == LLLayoutStack::HORIZONTAL) + return llmath::llround((F32)((mOrientation == LLLayoutStack::HORIZONTAL) ? getRect().getWidth() : getRect().getHeight())); } @@ -149,7 +149,7 @@ void LLLayoutPanel::setTargetDim(S32 value) S32 LLLayoutPanel::getVisibleDim() const { F32 min_dim = getRelevantMinDim(); - return llround(mVisibleAmt + return llmath::llround(mVisibleAmt * (min_dim + (((F32)mTargetDim - min_dim) * (1.f - mCollapseAmt)))); } @@ -157,7 +157,7 @@ S32 LLLayoutPanel::getVisibleDim() const void LLLayoutPanel::setOrientation( LLLayoutStack::ELayoutOrientation orientation ) { mOrientation = orientation; - S32 layout_dim = llround((F32)((mOrientation == LLLayoutStack::HORIZONTAL) + S32 layout_dim = llmath::llround((F32)((mOrientation == LLLayoutStack::HORIZONTAL) ? getRect().getWidth() : getRect().getHeight())); @@ -374,14 +374,14 @@ void LLLayoutStack::updateLayout() { panelp->mTargetDim = panelp->getRelevantMinDim(); } - space_to_distribute -= panelp->getVisibleDim() + llround((F32)mPanelSpacing * panelp->getVisibleAmount()); + space_to_distribute -= panelp->getVisibleDim() + llmath::llround((F32)mPanelSpacing * panelp->getVisibleAmount()); total_visible_fraction += panelp->mFractionalSize * panelp->getAutoResizeFactor(); } llassert(total_visible_fraction < 1.05f); // don't need spacing after last panel - space_to_distribute += panelp ? llround((F32)mPanelSpacing * panelp->getVisibleAmount()) : 0; + space_to_distribute += panelp ? llmath::llround((F32)mPanelSpacing * panelp->getVisibleAmount()) : 0; S32 remaining_space = space_to_distribute; F32 fraction_distributed = 0.f; @@ -392,7 +392,7 @@ void LLLayoutStack::updateLayout() if (panelp->mAutoResize) { F32 fraction_to_distribute = (panelp->mFractionalSize * panelp->getAutoResizeFactor()) / (total_visible_fraction); - S32 delta = llround((F32)space_to_distribute * fraction_to_distribute); + S32 delta = llmath::llround((F32)space_to_distribute * fraction_to_distribute); fraction_distributed += fraction_to_distribute; panelp->mTargetDim += delta; remaining_space -= delta; @@ -425,17 +425,17 @@ void LLLayoutStack::updateLayout() LLRect panel_rect; if (mOrientation == HORIZONTAL) { - panel_rect.setLeftTopAndSize(llround(cur_pos), + panel_rect.setLeftTopAndSize(llmath::llround(cur_pos), getRect().getHeight(), - llround(panel_dim), + llmath::llround(panel_dim), getRect().getHeight()); } else { panel_rect.setLeftTopAndSize(0, - llround(cur_pos), + llmath::llround(cur_pos), getRect().getWidth(), - llround(panel_dim)); + llmath::llround(panel_dim)); } panelp->setIgnoreReshape(true); panelp->setShape(panel_rect); @@ -447,14 +447,14 @@ void LLLayoutStack::updateLayout() if (mOrientation == HORIZONTAL) { resize_bar_rect.mLeft = panel_rect.mRight - mResizeBarOverlap; - resize_bar_rect.mRight = panel_rect.mRight + (S32)(llround(panel_spacing)) + mResizeBarOverlap; + resize_bar_rect.mRight = panel_rect.mRight + (S32)(llmath::llround(panel_spacing)) + mResizeBarOverlap; cur_pos += panel_visible_dim + panel_spacing; } else //VERTICAL { resize_bar_rect.mTop = panel_rect.mBottom + mResizeBarOverlap; - resize_bar_rect.mBottom = panel_rect.mBottom - (S32)(llround(panel_spacing)) - mResizeBarOverlap; + resize_bar_rect.mBottom = panel_rect.mBottom - (S32)(llmath::llround(panel_spacing)) - mResizeBarOverlap; cur_pos -= panel_visible_dim + panel_spacing; } diff --git a/indra/llui/lllineeditor.cpp b/indra/llui/lllineeditor.cpp index 6276c0f50..311003b6b 100644 --- a/indra/llui/lllineeditor.cpp +++ b/indra/llui/lllineeditor.cpp @@ -512,7 +512,7 @@ std::vector LLLineEditor::getMisspelledWordsPositions() { //misspelled word here, and you have just right clicked on it! //get the center of this word.. - //S32 center = llround( (wordEnd-wordStart)/2 ) + wordStart; + //S32 center = llmath::llround( (wordEnd-wordStart)/2 ) + wordStart; //turn this cursor position into a pixel pos //center = findPixelNearestPos(center-getCursor()); @@ -769,7 +769,7 @@ BOOL LLLineEditor::handleHover(S32 x, S32 y, MASK mask) // Scroll if mouse cursor outside of bounds if (mScrollTimer.hasExpired()) { - S32 increment = llround(mScrollTimer.getElapsedTimeF32() / AUTO_SCROLL_TIME); + S32 increment = llmath::llround(mScrollTimer.getElapsedTimeF32() / AUTO_SCROLL_TIME); mScrollTimer.reset(AUTO_SCROLL_TIME); if( (x < mMinHPixels) && (mScrollHPos > 0 ) ) { @@ -1929,7 +1929,7 @@ void LLLineEditor::draw() LLFontGL::NORMAL, LLFontGL::NO_SHADOW, select_left - mScrollHPos, - mMaxHPixels - llround(rendered_pixels_right), + mMaxHPixels - llmath::llround(rendered_pixels_right), &rendered_pixels_right); } @@ -1938,8 +1938,8 @@ void LLLineEditor::draw() LLColor4 color(1.f - bg_color.mV[0], 1.f - bg_color.mV[1], 1.f - bg_color.mV[2], alpha ); // selected middle S32 width = mGLFont->getWidth(mText.getWString().c_str(), mScrollHPos + rendered_text, select_right - mScrollHPos - rendered_text); - width = llmin(width, mMaxHPixels - llround(rendered_pixels_right)); - gl_rect_2d(llround(rendered_pixels_right), cursor_top, llround(rendered_pixels_right)+width, cursor_bottom, color); + width = llmin(width, mMaxHPixels - llmath::llround(rendered_pixels_right)); + gl_rect_2d(llmath::llround(rendered_pixels_right), cursor_top, llmath::llround(rendered_pixels_right)+width, cursor_bottom, color); LLColor4 tmp_color( 1.f - text_color.mV[0], 1.f - text_color.mV[1], 1.f - text_color.mV[2], alpha ); rendered_text += mGLFont->render( @@ -1950,7 +1950,7 @@ void LLLineEditor::draw() LLFontGL::NORMAL, LLFontGL::NO_SHADOW, select_right - mScrollHPos - rendered_text, - mMaxHPixels - llround(rendered_pixels_right), + mMaxHPixels - llmath::llround(rendered_pixels_right), &rendered_pixels_right); } @@ -1965,7 +1965,7 @@ void LLLineEditor::draw() LLFontGL::NORMAL, LLFontGL::NO_SHADOW, S32_MAX, - mMaxHPixels - llround(rendered_pixels_right), + mMaxHPixels - llmath::llround(rendered_pixels_right), &rendered_pixels_right); } } @@ -1979,7 +1979,7 @@ void LLLineEditor::draw() LLFontGL::NORMAL, LLFontGL::NO_SHADOW, S32_MAX, - mMaxHPixels - llround(rendered_pixels_right), + mMaxHPixels - llmath::llround(rendered_pixels_right), &rendered_pixels_right); } #if 0 // for when we're ready for image art. @@ -2047,7 +2047,7 @@ void LLLineEditor::draw() LLFontGL::NORMAL, LLFontGL::NO_SHADOW, S32_MAX, - mMaxHPixels - llround(rendered_pixels_right), + mMaxHPixels - llmath::llround(rendered_pixels_right), &rendered_pixels_right, FALSE); } @@ -2072,7 +2072,7 @@ void LLLineEditor::draw() LLFontGL::NORMAL, LLFontGL::NO_SHADOW, S32_MAX, - mMaxHPixels - llround(rendered_pixels_right), + mMaxHPixels - llmath::llround(rendered_pixels_right), &rendered_pixels_right, FALSE); } // Draw children (border) @@ -3021,7 +3021,7 @@ void LLLineEditor::markAsPreedit(S32 position, S32 length) S32 LLLineEditor::getPreeditFontSize() const { - return llround(mGLFont->getLineHeight() * LLUI::getScaleFactor().mV[VY]); + return llmath::llround(mGLFont->getLineHeight() * LLUI::getScaleFactor().mV[VY]); } void LLLineEditor::setReplaceNewlinesWithSpaces(BOOL replace) diff --git a/indra/llui/llmenugl.cpp b/indra/llui/llmenugl.cpp index 039c7a789..b35913d6d 100644 --- a/indra/llui/llmenugl.cpp +++ b/indra/llui/llmenugl.cpp @@ -342,7 +342,7 @@ void LLMenuItemGL::setJumpKey(KEY key) // virtual U32 LLMenuItemGL::getNominalHeight( void ) const { - return llround(mFont->getLineHeight()) + MENU_ITEM_PADDING; + return llmath::llround(mFont->getLineHeight()) + MENU_ITEM_PADDING; } //virtual @@ -1826,7 +1826,7 @@ void LLMenuItemBranchDownGL::draw( void ) std::string::size_type offset = upper_case_label.find(getJumpKey()); if (offset != std::string::npos) { - S32 x_offset = llround((F32)getRect().getWidth() / 2.f - getFont()->getWidthF32(mLabel.getString(), 0, S32_MAX) / 2.f); + S32 x_offset = llmath::llround((F32)getRect().getWidth() / 2.f - getFont()->getWidthF32(mLabel.getString(), 0, S32_MAX) / 2.f); S32 x_begin = x_offset + getFont()->getWidth(mLabel, 0, offset); S32 x_end = x_offset + getFont()->getWidth(mLabel, 0, offset + 1); gl_line_2d(x_begin, LABEL_BOTTOM_PAD_PIXELS, x_end, LABEL_BOTTOM_PAD_PIXELS); @@ -2660,7 +2660,7 @@ void LLMenuGL::arrange( void ) // *FIX: create the item first and then ask for its dimensions? S32 spillover_item_width = PLAIN_PAD_PIXELS + LLFontGL::getFontSansSerif()->getWidth( std::string("More") ); // *TODO: Translate - S32 spillover_item_height = llround(LLFontGL::getFontSansSerif()->getLineHeight()) + MENU_ITEM_PADDING; + S32 spillover_item_height = llmath::llround(LLFontGL::getFontSansSerif()->getLineHeight()) + MENU_ITEM_PADDING; // Scrolling support item_list_t::iterator first_visible_item_iter; @@ -3588,8 +3588,8 @@ BOOL LLMenuGL::handleHover( S32 x, S32 y, MASK mask ) LLVector2 mouse_avg_dir((F32)mMouseVelX, (F32)mMouseVelY); mouse_avg_dir.normVec(); F32 interp = 0.5f * (llclamp(mouse_dir * mouse_avg_dir, 0.f, 1.f)); - mMouseVelX = llround(lerp((F32)mouse_delta_x, (F32)mMouseVelX, interp)); - mMouseVelY = llround(lerp((F32)mouse_delta_y, (F32)mMouseVelY, interp)); + mMouseVelX = llmath::llround(lerp((F32)mouse_delta_x, (F32)mMouseVelX, interp)); + mMouseVelY = llmath::llround(lerp((F32)mouse_delta_y, (F32)mMouseVelY, interp)); mLastMouseX = x; mLastMouseY = y; diff --git a/indra/llui/llmodaldialog.cpp b/indra/llui/llmodaldialog.cpp index 8c8f94113..e210d856e 100644 --- a/indra/llui/llmodaldialog.cpp +++ b/indra/llui/llmodaldialog.cpp @@ -292,7 +292,7 @@ void LLModalDialog::draw() void LLModalDialog::centerOnScreen() { LLVector2 window_size = LLUI::getWindowSize(); - centerWithin(LLRect(0, 0, llround(window_size.mV[VX]), llround(window_size.mV[VY]))); + centerWithin(LLRect(0, 0, llmath::llround(window_size.mV[VX]), llmath::llround(window_size.mV[VY]))); } diff --git a/indra/llui/llprogressbar.cpp b/indra/llui/llprogressbar.cpp index 0443c480a..36ff5587e 100644 --- a/indra/llui/llprogressbar.cpp +++ b/indra/llui/llprogressbar.cpp @@ -84,7 +84,7 @@ void LLProgressBar::draw() bar_bg_imagep->draw(getLocalRect(), background_color % alpha); LLRect progress_rect = getLocalRect(); - progress_rect.mRight = llround(getRect().getWidth() * (mPercentDone / 100.f)); + progress_rect.mRight = llmath::llround(getRect().getWidth() * (mPercentDone / 100.f)); bar_fg_imagep->draw(progress_rect, LLColor4::white % alpha); } diff --git a/indra/llui/llscrollcontainer.cpp b/indra/llui/llscrollcontainer.cpp index f7a658ad6..ad1b4ead0 100644 --- a/indra/llui/llscrollcontainer.cpp +++ b/indra/llui/llscrollcontainer.cpp @@ -299,7 +299,7 @@ bool LLScrollContainer::autoScroll(S32 x, S32 y) // clip rect against root view inner_rect_local.intersectWith(screen_local_extents); - S32 auto_scroll_speed = llround(mAutoScrollRate * LLFrameTimer::getFrameDeltaTimeF32()); + S32 auto_scroll_speed = llmath::llround(mAutoScrollRate * LLFrameTimer::getFrameDeltaTimeF32()); // autoscroll region should take up no more than one third of visible scroller area S32 auto_scroll_region_width = llmin(inner_rect_local.getWidth() / 3, 10); S32 auto_scroll_region_height = llmin(inner_rect_local.getHeight() / 3, 10); diff --git a/indra/llui/llscrolllistcell.cpp b/indra/llui/llscrolllistcell.cpp index dba472842..cc5453445 100644 --- a/indra/llui/llscrolllistcell.cpp +++ b/indra/llui/llscrolllistcell.cpp @@ -254,7 +254,7 @@ BOOL LLScrollListText::getVisible() const //virtual S32 LLScrollListText::getHeight() const { - return llround(mFont->getLineHeight()); + return llmath::llround(mFont->getLineHeight()); } @@ -326,7 +326,7 @@ void LLScrollListText::draw(const LLColor4& color, const LLColor4& highlight_col break; } LLRect highlight_rect(left - 2, - llround(mFont->getLineHeight()) + 1, + llmath::llround(mFont->getLineHeight()) + 1, left + mFont->getWidth(mText.getString(), mHighlightOffset, mHighlightCount) + 1, 1); mRoundedRectImage->draw(highlight_rect, highlight_color); diff --git a/indra/llui/llscrolllistctrl.cpp b/indra/llui/llscrolllistctrl.cpp index 3e6e70703..22bf27f4d 100644 --- a/indra/llui/llscrolllistctrl.cpp +++ b/indra/llui/llscrolllistctrl.cpp @@ -602,7 +602,7 @@ bool LLScrollListCtrl::updateColumnWidths() S32 new_width = column->getWidth(); if (column->mRelWidth >= 0) { - new_width = (S32)llround(column->mRelWidth*mItemListRect.getWidth()); + new_width = (S32)llmath::llround(column->mRelWidth*mItemListRect.getWidth()); } else if (column->mDynamicWidth) { @@ -2829,7 +2829,7 @@ void LLScrollListCtrl::addColumn(const LLScrollListColumn::Params& column_params } if (new_column->mRelWidth >= 0) { - new_column->setWidth((S32)llround(new_column->mRelWidth*mItemListRect.getWidth())); + new_column->setWidth((S32)llmath::llround(new_column->mRelWidth*mItemListRect.getWidth())); } else if(new_column->mDynamicWidth) { diff --git a/indra/llui/llspinctrl.cpp b/indra/llui/llspinctrl.cpp index 489f71282..5944d0c11 100644 --- a/indra/llui/llspinctrl.cpp +++ b/indra/llui/llspinctrl.cpp @@ -147,7 +147,7 @@ F32 clamp_precision(F32 value, S32 decimal_precision) for (S32 i = 0; i < decimal_precision; i++) clamped_value *= 10.0; - clamped_value = llround((F32)clamped_value); + clamped_value = llmath::llround((F32)clamped_value); for (S32 i = 0; i < decimal_precision; i++) clamped_value /= 10.0; @@ -161,13 +161,13 @@ F32 get_increment(F32 inc, S32 decimal_precision) //CF: finetune increments if(gKeyboard->getKeyDown(KEY_ALT)) inc = inc * 10.f; else if(gKeyboard->getKeyDown(KEY_CONTROL)) { - if (llround(inc * 1000.f) == 25) // 0.025 gets 0.05 here + if (llmath::llround(inc * 1000.f) == 25) // 0.025 gets 0.05 here inc = inc * 0.2f; else inc = inc * 0.1f; } else if(gKeyboard->getKeyDown(KEY_SHIFT)) { - if (decimal_precision == 2 && llround(inc) == 1) // for rotations, finest step is 0.05 + if (decimal_precision == 2 && llmath::llround(inc) == 1) // for rotations, finest step is 0.05 inc = inc * 0.05f; else inc = inc * 0.01f; diff --git a/indra/llui/llstatgraph.cpp b/indra/llui/llstatgraph.cpp index 2e3be1803..c271e1706 100644 --- a/indra/llui/llstatgraph.cpp +++ b/indra/llui/llstatgraph.cpp @@ -120,7 +120,7 @@ void LLStatGraph::draw() color = mThresholdColors[i]; gGL.color4fv(color.mV); - gl_rect_2d(1, llround(frac*getRect().getHeight()), getRect().getWidth() - 1, 0, TRUE); + gl_rect_2d(1, llmath::llround(frac*getRect().getHeight()), getRect().getWidth() - 1, 0, TRUE); } void LLStatGraph::setValue(const LLSD& value) diff --git a/indra/llui/lltexteditor.cpp b/indra/llui/lltexteditor.cpp index 08989e628..4c210cb14 100644 --- a/indra/llui/lltexteditor.cpp +++ b/indra/llui/lltexteditor.cpp @@ -312,7 +312,7 @@ LLTextEditor::LLTextEditor( updateTextRect(); - S32 line_height = llround( mGLFont->getLineHeight() ); + S32 line_height = llmath::llround( mGLFont->getLineHeight() ); S32 page_size = mTextRect.getHeight() / line_height; // Init the scrollbar @@ -970,7 +970,7 @@ S32 LLTextEditor::getCursorPosFromLocalCoord( S32 local_x, S32 local_y, BOOL rou // Figure out which line we're nearest to. S32 total_lines = getLineCount(); - S32 line_height = llround( mGLFont->getLineHeight() ); + S32 line_height = llmath::llround( mGLFont->getLineHeight() ); S32 max_visible_lines = mTextRect.getHeight() / line_height; S32 scroll_lines = mScrollbar->getDocPos(); S32 visible_lines = llmin( total_lines - scroll_lines, max_visible_lines ); // Lines currently visible @@ -2927,7 +2927,7 @@ void LLTextEditor::drawSelectionBackground() const S32 text_len = getLength(); std::queue line_endings; - S32 line_height = llround( mGLFont->getLineHeight() ); + S32 line_height = llmath::llround( mGLFont->getLineHeight() ); S32 selection_left = llmin( mSelectionStart, mSelectionEnd ); S32 selection_right = llmax( mSelectionStart, mSelectionEnd ); @@ -3122,7 +3122,7 @@ void LLTextEditor::drawMisspelled() S32 line_end = 0; // Determine if the cursor is visible and if so what its coordinates are. - while( (mTextRect.mBottom <= llround(text_y)) && (search_pos < num_lines)) + while( (mTextRect.mBottom <= llmath::llround(text_y)) && (search_pos < num_lines)) { line_end = text_len + 1; S32 next_line = -1; @@ -3197,7 +3197,7 @@ void LLTextEditor::drawCursor() S32 line_end = 0; // Determine if the cursor is visible and if so what its coordinates are. - while( (mTextRect.mBottom <= llround(text_y)) && (cur_pos < num_lines)) + while( (mTextRect.mBottom <= llmath::llround(text_y)) && (cur_pos < num_lines)) { line_end = text_len + 1; S32 next_line = -1; @@ -3316,7 +3316,7 @@ void LLTextEditor::drawPreeditMarker() return; } - const S32 line_height = llround( mGLFont->getLineHeight() ); + const S32 line_height = llmath::llround( mGLFont->getLineHeight() ); S32 line_start = getLineStart(cur_line); S32 line_y = mTextRect.mTop - line_height; @@ -3436,7 +3436,7 @@ void LLTextEditor::drawText() if (seg_iter == mSegments.end() || (*seg_iter)->getStart() > line_start) --seg_iter; LLTextSegment* cur_segment = *seg_iter; - S32 line_height = llround( mGLFont->getLineHeight() ); + S32 line_height = llmath::llround( mGLFont->getLineHeight() ); F32 text_y = (F32)(mTextRect.mTop - line_height); while((mTextRect.mBottom <= text_y) && (cur_line < num_lines)) { @@ -3461,7 +3461,7 @@ void LLTextEditor::drawText() if( mShowLineNumbers && !cur_line_is_continuation) { const LLFontGL *num_font = LLFontGL::getFontMonospace(); - F32 y_top = text_y + ((F32)llround(num_font->getLineHeight()) / 2); + F32 y_top = text_y + ((F32)llmath::llround(num_font->getLineHeight()) / 2); const LLWString ltext = utf8str_to_wstring(llformat("%*d", UI_TEXTEDITOR_LINE_NUMBER_DIGITS, cur_line_num )); BOOL is_cur_line = getCurrentLine() == cur_line_num; const U8 style = is_cur_line ? LLFontGL::BOLD : LLFontGL::NORMAL; @@ -3505,7 +3505,7 @@ void LLTextEditor::drawText() S32 style_image_height = style->mImageHeight; S32 style_image_width = style->mImageWidth; LLUIImagePtr image = style->getImage(); - image->draw(llround(text_x), llround(text_y)+line_height-style_image_height, + image->draw(llmath::llround(text_x), llmath::llround(text_y)+line_height-style_image_height, style_image_width, style_image_height); } @@ -3592,7 +3592,7 @@ void LLTextEditor::drawClippedSegment(const LLWString &text, S32 seg_start, S32 } } - F32 y_top = y + (F32)llround(font->getLineHeight()); + F32 y_top = y + (F32)llmath::llround(font->getLineHeight()); if( selection_left > seg_start ) { @@ -3995,7 +3995,7 @@ void LLTextEditor::reshape(S32 width, S32 height, BOOL called_from_parent) // propagate shape information to scrollbar mScrollbar->setDocSize( getLineCount() ); - S32 line_height = llround( mGLFont->getLineHeight() ); + S32 line_height = llmath::llround( mGLFont->getLineHeight() ); S32 page_lines = mTextRect.getHeight() / line_height; mScrollbar->setPageSize( page_lines ); } @@ -5162,7 +5162,7 @@ BOOL LLTextEditor::getPreeditLocation(S32 query_offset, LLCoordGL *coord, LLRect } const llwchar * const text = mWText.c_str(); - const S32 line_height = llround(mGLFont->getLineHeight()); + const S32 line_height = llmath::llround(mGLFont->getLineHeight()); if (coord) { @@ -5265,7 +5265,7 @@ void LLTextEditor::markAsPreedit(S32 position, S32 length) S32 LLTextEditor::getPreeditFontSize() const { - return llround(mGLFont->getLineHeight() * LLUI::getScaleFactor().mV[VY]); + return llmath::llround(mGLFont->getLineHeight() * LLUI::getScaleFactor().mV[VY]); } void LLTextEditor::setKeystrokeCallback(const keystroke_signal_t::slot_type& callback) diff --git a/indra/llui/llui.cpp b/indra/llui/llui.cpp index aab2df83f..39f4598c5 100644 --- a/indra/llui/llui.cpp +++ b/indra/llui/llui.cpp @@ -158,8 +158,8 @@ void LLUI::cleanupClass() void LLUI::setMousePositionScreen(S32 x, S32 y) { S32 screen_x, screen_y; - screen_x = llround((F32)x * getScaleFactor().mV[VX]); - screen_y = llround((F32)y * getScaleFactor().mV[VY]); + screen_x = llmath::llround((F32)x * getScaleFactor().mV[VX]); + screen_y = llmath::llround((F32)y * getScaleFactor().mV[VY]); LLView::getWindow()->setCursorPosition(LLCoordGL(screen_x, screen_y).convert()); } @@ -170,8 +170,8 @@ void LLUI::getMousePositionScreen(S32 *x, S32 *y) LLCoordWindow cursor_pos_window; getWindow()->getCursorPosition(&cursor_pos_window); LLCoordGL cursor_pos_gl(cursor_pos_window.convert()); - *x = llround((F32)cursor_pos_gl.mX / getScaleFactor().mV[VX]); - *y = llround((F32)cursor_pos_gl.mY / getScaleFactor().mV[VX]); + *x = llmath::llround((F32)cursor_pos_gl.mX / getScaleFactor().mV[VX]); + *y = llmath::llround((F32)cursor_pos_gl.mY / getScaleFactor().mV[VX]); } //static @@ -262,15 +262,15 @@ LLVector2 LLUI::getWindowSize() //static void LLUI::screenPointToGL(S32 screen_x, S32 screen_y, S32 *gl_x, S32 *gl_y) { - *gl_x = llround((F32)screen_x * getScaleFactor().mV[VX]); - *gl_y = llround((F32)screen_y * getScaleFactor().mV[VY]); + *gl_x = llmath::llround((F32)screen_x * getScaleFactor().mV[VX]); + *gl_y = llmath::llround((F32)screen_y * getScaleFactor().mV[VY]); } //static void LLUI::glPointToScreen(S32 gl_x, S32 gl_y, S32 *screen_x, S32 *screen_y) { - *screen_x = llround((F32)gl_x / getScaleFactor().mV[VX]); - *screen_y = llround((F32)gl_y / getScaleFactor().mV[VY]); + *screen_x = llmath::llround((F32)gl_x / getScaleFactor().mV[VX]); + *screen_y = llmath::llround((F32)gl_y / getScaleFactor().mV[VY]); } //static diff --git a/indra/llui/llurlentry.cpp b/indra/llui/llurlentry.cpp index 9e83b9bd6..741954d11 100644 --- a/indra/llui/llurlentry.cpp +++ b/indra/llui/llurlentry.cpp @@ -835,9 +835,9 @@ void LLUrlEntryParcel::processParcelInfo(const LLParcelData& parcel_data) // If parcel name is empty use Sim_name (x, y, z) for parcel label. else if (!parcel_data.sim_name.empty()) { - S32 region_x = llround(parcel_data.global_x) % REGION_WIDTH_UNITS; - S32 region_y = llround(parcel_data.global_y) % REGION_WIDTH_UNITS; - S32 region_z = llround(parcel_data.global_z); + S32 region_x = llmath::llround(parcel_data.global_x) % REGION_WIDTH_UNITS; + S32 region_y = llmath::llround(parcel_data.global_y) % REGION_WIDTH_UNITS; + S32 region_z = llmath::llround(parcel_data.global_z); label = llformat("%s (%d, %d, %d)", parcel_data.sim_name.c_str(), region_x, region_y, region_z); diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 56bdc9219..23101bb56 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -7,13 +7,12 @@ include(Boost) include(DBusGlib) include(DirectX) include(ELFIO) +if(FMODSTUDIO) + include(FMODSTUDIO) +endif(FMODSTUDIO) if(FMODEX) include(FMODEX) - set(FMOD OFF) endif(FMODEX) -if(FMOD) - include(FMOD) -endif(FMOD) include(OPENAL) include(FindOpenGL) include(Hunspell) @@ -47,7 +46,6 @@ include(GLOD) include(LLAppearance) if (WINDOWS) - include(CopyWinLibs) set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP) include(InstallRequiredSystemLibraries) endif (WINDOWS) @@ -1230,7 +1228,6 @@ if (WINDOWS) res/arrowcopmulti.cur res/arrowdrag.cur res/circleandline.cur - res/icon1.ico res/llarrow.cur res/llarrowdrag.cur res/llarrowdragmulti.cur @@ -1250,8 +1247,7 @@ if (WINDOWS) res/lltooltranslate.cur res/lltoolzoomin.cur res/lltoolzoomout.cur - res/snowglobe_icon.BMP - res/snowglobe_icon.ico + res/${VIEWER_BRANDING_ID}_icon.ico res/resource.h res/toolpickobject.cur res/toolpickobject2.cur @@ -1303,24 +1299,26 @@ if (WINDOWS) winspool ) - if(FMODEX) - list(APPEND viewer_LIBRARIES ${FMODEX_LIBRARY}) - endif(FMODEX) - if(FMOD) - list(APPEND viewer_LIBRARIES ${FMOD_LIBRARY}) - endif(FMOD) + find_library(DEBUG_INTEL_MEMOPS_LIBRARY ll_intel_memops + PATHS + ${LIBS_PREBUILT_DIR}/lib/debug + ${LIBS_PREBUILT_LEGACY_DIR}/lib/debug + "${QUICKTIME_SDK_DIR}\\libraries" + ) - find_library(INTEL_MEMOPS_LIBRARY - NAMES ll_intel_memops - PATHS - optimized ${ARCH_PREBUILT_DIRS_RELEASE} - debug ${ARCH_PREBUILT_DIRS_DEBUG} - ) - mark_as_advanced(INTEL_MEMOPS_LIBRARY) + find_library(RELEASE_INTEL_MEMOPS_LIBRARY ll_intel_memops + PATHS + ${LIBS_PREBUILT_DIR}/lib/release + ${LIBS_PREBUILT_LEGACY_DIR}/lib/release + "${QUICKTIME_SDK_DIR}\\libraries" + ) - if (INTEL_MEMOPS_LIBRARY) - list(APPEND viewer_LIBRARIES ${INTEL_MEMOPS_LIBRARY}) - endif (INTEL_MEMOPS_LIBRARY) + if (DEBUG_INTEL_MEMOPS_LIBRARY AND RELEASE_INTEL_MEMOPS_LIBRARY) + list(APPEND viewer_LIBRARIES optimized ${RELEASE_INTEL_MEMOPS_LIBRARY}) + list(APPEND viewer_LIBRARIES debug ${DEBUG_INTEL_MEMOPS_LIBRARY}) + mark_as_advanced(RELEASE_INTEL_MEMOPS_LIBRARY) + mark_as_advanced(DEBUG_INTEL_MEMOPS_LIBRARY) + endif (DEBUG_INTEL_MEMOPS_LIBRARY AND RELEASE_INTEL_MEMOPS_LIBRARY) endif (WINDOWS) # Add the xui files. This is handy for searching for xui elements @@ -1404,42 +1402,6 @@ if (WINDOWS) list(APPEND viewer_SOURCE_FILES ${viewer_INSTALLER_FILES}) endif (WINDOWS) -if (OPENAL) - set(LLSTARTUP_COMPILE_FLAGS "${LLSTARTUP_COMPILE_FLAGS} -DLL_OPENAL") -endif (OPENAL) - -if (FMOD OR FMODEX) - if (FMODEX) - set(LLSTARTUP_COMPILE_FLAGS "${LLSTARTUP_COMPILE_FLAGS} -DLL_FMODEX") - endif (FMODEX) - if (FMOD) - set(LLSTARTUP_COMPILE_FLAGS "${LLSTARTUP_COMPILE_FLAGS} -DLL_FMOD") - endif (FMOD) - - if (DARWIN AND FMOD) - set(fmodwrapper_SOURCE_FILES fmodwrapper.cpp) - add_library(fmodwrapper SHARED ${fmodwrapper_SOURCE_FILES}) - set(fmodwrapper_needed_LIBRARIES ${FMOD_LIBRARY} ${CARBON_LIBRARY}) - set_target_properties( - fmodwrapper - PROPERTIES - BUILD_WITH_INSTALL_RPATH 1 - INSTALL_NAME_DIR "@executable_path/../Resources" - LINK_FLAGS "-unexported_symbols_list ${CMAKE_CURRENT_SOURCE_DIR}/fmod_hidden_symbols.exp" - ) - set(FMODWRAPPER_LIBRARY fmodwrapper) - target_link_libraries(fmodwrapper ${fmodwrapper_needed_LIBRARIES}) - else (DARWIN AND FMOD) - # fmodwrapper unnecessary on linux or windows, for fmod and fmodex - if (FMODEX) - set(FMODWRAPPER_LIBRARY ${FMODEX_LIBRARY}) - endif (FMODEX) - if (FMOD) - set(FMODWRAPPER_LIBRARY ${FMOD_LIBRARY}) - endif (FMOD) - endif (DARWIN AND FMOD) -endif (FMOD OR FMODEX) - set_source_files_properties(llstartup.cpp PROPERTIES COMPILE_FLAGS "${LLSTARTUP_COMPILE_FLAGS}") list(APPEND viewer_SOURCE_FILES ${viewer_HEADER_FILES}) @@ -1460,36 +1422,45 @@ endif (!DISABLE_TEMPLATE_CHECK) set(PACKAGE OFF CACHE BOOL "Add a package_viewer target that builds an installer package.") +if(FMOD_LIBRARY_RELEASE) + get_filename_component(fmod_lib_rel_name ${FMOD_LIBRARY_RELEASE} NAME) + get_filename_component(fmod_lib_deb_name ${FMOD_LIBRARY_DEBUG} NAME) + add_custom_command(OUTPUT fmod_lib.marker + COMMENT "Copying fmod library to executable directory" + COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<$>:${FMOD_LIBRARY_RELEASE}>$<$:${FMOD_LIBRARY_DEBUG}>" "${CMAKE_CFG_INTDIR}/$<$>:${fmod_lib_rel_name}>$<$:${fmod_lib_deb_name}>" + DEPENDS "${FMOD_LIBRARY_RELEASE}") + add_custom_target(fmod_lib_copy DEPENDS fmod_lib.marker prepare) + if(DARWIN) + add_custom_command(OUTPUT fmod_lib_install.marker + COMMAND install_name_tool -id "@executable_path/../Resources/$<$>:${fmod_lib_rel_name}>$<$:${FMOD_LIBRARY_DEBUG}>" "${CMAKE_CFG_INTDIR}/$<$>:${fmod_lib_rel_name}>$<$:${fmod_lib_deb_name}>" + DEPENDS fmod_lib.marker) + add_dependencies(fmod_lib_copy fmod_lib_install.marker) + endif(DARWIN) + add_dependencies(${VIEWER_BINARY_NAME} fmod_lib_copy) + + #viewer_manifest.py needs these libraries (for now its all dylib) + if(MANIFEST_LIBRARIES) + set(MANIFEST_LIBRARIES ${MANIFEST_LIBRARIES}|optimized ${fmod_lib_rel_name}|debug ${fmod_lib_deb_name}) + else(MANIFEST_LIBRARIES) + set(MANIFEST_LIBRARIES optimized ${fmod_lib_rel_name}|debug ${fmod_lib_deb_name}) + endif(MANIFEST_LIBRARIES) + + if(WINDOWS) #If windows, fmod_lib_ points to a dll. The correct .lib needs to be linked (but copying is not necessary) + set(EXTRA_LINKER_FLAGS_RELEASE "/DELAYLOAD:${fmod_lib_rel_name}") + set(EXTRA_LINKER_FLAGS_DEBUG "/DELAYLOAD:${fmod_lib_deb_name}") + endif(WINDOWS) + list(APPEND viewer_LIBRARIES optimized "${FMOD_LINK_LIBRARY_RELEASE}" debug "${FMOD_LINK_LIBRARY_DEBUG}" ) +endif(FMOD_LIBRARY_RELEASE) + if (WINDOWS) - set(release_flags "/MAPRelease/${VIEWER_BINARY_NAME}.map") - - if (FMOD) - if(MANIFEST_LIBRARIES) - set(MANIFEST_LIBRARIES "${MANIFEST_LIBRARIES}|${FMOD_BINARY_DIR}/fmod.dll") - else(MANIFEST_LIBRARIES) - set(MANIFEST_LIBRARIES "--extra_libraries=${FMOD_BINARY_DIR}/fmod.dll") - endif(MANIFEST_LIBRARIES) - endif (FMOD) - if (FMODEX) - if (WORD_SIZE EQUAL 32) - set(fmodex_dll_file "fmodex.dll") - else (WORD_SIZE EQUAL 32) - set(fmodex_dll_file "fmodex64.dll") - endif (WORD_SIZE EQUAL 32) - - if(MANIFEST_LIBRARIES) - set(MANIFEST_LIBRARIES "${MANIFEST_LIBRARIES}|${FMODEX_BINARY_DIR}/${fmodex_dll_file}") - else(MANIFEST_LIBRARIES) - set(MANIFEST_LIBRARIES "--extra_libraries=${FMODEX_BINARY_DIR}/${fmodex_dll_file}") - endif(MANIFEST_LIBRARIES) - set(EXTRA_LINKER_FLAGS "/DELAYLOAD:${fmodex_dll_file}") - endif (FMODEX) + set(release_flags "/MAP") set_target_properties(${VIEWER_BINARY_NAME} PROPERTIES - LINK_FLAGS "/debug /NODEFAULTLIB:LIBCMT /SUBSYSTEM:WINDOWS ${GOOGLE_PERFTOOLS_LINKER_FLAGS} ${EXTRA_LINKER_FLAGS}" - LINK_FLAGS_DEBUG "/NODEFAULTLIB:\"LIBCMT;LIBCMTD;MSVCRT\"" - LINK_FLAGS_RELEASE ${release_flags} + LINK_FLAGS "/debug /NODEFAULTLIB:LIBCMT /SUBSYSTEM:WINDOWS ${GOOGLE_PERFTOOLS_LINKER_FLAGS}" + LINK_FLAGS_DEBUG "/NODEFAULTLIB:\"LIBCMT;LIBCMTD;MSVCRT\" ${EXTRA_LINKER_FLAGS_DEBUG}" + LINK_FLAGS_RELEASE "${release_flags} ${EXTRA_LINKER_FLAGS_RELEASE}" + LINK_FLAGS_RELWITHDEBINFO "${release_flags} ${EXTRA_LINKER_FLAGS_RELEASE}" ) # sets the 'working directory' for debugging from visual studio. @@ -1529,8 +1500,6 @@ if (WINDOWS) COMMENT "Copying message.xml to the runtime folder." ) - add_dependencies(${VIEWER_BINARY_NAME} copy_win_libs) - if (EXISTS ${CMAKE_SOURCE_DIR}/copy_win_scripts) add_dependencies(${VIEWER_BINARY_NAME} copy_win_scripts) endif (EXISTS ${CMAKE_SOURCE_DIR}/copy_win_scripts) @@ -1551,7 +1520,7 @@ if (WINDOWS) --login_channel=${VIEWER_LOGIN_CHANNEL} --source=${CMAKE_CURRENT_SOURCE_DIR} --touch=${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/touched.bat - ${MANIFEST_LIBRARIES} + --extra_libraries="${MANIFEST_LIBRARIES}" DEPENDS ${VIEWER_BINARY_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/viewer_manifest.py @@ -1574,14 +1543,18 @@ if (WINDOWS) --login_channel=${VIEWER_LOGIN_CHANNEL} --source=${CMAKE_CURRENT_SOURCE_DIR} --touch=${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/copy_touched.bat - ${MANIFEST_LIBRARIES} + --extra_libraries="${MANIFEST_LIBRARIES}" DEPENDS ${VIEWER_BINARY_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/viewer_manifest.py COMMENT "Performing viewer_manifest copy" ) - add_dependencies(${VIEWER_BINARY_NAME} SLPlugin media_plugin_quicktime media_plugin_webkit basic_plugin_filepicker winmm_shim) + add_dependencies(${VIEWER_BINARY_NAME} SLPlugin media_plugin_quicktime media_plugin_webkit basic_plugin_filepicker) + + if(WORD_SIZE EQUAL 32) + add_dependencies(${VIEWER_BINARY_NAME} winmm_shim) + endif(WORD_SIZE EQUAL 32) if (PACKAGE) add_custom_target(package_viewer ALL DEPENDS ${CMAKE_CFG_INTDIR}/touched.bat) @@ -1626,7 +1599,6 @@ target_link_libraries(${VIEWER_BINARY_NAME} ${Boost_DATE_TIME_LIBRARY} ${DBUSGLIB_LIBRARIES} ${OPENGL_LIBRARIES} - ${FMODWRAPPER_LIBRARY} # must come after LLAudio ${GLOD_LIBRARIES} ${APRUTIL_LIBRARIES} ${OPENGL_LIBRARIES} @@ -1650,15 +1622,7 @@ if (LINUX) DEPENDS ${VIEWER_BINARY_NAME} ) - set(product ${VIEWER_BRANDING_NAME_CAMELCASE}-${ARCH}-${viewer_VERSION}) - - if (FMODEX) - if(MANIFEST_LIBRARIES) - set(MANIFEST_LIBRARIES "${MANIFEST_LIBRARIES}|${FMODEX_LIBRARY}") - else(MANIFEST_LIBRARIES) - set(MANIFEST_LIBRARIES "--extra_libraries=${FMODEX_LIBRARY}") - endif(MANIFEST_LIBRARIES) - endif (FMODEX) + set(product ${VIEWER_BRANDING_NAME_CAMELCASE}-${ARCH}-${${ROOT_PROJECT_NAME}_VERSION}) add_custom_command( OUTPUT ${product}.tar.bz2 @@ -1678,7 +1642,7 @@ if (LINUX) --source=${CMAKE_CURRENT_SOURCE_DIR} --standalone=${STANDALONE} --touch=${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/.${product}.touched - ${MANIFEST_LIBRARIES} + --extra_libraries="${MANIFEST_LIBRARIES}" DEPENDS secondlife-stripped ${CMAKE_CURRENT_SOURCE_DIR}/viewer_manifest.py @@ -1702,7 +1666,7 @@ if (LINUX) --login_channel=${VIEWER_LOGIN_CHANNEL} --source=${CMAKE_CURRENT_SOURCE_DIR} --standalone=${STANDALONE} - ${MANIFEST_LIBRARIES} + --extra_libraries="${MANIFEST_LIBRARIES}" DEPENDS secondlife-stripped ${CMAKE_CURRENT_SOURCE_DIR}/viewer_manifest.py @@ -1726,10 +1690,10 @@ if (DARWIN) MACOSX_BUNDLE_INFO_STRING "A stable third-party Second Life viewer." MACOSX_BUNDLE_ICON_FILE "${VIEWER_BRANDING_ID}_icon.icns" MACOSX_BUNDLE_GUI_IDENTIFIER "${VIEWER_BRANDING_NAME}" - MACOSX_BUNDLE_LONG_VERSION_STRING "${viewer_VERSION}" + MACOSX_BUNDLE_LONG_VERSION_STRING "${${ROOT_PROJECT_NAME}_VERSION}" MACOSX_BUNDLE_BUNDLE_NAME "${VIEWER_BRANDING_NAME}" - MACOSX_BUNDLE_SHORT_VERSION_STRING "${viewer_VERSION}" - MACOSX_BUNDLE_BUNDLE_VERSION "${viewer_VERSION}" + MACOSX_BUNDLE_SHORT_VERSION_STRING "${${ROOT_PROJECT_NAME}_VERSION}" + MACOSX_BUNDLE_BUNDLE_VERSION "${${ROOT_PROJECT_NAME}_VERSION}" MACOSX_BUNDLE_COPYRIGHT "Copyright 2013 Siana Gearz" ) @@ -1752,15 +1716,6 @@ if (DARWIN) add_dependencies(${VIEWER_BINARY_NAME} SLPlugin media_plugin_quicktime media_plugin_webkit basic_plugin_filepicker) - if (FMODEX) - add_custom_command(OUTPUT "${FMODEX_LIBRARY}" - COMMAND cp "${FMODEX_ORIG_LIBRARY}" "${FMODEX_LIBRARY}" - COMMAND install_name_tool -id "@executable_path/../Resources/libfmodex.dylib" ${FMODEX_LIBRARY} - DEPENDS "${FMODEX_ORIG_LIBRARY}") - add_custom_target(fmodex_modified_library DEPENDS "${FMODEX_LIBRARY}") - add_dependencies(${VIEWER_BINARY_NAME} fmodex_modified_library) - endif (FMODEX) - if (PACKAGE) add_custom_target(package_viewer ALL DEPENDS ${VIEWER_BINARY_NAME}) @@ -1790,34 +1745,38 @@ if (INSTALL) include(${CMAKE_CURRENT_SOURCE_DIR}/ViewerInstall.cmake) endif (INSTALL) + if (PACKAGE) + set(SYMBOL_NAME ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${VIEWER_BRANDING_NAME_CAMELCASE}-${${ROOT_PROJECT_NAME}_VERSION}-symbols) set(SYMBOL_SEARCH_DIRS "") if (WINDOWS) list(APPEND SYMBOL_SEARCH_DIRS "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}") - set(VIEWER_SYMBOL_FILE "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/secondlife-symbols-windows.tar.bz2") + set(VIEWER_SYMBOL_FILE "${SYMBOL_NAME}-${PREBUILT_TYPE}.tar.bz2") # slplugin.exe failing symbols dump - need to debug, might have to do with updated version of google breakpad # set(VIEWER_EXE_GLOBS "${VIEWER_BINARY_NAME}${CMAKE_EXECUTABLE_SUFFIX} slplugin.exe") set(VIEWER_EXE_GLOBS "${VIEWER_BINARY_NAME}${CMAKE_EXECUTABLE_SUFFIX}") set(VIEWER_LIB_GLOB "*${CMAKE_SHARED_MODULE_SUFFIX}") - set(VIEWER_COPY_MANIFEST copy_w_viewer_manifest) + set(VIEWER_DUMP_SYMS dump_syms.exe) endif (WINDOWS) if (DARWIN) list(APPEND SYMBOL_SEARCH_DIRS "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}") # *TODO: Generate these search dirs in the cmake files related to each binary. list(APPEND SYMBOL_SEARCH_DIRS "${CMAKE_BINARY_DIR}/llplugin/slplugin/${CMAKE_CFG_INTDIR}") - list(APPEND SYMBOL_SEARCH_DIRS "${CMAKE_BINARY_DIR}/media_plugins/gstreamer010/${CMAKE_CFG_INTDIR}") - list(APPEND SYMBOL_SEARCH_DIRS "${CMAKE_BINARY_DIR}/media_plugins/quicktime/${CMAKE_CFG_INTDIR}") - list(APPEND SYMBOL_SEARCH_DIRS "${CMAKE_BINARY_DIR}/media_plugins/webkit/${CMAKE_CFG_INTDIR}") - set(VIEWER_SYMBOL_FILE "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/secondlife-symbols-darwin.tar.bz2") + list(APPEND SYMBOL_SEARCH_DIRS "${CMAKE_BINARY_DIR}/plugins/gstreamer010/${CMAKE_CFG_INTDIR}") + list(APPEND SYMBOL_SEARCH_DIRS "${CMAKE_BINARY_DIR}/plugins/quicktime/${CMAKE_CFG_INTDIR}") + list(APPEND SYMBOL_SEARCH_DIRS "${CMAKE_BINARY_DIR}/plugins/webkit/${CMAKE_CFG_INTDIR}") + set(VIEWER_SYMBOL_FILE "${SYMBOL_NAME}-darwin.tar.bz2") set(VIEWER_EXE_GLOBS "'${VIEWER_BRANDING_NAME}' SLPlugin") set(VIEWER_LIB_GLOB "*.dylib") + set(VIEWER_DUMP_SYMS dump_syms) endif (DARWIN) if (LINUX) list(APPEND SYMBOL_SEARCH_DIRS "${CMAKE_CURRENT_BINARY_DIR}/packaged") - set(VIEWER_SYMBOL_FILE "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/secondlife-symbols-linux.tar.bz2") + set(VIEWER_SYMBOL_FILE "${SYMBOL_NAME}-linux-${ARCH}.tar.bz2") set(VIEWER_EXE_GLOBS "${VIEWER_BRANDING_ID}-do-not-run-directly SLPlugin") set(VIEWER_LIB_GLOB "*${CMAKE_SHARED_MODULE_SUFFIX}*") set(VIEWER_COPY_MANIFEST copy_l_viewer_manifest) + set(VIEWER_DUMP_SYMS dump_syms) endif (LINUX) if(RELEASE_CRASH_REPORTING OR NON_RELEASE_CRASH_REPORTING) @@ -1836,13 +1795,16 @@ if (PACKAGE) "${SYMBOL_SEARCH_DIRS}" "${VIEWER_EXE_GLOBS}" "${VIEWER_LIB_GLOB}" - "${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/bin/dump_syms" + "${LIBS_PREBUILT_DIR}/bin/${VIEWER_DUMP_SYMS}|${LIBS_PREBUILT_LEGACY_DIR}/bin/${VIEWER_DUMP_SYMS}" "${VIEWER_SYMBOL_FILE}" DEPENDS generate_breakpad_symbols.py VERBATIM) add_custom_target(generate_breakpad_symbols DEPENDS "${VIEWER_SYMBOL_FILE}") - add_dependencies(generate_breakpad_symbols "${VIEWER_BINARY_NAME}" "${VIEWER_COPY_MANIFEST}") + add_dependencies(generate_breakpad_symbols ${VIEWER_BINARY_NAME}) +if(VIEWER_COPY_MANIFEST) + add_dependencies(generate_breakpad_symbols ${VIEWER_COPY_MANIFEST}) +endif(VIEWER_COPY_MANIFEST) add_dependencies(package_viewer generate_breakpad_symbols) endif(RELEASE_CRASH_REPORTING OR NON_RELEASE_CRASH_REPORTING) endif (PACKAGE) @@ -1876,12 +1838,14 @@ if (WINDOWS) ENDFOREACH(RUNTIME_LIB ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS}) ENDIF(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS) - get_target_property(BUILT_LLCOMMON llcommon LOCATION) + SET(BUILT_LLCOMMON $) set_target_properties(llcommon PROPERTIES - LINK_FLAGS "/debug /NODEFAULTLIB:LIBCMT /LTCG" + LINK_FLAGS "/debug /NODEFAULTLIB:LIBCMT" LINK_FLAGS_DEBUG "/NODEFAULTLIB:\"LIBCMT;LIBCMTD;MSVCRT\"" + LINK_FLAGS_RELEASE "${release_flags} /LTCG" + LINK_FLAGS_RELWITHDEBINFO "${release_flags}" ) add_custom_command( @@ -1895,7 +1859,7 @@ if (WINDOWS) COMMENT "Copying llcommon.dll to the runtime folder." ) - get_target_property(BUILT_SLPLUGIN SLPlugin LOCATION) + SET(BUILT_SLPLUGIN $) add_custom_command( TARGET ${VIEWER_BINARY_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} @@ -1907,7 +1871,7 @@ if (WINDOWS) COMMENT "Copying SLPlugin executable to the runtime folder." ) - get_target_property(BUILT_WEBKIT_PLUGIN media_plugin_webkit LOCATION) + SET(BUILT_WEBKIT_PLUGIN $) add_custom_command( TARGET ${VIEWER_BINARY_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} @@ -1919,7 +1883,7 @@ if (WINDOWS) COMMENT "Copying WebKit Plugin to the runtime folder." ) - get_target_property(BUILT_QUICKTIME_PLUGIN media_plugin_quicktime LOCATION) + SET(BUILT_QUICKTIME_PLUGIN $) add_custom_command( TARGET ${VIEWER_BINARY_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} @@ -1931,7 +1895,7 @@ if (WINDOWS) COMMENT "Copying Quicktime Plugin to the runtime folder." ) - get_target_property(BUILT_FILEPICKER_PLUGIN basic_plugin_filepicker LOCATION) + SET(BUILT_FILEPICKER_PLUGIN $) add_custom_command( TARGET ${VIEWER_BINARY_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} @@ -1945,7 +1909,7 @@ if (WINDOWS) # winmm doesn't build on windows 64 if(WORD_SIZE EQUAL 32) - get_target_property(BUILT_WINMM_SHIM_PLUGIN winmm_shim LOCATION) + SET(BUILT_WINMM_SHIM_PLUGIN $) add_custom_command( TARGET ${VIEWER_BINARY_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} diff --git a/indra/newview/aihttpview.cpp b/indra/newview/aihttpview.cpp index 7e97f9768..49f6f726f 100644 --- a/indra/newview/aihttpview.cpp +++ b/indra/newview/aihttpview.cpp @@ -190,7 +190,7 @@ class AIGLHTTPHeaderBar : public LLView AIGLHTTPHeaderBar(std::string const& name, AIHTTPView* httpview) : LLView(name, FALSE), mHTTPView(httpview) { - sLineHeight = llround(LLFontGL::getFontMonospace()->getLineHeight()); + sLineHeight = llmath::llround(LLFontGL::getFontMonospace()->getLineHeight()); setRect(LLRect(0, 0, 200, sLineHeight * number_of_header_lines)); } diff --git a/indra/newview/generate_breakpad_symbols.py b/indra/newview/generate_breakpad_symbols.py index 4181e4ebb..c1fd05935 100644 --- a/indra/newview/generate_breakpad_symbols.py +++ b/indra/newview/generate_breakpad_symbols.py @@ -83,10 +83,15 @@ def main(configuration, search_dirs, viewer_exes, libs_suffix, dump_syms_tool, v def dump_module(m): print "dumping module '%s' with '%s'..." % (m, dump_syms_tool) dsym_full_path = m - child = subprocess.Popen([dump_syms_tool, dsym_full_path] , stdout=subprocess.PIPE) - out, err = child.communicate() - return (m,child.returncode, out, err) - + + tools = dump_syms_tool.split('|') + for tool in tools: + if tool: + if os.path.isfile(tool): + child = subprocess.Popen([tool, dsym_full_path] , stdout=subprocess.PIPE) + out, err = child.communicate() + return (m,child.returncode, out, err) + raise IOError('Failed to find dump_syms tool!') modules = {} diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index e35d5ab27..3ed202986 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -4479,12 +4479,6 @@ void LLAppViewer::shutdownAudio() { if (gAudiop) { - // shut down the streaming audio sub-subsystem first, in case it relies on not outliving the general audio subsystem. - - LLStreamingAudioInterface *sai = gAudiop->getStreamingAudioImpl(); - delete sai; - gAudiop->setStreamingAudioImpl(NULL); - // shut down the audio subsystem bool want_longname = false; diff --git a/indra/newview/llcloud.cpp b/indra/newview/llcloud.cpp index fcdfbecd4..12c260b87 100644 --- a/indra/newview/llcloud.cpp +++ b/indra/newview/llcloud.cpp @@ -189,7 +189,7 @@ void LLCloudGroup::updatePuffCount() return; } S32 i; - S32 target_puff_count = llround(CLOUD_DENSITY * mDensity); + S32 target_puff_count = llmath::llround(CLOUD_DENSITY * mDensity); target_puff_count = llmax(0, target_puff_count); target_puff_count = llmin(CLOUD_COUNT_MAX, target_puff_count); S32 current_puff_count = (S32) mCloudPuffs.size(); diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp index 56fe132d3..449753b47 100644 --- a/indra/newview/lldrawable.cpp +++ b/indra/newview/lldrawable.cpp @@ -812,7 +812,7 @@ void LLDrawable::updateDistance(LLCamera& camera, bool force_update) } pos -= camera.getOrigin(); - mDistanceWRTCamera = llround(pos.magVec(), 0.01f); + mDistanceWRTCamera = llmath::llround(pos.magVec(), 0.01f); mVObjp->updateLOD(); } } diff --git a/indra/newview/lldrawpoolbump.cpp b/indra/newview/lldrawpoolbump.cpp index 0a0a2d610..fcebf26e7 100644 --- a/indra/newview/lldrawpoolbump.cpp +++ b/indra/newview/lldrawpoolbump.cpp @@ -1309,7 +1309,7 @@ void LLBumpImageList::onSourceLoaded( BOOL success, LLViewerTexture *src_vi, LLI for( i = minimum; i <= maximum; i++ ) { F32 minus_one_to_one = F32(maximum - i) * twice_one_over_range - 1.f; - bias_and_scale_lut[i] = llclampb(llround(127 * minus_one_to_one * ARTIFICIAL_SCALE + 128)); + bias_and_scale_lut[i] = llclampb(llmath::llround(127 * minus_one_to_one * ARTIFICIAL_SCALE + 128)); } } else @@ -1318,7 +1318,7 @@ void LLBumpImageList::onSourceLoaded( BOOL success, LLViewerTexture *src_vi, LLI for( i = minimum; i <= maximum; i++ ) { F32 minus_one_to_one = F32(i - minimum) * twice_one_over_range - 1.f; - bias_and_scale_lut[i] = llclampb(llround(127 * minus_one_to_one * ARTIFICIAL_SCALE + 128)); + bias_and_scale_lut[i] = llclampb(llmath::llround(127 * minus_one_to_one * ARTIFICIAL_SCALE + 128)); } } diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index 30864755c..eb360e120 100644 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -256,7 +256,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask) if (hasMouseCapture()) { F32 lerp = llclamp(1.f - (F32) (x - mGraphRect.mLeft) / (F32) mGraphRect.getWidth(), 0.f, 1.f); - mScrollIndex = llround( lerp * (F32)(LLFastTimer::NamedTimer::HISTORY_NUM - MAX_VISIBLE_HISTORY)); + mScrollIndex = llmath::llround( lerp * (F32)(LLFastTimer::NamedTimer::HISTORY_NUM - MAX_VISIBLE_HISTORY)); mScrollIndex = llclamp( mScrollIndex, 0, LLFastTimer::getLastFrameIndex()); return TRUE; } @@ -298,9 +298,9 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask) } mToolTipRect.set(mBarStart[mHoverBarIndex][i], - mBarRect.mBottom + llround(((F32)(MAX_VISIBLE_HISTORY - mHoverBarIndex + 1)) * ((F32)mBarRect.getHeight() / ((F32)MAX_VISIBLE_HISTORY + 2.f))), + mBarRect.mBottom + llmath::llround(((F32)(MAX_VISIBLE_HISTORY - mHoverBarIndex + 1)) * ((F32)mBarRect.getHeight() / ((F32)MAX_VISIBLE_HISTORY + 2.f))), mBarEnd[mHoverBarIndex][i], - mBarRect.mBottom + llround((F32)(MAX_VISIBLE_HISTORY - mHoverBarIndex) * ((F32)mBarRect.getHeight() / ((F32)MAX_VISIBLE_HISTORY + 2.f)))); + mBarRect.mBottom + llmath::llround((F32)(MAX_VISIBLE_HISTORY - mHoverBarIndex) * ((F32)mBarRect.getHeight() / ((F32)MAX_VISIBLE_HISTORY + 2.f)))); } if ((*it)->getCollapsed()) @@ -432,7 +432,7 @@ void LLFastTimerView::draw() mAverageCyclesPerTimer = LLFastTimer::sTimerCalls == 0 ? 0 - : llround(lerp((F32)mAverageCyclesPerTimer, (F32)(LLFastTimer::sTimerCycles / (U64)LLFastTimer::sTimerCalls), 0.1f)); + : llmath::llround(lerp((F32)mAverageCyclesPerTimer, (F32)(LLFastTimer::sTimerCycles / (U64)LLFastTimer::sTimerCalls), 0.1f)); LLFastTimer::sTimerCycles = 0; LLFastTimer::sTimerCalls = 0; @@ -800,7 +800,7 @@ void LLFastTimerView::draw() ? (F32)idp->getCountAverage() / (F32)totalticks : (F32)idp->getHistoricalCount(tidx) / (F32)totalticks; - dx = llround(frac * (F32)barw); + dx = llmath::llround(frac * (F32)barw); S32 prev_delta_x = deltax.empty() ? 0 : deltax.back(); deltax.push_back(dx); diff --git a/indra/newview/llflexibleobject.cpp b/indra/newview/llflexibleobject.cpp index cf97d4e82..1bcf79278 100644 --- a/indra/newview/llflexibleobject.cpp +++ b/indra/newview/llflexibleobject.cpp @@ -302,7 +302,7 @@ void LLVolumeImplFlexible::updateRenderRes() mRenderRes = (S32) (12.f*app_angle); #else //legacy behavior //number of segments only cares about z axis - F32 app_angle = llround((F32) atan2( mVO->getScale().mV[2]*2.f, drawablep->mDistanceWRTCamera) * RAD_TO_DEG, 0.01f); + F32 app_angle = llmath::llround((F32) atan2( mVO->getScale().mV[2]*2.f, drawablep->mDistanceWRTCamera) * RAD_TO_DEG, 0.01f); // Rendering sections increases with visible angle on the screen mRenderRes = (S32)(FLEXIBLE_OBJECT_MAX_SECTIONS*4*app_angle*DEG_TO_RAD/LLViewerCamera::getInstance()->getView()); diff --git a/indra/newview/llfloaterbuyland.cpp b/indra/newview/llfloaterbuyland.cpp index b955e31fb..86ed6505f 100644 --- a/indra/newview/llfloaterbuyland.cpp +++ b/indra/newview/llfloaterbuyland.cpp @@ -386,9 +386,9 @@ void LLFloaterBuyLandUI::updateParcelInfo() } mParcelBillableArea = - llround(mRegion->getBillableFactor() * mParcelActualArea); + llmath::llround(mRegion->getBillableFactor() * mParcelActualArea); - mParcelSupportedObjects = llround( + mParcelSupportedObjects = llmath::llround( parcel->getMaxPrimCapacity() * parcel->getParcelPrimBonus()); // Can't have more than region max tasks, regardless of parcel // object bonus factor. diff --git a/indra/newview/llfloaterenvsettings.cpp b/indra/newview/llfloaterenvsettings.cpp index 09f6ff402..c54a62545 100644 --- a/indra/newview/llfloaterenvsettings.cpp +++ b/indra/newview/llfloaterenvsettings.cpp @@ -316,7 +316,7 @@ std::string LLFloaterEnvSettings::timeToString(F32 curTime) // get hours and minutes hours = (S32) (24.0 * curTime); curTime -= ((F32) hours / 24.0f); - min = llround(24.0f * 60.0f * curTime); + min = llmath::llround(24.0f * 60.0f * curTime); // handle case where it's 60 if(min == 60) diff --git a/indra/newview/llfloaterexploreanimations.h b/indra/newview/llfloaterexploreanimations.h index bb3b91469..b0ec7f8e2 100644 --- a/indra/newview/llfloaterexploreanimations.h +++ b/indra/newview/llfloaterexploreanimations.h @@ -27,6 +27,16 @@ public: void update(); + void* operator new(size_t size) + { + return ll_aligned_malloc_16(size); + } + + void operator delete(void* ptr) + { + ll_aligned_free_16(ptr); + } + private: virtual ~LLFloaterExploreAnimations(); diff --git a/indra/newview/llfloaterland.cpp b/indra/newview/llfloaterland.cpp index 488f32186..57e4c0f20 100644 --- a/indra/newview/llfloaterland.cpp +++ b/indra/newview/llfloaterland.cpp @@ -1228,7 +1228,7 @@ void LLPanelLandObjects::refresh() { S32 sw_max = parcel->getSimWideMaxPrimCapacity(); S32 sw_total = parcel->getSimWidePrimCount(); - S32 max = llround(parcel->getMaxPrimCapacity() * parcel->getParcelPrimBonus()); + S32 max = llmath::llround(parcel->getMaxPrimCapacity() * parcel->getParcelPrimBonus()); S32 total = parcel->getPrimCount(); S32 owned = parcel->getOwnerPrimCount(); S32 group = parcel->getGroupPrimCount(); @@ -2106,9 +2106,9 @@ void LLPanelLandOptions::refresh() else { mLocationText->setTextArg("[LANDING]",llformat("%d, %d, %d", - llround(pos.mV[VX]), - llround(pos.mV[VY]), - llround(pos.mV[VZ]))); + llmath::llround(pos.mV[VX]), + llmath::llround(pos.mV[VY]), + llmath::llround(pos.mV[VZ]))); } mSetBtn->setEnabled( can_change_landing_point ); diff --git a/indra/newview/llfloaterlandholdings.cpp b/indra/newview/llfloaterlandholdings.cpp index 9046e768f..b672cbe91 100644 --- a/indra/newview/llfloaterlandholdings.cpp +++ b/indra/newview/llfloaterlandholdings.cpp @@ -227,8 +227,8 @@ void LLFloaterLandHoldings::processPlacesReply(LLMessageSystem* msg, void**) self->mActualArea += actual_area; self->mBillableArea += billable_area; - S32 region_x = llround(global_x) % REGION_WIDTH_UNITS; - S32 region_y = llround(global_y) % REGION_WIDTH_UNITS; + S32 region_x = llmath::llround(global_x) % REGION_WIDTH_UNITS; + S32 region_y = llmath::llround(global_y) % REGION_WIDTH_UNITS; std::string location; location = llformat("%s (%d, %d)", sim_name.c_str(), region_x, region_y); diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp index 26f4c136c..da11cbaf9 100644 --- a/indra/newview/llfloatermodelpreview.cpp +++ b/indra/newview/llfloatermodelpreview.cpp @@ -1446,8 +1446,11 @@ bool LLModelLoader::doLoadModel() } //no suitable slm exists, load from the .dae file + //replace illegal # in path as collada's escapser is broken + std::string tmp_file = mFilename; + boost::replace_all(tmp_file, "#", "%23"); DAE dae; - domCOLLADA* dom = dae.open(mFilename); + domCOLLADA* dom = dae.open(tmp_file); if (!dom) { @@ -1474,7 +1477,7 @@ bool LLModelLoader::doLoadModel() daeInt count = db->getElementCount(NULL, COLLADA_TYPE_MESH); - daeDocument* doc = dae.getDoc(mFilename); + daeDocument* doc = dae.getDoc(tmp_file); if (!doc) { llwarns << "can't find internal doc" << llendl; diff --git a/indra/newview/llfloaterpathfindingcharacters.cpp b/indra/newview/llfloaterpathfindingcharacters.cpp index d5e7fc089..d335b9566 100644 --- a/indra/newview/llfloaterpathfindingcharacters.cpp +++ b/indra/newview/llfloaterpathfindingcharacters.cpp @@ -219,7 +219,7 @@ LLSD LLFloaterPathfindingCharacters::buildCharacterScrollListItemData(const LLPa columns[2]["column"] = "owner"; columns[2]["value"] = getOwnerName(pCharacterPtr); - S32 cpuTime = llround(pCharacterPtr->getCPUTime()); + S32 cpuTime = llmath::llround(pCharacterPtr->getCPUTime()); std::string cpuTimeString = llformat("%d", cpuTime); LLStringUtil::format_map_t string_args; string_args["[CPU_TIME]"] = cpuTimeString; diff --git a/indra/newview/llfloatersnapshot.cpp b/indra/newview/llfloatersnapshot.cpp index 29019118c..f8c1b504b 100644 --- a/indra/newview/llfloatersnapshot.cpp +++ b/indra/newview/llfloatersnapshot.cpp @@ -493,16 +493,16 @@ void LLSnapshotLivePreview::updateSnapshot(BOOL new_snapshot, BOOL new_thumbnail if (mAspectRatio > window_aspect_ratio) { // trim off top and bottom - S32 height_diff = llround(getRect().getHeight() - (F32)getRect().getWidth() / mAspectRatio); - S32 half_height_diff = llround((getRect().getHeight() - (F32)getRect().getWidth() / mAspectRatio) * 0.5); + S32 height_diff = llmath::llround(getRect().getHeight() - (F32)getRect().getWidth() / mAspectRatio); + S32 half_height_diff = llmath::llround((getRect().getHeight() - (F32)getRect().getWidth() / mAspectRatio) * 0.5); rect.mBottom += half_height_diff; rect.mTop -= height_diff - half_height_diff; } else if (mAspectRatio < window_aspect_ratio) { // trim off left and right - S32 width_diff = llround(getRect().getWidth() - (F32)getRect().getHeight() * mAspectRatio); - S32 half_width_diff = llround((getRect().getWidth() - (F32)getRect().getHeight() * mAspectRatio) * 0.5f); + S32 width_diff = llmath::llround(getRect().getWidth() - (F32)getRect().getHeight() * mAspectRatio); + S32 half_width_diff = llmath::llround((getRect().getWidth() - (F32)getRect().getHeight() * mAspectRatio) * 0.5f); rect.mLeft += half_width_diff; rect.mRight -= width_diff - half_width_diff; } @@ -639,9 +639,9 @@ void LLSnapshotLivePreview::draw() LLLocalClipRect clip(getLocalRect()); { // draw diagonal stripe with gradient that passes over screen - S32 x1 = gViewerWindow->getWindowWidthScaled() * llround((clamp_rescale(shine_interp, 0.f, 1.f, -1.f - SHINE_WIDTH, 1.f))); - S32 x2 = x1 + llround(gViewerWindow->getWindowWidthScaled() * SHINE_WIDTH); - S32 x3 = x2 + llround(gViewerWindow->getWindowWidthScaled() * SHINE_WIDTH); + S32 x1 = gViewerWindow->getWindowWidthScaled() * llmath::llround((clamp_rescale(shine_interp, 0.f, 1.f, -1.f - SHINE_WIDTH, 1.f))); + S32 x2 = x1 + llmath::llround(gViewerWindow->getWindowWidthScaled() * SHINE_WIDTH); + S32 x3 = x2 + llmath::llround(gViewerWindow->getWindowWidthScaled() * SHINE_WIDTH); S32 y1 = 0; S32 y2 = gViewerWindow->getWindowHeightScaled(); @@ -719,7 +719,7 @@ void LLSnapshotLivePreview::draw() gGL.pushMatrix(); { LLRect const& rect = mFallFullScreenImageRect; - gGL.translatef((F32)rect.mLeft, (F32)rect.mBottom - llround(getRect().getHeight() * 2.f * (fall_interp * fall_interp)), 0.f); + gGL.translatef((F32)rect.mLeft, (F32)rect.mBottom - llmath::llround(getRect().getHeight() * 2.f * (fall_interp * fall_interp)), 0.f); gGL.rotatef(-45.f * fall_interp, 0.f, 0.f, 1.f); gGL.begin(LLRender::QUADS); { @@ -772,13 +772,13 @@ BOOL LLSnapshotLivePreview::setThumbnailImageSize() { // image too wide, shrink to width mThumbnailWidth = max_width; - mThumbnailHeight = llround((F32)max_width / window_aspect_ratio); + mThumbnailHeight = llmath::llround((F32)max_width / window_aspect_ratio); } else { // image too tall, shrink to height mThumbnailHeight = max_height; - mThumbnailWidth = llround((F32)max_height * window_aspect_ratio); + mThumbnailWidth = llmath::llround((F32)max_height * window_aspect_ratio); } if(mThumbnailWidth > window_width || mThumbnailHeight > window_height) @@ -790,11 +790,11 @@ BOOL LLSnapshotLivePreview::setThumbnailImageSize() F32 ratio = mAspectRatio * window_height / window_width; if(ratio > 1.f) { - top = llround(top / ratio); + top = llmath::llround(top / ratio); } else { - right = llround(right * ratio); + right = llmath::llround(right * ratio); } left = (mThumbnailWidth - right + 1) / 2; bottom = (mThumbnailHeight - top + 1) / 2; @@ -991,8 +991,8 @@ LLSnapshotLivePreview::EAspectSizeProblem LLSnapshotLivePreview::getAspectSizePr // We need an image with the aspect mAspectRatio (from which mWidth and mHeight were derived). // The current aspect ratio of mRawSnapshot. This should be (almost) equal to window_width / window_height, - // since these values are calculated in rawRawSnapshot with llround(window_width * scale_factor) and - // llround(window_height * scale_factor) respectively (since we set uncrop = true). + // since these values are calculated in rawRawSnapshot with llmath::llround(window_width * scale_factor) and + // llmath::llround(window_height * scale_factor) respectively (since we set uncrop = true). F32 raw_aspect = (F32)mRawSnapshotWidth / mRawSnapshotHeight; // The smaller dimension might have been rounded up to 0.5 up or down. Calculate upper and lower limits. F32 lower_raw_aspect = (mRawSnapshotWidth - 0.5) / (mRawSnapshotHeight + 0.5); @@ -1017,7 +1017,7 @@ LLSnapshotLivePreview::EAspectSizeProblem LLSnapshotLivePreview::getAspectSizePr height_out = mRawSnapshotHeight; if (mAspectRatio < lower_raw_aspect) { - width_out = llround(width_out * mAspectRatio / raw_aspect); + width_out = llmath::llround(width_out * mAspectRatio / raw_aspect); if (width_out < mRawSnapshotWidth) { // Only set this to false when there is actually something to crop. @@ -1033,7 +1033,7 @@ LLSnapshotLivePreview::EAspectSizeProblem LLSnapshotLivePreview::getAspectSizePr } else if (mAspectRatio > upper_raw_aspect) { - height_out = llround(height_out * raw_aspect / mAspectRatio); + height_out = llmath::llround(height_out * raw_aspect / mAspectRatio); if (height_out < mRawSnapshotHeight) { if (!allow_vertical_crop) @@ -2407,8 +2407,8 @@ void LLFloaterSnapshot::Impl::keepAspect(LLFloaterSnapshot* view, bool on, bool LLSnapshotLivePreview* previewp = getPreviewView(); if (previewp) { - S32 w = llround(view->childGetValue("snapshot_width").asReal(), 1.0); - S32 h = llround(view->childGetValue("snapshot_height").asReal(), 1.0); + S32 w = llmath::llround(view->childGetValue("snapshot_width").asReal(), 1.0); + S32 h = llmath::llround(view->childGetValue("snapshot_height").asReal(), 1.0); gSavedSettings.setS32(lastSnapshotWidthName(), w); gSavedSettings.setS32(lastSnapshotHeightName(), h); comboSetCustom(view, previewp->resolutionComboName()); @@ -2468,8 +2468,8 @@ void LLFloaterSnapshot::Impl::updateResolution(LLUICtrl* ctrl, void* data, bool // The size is actually the source aspect now, encoded in the width. F32 source_aspect = width / 630.f; // Use the size of the current window, cropped to the required aspect. - width = llmin(gViewerWindow->getWindowDisplayWidth(), llround(gViewerWindow->getWindowDisplayHeight() * source_aspect)); - height = llmin(gViewerWindow->getWindowDisplayHeight(), llround(gViewerWindow->getWindowDisplayWidth() / source_aspect)); + width = llmin(gViewerWindow->getWindowDisplayWidth(), llmath::llround(gViewerWindow->getWindowDisplayHeight() * source_aspect)); + height = llmin(gViewerWindow->getWindowDisplayHeight(), llmath::llround(gViewerWindow->getWindowDisplayWidth() / source_aspect)); previewp->setSize(width, height); } else @@ -2656,8 +2656,8 @@ void LLFloaterSnapshot::Impl::enforceResolution(LLFloaterSnapshot* floater, F32 nw = llmin(nw, nh * new_aspect); nh = llmin(nh, nw / new_aspect); // Round off to nearest integer. - S32 new_width = llround(nw); - S32 new_height = llround(nh); + S32 new_width = llmath::llround(nw); + S32 new_height = llmath::llround(nh); gSavedSettings.setS32(lastSnapshotWidthName(), new_width); gSavedSettings.setS32(lastSnapshotHeightName(), new_height); @@ -2758,8 +2758,8 @@ void LLFloaterSnapshot::Impl::onCommitCustomResolution(LLUICtrl *ctrl, void* dat LLSpinCtrl* width_spinner = view->getChild("snapshot_width"); LLSpinCtrl* height_spinner = view->getChild("snapshot_height"); - S32 w = llround((F32)width_spinner->getValue().asReal(), 1.0f); - S32 h = llround((F32)height_spinner->getValue().asReal(), 1.0f); + S32 w = llmath::llround((F32)width_spinner->getValue().asReal(), 1.0f); + S32 h = llmath::llround((F32)height_spinner->getValue().asReal(), 1.0f); LLSnapshotLivePreview* previewp = getPreviewView(); if (previewp) @@ -2786,12 +2786,12 @@ void LLFloaterSnapshot::Impl::onCommitCustomResolution(LLUICtrl *ctrl, void* dat if (h == curh) { // Width was changed. Change height to keep aspect constant. - h = llround(w / aspect); + h = llmath::llround(w / aspect); } else { // Height was changed. Change width to keep aspect constant. - w = llround(h * aspect); + w = llmath::llround(h * aspect); } } width_spinner->forceSetValue(LLSD::Real(w)); diff --git a/indra/newview/llfloaterworldmap.cpp b/indra/newview/llfloaterworldmap.cpp index 1d33194a0..c930fa461 100644 --- a/indra/newview/llfloaterworldmap.cpp +++ b/indra/newview/llfloaterworldmap.cpp @@ -710,9 +710,9 @@ void LLFloaterWorldMap::trackLocation(const LLVector3d& pos_global) // std::string full_name = llformat("%s (%d, %d, %d)", sim_name.c_str(), - llround(region_x), - llround(region_y), - llround((F32)pos_global.mdV[VZ])); + llmath::llround(region_x), + llmath::llround(region_y), + llmath::llround((F32)pos_global.mdV[VZ])); std::string tooltip(""); mTrackedStatus = LLTracker::TRACKING_LOCATION; diff --git a/indra/newview/llfolderview.cpp b/indra/newview/llfolderview.cpp index 8e36725c8..14259fe99 100644 --- a/indra/newview/llfolderview.cpp +++ b/indra/newview/llfolderview.cpp @@ -535,7 +535,7 @@ S32 LLFolderView::arrange( S32* unused_width, S32* unused_height, S32 filter_gen updateRenamerPosition(); mTargetHeight = (F32)target_height; - return llround(mTargetHeight); + return llmath::llround(mTargetHeight); } const std::string LLFolderView::getFilterSubString(BOOL trim) @@ -2041,7 +2041,7 @@ void LLFolderView::scrollToShowItem(LLFolderViewItem* item, const LLRect& constr LLRect item_scrolled_rect; // item position relative to display area of scroller S32 icon_height = mIcon.isNull() ? 0 : mIcon->getHeight(); - S32 label_height = llround(getLabelFontForStyle(mLabelStyle)->getLineHeight()); + S32 label_height = llmath::llround(getLabelFontForStyle(mLabelStyle)->getLineHeight()); // when navigating with keyboard, only move top of opened folder on screen, otherwise show whole folder S32 max_height_to_show = item->isOpen() && mScrollContainer->hasFocus() ? (llmax( icon_height, label_height ) + ICON_PAD) : local_rect.getHeight(); diff --git a/indra/newview/llfolderviewitem.cpp b/indra/newview/llfolderviewitem.cpp index 52c6cd998..3014bf180 100644 --- a/indra/newview/llfolderviewitem.cpp +++ b/indra/newview/llfolderviewitem.cpp @@ -1088,7 +1088,7 @@ void LLFolderViewItem::draw() if (filter_string_length > 0 && (mRoot->getSearchType() & 1)) { std::string combined_string = mLabel + mLabelSuffix; - S32 left = llround(text_left) + font->getWidth(combined_string, 0, mStringMatchOffset) - 1; + S32 left = llmath::llround(text_left) + font->getWidth(combined_string, 0, mStringMatchOffset) - 1; S32 right = left + font->getWidth(combined_string, mStringMatchOffset, filter_string_length) + 2; S32 bottom = llfloor(getRect().getHeight() - font->getLineHeight() - 3 - TOP_PAD); S32 top = getRect().getHeight() - TOP_PAD; @@ -1225,7 +1225,7 @@ S32 LLFolderViewFolder::arrange( S32* width, S32* height, S32 filter_generation) { S32 child_width = *width; S32 child_height = 0; - S32 child_top = parent_item_height - llround(running_height); + S32 child_top = parent_item_height - llmath::llround(running_height); target_height += folderp->arrange( &child_width, &child_height, filter_generation ); @@ -1251,7 +1251,7 @@ S32 LLFolderViewFolder::arrange( S32* width, S32* height, S32 filter_generation) { S32 child_width = *width; S32 child_height = 0; - S32 child_top = parent_item_height - llround(running_height); + S32 child_top = parent_item_height - llmath::llround(running_height); target_height += itemp->arrange( &child_width, &child_height, filter_generation ); // don't change width, as this item is as wide as its parent folder by construction @@ -1288,7 +1288,7 @@ S32 LLFolderViewFolder::arrange( S32* width, S32* height, S32 filter_generation) folders_t::iterator fit = iter++; // number of pixels that bottom of folder label is from top of parent folder if (getRect().getHeight() - (*fit)->getRect().mTop + (*fit)->getItemHeight() - > llround(mCurHeight) + MAX_FOLDER_ITEM_OVERLAP) + > llmath::llround(mCurHeight) + MAX_FOLDER_ITEM_OVERLAP) { // hide if beyond current folder height (*fit)->setVisible(FALSE); @@ -1301,7 +1301,7 @@ S32 LLFolderViewFolder::arrange( S32* width, S32* height, S32 filter_generation) items_t::iterator iit = iter++; // number of pixels that bottom of item label is from top of parent folder if (getRect().getHeight() - (*iit)->getRect().mBottom - > llround(mCurHeight) + MAX_FOLDER_ITEM_OVERLAP) + > llmath::llround(mCurHeight) + MAX_FOLDER_ITEM_OVERLAP) { (*iit)->setVisible(FALSE); } @@ -1313,12 +1313,12 @@ S32 LLFolderViewFolder::arrange( S32* width, S32* height, S32 filter_generation) } // don't change width as this item is already as wide as its parent folder - reshape(getRect().getWidth(),llround(mCurHeight)); + reshape(getRect().getWidth(),llmath::llround(mCurHeight)); // pass current height value back to parent - *height = llround(mCurHeight); + *height = llmath::llround(mCurHeight); - return llround(mTargetHeight); + return llmath::llround(mTargetHeight); } BOOL LLFolderViewFolder::needsArrange() diff --git a/indra/newview/llglsandbox.cpp b/indra/newview/llglsandbox.cpp index 53caaee64..c951fe953 100644 --- a/indra/newview/llglsandbox.cpp +++ b/indra/newview/llglsandbox.cpp @@ -100,10 +100,10 @@ void LLToolSelectRect::handleRectangleSelection(S32 x, S32 y, MASK mask) S32 top = llmax(y, mDragStartY); S32 bottom =llmin(y, mDragStartY); - left = llround((F32) left * LLUI::getScaleFactor().mV[VX]); - right = llround((F32) right * LLUI::getScaleFactor().mV[VX]); - top = llround((F32) top * LLUI::getScaleFactor().mV[VY]); - bottom = llround((F32) bottom * LLUI::getScaleFactor().mV[VY]); + left = llmath::llround((F32) left * LLUI::getScaleFactor().mV[VX]); + right = llmath::llround((F32) right * LLUI::getScaleFactor().mV[VX]); + top = llmath::llround((F32) top * LLUI::getScaleFactor().mV[VY]); + bottom = llmath::llround((F32) bottom * LLUI::getScaleFactor().mV[VY]); F32 old_far_plane = LLViewerCamera::getInstance()->getFar(); F32 old_near_plane = LLViewerCamera::getInstance()->getNear(); diff --git a/indra/newview/llmanip.cpp b/indra/newview/llmanip.cpp index f83e14e9b..c0f606414 100644 --- a/indra/newview/llmanip.cpp +++ b/indra/newview/llmanip.cpp @@ -538,8 +538,8 @@ void LLManip::renderTickValue(const LLVector3& pos, F32 value, const std::string std::string val_string; std::string fraction_string; - F32 val_to_print = llround(value, 0.001f); - S32 fractional_portion = llround(fmodf(llabs(val_to_print), 1.f) * 100.f); + F32 val_to_print = llmath::llround(value, 0.001f); + S32 fractional_portion = llmath::llround(fmodf(llabs(val_to_print), 1.f) * 100.f); if (val_to_print < 0.f) { if (fractional_portion == 0) diff --git a/indra/newview/llmaniprotate.cpp b/indra/newview/llmaniprotate.cpp index b04c0260e..5c160e5b6 100644 --- a/indra/newview/llmaniprotate.cpp +++ b/indra/newview/llmaniprotate.cpp @@ -373,9 +373,9 @@ void LLManipRotate::render() LLQuaternion object_rot = first_object->getRotationEdit(); object_rot.getEulerAngles(&(euler_angles.mV[VX]), &(euler_angles.mV[VY]), &(euler_angles.mV[VZ])); euler_angles *= RAD_TO_DEG; - euler_angles.mV[VX] = llround(fmodf(euler_angles.mV[VX] + 360.f, 360.f), 0.05f); - euler_angles.mV[VY] = llround(fmodf(euler_angles.mV[VY] + 360.f, 360.f), 0.05f); - euler_angles.mV[VZ] = llround(fmodf(euler_angles.mV[VZ] + 360.f, 360.f), 0.05f); + euler_angles.mV[VX] = llmath::llround(fmodf(euler_angles.mV[VX] + 360.f, 360.f), 0.05f); + euler_angles.mV[VY] = llmath::llround(fmodf(euler_angles.mV[VY] + 360.f, 360.f), 0.05f); + euler_angles.mV[VZ] = llmath::llround(fmodf(euler_angles.mV[VZ] + 360.f, 360.f), 0.05f); renderXYZ(euler_angles); } @@ -1500,7 +1500,7 @@ LLQuaternion LLManipRotate::dragConstrained( S32 x, S32 y ) F32 mouse_angle = fmodf(atan2(projected_mouse * axis1, projected_mouse * axis2) * RAD_TO_DEG + 360.f, 360.f); F32 relative_mouse_angle = fmodf(mouse_angle + (SNAP_ANGLE_DETENTE / 2), SNAP_ANGLE_INCREMENT); - //fmodf(llround(mouse_angle * RAD_TO_DEG, 7.5f) + 360.f, 360.f); + //fmodf(llmath::llround(mouse_angle * RAD_TO_DEG, 7.5f) + 360.f, 360.f); LLVector3 object_axis; getObjectAxisClosestToMouse(object_axis); @@ -1584,7 +1584,7 @@ LLQuaternion LLManipRotate::dragConstrained( S32 x, S32 y ) F32 mouse_angle = fmodf(atan2(projected_mouse * axis1, projected_mouse * axis2) * RAD_TO_DEG + 360.f, 360.f); F32 relative_mouse_angle = fmodf(mouse_angle + (SNAP_ANGLE_DETENTE / 2), SNAP_ANGLE_INCREMENT); - //fmodf(llround(mouse_angle * RAD_TO_DEG, 7.5f) + 360.f, 360.f); + //fmodf(llmath::llround(mouse_angle * RAD_TO_DEG, 7.5f) + 360.f, 360.f); LLVector3 object_axis; getObjectAxisClosestToMouse(object_axis); diff --git a/indra/newview/llmanipscale.cpp b/indra/newview/llmanipscale.cpp index 3ef134ee0..1a40a9e12 100644 --- a/indra/newview/llmanipscale.cpp +++ b/indra/newview/llmanipscale.cpp @@ -1559,8 +1559,8 @@ void LLManipScale::updateSnapGuides(const LLBBox& bbox) mScaleSnapUnit1 = mScaleSnapUnit1 / (mSnapDir1 * mScaleDir); mScaleSnapUnit2 = mScaleSnapUnit2 / (mSnapDir2 * mScaleDir); - mTickPixelSpacing1 = llround((F32)MIN_DIVISION_PIXEL_WIDTH / (mScaleDir % mSnapGuideDir1).length()); - mTickPixelSpacing2 = llround((F32)MIN_DIVISION_PIXEL_WIDTH / (mScaleDir % mSnapGuideDir2).length()); + mTickPixelSpacing1 = llmath::llround((F32)MIN_DIVISION_PIXEL_WIDTH / (mScaleDir % mSnapGuideDir1).length()); + mTickPixelSpacing2 = llmath::llround((F32)MIN_DIVISION_PIXEL_WIDTH / (mScaleDir % mSnapGuideDir2).length()); if (uniform) { @@ -1632,8 +1632,8 @@ void LLManipScale::renderSnapGuides(const LLBBox& bbox) F32 grid_offset2 = fmodf(dist_grid_axis, smallest_subdivision2); // how many smallest grid units are we away from largest grid scale? - S32 sub_div_offset_1 = llround(fmod(dist_grid_axis - grid_offset1, mScaleSnapUnit1 / sGridMinSubdivisionLevel) / smallest_subdivision1); - S32 sub_div_offset_2 = llround(fmod(dist_grid_axis - grid_offset2, mScaleSnapUnit2 / sGridMinSubdivisionLevel) / smallest_subdivision2); + S32 sub_div_offset_1 = llmath::llround(fmod(dist_grid_axis - grid_offset1, mScaleSnapUnit1 / sGridMinSubdivisionLevel) / smallest_subdivision1); + S32 sub_div_offset_2 = llmath::llround(fmod(dist_grid_axis - grid_offset2, mScaleSnapUnit2 / sGridMinSubdivisionLevel) / smallest_subdivision2); S32 num_ticks_per_side1 = llmax(1, lltrunc(0.5f * mSnapGuideLength / smallest_subdivision1)); S32 num_ticks_per_side2 = llmax(1, lltrunc(0.5f * mSnapGuideLength / smallest_subdivision2)); @@ -1687,7 +1687,7 @@ void LLManipScale::renderSnapGuides(const LLBBox& bbox) LLVector2 screen_translate_axis(llabs(mScaleDir * LLViewerCamera::getInstance()->getLeftAxis()), llabs(mScaleDir * LLViewerCamera::getInstance()->getUpAxis())); screen_translate_axis.normalize(); - S32 tick_label_spacing = llround(screen_translate_axis * sTickLabelSpacing); + S32 tick_label_spacing = llmath::llround(screen_translate_axis * sTickLabelSpacing); for (pass = 0; pass < 3; pass++) { @@ -1767,8 +1767,8 @@ void LLManipScale::renderSnapGuides(const LLBBox& bbox) stop_tick = llmin(max_ticks1, num_ticks_per_side1); F32 grid_resolution = mObjectSelection->getSelectType() == SELECT_TYPE_HUD ? 0.25f : llmax(gSavedSettings.getF32("GridResolution"), 0.001f); - S32 label_sub_div_offset_1 = llround(fmod(dist_grid_axis - grid_offset1, mScaleSnapUnit1 * 32.f) / smallest_subdivision1); - S32 label_sub_div_offset_2 = llround(fmod(dist_grid_axis - grid_offset2, mScaleSnapUnit2 * 32.f) / smallest_subdivision2); + S32 label_sub_div_offset_1 = llmath::llround(fmod(dist_grid_axis - grid_offset1, mScaleSnapUnit1 * 32.f) / smallest_subdivision1); + S32 label_sub_div_offset_2 = llmath::llround(fmod(dist_grid_axis - grid_offset2, mScaleSnapUnit2 * 32.f) / smallest_subdivision2); for (S32 i = start_tick; i <= stop_tick; i++) { diff --git a/indra/newview/llmaniptranslate.cpp b/indra/newview/llmaniptranslate.cpp index b066e5275..3be734b62 100644 --- a/indra/newview/llmaniptranslate.cpp +++ b/indra/newview/llmaniptranslate.cpp @@ -1263,7 +1263,7 @@ void LLManipTranslate::renderSnapGuides() // find distance to nearest smallest grid unit F32 offset_nearest_grid_unit = fmodf(dist_grid_axis, smallest_grid_unit_scale); // how many smallest grid units are we away from largest grid scale? - S32 sub_div_offset = llround(fmodf(dist_grid_axis - offset_nearest_grid_unit, getMinGridScale() / sGridMinSubdivisionLevel) / smallest_grid_unit_scale); + S32 sub_div_offset = llmath::llround(fmodf(dist_grid_axis - offset_nearest_grid_unit, getMinGridScale() / sGridMinSubdivisionLevel) / smallest_grid_unit_scale); S32 num_ticks_per_side = llmax(1, llfloor(0.5f * guide_size_meters / smallest_grid_unit_scale)); LLGLDepthTest gls_depth(GL_FALSE); @@ -1377,12 +1377,12 @@ void LLManipTranslate::renderSnapGuides() } } - sub_div_offset = llround(fmod(dist_grid_axis - offset_nearest_grid_unit, getMinGridScale() * 32.f) / smallest_grid_unit_scale); + sub_div_offset = llmath::llround(fmod(dist_grid_axis - offset_nearest_grid_unit, getMinGridScale() * 32.f) / smallest_grid_unit_scale); LLVector2 screen_translate_axis(llabs(translate_axis * LLViewerCamera::getInstance()->getLeftAxis()), llabs(translate_axis * LLViewerCamera::getInstance()->getUpAxis())); screen_translate_axis.normVec(); - S32 tick_label_spacing = llround(screen_translate_axis * sTickLabelSpacing); + S32 tick_label_spacing = llmath::llround(screen_translate_axis * sTickLabelSpacing); // render tickmark values for (S32 i = -num_ticks_per_side; i <= num_ticks_per_side; i++) @@ -1420,7 +1420,7 @@ void LLManipTranslate::renderSnapGuides() F32 offset_val = 0.5f * tick_offset.mV[ARROW_TO_AXIS[mManipPart]] / getMinGridScale(); EGridMode grid_mode = LLSelectMgr::getInstance()->getGridMode(); F32 text_highlight = 0.8f; - if(i - llround(offset_nearest_grid_unit / smallest_grid_unit_scale) == 0 && mInSnapRegime) + if(i - llmath::llround(offset_nearest_grid_unit / smallest_grid_unit_scale) == 0 && mInSnapRegime) { text_highlight = 1.f; } diff --git a/indra/newview/llmediactrl.cpp b/indra/newview/llmediactrl.cpp index e4bbcec50..b4239080a 100644 --- a/indra/newview/llmediactrl.cpp +++ b/indra/newview/llmediactrl.cpp @@ -120,8 +120,8 @@ LLMediaCtrl::LLMediaCtrl( const Params& p) : if(!getDecoupleTextureSize()) { - S32 screen_width = llround((F32)getRect().getWidth() * LLUI::getScaleFactor().mV[VX]); - S32 screen_height = llround((F32)getRect().getHeight() * LLUI::getScaleFactor().mV[VY]); + S32 screen_width = llmath::llround((F32)getRect().getWidth() * LLUI::getScaleFactor().mV[VX]); + S32 screen_height = llmath::llround((F32)getRect().getHeight() * LLUI::getScaleFactor().mV[VY]); setTextureSize(screen_width, screen_height); } @@ -464,8 +464,8 @@ void LLMediaCtrl::reshape( S32 width, S32 height, BOOL called_from_parent ) { if(!getDecoupleTextureSize()) { - S32 screen_width = llround((F32)width * LLUI::getScaleFactor().mV[VX]); - S32 screen_height = llround((F32)height * LLUI::getScaleFactor().mV[VY]); + S32 screen_width = llmath::llround((F32)width * LLUI::getScaleFactor().mV[VX]); + S32 screen_height = llmath::llround((F32)height * LLUI::getScaleFactor().mV[VY]); // when floater is minimized, these sizes are negative if ( screen_height > 0 && screen_width > 0 ) @@ -797,13 +797,13 @@ void LLMediaCtrl::draw() { // max width, adjusted height width = r.getWidth(); - height = llmin(llmax(llround(width / media_aspect), 0), r.getHeight()); + height = llmin(llmax(llmath::llround(width / media_aspect), 0), r.getHeight()); } else { // max height, adjusted width height = r.getHeight(); - width = llmin(llmax(llround(height * media_aspect), 0), r.getWidth()); + width = llmin(llmax(llmath::llround(height * media_aspect), 0), r.getWidth()); } } else @@ -823,10 +823,10 @@ void LLMediaCtrl::draw() /*if (mIgnoreUIScale) { - x_offset = llround((F32)x_offset * LLUI::getScaleFactor().mV[VX]); - y_offset = llround((F32)y_offset * LLUI::getScaleFactor().mV[VY]); - width = llround((F32)width * LLUI::getScaleFactor().mV[VX]); - height = llround((F32)height * LLUI::getScaleFactor().mV[VY]); + x_offset = llmath::llround((F32)x_offset * LLUI::getScaleFactor().mV[VX]); + y_offset = llmath::llround((F32)y_offset * LLUI::getScaleFactor().mV[VY]); + width = llmath::llround((F32)width * LLUI::getScaleFactor().mV[VX]); + height = llmath::llround((F32)height * LLUI::getScaleFactor().mV[VY]); }*/ // draw the browser @@ -897,14 +897,14 @@ void LLMediaCtrl::convertInputCoords(S32& x, S32& y) coords_opengl = mMediaSource->getMediaPlugin()->getTextureCoordsOpenGL(); } - x = llround((F32)x * LLUI::getScaleFactor().mV[VX]); + x = llmath::llround((F32)x * LLUI::getScaleFactor().mV[VX]); if ( ! coords_opengl ) { - y = llround((F32)(y) * LLUI::getScaleFactor().mV[VY]); + y = llmath::llround((F32)(y) * LLUI::getScaleFactor().mV[VY]); } else { - y = llround((F32)(getRect().getHeight() - y) * LLUI::getScaleFactor().mV[VY]); + y = llmath::llround((F32)(getRect().getHeight() - y) * LLUI::getScaleFactor().mV[VY]); }; } diff --git a/indra/newview/llnetmap.cpp b/indra/newview/llnetmap.cpp index 84b491949..adacb2a79 100644 --- a/indra/newview/llnetmap.cpp +++ b/indra/newview/llnetmap.cpp @@ -314,7 +314,7 @@ void LLNetMap::draw() static const LLCachedControl live_region_color(gColors, "NetMapLiveRegion"); static const LLCachedControl dead_region_color(gColors, "NetMapDeadRegion"); // Aurora Sim - //S32 region_width = llround(LLWorld::getInstance()->getRegionWidthInMeters()); + //S32 region_width = llmath::llround(LLWorld::getInstance()->getRegionWidthInMeters()); S32 region_width = REGION_WIDTH_UNITS; // Aurora Sim @@ -650,8 +650,8 @@ void LLNetMap::draw() (pos_map.mV[VX] >= getRect().getWidth()) || (pos_map.mV[VY] >= getRect().getHeight()) ) { - S32 x = llround( pos_map.mV[VX] ); - S32 y = llround( pos_map.mV[VY] ); + S32 x = llmath::llround( pos_map.mV[VX] ); + S32 y = llmath::llround( pos_map.mV[VY] ); LLWorldMapView::drawTrackingCircle( getRect(), x, y, color, 1, 10); } @@ -687,13 +687,13 @@ void LLNetMap::draw() } pos_map = globalPosToView(gAgent.getPositionGlobal()); - S32 dot_width = llround(mDotRadius * 2.f); + S32 dot_width = llmath::llround(mDotRadius * 2.f); LLUIImagePtr you = LLWorldMapView::sAvatarYouLargeImage; if (you) { - you->draw(llround(pos_map.mV[VX] - mDotRadius), - llround(pos_map.mV[VY] - mDotRadius), + you->draw(llmath::llround(pos_map.mV[VX] - mDotRadius), + llmath::llround(pos_map.mV[VY] - mDotRadius), dot_width, dot_width); @@ -856,8 +856,8 @@ void LLNetMap::drawTracking(const LLVector3d& pos_global, const LLColor4& color, { if (draw_arrow) { - S32 x = llround( pos_local.mV[VX] ); - S32 y = llround( pos_local.mV[VY] ); + S32 x = llmath::llround( pos_local.mV[VX] ); + S32 y = llmath::llround( pos_local.mV[VY] ); LLWorldMapView::drawTrackingCircle( getRect(), x, y, color, 1, 10 ); LLWorldMapView::drawTrackingArrow( getRect(), x, y, color ); } @@ -873,8 +873,8 @@ void LLNetMap::drawTracking(const LLVector3d& pos_global, const LLColor4& color, LLVector3d LLNetMap::viewPosToGlobal( S32 x, S32 y ) { - x -= llround(getRect().getWidth() / 2 + mCurPan.mV[VX]); - y -= llround(getRect().getHeight() / 2 + mCurPan.mV[VY]); + x -= llmath::llround(getRect().getWidth() / 2 + mCurPan.mV[VX]); + y -= llmath::llround(getRect().getHeight() / 2 + mCurPan.mV[VY]); LLVector3 pos_local( (F32)x, (F32)y, 0 ); @@ -1020,8 +1020,8 @@ void LLNetMap::setDirectionPos( LLTextBox* text_box, F32 rotation ) // Inset by a little to account for position display. radius -= 8.f; - text_box->setOrigin(llround(half_width + radius * cos( rotation )), - llround(half_height + radius * sin( rotation ))); + text_box->setOrigin(llmath::llround(half_width + radius * cos( rotation )), + llmath::llround(half_height + radius * sin( rotation ))); } void LLNetMap::updateMinorDirections() @@ -1050,7 +1050,7 @@ void LLNetMap::renderScaledPointGlobal( const LLVector3d& pos, const LLColor4U & const F32 MAX_RADIUS = 256.0f; F32 radius_clamped = llmin(radius_meters, MAX_RADIUS); - S32 diameter_pixels = llround(2 * radius_clamped * mObjectMapTPM); + S32 diameter_pixels = llmath::llround(2 * radius_clamped * mObjectMapTPM); renderPoint( local_pos, color, diameter_pixels ); } @@ -1066,8 +1066,8 @@ void LLNetMap::renderPoint(const LLVector3 &pos_local, const LLColor4U &color, const S32 image_width = (S32)mObjectImagep->getWidth(); const S32 image_height = (S32)mObjectImagep->getHeight(); - S32 x_offset = llround(pos_local.mV[VX] * mObjectMapTPM + image_width / 2); - S32 y_offset = llround(pos_local.mV[VY] * mObjectMapTPM + image_height / 2); + S32 x_offset = llmath::llround(pos_local.mV[VX] * mObjectMapTPM + image_width / 2); + S32 y_offset = llmath::llround(pos_local.mV[VY] * mObjectMapTPM + image_height / 2); if ((x_offset < 0) || (x_offset >= image_width)) { @@ -1147,8 +1147,8 @@ void LLNetMap::renderPropertyLinesForRegion(const LLViewerRegion* pRegion, const const S32 imgHeight = (S32)mParcelImagep->getHeight(); const LLVector3 originLocal(pRegion->getOriginGlobal() - mParcelImageCenterGlobal); - const S32 originX = llround(originLocal.mV[VX] * mObjectMapTPM + imgWidth / 2); - const S32 originY = llround(originLocal.mV[VY] * mObjectMapTPM + imgHeight / 2); + const S32 originX = llmath::llround(originLocal.mV[VX] * mObjectMapTPM + imgWidth / 2); + const S32 originY = llmath::llround(originLocal.mV[VY] * mObjectMapTPM + imgHeight / 2); U32* pTextureData = (U32*)mParcelRawImagep->getData(); @@ -1156,17 +1156,17 @@ void LLNetMap::renderPropertyLinesForRegion(const LLViewerRegion* pRegion, const // Draw the north and east region borders // const F32 real_width(pRegion->getWidth()); - const S32 borderY = originY + llround(real_width * mObjectMapTPM); +const S32 borderY = originY + llmath::llround(real_width * mObjectMapTPM); if ( (borderY >= 0) && (borderY < imgHeight) ) { - S32 curX = llclamp(originX, 0, imgWidth), endX = llclamp(originX + llround(real_width * mObjectMapTPM), 0, imgWidth - 1); + S32 curX = llclamp(originX, 0, imgWidth), endX = llclamp(originX + llmath::llround(real_width * mObjectMapTPM), 0, imgWidth - 1); for (; curX <= endX; curX++) pTextureData[borderY * imgWidth + curX] = clrOverlay.mAll; } - const S32 borderX = originX + llround(real_width * mObjectMapTPM); + const S32 borderX = originX + llmath::llround(real_width * mObjectMapTPM); if ( (borderX >= 0) && (borderX < imgWidth) ) { - S32 curY = llclamp(originY, 0, imgHeight), endY = llclamp(originY + llround(real_width * mObjectMapTPM), 0, imgHeight - 1); + S32 curY = llclamp(originY, 0, imgHeight), endY = llclamp(originY + llmath::llround(real_width * mObjectMapTPM), 0, imgHeight - 1); for (; curY <= endY; curY++) pTextureData[curY * imgWidth + borderX] = clrOverlay.mAll; } @@ -1190,17 +1190,17 @@ void LLNetMap::renderPropertyLinesForRegion(const LLViewerRegion* pRegion, const if ( (!fForSale) && (!fCollision) && (0 == (overlay & (PARCEL_SOUTH_LINE | PARCEL_WEST_LINE))) ) continue; - const S32 posX = originX + llround(idxCol * GRID_STEP * mObjectMapTPM); - const S32 posY = originY + llround(idxRow * GRID_STEP * mObjectMapTPM); + const S32 posX = originX + llmath::llround(idxCol * GRID_STEP * mObjectMapTPM); + const S32 posY = originY + llmath::llround(idxRow * GRID_STEP * mObjectMapTPM); static LLCachedControl s_fForSaleParcels(gSavedSettings, "MiniMapForSaleParcels"); static LLCachedControl s_fShowCollisionParcels(gSavedSettings, "MiniMapCollisionParcels"); if ( ((s_fForSaleParcels) && (fForSale)) || ((s_fShowCollisionParcels) && (fCollision)) ) { - S32 curY = llclamp(posY, 0, imgHeight), endY = llclamp(posY + llround(GRID_STEP * mObjectMapTPM), 0, imgHeight - 1); + S32 curY = llclamp(posY, 0, imgHeight), endY = llclamp(posY + llmath::llround(GRID_STEP * mObjectMapTPM), 0, imgHeight - 1); for (; curY <= endY; curY++) { - S32 curX = llclamp(posX, 0, imgWidth) , endX = llclamp(posX + llround(GRID_STEP * mObjectMapTPM), 0, imgWidth - 1); + S32 curX = llclamp(posX, 0, imgWidth) , endX = llclamp(posX + llmath::llround(GRID_STEP * mObjectMapTPM), 0, imgWidth - 1); for (; curX <= endX; curX++) { pTextureData[curY * imgWidth + curX] = (fForSale) ? LLColor4U(255, 255, 128, 192).mAll @@ -1212,7 +1212,7 @@ void LLNetMap::renderPropertyLinesForRegion(const LLViewerRegion* pRegion, const { if ( (posY >= 0) && (posY < imgHeight) ) { - S32 curX = llclamp(posX, 0, imgWidth), endX = llclamp(posX + llround(GRID_STEP * mObjectMapTPM), 0, imgWidth - 1); + S32 curX = llclamp(posX, 0, imgWidth), endX = llclamp(posX + llmath::llround(GRID_STEP * mObjectMapTPM), 0, imgWidth - 1); for (; curX <= endX; curX++) pTextureData[posY * imgWidth + curX] = clrOverlay.mAll; } @@ -1221,7 +1221,7 @@ void LLNetMap::renderPropertyLinesForRegion(const LLViewerRegion* pRegion, const { if ( (posX >= 0) && (posX < imgWidth) ) { - S32 curY = llclamp(posY, 0, imgHeight), endY = llclamp(posY + llround(GRID_STEP * mObjectMapTPM), 0, imgHeight - 1); + S32 curY = llclamp(posY, 0, imgHeight), endY = llclamp(posY + llmath::llround(GRID_STEP * mObjectMapTPM), 0, imgHeight - 1); for (; curY <= endY; curY++) pTextureData[curY * imgWidth + posX] = clrOverlay.mAll; } @@ -1240,7 +1240,7 @@ bool LLNetMap::createImage(LLPointer& rawimagep) const // ... which is, the diagonal of the rect. F32 width = (F32)getRect().getWidth(); F32 height = (F32)getRect().getHeight(); - S32 square_size = llround( sqrt(width*width + height*height) ); + S32 square_size = llmath::llround( sqrt(width*width + height*height) ); // Find the least power of two >= the minimum size. const S32 MIN_SIZE = 64; diff --git a/indra/newview/llpanelclassified.cpp b/indra/newview/llpanelclassified.cpp index 766cbe50c..b08150b57 100644 --- a/indra/newview/llpanelclassified.cpp +++ b/indra/newview/llpanelclassified.cpp @@ -332,9 +332,9 @@ void LLPanelClassifiedInfo::processProperties(void* data, EAvatarProcessorType t if (!location_text.empty()) location_text.append(", "); - S32 region_x = llround((F32)c_info->pos_global.mdV[VX]) % REGION_WIDTH_UNITS; - S32 region_y = llround((F32)c_info->pos_global.mdV[VY]) % REGION_WIDTH_UNITS; - S32 region_z = llround((F32)c_info->pos_global.mdV[VZ]); + S32 region_x = llmath::llround((F32)c_info->pos_global.mdV[VX]) % REGION_WIDTH_UNITS; + S32 region_y = llmath::llround((F32)c_info->pos_global.mdV[VY]) % REGION_WIDTH_UNITS; + S32 region_z = llmath::llround((F32)c_info->pos_global.mdV[VZ]); std::string buffer = llformat("%s (%d, %d, %d)", c_info->sim_name.c_str(), region_x, region_y, region_z); location_text.append(buffer); @@ -893,9 +893,9 @@ void LLPanelClassifiedInfo::onClickSet() location_text.assign(regionName); location_text.append(", "); - S32 region_x = llround((F32)mPosGlobal.mdV[VX]) % REGION_WIDTH_UNITS; - S32 region_y = llround((F32)mPosGlobal.mdV[VY]) % REGION_WIDTH_UNITS; - S32 region_z = llround((F32)mPosGlobal.mdV[VZ]); + S32 region_x = llmath::llround((F32)mPosGlobal.mdV[VX]) % REGION_WIDTH_UNITS; + S32 region_y = llmath::llround((F32)mPosGlobal.mdV[VY]) % REGION_WIDTH_UNITS; + S32 region_z = llmath::llround((F32)mPosGlobal.mdV[VZ]); location_text.append(mSimName); location_text.append(llformat(" (%d, %d, %d)", region_x, region_y, region_z)); diff --git a/indra/newview/llpaneldisplay.cpp b/indra/newview/llpaneldisplay.cpp index 1f979caab..70e98a663 100644 --- a/indra/newview/llpaneldisplay.cpp +++ b/indra/newview/llpaneldisplay.cpp @@ -906,8 +906,8 @@ void LLPanelDisplay::fractionFromDecimal(F32 decimal_val, S32& numerator, S32& d { if (fmodf((decimal_val * test_denominator) + 0.01f, 1.f) < 0.02f) { - numerator = llround(decimal_val * test_denominator); - denominator = llround(test_denominator); + numerator = llmath::llround(decimal_val * test_denominator); + denominator = llmath::llround(test_denominator); break; } } diff --git a/indra/newview/llpanelevent.cpp b/indra/newview/llpanelevent.cpp index ef25b25e9..6b57f1cf9 100644 --- a/indra/newview/llpanelevent.cpp +++ b/indra/newview/llpanelevent.cpp @@ -154,9 +154,9 @@ void LLPanelEvent::processEventInfoReply(LLMessageSystem *msg, void **) F32 global_x = (F32)self->mEventInfo.mPosGlobal.mdV[VX]; F32 global_y = (F32)self->mEventInfo.mPosGlobal.mdV[VY]; - S32 region_x = llround(global_x) % REGION_WIDTH_UNITS; - S32 region_y = llround(global_y) % REGION_WIDTH_UNITS; - S32 region_z = llround((F32)self->mEventInfo.mPosGlobal.mdV[VZ]); + S32 region_x = llmath::llround(global_x) % REGION_WIDTH_UNITS; + S32 region_y = llmath::llround(global_y) % REGION_WIDTH_UNITS; + S32 region_z = llmath::llround((F32)self->mEventInfo.mPosGlobal.mdV[VZ]); std::string desc = self->mEventInfo.mSimName + llformat(" (%d, %d, %d)", region_x, region_y, region_z); self->mTBLocation->setText(desc); diff --git a/indra/newview/llpanelgrouplandmoney.cpp b/indra/newview/llpanelgrouplandmoney.cpp index 8a66eef09..18000914c 100644 --- a/indra/newview/llpanelgrouplandmoney.cpp +++ b/indra/newview/llpanelgrouplandmoney.cpp @@ -462,8 +462,8 @@ void LLPanelGroupLandMoney::impl::processGroupLand(LLMessageSystem* msg) land_type = LLTrans::getString("land_type_unknown"); } - S32 region_x = llround(global_x) % REGION_WIDTH_UNITS; - S32 region_y = llround(global_y) % REGION_WIDTH_UNITS; + S32 region_x = llmath::llround(global_x) % REGION_WIDTH_UNITS; + S32 region_y = llmath::llround(global_y) % REGION_WIDTH_UNITS; std::string location = sim_name + llformat(" (%d, %d)", region_x, region_y); std::string area; committed+=billable_area; diff --git a/indra/newview/llpanelmaininventory.cpp b/indra/newview/llpanelmaininventory.cpp index 71b507ef6..490e22399 100644 --- a/indra/newview/llpanelmaininventory.cpp +++ b/indra/newview/llpanelmaininventory.cpp @@ -270,7 +270,7 @@ LLInventoryView::~LLInventoryView( void ) llofstream filtersFile(filterSaveName.str()); if(!LLSDSerialize::toPrettyXML(filterRoot, filtersFile)) { - llwarns << "Could not write to filters save file " << filterSaveName << llendl; + llwarns << "Could not write to filters save file " << filterSaveName.str().c_str() << llendl; } else filtersFile.close(); diff --git a/indra/newview/llpanelobject.cpp b/indra/newview/llpanelobject.cpp index 1cf09178e..c93f41aa6 100644 --- a/indra/newview/llpanelobject.cpp +++ b/indra/newview/llpanelobject.cpp @@ -565,9 +565,9 @@ void LLPanelObject::getState( ) LLQuaternion object_rot = objectp->getRotationEdit(); object_rot.getEulerAngles(&(mCurEulerDegrees.mV[VX]), &(mCurEulerDegrees.mV[VY]), &(mCurEulerDegrees.mV[VZ])); mCurEulerDegrees *= RAD_TO_DEG; - mCurEulerDegrees.mV[VX] = fmod(llround(mCurEulerDegrees.mV[VX], OBJECT_ROTATION_PRECISION) + 360.f, 360.f); - mCurEulerDegrees.mV[VY] = fmod(llround(mCurEulerDegrees.mV[VY], OBJECT_ROTATION_PRECISION) + 360.f, 360.f); - mCurEulerDegrees.mV[VZ] = fmod(llround(mCurEulerDegrees.mV[VZ], OBJECT_ROTATION_PRECISION) + 360.f, 360.f); + mCurEulerDegrees.mV[VX] = fmod(llmath::llround(mCurEulerDegrees.mV[VX], OBJECT_ROTATION_PRECISION) + 360.f, 360.f); + mCurEulerDegrees.mV[VY] = fmod(llmath::llround(mCurEulerDegrees.mV[VY], OBJECT_ROTATION_PRECISION) + 360.f, 360.f); + mCurEulerDegrees.mV[VZ] = fmod(llmath::llround(mCurEulerDegrees.mV[VZ], OBJECT_ROTATION_PRECISION) + 360.f, 360.f); if (enable_rotate) { @@ -1965,9 +1965,9 @@ void LLPanelObject::sendRotation(BOOL btn_down) if (mObject.isNull()) return; LLVector3 new_rot(mCtrlRotX->get(), mCtrlRotY->get(), mCtrlRotZ->get()); - new_rot.mV[VX] = llround(new_rot.mV[VX], OBJECT_ROTATION_PRECISION); - new_rot.mV[VY] = llround(new_rot.mV[VY], OBJECT_ROTATION_PRECISION); - new_rot.mV[VZ] = llround(new_rot.mV[VZ], OBJECT_ROTATION_PRECISION); + new_rot.mV[VX] = llmath::llround(new_rot.mV[VX], OBJECT_ROTATION_PRECISION); + new_rot.mV[VY] = llmath::llround(new_rot.mV[VY], OBJECT_ROTATION_PRECISION); + new_rot.mV[VZ] = llmath::llround(new_rot.mV[VZ], OBJECT_ROTATION_PRECISION); // Note: must compare before conversion to radians LLVector3 delta = new_rot - mCurEulerDegrees; diff --git a/indra/newview/llpanelpick.cpp b/indra/newview/llpanelpick.cpp index 674d9b65d..c2e2a2cb1 100644 --- a/indra/newview/llpanelpick.cpp +++ b/indra/newview/llpanelpick.cpp @@ -178,9 +178,9 @@ void LLPanelPick::processProperties(void* data, EAvatarProcessorType type) self->mImporting = false; } - S32 region_x = llround((F32)pick_info->pos_global.mdV[VX]) % REGION_WIDTH_UNITS; - S32 region_y = llround((F32)pick_info->pos_global.mdV[VY]) % REGION_WIDTH_UNITS; - S32 region_z = llround((F32)pick_info->pos_global.mdV[VZ]); + S32 region_x = llmath::llround((F32)pick_info->pos_global.mdV[VX]) % REGION_WIDTH_UNITS; + S32 region_y = llmath::llround((F32)pick_info->pos_global.mdV[VY]) % REGION_WIDTH_UNITS; + S32 region_z = llmath::llround((F32)pick_info->pos_global.mdV[VZ]); location_text.append(llformat("(%d, %d, %d)", region_x, region_y, region_z)); mDataReceived = true; @@ -401,9 +401,9 @@ void LLPanelPick::onClickSet() std::string location_text("(will update after save), " + mSimName); - S32 region_x = llround((F32)mPosGlobal.mdV[VX]) % REGION_WIDTH_UNITS; - S32 region_y = llround((F32)mPosGlobal.mdV[VY]) % REGION_WIDTH_UNITS; - S32 region_z = llround((F32)mPosGlobal.mdV[VZ]); + S32 region_x = llmath::llround((F32)mPosGlobal.mdV[VX]) % REGION_WIDTH_UNITS; + S32 region_y = llmath::llround((F32)mPosGlobal.mdV[VY]) % REGION_WIDTH_UNITS; + S32 region_z = llmath::llround((F32)mPosGlobal.mdV[VZ]); location_text.append(llformat(" (%d, %d, %d)", region_x, region_y, region_z)); // if sim name in pick is different from current sim name diff --git a/indra/newview/llpanelplace.cpp b/indra/newview/llpanelplace.cpp index 80af2ac56..dfa5d88ef 100644 --- a/indra/newview/llpanelplace.cpp +++ b/indra/newview/llpanelplace.cpp @@ -289,16 +289,16 @@ void LLPanelPlace::processParcelInfo(const LLParcelData& parcel_data) } // Just use given region position for display - S32 region_x = llround(mPosRegion.mV[0]); - S32 region_y = llround(mPosRegion.mV[1]); - S32 region_z = llround(mPosRegion.mV[2]); + S32 region_x = llmath::llround(mPosRegion.mV[0]); + S32 region_y = llmath::llround(mPosRegion.mV[1]); + S32 region_z = llmath::llround(mPosRegion.mV[2]); // If the region position is zero, grab position from the global if(mPosRegion.isExactlyZero()) { - region_x = llround(parcel_data.global_x) % REGION_WIDTH_UNITS; - region_y = llround(parcel_data.global_y) % REGION_WIDTH_UNITS; - region_z = llround(parcel_data.global_z); + region_x = llmath::llround(parcel_data.global_x) % REGION_WIDTH_UNITS; + region_y = llmath::llround(parcel_data.global_y) % REGION_WIDTH_UNITS; + region_z = llmath::llround(parcel_data.global_z); } if(mPosGlobal.isExactlyZero()) diff --git a/indra/newview/llpanelprimmediacontrols.cpp b/indra/newview/llpanelprimmediacontrols.cpp index 5fa463a34..91372b23c 100644 --- a/indra/newview/llpanelprimmediacontrols.cpp +++ b/indra/newview/llpanelprimmediacontrols.cpp @@ -642,12 +642,12 @@ void LLPanelPrimMediaControls::updateShape() // convert screenspace bbox to pixels (in screen coords) LLRect window_rect = gViewerWindow->getWorldViewRectScaled(); LLCoordGL screen_min; - screen_min.mX = llround((F32)window_rect.mLeft + (F32)window_rect.getWidth() * (min.getF32ptr()[VX] + 1.f) * 0.5f); - screen_min.mY = llround((F32)window_rect.mBottom + (F32)window_rect.getHeight() * (min.getF32ptr()[VY] + 1.f) * 0.5f); + screen_min.mX = llmath::llround((F32)window_rect.mLeft + (F32)window_rect.getWidth() * (min.getF32ptr()[VX] + 1.f) * 0.5f); + screen_min.mY = llmath::llround((F32)window_rect.mBottom + (F32)window_rect.getHeight() * (min.getF32ptr()[VY] + 1.f) * 0.5f); LLCoordGL screen_max; - screen_max.mX = llround((F32)window_rect.mLeft + (F32)window_rect.getWidth() * (max.getF32ptr()[VX] + 1.f) * 0.5f); - screen_max.mY = llround((F32)window_rect.mBottom + (F32)window_rect.getHeight() * (max.getF32ptr()[VY] + 1.f) * 0.5f); + screen_max.mX = llmath::llround((F32)window_rect.mLeft + (F32)window_rect.getWidth() * (max.getF32ptr()[VX] + 1.f) * 0.5f); + screen_max.mY = llmath::llround((F32)window_rect.mBottom + (F32)window_rect.getHeight() * (max.getF32ptr()[VY] + 1.f) * 0.5f); // grow panel so that screenspace bounding box fits inside "media_region" element of panel LLRect media_panel_rect; diff --git a/indra/newview/llpreviewtexture.cpp b/indra/newview/llpreviewtexture.cpp index 6d686b252..4127cfadc 100644 --- a/indra/newview/llpreviewtexture.cpp +++ b/indra/newview/llpreviewtexture.cpp @@ -590,7 +590,7 @@ void LLPreviewTexture::updateDimensions() client_width = getRect().getWidth() - horiz_pad; if (mAspectRatio > 0.f) { - client_height = llround(client_width / mAspectRatio); + client_height = llmath::llround(client_width / mAspectRatio); } else { @@ -608,7 +608,7 @@ void LLPreviewTexture::updateDimensions() if (client_height > max_height) { client_height = max_height; - client_width = llround(client_height * mAspectRatio); + client_width = llmath::llround(client_height * mAspectRatio); } } else diff --git a/indra/newview/llslurl.cpp b/indra/newview/llslurl.cpp index fdd812d65..5862dd958 100644 --- a/indra/newview/llslurl.cpp +++ b/indra/newview/llslurl.cpp @@ -356,9 +356,9 @@ LLSLURL::LLSLURL(const std::string& grid, { mGrid = grid; mRegion = region; - S32 x = llround( (F32)position[VX] ); - S32 y = llround( (F32)position[VY] ); - S32 z = llround( (F32)position[VZ] ); + S32 x = llmath::llround( (F32)position[VX] ); + S32 y = llmath::llround( (F32)position[VY] ); + S32 z = llmath::llround( (F32)position[VZ] ); mType = LOCATION; mPosition = LLVector3(x, y, z); } @@ -417,9 +417,9 @@ std::string LLSLURL::getSLURLString() const case LOCATION: { // lookup the grid - S32 x = llround( (F32)mPosition[VX] ); - S32 y = llround( (F32)mPosition[VY] ); - S32 z = llround( (F32)mPosition[VZ] ); + S32 x = llmath::llround( (F32)mPosition[VX] ); + S32 y = llmath::llround( (F32)mPosition[VY] ); + S32 z = llmath::llround( (F32)mPosition[VZ] ); //return LLGridManager::getInstance()->getSLURLBase(mGrid) + //Singu TODO: Implement LLHippoGridMgr::getSLURLBase some day. For now it's hardcoded. std::string fixed_slurl; @@ -471,9 +471,9 @@ std::string LLSLURL::getLoginString() const case LOCATION: unescaped_start << "uri:" << mRegion << "&" - << llround(mPosition[0]) << "&" - << llround(mPosition[1]) << "&" - << llround(mPosition[2]); + << llmath::llround(mPosition[0]) << "&" + << llmath::llround(mPosition[1]) << "&" + << llmath::llround(mPosition[2]); break; case HOME_LOCATION: unescaped_start << "home"; @@ -517,9 +517,9 @@ std::string LLSLURL::getLocationString() const { return llformat("%s/%d/%d/%d", mRegion.c_str(), - (int)llround(mPosition[0]), - (int)llround(mPosition[1]), - (int)llround(mPosition[2])); + (int)llmath::llround(mPosition[0]), + (int)llmath::llround(mPosition[1]), + (int)llmath::llround(mPosition[2])); } // static diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index 1448681ce..665fe75a8 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -44,12 +44,13 @@ #include "llviewermedia_streamingaudio.h" #include "llaudioengine.h" -#if LL_FMODEX -# include "llaudioengine_fmodex.h" + +#if LL_FMODSTUDIO +# include "llaudioengine_fmodstudio.h" #endif -#if LL_FMOD -# include "llaudioengine_fmod.h" +#if LL_FMODEX +# include "llaudioengine_fmodex.h" #endif #ifdef LL_OPENAL @@ -415,6 +416,17 @@ void init_audio() { gAudiop = NULL; +#ifdef LL_FMODSTUDIO + if (!gAudiop +#if !LL_WINDOWS + && NULL == getenv("LL_BAD_FMODSTUDIO_DRIVER") +#endif // !LL_WINDOWS + ) + { + gAudiop = (LLAudioEngine *) new LLAudioEngine_FMODSTUDIO(gSavedSettings.getBOOL("SHEnableFMODExProfiler"), gSavedSettings.getBOOL("SHEnableFMODEXVerboseDebugging")); + } +#endif + #ifdef LL_FMODEX if (!gAudiop #if !LL_WINDOWS @@ -437,17 +449,6 @@ void init_audio() } #endif -#ifdef LL_FMOD - if (!gAudiop -#if !LL_WINDOWS - && NULL == getenv("LL_BAD_FMOD_DRIVER") -#endif // !LL_WINDOWS - ) - { - gAudiop = (LLAudioEngine *) new LLAudioEngine_FMOD(); - } -#endif - if (gAudiop) { #if LL_WINDOWS @@ -1614,7 +1615,7 @@ bool idle_startup() if (gNoRender) { LL_WARNS("AppInit") << "Bad login - missing return values" << LL_ENDL; - LL_WARNS("AppInit") << emsg << LL_ENDL; + LL_WARNS("AppInit") << emsg.str() << LL_ENDL; exit(0); } // Bounce back to the login screen. @@ -1630,7 +1631,7 @@ bool idle_startup() if (gNoRender) { LL_WARNS("AppInit") << "Failed to login!" << LL_ENDL; - LL_WARNS("AppInit") << emsg << LL_ENDL; + LL_WARNS("AppInit") << emsg.str() << LL_ENDL; exit(0); } // Bounce back to the login screen. diff --git a/indra/newview/llsurface.cpp b/indra/newview/llsurface.cpp index fd7c0da59..bdf34d6c6 100644 --- a/indra/newview/llsurface.cpp +++ b/indra/newview/llsurface.cpp @@ -1425,10 +1425,10 @@ BOOL LLSurface::generateWaterTexture(const F32 x, const F32 y, S32 x_begin, y_begin, x_end, y_end; - x_begin = llround(x * scale_inv); - y_begin = llround(y * scale_inv); - x_end = llround((x + width) * scale_inv); - y_end = llround((y + width) * scale_inv); + x_begin = llmath::llround(x * scale_inv); + y_begin = llmath::llround(y * scale_inv); + x_end = llmath::llround((x + width) * scale_inv); + y_end = llmath::llround((y + width) * scale_inv); if (x_end > tex_width) { @@ -1476,9 +1476,9 @@ BOOL LLSurface::generateWaterTexture(const F32 x, const F32 y, // Want non-linear curve for transparency gradient coloru = MAX_WATER_COLOR; const F32 frac = 1.f - 2.f/(2.f - (height - WATER_HEIGHT)); - S32 alpha = 64 + llround((255-64)*frac); + S32 alpha = 64 + llmath::llround((255-64)*frac); - alpha = llmin(llround((F32)MAX_WATER_COLOR.mV[3]), alpha); + alpha = llmin(llmath::llround((F32)MAX_WATER_COLOR.mV[3]), alpha); alpha = llmax(64, alpha); coloru.mV[3] = alpha; diff --git a/indra/newview/lltexturectrl.cpp b/indra/newview/lltexturectrl.cpp index 7a0955c4f..fca81e83f 100644 --- a/indra/newview/lltexturectrl.cpp +++ b/indra/newview/lltexturectrl.cpp @@ -1167,7 +1167,7 @@ LLTextureCtrl::LLTextureCtrl( S32 image_top = getRect().getHeight(); S32 image_bottom = BTN_HEIGHT_SMALL; S32 image_middle = (image_top + image_bottom) / 2; - S32 line_height = llround(LLFontGL::getFontSansSerifSmall()->getLineHeight()); + S32 line_height = llmath::llround(LLFontGL::getFontSansSerifSmall()->getLineHeight()); mTentativeLabel = new LLTextBox( std::string("Multiple"), LLRect( diff --git a/indra/newview/lltoolselectland.cpp b/indra/newview/lltoolselectland.cpp index 0c6637828..9a09c3ed3 100644 --- a/indra/newview/lltoolselectland.cpp +++ b/indra/newview/lltoolselectland.cpp @@ -226,8 +226,8 @@ void LLToolSelectLand::handleDeselect() void LLToolSelectLand::roundXY(LLVector3d &vec) { - vec.mdV[VX] = llround( vec.mdV[VX], (F64)PARCEL_GRID_STEP_METERS ); - vec.mdV[VY] = llround( vec.mdV[VY], (F64)PARCEL_GRID_STEP_METERS ); + vec.mdV[VX] = llmath::llround( vec.mdV[VX], (F64)PARCEL_GRID_STEP_METERS ); + vec.mdV[VY] = llmath::llround( vec.mdV[VY], (F64)PARCEL_GRID_STEP_METERS ); } diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index 4994869ce..6fe2d4d9d 100644 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -1254,8 +1254,8 @@ LLRect get_whole_screen_region() if (zoom_factor > 1.f) { S32 num_horizontal_tiles = llceil(zoom_factor); - S32 tile_width = llround((F32)gViewerWindow->getWorldViewWidthScaled() / zoom_factor); - S32 tile_height = llround((F32)gViewerWindow->getWorldViewHeightScaled() / zoom_factor); + S32 tile_width = llmath::llround((F32)gViewerWindow->getWorldViewWidthScaled() / zoom_factor); + S32 tile_height = llmath::llround((F32)gViewerWindow->getWorldViewHeightScaled() / zoom_factor); int tile_y = sub_region / num_horizontal_tiles; int tile_x = sub_region - (tile_y * num_horizontal_tiles); @@ -1539,8 +1539,8 @@ void render_ui_2d() int pos_y = sub_region / llceil(zoom_factor); int pos_x = sub_region - (pos_y*llceil(zoom_factor)); // offset for this tile - LLFontGL::sCurOrigin.mX -= llround((F32)gViewerWindow->getWindowWidthScaled() * (F32)pos_x / zoom_factor); - LLFontGL::sCurOrigin.mY -= llround((F32)gViewerWindow->getWindowHeightScaled() * (F32)pos_y / zoom_factor); + LLFontGL::sCurOrigin.mX -= llmath::llround((F32)gViewerWindow->getWindowWidthScaled() * (F32)pos_x / zoom_factor); + LLFontGL::sCurOrigin.mY -= llmath::llround((F32)gViewerWindow->getWindowHeightScaled() * (F32)pos_y / zoom_factor); } stop_glerror(); diff --git a/indra/newview/llviewerjoint.h b/indra/newview/llviewerjoint.h index fd262b6e8..1ec87ee41 100644 --- a/indra/newview/llviewerjoint.h +++ b/indra/newview/llviewerjoint.h @@ -49,6 +49,16 @@ public: LLViewerJoint(const std::string &name, LLJoint *parent = NULL); virtual ~LLViewerJoint(); + void* operator new(size_t size) + { + return ll_aligned_malloc_16(size); + } + + void operator delete(void* ptr) + { + ll_aligned_free_16(ptr); + } + // Render character hierarchy. // Traverses the entire joint hierarchy, setting up // transforms and calling the drawShape(). diff --git a/indra/newview/llviewerjointattachment.h b/indra/newview/llviewerjointattachment.h index 9addafaee..bb94c3678 100644 --- a/indra/newview/llviewerjointattachment.h +++ b/indra/newview/llviewerjointattachment.h @@ -47,6 +47,16 @@ public: LLViewerJointAttachment(); virtual ~LLViewerJointAttachment(); + void* operator new(size_t size) + { + return ll_aligned_malloc_16(size); + } + + void operator delete(void* ptr) + { + ll_aligned_free_16(ptr); + } + //virtual U32 render( F32 pixelArea ); // Returns triangle count // Returns true if this object is transparent. diff --git a/indra/newview/llviewerjointmesh.h b/indra/newview/llviewerjointmesh.h index c5b872ede..017a7fe11 100644 --- a/indra/newview/llviewerjointmesh.h +++ b/indra/newview/llviewerjointmesh.h @@ -50,6 +50,16 @@ public: // Destructor virtual ~LLViewerJointMesh(); + void* operator new(size_t size) + { + return ll_aligned_malloc_16(size); + } + + void operator delete(void* ptr) + { + ll_aligned_free_16(ptr); + } + // Render time method to upload batches of joint matrices void uploadJointMatrices(); diff --git a/indra/newview/llviewerkeyboard.cpp b/indra/newview/llviewerkeyboard.cpp index c756354d8..535b66001 100644 --- a/indra/newview/llviewerkeyboard.cpp +++ b/indra/newview/llviewerkeyboard.cpp @@ -71,7 +71,7 @@ void agent_jump( EKeystate s ) { if( KEYSTATE_UP == s ) return; F32 time = gKeyboard->getCurKeyElapsedTime(); - S32 frame_count = llround(gKeyboard->getCurKeyElapsedFrameCount()); + S32 frame_count = llmath::llround(gKeyboard->getCurKeyElapsedFrameCount()); if( time < FLY_TIME || frame_count <= FLY_FRAMES @@ -148,7 +148,7 @@ static void agent_push_forwardbackward( EKeystate s, S32 direction, LLAgent::EDo if (KEYSTATE_UP == s) return; F32 time = gKeyboard->getCurKeyElapsedTime(); - S32 frame_count = llround(gKeyboard->getCurKeyElapsedFrameCount()); + S32 frame_count = llmath::llround(gKeyboard->getCurKeyElapsedFrameCount()); if( time < NUDGE_TIME || frame_count <= NUDGE_FRAMES) { @@ -176,7 +176,7 @@ static void agent_slide_leftright( EKeystate s, S32 direction, LLAgent::EDoubleT agent_handle_doubletap_run(s, mode); if( KEYSTATE_UP == s ) return; F32 time = gKeyboard->getCurKeyElapsedTime(); - S32 frame_count = llround(gKeyboard->getCurKeyElapsedFrameCount()); + S32 frame_count = llmath::llround(gKeyboard->getCurKeyElapsedFrameCount()); if( time < NUDGE_TIME || frame_count <= NUDGE_FRAMES) { diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp index 3c274ff33..52ccb9c7c 100644 --- a/indra/newview/llviewermedia.cpp +++ b/indra/newview/llviewermedia.cpp @@ -941,7 +941,7 @@ void LLViewerMedia::updateMedia(void *dummy_arg) { F32 approximate_interest_dimension = (F32) sqrt(pimpl->getInterest()); - pimpl->setLowPrioritySizeLimit(llround(approximate_interest_dimension)); + pimpl->setLowPrioritySizeLimit(llmath::llround(approximate_interest_dimension)); } } else @@ -2367,8 +2367,8 @@ void LLViewerMediaImpl::scaleTextureCoords(const LLVector2& texture_coords, S32 texture_y = 1.0 + texture_y; // scale x and y to texel units. - *x = llround(texture_x * plugin->getTextureWidth()); - *y = llround((1.0f - texture_y) * plugin->getTextureHeight()); + *x = llmath::llround(texture_x * plugin->getTextureWidth()); + *y = llmath::llround((1.0f - texture_y) * plugin->getTextureHeight()); // Adjust for the difference between the actual texture height and the amount of the texture in use. *y -= (plugin->getTextureHeight() - plugin->getHeight()); diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index 9485a7712..2779f1404 100644 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -3961,9 +3961,9 @@ void process_chat_from_simulator(LLMessageSystem *msg, void **user_data) const LLViewerObject* obj(chatter ? chatter : gObjectList.findObject(owner_id)); // Compute the object SLURL. LLVector3 pos = obj ? obj->getPositionRegion() : LLVector3::zero; - S32 x = llround((F32)fmod((F64)pos.mV[VX], (F64)REGION_WIDTH_METERS)); - S32 y = llround((F32)fmod((F64)pos.mV[VY], (F64)REGION_WIDTH_METERS)); - S32 z = llround((F32)pos.mV[VZ]); + S32 x = llmath::llround((F32)fmod((F64)pos.mV[VX], (F64)REGION_WIDTH_METERS)); + S32 y = llmath::llround((F32)fmod((F64)pos.mV[VY], (F64)REGION_WIDTH_METERS)); + S32 z = llmath::llround((F32)pos.mV[VZ]); std::ostringstream location; location << (obj ? obj->getRegion() : gAgent.getRegion())->getName() << "/" << x << "/" << y << "/" << z; if (chatter != obj) location << "?owner_not_object"; diff --git a/indra/newview/llviewerparcelmgr.cpp b/indra/newview/llviewerparcelmgr.cpp index 977d8fede..63ba67994 100644 --- a/indra/newview/llviewerparcelmgr.cpp +++ b/indra/newview/llviewerparcelmgr.cpp @@ -315,7 +315,7 @@ S32 LLViewerParcelMgr::getSelectedArea() const F64 width = mEastNorth.mdV[VX] - mWestSouth.mdV[VX]; F64 height = mEastNorth.mdV[VY] - mWestSouth.mdV[VY]; F32 area = (F32)(width * height); - rv = llround(area); + rv = llmath::llround(area); } return rv; } @@ -335,10 +335,10 @@ void LLViewerParcelMgr::writeHighlightSegments(F32 west, F32 south, F32 east, F32 north) { S32 x, y; - S32 min_x = llround( west / PARCEL_GRID_STEP_METERS ); - S32 max_x = llround( east / PARCEL_GRID_STEP_METERS ); - S32 min_y = llround( south / PARCEL_GRID_STEP_METERS ); - S32 max_y = llround( north / PARCEL_GRID_STEP_METERS ); + S32 min_x = llmath::llround( west / PARCEL_GRID_STEP_METERS ); + S32 max_x = llmath::llround( east / PARCEL_GRID_STEP_METERS ); + S32 min_y = llmath::llround( south / PARCEL_GRID_STEP_METERS ); + S32 max_y = llmath::llround( north / PARCEL_GRID_STEP_METERS ); const S32 STRIDE = mParcelsPerEdge+1; @@ -450,12 +450,12 @@ LLParcelSelectionHandle LLViewerParcelMgr::selectParcelAt(const LLVector3d& pos_ LLVector3d northeast = pos_global; southwest -= LLVector3d( PARCEL_GRID_STEP_METERS/2, PARCEL_GRID_STEP_METERS/2, 0 ); - southwest.mdV[VX] = llround( southwest.mdV[VX], (F64)PARCEL_GRID_STEP_METERS ); - southwest.mdV[VY] = llround( southwest.mdV[VY], (F64)PARCEL_GRID_STEP_METERS ); + southwest.mdV[VX] = llmath::llround( southwest.mdV[VX], (F64)PARCEL_GRID_STEP_METERS ); + southwest.mdV[VY] = llmath::llround( southwest.mdV[VY], (F64)PARCEL_GRID_STEP_METERS ); northeast += LLVector3d( PARCEL_GRID_STEP_METERS/2, PARCEL_GRID_STEP_METERS/2, 0 ); - northeast.mdV[VX] = llround( northeast.mdV[VX], (F64)PARCEL_GRID_STEP_METERS ); - northeast.mdV[VY] = llround( northeast.mdV[VY], (F64)PARCEL_GRID_STEP_METERS ); + northeast.mdV[VX] = llmath::llround( northeast.mdV[VX], (F64)PARCEL_GRID_STEP_METERS ); + northeast.mdV[VY] = llmath::llround( northeast.mdV[VY], (F64)PARCEL_GRID_STEP_METERS ); // Snap to parcel return selectLand( southwest, northeast, TRUE ); diff --git a/indra/newview/llviewerpartsim.cpp b/indra/newview/llviewerpartsim.cpp index 3c0c37b3e..5e334e634 100644 --- a/indra/newview/llviewerpartsim.cpp +++ b/indra/newview/llviewerpartsim.cpp @@ -397,7 +397,7 @@ void LLViewerPartGroup::updateParticles(const F32 lastdt) } // Do glow interpolation - part->mGlow.mV[3] = (U8) llround(lerp(part->mStartGlow, part->mEndGlow, frac)*255.f); + part->mGlow.mV[3] = (U8) llmath::llround(lerp(part->mStartGlow, part->mEndGlow, frac)*255.f); // Set the last update time to now. part->mLastUpdateTime = cur_time; diff --git a/indra/newview/llviewerpartsource.cpp b/indra/newview/llviewerpartsource.cpp index cbd0cc31e..10b70f398 100644 --- a/indra/newview/llviewerpartsource.cpp +++ b/indra/newview/llviewerpartsource.cpp @@ -322,7 +322,7 @@ void LLViewerPartSourceScript::update(const F32 dt) part->mStartGlow = mPartSysData.mPartData.mStartGlow; part->mEndGlow = mPartSysData.mPartData.mEndGlow; - part->mGlow = LLColor4U(0, 0, 0, (U8) llround(part->mStartGlow*255.f)); + part->mGlow = LLColor4U(0, 0, 0, (U8) llmath::llround(part->mStartGlow*255.f)); if (mPartSysData.mPattern & LLPartSysData::LL_PART_SRC_PATTERN_DROP) { diff --git a/indra/newview/llviewertextureanim.cpp b/indra/newview/llviewertextureanim.cpp index 1e6b7a343..fc5d30890 100644 --- a/indra/newview/llviewertextureanim.cpp +++ b/indra/newview/llviewertextureanim.cpp @@ -174,7 +174,7 @@ S32 LLViewerTextureAnim::animateTextures(F32 &off_s, F32 &off_t, if (!(mMode & SMOOTH)) { - frame_counter = (F32)llround(frame_counter); + frame_counter = (F32)llmath::llround(frame_counter); } // diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index d87a94c9f..ebc25abab 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -846,8 +846,8 @@ BOOL LLViewerWindow::handleAnyMouseClick(LLWindow *window, LLCoordGL pos, MASK BOOL handled = FALSE; S32 x = pos.mX; S32 y = pos.mY; - x = llround((F32)x / mDisplayScale.mV[VX]); - y = llround((F32)y / mDisplayScale.mV[VY]); + x = llmath::llround((F32)x / mDisplayScale.mV[VX]); + y = llmath::llround((F32)y / mDisplayScale.mV[VY]); if (down) { @@ -1021,8 +1021,8 @@ BOOL LLViewerWindow::handleRightMouseDown(LLWindow *window, LLCoordGL pos, MASK { S32 x = pos.mX; S32 y = pos.mY; - x = llround((F32)x / mDisplayScale.mV[VX]); - y = llround((F32)y / mDisplayScale.mV[VY]); + x = llmath::llround((F32)x / mDisplayScale.mV[VX]); + y = llmath::llround((F32)y / mDisplayScale.mV[VY]); LLView::sMouseHandlerMessage.clear(); @@ -1220,8 +1220,8 @@ void LLViewerWindow::handleMouseMove(LLWindow *window, LLCoordGL pos, MASK mask S32 x = pos.mX; S32 y = pos.mY; - x = llround((F32)x / mDisplayScale.mV[VX]); - y = llround((F32)y / mDisplayScale.mV[VY]); + x = llmath::llround((F32)x / mDisplayScale.mV[VX]); + y = llmath::llround((F32)y / mDisplayScale.mV[VY]); mMouseInWindow = TRUE; @@ -1716,7 +1716,7 @@ LLViewerWindow::LLViewerWindow( LLCoordWindow size; mWindow->getSize(&size); mWindowRectRaw.set(0, size.mY, size.mX, 0); - mWindowRectScaled.set(0, llround((F32)size.mY / mDisplayScale.mV[VY]), llround((F32)size.mX / mDisplayScale.mV[VX]), 0); + mWindowRectScaled.set(0, llmath::llround((F32)size.mY / mDisplayScale.mV[VY]), llmath::llround((F32)size.mX / mDisplayScale.mV[VX]), 0); } LLFontManager::initClass(); @@ -2398,8 +2398,8 @@ void LLViewerWindow::reshape(S32 width, S32 height) LLUI::setScaleFactor(mDisplayScale); // update our window rectangle - mWindowRectScaled.mRight = mWindowRectScaled.mLeft + llround((F32)width / mDisplayScale.mV[VX]); - mWindowRectScaled.mTop = mWindowRectScaled.mBottom + llround((F32)height / mDisplayScale.mV[VY]); + mWindowRectScaled.mRight = mWindowRectScaled.mLeft + llmath::llround((F32)width / mDisplayScale.mV[VX]); + mWindowRectScaled.mTop = mWindowRectScaled.mBottom + llmath::llround((F32)height / mDisplayScale.mV[VY]); setup2DViewport(); @@ -2560,8 +2560,8 @@ void LLViewerWindow::draw() microsecondsToTimecodeString(gFrameTime,text); const LLFontGL* font = LLFontGL::getFontSansSerif(); font->renderUTF8(text, 0, - llround((getWindowWidthScaled()/2)-100.f), - llround((getWindowHeightScaled()-60.f)), + llmath::llround((getWindowWidthScaled()/2)-100.f), + llmath::llround((getWindowHeightScaled()-60.f)), LLColor4( 1.f, 1.f, 1.f, 1.f ), LLFontGL::LEFT, LLFontGL::TOP); } @@ -2661,7 +2661,7 @@ void LLViewerWindow::draw() const S32 DIST_FROM_TOP = 20; LLFontGL::getFontSansSerifBig()->renderUTF8( mOverlayTitle, 0, - llround( getWindowWidthScaled() * 0.5f), + llmath::llround( getWindowWidthScaled() * 0.5f), getWindowHeightScaled() - DIST_FROM_TOP, LLColor4(1, 1, 1, 0.4f), LLFontGL::HCENTER, LLFontGL::TOP); @@ -3514,7 +3514,7 @@ void LLViewerWindow::updateMouseDelta() fdx = fdx + ((F32) dx - fdx) * llmin(gFrameIntervalSeconds*amount,1.f); fdy = fdy + ((F32) dy - fdy) * llmin(gFrameIntervalSeconds*amount,1.f); - mCurrentMouseDelta.set(llround(fdx), llround(fdy)); + mCurrentMouseDelta.set(llmath::llround(fdx), llmath::llround(fdy)); mouse_vel.setVec(fdx,fdy); } else @@ -4804,10 +4804,10 @@ bool LLViewerWindow::rawRawSnapshot(LLImageRaw *raw, // However, if the buffer turns out to be too large, then clamp it to max_size. scale_factor = llmin(max_size / snapshot_width, max_size / snapshot_height)) // Clamp { - image_buffer_x = llround(unscaled_image_buffer_x * scale_factor); - image_buffer_y = llround(unscaled_image_buffer_y * scale_factor); - S32 image_size_x = llround(snapshot_width * scale_factor); - S32 image_size_y = llround(snapshot_width * scale_factor); + image_buffer_x = llmath::llround(unscaled_image_buffer_x * scale_factor); + image_buffer_y = llmath::llround(unscaled_image_buffer_y * scale_factor); + S32 image_size_x = llmath::llround(snapshot_width * scale_factor); + S32 image_size_y = llmath::llround(snapshot_width * scale_factor); if (llmax(image_size_x, image_size_y) > max_size && // Boundary check to avoid memory overflow. internal_scale <= 1.f && !reset_deferred) // SHY_MOD: If supersampling... Don't care about max_size. { @@ -5075,7 +5075,7 @@ void LLViewerWindow::drawMouselookInstructions() INSTRUCTIONS_PAD, getWindowHeight() - INSTRUCTIONS_PAD, font->getWidth( instructions ) + 2 * INSTRUCTIONS_PAD, - llround(font->getLineHeight() + 2 * INSTRUCTIONS_PAD)); + llmath::llround(font->getLineHeight() + 2 * INSTRUCTIONS_PAD)); { gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); @@ -5685,8 +5685,8 @@ void LLViewerWindow::calcDisplayScale() if (mWindow->getFullscreen()) { - display_scale.mV[0] = llround(display_scale.mV[0], 2.0f/(F32) mWindowRectRaw.getWidth()); - display_scale.mV[1] = llround(display_scale.mV[1], 2.0f/(F32) mWindowRectRaw.getHeight()); + display_scale.mV[0] = llmath::llround(display_scale.mV[0], 2.0f/(F32) mWindowRectRaw.getWidth()); + display_scale.mV[1] = llmath::llround(display_scale.mV[1], 2.0f/(F32) mWindowRectRaw.getHeight()); } if (display_scale != mDisplayScale) @@ -5970,8 +5970,8 @@ void LLPickInfo::updateXYCoords() LLPointer imagep = LLViewerTextureManager::getFetchedTexture(tep->getID()); if(mUVCoords.mV[VX] >= 0.f && mUVCoords.mV[VY] >= 0.f && imagep.notNull()) { - mXYCoords.mX = llround(mUVCoords.mV[VX] * (F32)imagep->getWidth()); - mXYCoords.mY = llround((1.f - mUVCoords.mV[VY]) * (F32)imagep->getHeight()); + mXYCoords.mX = llmath::llround(mUVCoords.mV[VX] * (F32)imagep->getWidth()); + mXYCoords.mY = llmath::llround((1.f - mUVCoords.mV[VY]) * (F32)imagep->getHeight()); } } } @@ -6000,7 +6000,7 @@ void LLPickInfo::getSurfaceInfo() if (objectp) { - if (gViewerWindow->cursorIntersect(llround((F32)mMousePt.mX), llround((F32)mMousePt.mY), 1024.f, + if (gViewerWindow->cursorIntersect(llmath::llround((F32)mMousePt.mX), llmath::llround((F32)mMousePt.mY), 1024.f, objectp, -1, mPickTransparent, &mObjectFace, &intersection, @@ -6058,8 +6058,8 @@ LLVector2 LLPickInfo::pickUV() objectp->mDrawable.notNull() && objectp->getPCode() == LL_PCODE_VOLUME && mObjectFace < objectp->mDrawable->getNumFaces()) { - S32 scaled_x = llround((F32)mPickPt.mX * gViewerWindow->getDisplayScale().mV[VX]); - S32 scaled_y = llround((F32)mPickPt.mY * gViewerWindow->getDisplayScale().mV[VY]); + S32 scaled_x = llmath::llround((F32)mPickPt.mX * gViewerWindow->getDisplayScale().mV[VX]); + S32 scaled_y = llmath::llround((F32)mPickPt.mY * gViewerWindow->getDisplayScale().mV[VY]); const S32 UV_PICK_WIDTH = 5; const S32 UV_PICK_HALF_WIDTH = (UV_PICK_WIDTH - 1) / 2; U8 uv_pick_buffer[UV_PICK_WIDTH * UV_PICK_WIDTH * 4]; diff --git a/indra/newview/llvlcomposition.cpp b/indra/newview/llvlcomposition.cpp index 94ae918be..a15fb9872 100644 --- a/indra/newview/llvlcomposition.cpp +++ b/indra/newview/llvlcomposition.cpp @@ -133,10 +133,10 @@ BOOL LLVLComposition::generateHeights(const F32 x, const F32 y, S32 x_begin, y_begin, x_end, y_end; - x_begin = llround( x * mScaleInv ); - y_begin = llround( y * mScaleInv ); - x_end = llround( (x + width) * mScaleInv ); - y_end = llround( (y + width) * mScaleInv ); + x_begin = llmath::llround( x * mScaleInv ); + y_begin = llmath::llround( y * mScaleInv ); + x_end = llmath::llround( (x + width) * mScaleInv ); + y_end = llmath::llround( (y + width) * mScaleInv ); if (x_end > mWidth) { @@ -331,8 +331,8 @@ BOOL LLVLComposition::generateTexture(const F32 x, const F32 y, S32 x_begin, y_begin, x_end, y_end; x_begin = (S32)(x * mScaleInv); y_begin = (S32)(y * mScaleInv); - x_end = llround( (x + width) * mScaleInv ); - y_end = llround( (y + width) * mScaleInv ); + x_end = llmath::llround( (x + width) * mScaleInv ); + y_end = llmath::llround( (y + width) * mScaleInv ); if (x_end > mWidth) { diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index 82584ef15..3378242b3 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -8008,7 +8008,7 @@ void LLVOAvatar::parseAppearanceMessage(LLMessageSystem* mesgsys, LLAppearanceMe if (it != contents.mParams.end()) { S32 index = it - contents.mParams.begin(); - contents.mParamAppearanceVersion = llround(contents.mParamWeights[index]); + contents.mParamAppearanceVersion = llmath::llround(contents.mParamWeights[index]); LL_DEBUGS("Avatar") << "appversion req by appearance_version param: " << contents.mParamAppearanceVersion << LL_ENDL; } } diff --git a/indra/newview/llvoicevivox.cpp b/indra/newview/llvoicevivox.cpp index b4cc3e1fa..ebffc93ec 100644 --- a/indra/newview/llvoicevivox.cpp +++ b/indra/newview/llvoicevivox.cpp @@ -2647,7 +2647,7 @@ void LLVivoxVoiceClient::sendPositionalUpdate(void) if(!p->mIsSelf) { // scale from the range 0.0-1.0 to vivox volume in the range 0-100 - S32 volume = llround(p->mVolume / VOLUME_SCALE_VIVOX); + S32 volume = llmath::llround(p->mVolume / VOLUME_SCALE_VIVOX); bool mute = p->mOnMuteList; if(mute) diff --git a/indra/newview/llvopartgroup.cpp b/indra/newview/llvopartgroup.cpp index 7b4077798..837d0aea2 100644 --- a/indra/newview/llvopartgroup.cpp +++ b/indra/newview/llvopartgroup.cpp @@ -699,7 +699,7 @@ void LLVOPartGroup::getGeometry(S32 idx, } else { - pglow = LLColor4U(0, 0, 0, (U8) llround(255.f*part.mStartGlow)); + pglow = LLColor4U(0, 0, 0, (U8) llmath::llround(255.f*part.mStartGlow)); pcolor = part.mStartColor; } } diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 4411ce17e..751c93ef2 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -1210,7 +1210,7 @@ S32 LLVOVolume::computeLODDetail(F32 distance, F32 radius) { // We've got LOD in the profile, and in the twist. Use radius. F32 tan_angle = (LLVOVolume::sLODFactor*radius)/distance; - cur_detail = LLVolumeLODGroup::getDetailFromTan(llround(tan_angle, 0.01f)); + cur_detail = LLVolumeLODGroup::getDetailFromTan(llmath::llround(tan_angle, 0.01f)); } else { @@ -1257,8 +1257,8 @@ BOOL LLVOVolume::calcLOD() // DON'T Compensate for field of view changing on FOV zoom. distance *= F_PI/3.f; - cur_detail = computeLODDetail(llround(distance, 0.01f), - llround(radius, 0.01f)); + cur_detail = computeLODDetail(llmath::llround(distance, 0.01f), + llmath::llround(radius, 0.01f)); if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_LOD_INFO) && @@ -1271,7 +1271,7 @@ BOOL LLVOVolume::calcLOD() if (cur_detail != mLOD) { - mAppAngle = llround((F32) atan2( mDrawable->getRadius(), mDrawable->mDistanceWRTCamera) * RAD_TO_DEG, 0.01f); + mAppAngle = llmath::llround((F32) atan2( mDrawable->getRadius(), mDrawable->mDistanceWRTCamera) * RAD_TO_DEG, 0.01f); mLOD = cur_detail; return TRUE; } @@ -4903,7 +4903,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) } } /*LLColor4 clr = facep->getFaceColor(); - LLColor4U clru = LLColor4U(llround(clr.mV[0] * 255.f), llround(clr.mV[0] * 255.f), llround(clr.mV[0] * 255.f), llround(clr.mV[0] * 255.f)); + LLColor4U clru = LLColor4U(llmath::llround(clr.mV[0] * 255.f), llmath::llround(clr.mV[0] * 255.f), llmath::llround(clr.mV[0] * 255.f), llmath::llround(clr.mV[0] * 255.f)); if(clru.mV[0] == 164 && clru.mV[1] == 106 && clr.mV[2] == 65) { llinfos << "Facepool = " << type << " alpha = " << clr.mV[3] << llendl; diff --git a/indra/newview/llwlanimator.cpp b/indra/newview/llwlanimator.cpp index 953898fe6..3bdc1ae5e 100644 --- a/indra/newview/llwlanimator.cpp +++ b/indra/newview/llwlanimator.cpp @@ -267,7 +267,7 @@ std::string LLWLAnimator::timeToString(F32 curTime) // get hours and minutes hours = (S32) (24.0 * curTime); curTime -= ((F32) hours / 24.0f); - min = llround(24.0f * 60.0f * curTime); + min = llmath::llround(24.0f * 60.0f * curTime); // handle case where it's 60 if(min == 60) diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp index a52bf2d53..d83f6013c 100644 --- a/indra/newview/llworld.cpp +++ b/indra/newview/llworld.cpp @@ -1124,7 +1124,7 @@ void LLWorld::updateWaterObjects() // Count the found coastline. F32 new_water_height = water_heights[index]; LL_DEBUGS("WaterHeight") << " This is void; counting coastline with water height of " << new_water_height << LL_ENDL; - S32 new_water_height_cm = llround(new_water_height * 100); + S32 new_water_height_cm = llmath::llround(new_water_height * 100); int count = (water_height_counts[new_water_height_cm] += 1); // Just use the lowest water height: this is mainly about the horizon water, // and whatever we do, we don't want it to be possible to look under the water diff --git a/indra/newview/llworldmapview.cpp b/indra/newview/llworldmapview.cpp index 2d76879e2..3742ba4df 100644 --- a/indra/newview/llworldmapview.cpp +++ b/indra/newview/llworldmapview.cpp @@ -467,9 +467,9 @@ void LLWorldMapView::draw() if (overlayimage) { // Inform the fetch mechanism of the size we need - S32 draw_size = llround(sMapScale); - overlayimage->setKnownDrawSize( llround(draw_size * LLUI::getScaleFactor().mV[VX] * ((F32)info->getSizeX() / REGION_WIDTH_METERS)), - llround(draw_size * LLUI::getScaleFactor().mV[VY] * ((F32)info->getSizeY() / REGION_WIDTH_METERS))); + S32 draw_size = llmath::llround(sMapScale); + overlayimage->setKnownDrawSize( llmath::llround(draw_size * LLUI::getScaleFactor().mV[VX] * ((F32)info->getSizeX() / REGION_WIDTH_METERS)), + llmath::llround(draw_size * LLUI::getScaleFactor().mV[VY] * ((F32)info->getSizeY() / REGION_WIDTH_METERS))); // Draw something whenever we have enough info if (overlayimage->hasGLTexture() && !overlayimage->isMissingAsset() && overlayimage->getID() != IMG_DEFAULT) { @@ -674,14 +674,14 @@ void LLWorldMapView::draw() drawImage(pos_global, sAvatarYouImage); LLVector3 pos_map = globalPosToView(pos_global); - if (!pointInView(llround(pos_map.mV[VX]), llround(pos_map.mV[VY]))) + if (!pointInView(llmath::llround(pos_map.mV[VX]), llmath::llround(pos_map.mV[VY]))) { drawTracking(pos_global, lerp(LLColor4::yellow, LLColor4::orange, 0.4f), TRUE, "You are here", "", - llround(LLFontGL::getFontSansSerifSmall()->getLineHeight())); // offset vertically by one line, to avoid overlap with target tracking + llmath::llround(LLFontGL::getFontSansSerifSmall()->getLineHeight())); // offset vertically by one line, to avoid overlap with target tracking } // Show your viewing angle @@ -823,8 +823,8 @@ void LLWorldMapView::drawLegacyBackgroundLayers(S32 width, S32 height) { } current_image->setBoostLevel(LLGLTexture::BOOST_MAP); - current_image->setKnownDrawSize(llround(pix_width * LLUI::getScaleFactor().mV[VX]), - llround(pix_height * LLUI::getScaleFactor().mV[VY])); + current_image->setKnownDrawSize(llmath::llround(pix_width * LLUI::getScaleFactor().mV[VX]), + llmath::llround(pix_height * LLUI::getScaleFactor().mV[VY])); if (!current_image->hasGLTexture()) //Still loading. { @@ -911,9 +911,9 @@ F32 LLWorldMapView::drawLegacySimTile(LLSimInfo& sim_info, S32 left, S32 top, S3 //call setKnownDrawSize if image is still loading, or its actually being drawn. if(sim_fetching || alpha >= ALPHA_CUTOFF) { - S32 draw_size = llround(sMapScale); - simimage->setKnownDrawSize( llround(draw_size * LLUI::getScaleFactor().mV[VX] * ((F32)sim_info.getSizeX() / REGION_WIDTH_METERS)), - llround(draw_size * LLUI::getScaleFactor().mV[VY] * ((F32)sim_info.getSizeY() / REGION_WIDTH_METERS))); + S32 draw_size = llmath::llround(sMapScale); + simimage->setKnownDrawSize( llmath::llround(draw_size * LLUI::getScaleFactor().mV[VX] * ((F32)sim_info.getSizeX() / REGION_WIDTH_METERS)), + llmath::llround(draw_size * LLUI::getScaleFactor().mV[VY] * ((F32)sim_info.getSizeY() / REGION_WIDTH_METERS))); simimage->setBoostLevel(LLGLTexture::BOOST_MAP); if(alpha >= ALPHA_CUTOFF) { @@ -1128,8 +1128,8 @@ void LLWorldMapView::drawGenericItem(const LLItemInfo& item, LLUIImagePtr image) void LLWorldMapView::drawImage(const LLVector3d& global_pos, LLUIImagePtr image, const LLColor4& color) { LLVector3 pos_map = globalPosToView( global_pos ); - image->draw(llround(pos_map.mV[VX] - image->getWidth() /2.f), - llround(pos_map.mV[VY] - image->getHeight()/2.f), + image->draw(llmath::llround(pos_map.mV[VX] - image->getWidth() /2.f), + llmath::llround(pos_map.mV[VY] - image->getHeight()/2.f), color); } @@ -1138,8 +1138,8 @@ void LLWorldMapView::drawImageStack(const LLVector3d& global_pos, LLUIImagePtr i LLVector3 pos_map = globalPosToView( global_pos ); for(U32 i=0; idraw(llround(pos_map.mV[VX] - image->getWidth() /2.f), - llround(pos_map.mV[VY] - image->getHeight()/2.f + i*offset), + image->draw(llmath::llround(pos_map.mV[VX] - image->getWidth() /2.f), + llmath::llround(pos_map.mV[VY] - image->getHeight()/2.f + i*offset), color); } } @@ -1323,8 +1323,8 @@ void LLWorldMapView::drawTracking(const LLVector3d& pos_global, const LLColor4& const std::string& label, const std::string& tooltip, S32 vert_offset ) { LLVector3 pos_local = globalPosToView( pos_global ); - S32 x = llround( pos_local.mV[VX] ); - S32 y = llround( pos_local.mV[VY] ); + S32 x = llmath::llround( pos_local.mV[VX] ); + S32 y = llmath::llround( pos_local.mV[VY] ); LLFontGL* font = LLFontGL::getFontSansSerifSmall(); S32 text_x = x; S32 text_y = (S32)(y - sTrackCircleImage->getHeight()/2 - font->getLineHeight()); @@ -1356,7 +1356,7 @@ void LLWorldMapView::drawTracking(const LLVector3d& pos_global, const LLColor4& const S32 TEXT_PADDING = DEFAULT_TRACKING_ARROW_SIZE + 2; S32 half_text_width = llfloor(font->getWidthF32(label) * 0.5f); text_x = llclamp(text_x, half_text_width + TEXT_PADDING, getRect().getWidth() - half_text_width - TEXT_PADDING); - text_y = llclamp(text_y + vert_offset, TEXT_PADDING + vert_offset, getRect().getHeight() - llround(font->getLineHeight()) - TEXT_PADDING - vert_offset); + text_y = llclamp(text_y + vert_offset, TEXT_PADDING + vert_offset, getRect().getHeight() - llmath::llround(font->getLineHeight()) - TEXT_PADDING - vert_offset); //if (label != "") // [RLVa:KB] - Checked: 2009-07-04 (RLVa-1.4.5) | Added: RLVa-1.0.0 @@ -1484,8 +1484,8 @@ static void drawDot(F32 x_pixels, F32 y_pixels, if(-HEIGHT_THRESHOLD <= relative_z && relative_z <= HEIGHT_THRESHOLD) { - dot_image->draw(llround(x_pixels) - dot_image->getWidth()/2, - llround(y_pixels) - dot_image->getHeight()/2, + dot_image->draw(llmath::llround(x_pixels) - dot_image->getWidth()/2, + llmath::llround(y_pixels) - dot_image->getHeight()/2, color); } else @@ -1540,9 +1540,9 @@ void LLWorldMapView::drawAvatar(F32 x_pixels, dot_image = sAvatarAboveImage; } - S32 dot_width = llround(dot_radius * 2.f); - dot_image->draw(llround(x_pixels - dot_radius), - llround(y_pixels - dot_radius), + S32 dot_width = llmath::llround(dot_radius * 2.f); + dot_image->draw(llmath::llround(x_pixels - dot_radius), + llmath::llround(y_pixels - dot_radius), dot_width, dot_width, color); @@ -1569,8 +1569,8 @@ void LLWorldMapView::drawIconName(F32 x_pixels, const std::string& second_line) { const S32 VERT_PAD = 8; - S32 text_x = llround(x_pixels); - S32 text_y = llround(y_pixels + S32 text_x = llmath::llround(x_pixels); + S32 text_y = llmath::llround(y_pixels - BIG_DOT_RADIUS - VERT_PAD); @@ -1584,7 +1584,7 @@ void LLWorldMapView::drawIconName(F32 x_pixels, LLFontGL::NORMAL, LLFontGL::DROP_SHADOW); - text_y -= llround(LLFontGL::getFontSansSerif()->getLineHeight()); + text_y -= llmath::llround(LLFontGL::getFontSansSerif()->getLineHeight()); // render text LLFontGL::getFontSansSerif()->renderUTF8(second_line, 0, @@ -1758,8 +1758,8 @@ void LLWorldMapView::setDirectionPos( LLTextBox* text_box, F32 rotation ) F32 radius = llmin( map_half_height - text_half_height, map_half_width - text_half_width ); text_box->setOrigin( - llround(map_half_width - text_half_width + radius * cos( rotation )), - llround(map_half_height - text_half_height + radius * sin( rotation )) ); + llmath::llround(map_half_width - text_half_width + radius * cos( rotation )), + llmath::llround(map_half_height - text_half_height + radius * sin( rotation )) ); } @@ -1807,8 +1807,8 @@ void LLWorldMapView::reshape( S32 width, S32 height, BOOL called_from_parent ) bool LLWorldMapView::checkItemHit(S32 x, S32 y, LLItemInfo& item, LLUUID* id, bool track) { LLVector3 pos_view = globalPosToView(item.getGlobalPosition()); - S32 item_x = llround(pos_view.mV[VX]); - S32 item_y = llround(pos_view.mV[VY]); + S32 item_x = llmath::llround(pos_view.mV[VX]); + S32 item_y = llmath::llround(pos_view.mV[VY]); if (x < item_x - BIG_DOT_RADIUS) return false; if (x > item_x + BIG_DOT_RADIUS) return false; @@ -1983,8 +1983,8 @@ BOOL LLWorldMapView::handleMouseDown( S32 x, S32 y, MASK mask ) { gFocusMgr.setMouseCapture( this ); - mMouseDownPanX = llround(sPanX); - mMouseDownPanY = llround(sPanY); + mMouseDownPanX = llmath::llround(sPanX); + mMouseDownPanY = llmath::llround(sPanY); mMouseDownX = x; mMouseDownY = y; sHandledLastClick = TRUE; diff --git a/indra/newview/res-sdl/ll_icon.BMP b/indra/newview/res-sdl/ll_icon.BMP deleted file mode 100644 index 4a44aafbf..000000000 Binary files a/indra/newview/res-sdl/ll_icon.BMP and /dev/null differ diff --git a/indra/newview/res-sdl/snowglobe_icon.BMP b/indra/newview/res-sdl/snowglobe_icon.BMP deleted file mode 100644 index af6eab9fe..000000000 Binary files a/indra/newview/res-sdl/snowglobe_icon.BMP and /dev/null differ diff --git a/indra/newview/res/Ascent_icon.png b/indra/newview/res/Ascent_icon.png deleted file mode 100644 index ac8444a63..000000000 Binary files a/indra/newview/res/Ascent_icon.png and /dev/null differ diff --git a/indra/newview/res/icon1.ico b/indra/newview/res/icon1.ico deleted file mode 100644 index ad607598f..000000000 Binary files a/indra/newview/res/icon1.ico and /dev/null differ diff --git a/indra/newview/res/ll_icon.BMP b/indra/newview/res/ll_icon.BMP deleted file mode 100644 index 3a9964cd9..000000000 Binary files a/indra/newview/res/ll_icon.BMP and /dev/null differ diff --git a/indra/newview/res/ll_icon.ico b/indra/newview/res/ll_icon.ico deleted file mode 100644 index c35a3fa3a..000000000 Binary files a/indra/newview/res/ll_icon.ico and /dev/null differ diff --git a/indra/newview/res/ll_icon.png b/indra/newview/res/ll_icon.png deleted file mode 100644 index 680ef2137..000000000 Binary files a/indra/newview/res/ll_icon.png and /dev/null differ diff --git a/indra/newview/res/singularity_icon.bmp b/indra/newview/res/singularity_icon.bmp deleted file mode 100644 index 7e27d0eca..000000000 Binary files a/indra/newview/res/singularity_icon.bmp and /dev/null differ diff --git a/indra/newview/res/singularity_icon_bc.ico b/indra/newview/res/singularity_icon_bc.ico deleted file mode 100644 index 1287f3e20..000000000 Binary files a/indra/newview/res/singularity_icon_bc.ico and /dev/null differ diff --git a/indra/newview/res/snowglobe_icon.BMP b/indra/newview/res/snowglobe_icon.BMP deleted file mode 100644 index 778779b1f..000000000 Binary files a/indra/newview/res/snowglobe_icon.BMP and /dev/null differ diff --git a/indra/newview/res/snowglobe_icon.ico b/indra/newview/res/snowglobe_icon.ico deleted file mode 100644 index 84a455a22..000000000 Binary files a/indra/newview/res/snowglobe_icon.ico and /dev/null differ diff --git a/indra/newview/res/snowglobe_icon.png b/indra/newview/res/snowglobe_icon.png deleted file mode 100644 index fdd54c3aa..000000000 Binary files a/indra/newview/res/snowglobe_icon.png and /dev/null differ diff --git a/indra/newview/res/viewerRes_bc.rc.in b/indra/newview/res/viewerRes_bc.rc.in deleted file mode 100644 index 3413cf937..000000000 --- a/indra/newview/res/viewerRes_bc.rc.in +++ /dev/null @@ -1,193 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#include "resource.h" - -#ifdef IDC_STATIC -#undef IDC_STATIC -#endif -#define IDC_STATIC (-1) -#include "winresrc.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -// Commented out because it only compiles if you have MFC installed. -//#include "winres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) -#endif //_WIN32 - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#include ""winres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDI_LL_ICON ICON "${VIEWER_BRANDING_ID}_icon_bc.ico" -IDI_LCD_LL_ICON ICON "${VIEWER_BRANDING_ID}_icon_bc.ico" - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -SPLASHSCREEN DIALOG 32, 32, 144, 34 -STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE -FONT 8, "MS Sans Serif" -BEGIN - ICON IDI_LL_ICON,IDC_STATIC,7,7,20,20 - LTEXT "Loading ${VIEWER_CHANNEL}...",666,36,13,91,8 -END - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO -BEGIN - - "SPLASHSCREEN", DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 137 - VERTGUIDE, 36 - TOPMARGIN, 7 - BOTTOMMARGIN, 27 - END -END -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Cursor -// - -TOOLGRAB CURSOR "lltoolgrab.cur" -TOOLLAND CURSOR "lltoolland.cur" -TOOLZOOMIN CURSOR "lltoolzoomin.cur" -TOOLCREATE CURSOR "lltoolcreate.cur" -ARROWDRAG CURSOR "llarrowdrag.cur" -ARROW CURSOR "llarrow.cur" -NOLOCKED CURSOR "llnolocked.cur" -ARROWLOCKED CURSOR "llarrowlocked.cur" -GRABLOCKED CURSOR "llgrablocked.cur" -TOOLROTATE CURSOR "lltoolrotate.cur" -TOOLTRANSLATE CURSOR "lltooltranslate.cur" -TOOLSCALE CURSOR "lltoolscale.cur" -TOOLCAMERA CURSOR "lltoolcamera.cur" -TOOLPAN CURSOR "lltoolpan.cur" -TOOLFOCUS CURSOR "lltoolfocus.cur" -TOOLPICKOBJECT3 CURSOR "toolpickobject3.cur" -ARROWCOPY CURSOR "arrowcop.cur" -ARROWDRAGMULTI CURSOR "llarrowdragmulti.cur" -ARROWCOPYMULTI CURSOR "arrowcopmulti.cur" -TOOLSIT CURSOR "toolsit.cur" -TOOLBUY CURSOR "toolbuy.cur" -TOOLPAY CURSOR "toolpay.cur" -TOOLOPEN CURSOR "toolopen.cur" -TOOLPIPETTE CURSOR "toolpipette.cur" -TOOLPLAY CURSOR "toolplay.cur" -TOOLPAUSE CURSOR "toolpause.cur" -TOOLMEDIAOPEN CURSOR "toolmediaopen.cur" - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION ${vMAJOR},${vMINOR},${vPATCH},${vBUILD} - PRODUCTVERSION ${vMAJOR},${vMINOR},${vPATCH},${vBUILD} - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x40004L - FILETYPE 0x1L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904b0" - BEGIN - VALUE "CompanyName", "Siana Gearz" - VALUE "FileDescription", "Singularity Viewer" - VALUE "FileVersion", "${vMAJOR}.${vMINOR}.${vPATCH}.${vBUILD}" - VALUE "InternalName", "Second Life" - VALUE "LegalCopyright", "Copyright © 2001-2010, Linden Research, Inc., Copyright 2010 Siana Gearz" - VALUE "OriginalFilename", "SingularityViewer.exe" - VALUE "ProductName", "Singularity Viewer" - VALUE "ProductVersion", "${vMAJOR}.${vMINOR}.${vPATCH}.${vBUILD}" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Bitmap -// - -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/indra/newview/viewer_manifest.py b/indra/newview/viewer_manifest.py index 723d21a27..4079eb7bf 100755 --- a/indra/newview/viewer_manifest.py +++ b/indra/newview/viewer_manifest.py @@ -37,6 +37,7 @@ import re import tarfile import time import subprocess +import errno viewer_dir = os.path.dirname(__file__) # add llmanifest library to our path so we don't have to muck with PYTHONPATH sys.path.append(os.path.join(viewer_dir, '../lib/python/indra/util')) @@ -174,6 +175,55 @@ class ViewerManifest(LLManifest): return " ".join((channel_flags, grid_flags, setting_flags)).strip() + def icon_path(self): + return "../../indra/newview/res/" + + def path_optional(self, src, dst=None): + """ + For a number of our self.path() calls, not only do we want + to deal with the absence of src, we also want to remember + which were present. Return either an empty list (absent) + or a list containing dst (present). Concatenate these + return values to get a list of all libs that are present. + """ + found_files = [] + try: + found_files = self.path(src, dst) + except RuntimeError, err: + pass + if not found_files: + print "Skipping %s" % dst + return found_files + + def add_extra_libraries(self): + found_libs = [] + if 'extra_libraries' in self.args and self.args['extra_libraries'] != '': + try: + path_list = self.args['extra_libraries'].strip('"').split('|') + except: + return None + for cur_path in path_list: + if cur_path is None or cur_path == '': + continue + try: + config, file = cur_path.split(' ', 1) + except: + config, file = (None, None) + if(config == 'optimized'): + if(self.args['configuration'].lower() != 'release' and self.args['configuration'].lower() != 'relwithdebinfo' and self.args['configuration'].lower() != 'universal'): + continue + cur_path = file + if(config == 'debug'): + if(self.args['configuration'].lower() != 'debug'): + continue + cur_path = file + if(cur_path != ''): + if sys.platform == "linux" or sys.platform == "linux2": + found_libs += self.path_optional(cur_path+"*") + else: + found_libs += self.path_optional(cur_path) + return found_libs + class WindowsManifest(ViewerManifest): def is_win64(self): return self.args.get('arch') == "x86_64" @@ -187,56 +237,76 @@ class WindowsManifest(ViewerManifest): # the final exe is complicated because we're not sure where it's coming from, # nor do we have a fixed name for the executable self.path(src='%s/secondlife-bin.exe' % self.args['configuration'], dst=self.final_exe()) - - if self.is_win64(): - release_lib_dir = "../../libraries/x86_64-win/lib/release" - else: - release_lib_dir = "../../libraries/i686-win32/lib/release" # Plugin host application - self.path(os.path.join(os.pardir, - 'llplugin', 'slplugin', self.args['configuration'], "SLPlugin.exe"), - "SLPlugin.exe") + self.path2basename(os.path.join(os.pardir, + 'llplugin', 'slplugin', self.args['configuration']), + "SLplugin.exe") - # Plugin volume control - if not self.is_win64() and self.prefix(src=self.args['configuration'], dst=""): - self.path("winmm.dll") + + # Get llcommon and deps. If missing assume static linkage and continue. + if self.prefix(src=self.args['configuration'], dst=""): + try: + self.path('llcommon.dll') + except RuntimeError, err: + print err.message + print "Skipping llcommon.dll (assuming llcommon was linked statically)" + + try: + self.path('libapr-1.dll') + self.path('libaprutil-1.dll') + self.path('libapriconv-1.dll') + except RuntimeError, err: + pass + + # For mesh upload + if not self.is_win64(): + self.path("libcollada14dom22.dll") + + self.path("glod.dll") + + self.add_extra_libraries() + + if(self.prefix(src="..", dst="")): + found_files = self.path("msvc*.dll") + self.end_prefix() + if(not found_files): + try: + if self.prefix(src="msvcrt", dst=""): + self.path("*.dll") + self.path("*.manifest") + self.end_prefix() + except: + pass + + # Vivox runtimes + self.path("SLVoice.exe") + self.path("vivoxsdk.dll") + self.path("ortp.dll") + self.path("libsndfile-1.dll") + self.path("zlib1.dll") + self.path("vivoxplatform.dll") + self.path("vivoxoal.dll") + self.path("ca-bundle.crt") + + # Security + self.path("ssleay32.dll") + self.path("libeay32.dll") + + # For spellchecking + self.path("libhunspell.dll") + + # For google-perftools tcmalloc allocator. + if not self.is_win64(): + try: + self.path('libtcmalloc_minimal.dll') + except: + print "Skipping libtcmalloc_minimal.dll" self.end_prefix() self.path(src="licenses-win32.txt", dst="licenses.txt") - self.path("featuretable.txt") - # For spellchecking - if self.prefix(src=self.args['configuration'], dst=""): - self.path("libhunspell.dll") - self.end_prefix() - - # For mesh upload - if self.prefix(src=self.args['configuration'], dst=""): - self.path("libcollada14dom22.dll") - self.path("glod.dll") - self.end_prefix() - - # For use in crash reporting (generates minidumps) - #self.path("dbghelp.dll") - #is shipped with windows anyway - - # For using FMOD for sound... DJS - #~if self.prefix(src=release_lib_dir, dst=""): - #~try: - #~self.path("fmod.dll") - #~pass - #~except: - #~print "Skipping fmod.dll - not found" - #~ pass - #~self.end_prefix() - - # For textures - #if self.prefix(src=release_lib_dir, dst=""): - # self.path("openjpeg.dll") - # self.end_prefix() - # Plugins - FilePicker if self.prefix(src='../plugins/filepicker/%s' % self.args['configuration'], dst="llplugin"): self.path("basic_plugin_filepicker.dll") @@ -252,8 +322,13 @@ class WindowsManifest(ViewerManifest): self.path("media_plugin_webkit.dll") self.end_prefix() + # Plugin volume control + if not self.is_win64() and self.prefix(src='../plugins/winmmshim/%s' % self.args['configuration'], dst=""): + self.path("winmm.dll") + self.end_prefix() + # For WebKit/Qt plugin runtimes - if self.prefix(src=release_lib_dir, dst="llplugin"): + if self.prefix(src=self.args['configuration']+"/llplugin", dst="llplugin"): self.path("libeay32.dll") self.path("qtcore4.dll") self.path("qtgui4.dll") @@ -262,83 +337,29 @@ class WindowsManifest(ViewerManifest): self.path("qtwebkit4.dll") self.path("qtxmlpatterns4.dll") self.path("ssleay32.dll") + + # For WebKit/Qt plugin runtimes (image format plugins) + if self.prefix(src="imageformats", dst="imageformats"): + self.path("qgif4.dll") + self.path("qico4.dll") + self.path("qjpeg4.dll") + self.path("qmng4.dll") + self.path("qsvg4.dll") + self.path("qtiff4.dll") + self.end_prefix() + + if self.prefix(src="codecs", dst="codecs"): + self.path("qcncodecs4.dll") + self.path("qjpcodecs4.dll") + self.path("qkrcodecs4.dll") + self.path("qtwcodecs4.dll") + self.end_prefix() + self.end_prefix() - # For WebKit/Qt plugin runtimes (image format plugins) - if self.prefix(src=release_lib_dir+"/imageformats", dst="llplugin/imageformats"): - self.path("qgif4.dll") - self.path("qico4.dll") - self.path("qjpeg4.dll") - self.path("qmng4.dll") - self.path("qsvg4.dll") - self.path("qtiff4.dll") - self.end_prefix() - - if self.prefix(src=release_lib_dir+"/codecs", dst="llplugin/codecs"): - self.path("qcncodecs4.dll") - self.path("qjpcodecs4.dll") - self.path("qkrcodecs4.dll") - self.path("qtwcodecs4.dll") - self.end_prefix() - - # Get llcommon and deps. If missing assume static linkage and continue. - if self.prefix(src=self.args['configuration'], dst=""): - try: - self.path('llcommon.dll') - except RuntimeError, err: - print err.message - print "Skipping llcommon.dll (assuming llcommon was linked statically)" - self.end_prefix() - if self.prefix(src=release_lib_dir, dst=""): - self.path("libeay32.dll") - self.path("ssleay32.dll") - try: - self.path('libapr-1.dll') - self.path('libaprutil-1.dll') - self.path('libapriconv-1.dll') - except RuntimeError, err: - pass - self.end_prefix() - - # For google-perftools tcmalloc allocator. - if not self.is_win64(): - self.path(release_lib_dir+"/libtcmalloc_minimal.dll", dst="libtcmalloc_minimal.dll") - - try: - self.path("msvc*.dll") - except: - try: - if self.prefix(release_lib_dir+"/msvcrt", dst=""): - self.path("*.dll") - self.path("*.manifest") - self.end_prefix() - except: - pass - - # Vivox runtimes - if self.prefix(src="vivox-runtime/i686-win32", dst=""): - self.path("SLVoice.exe") - self.path("ca-bundle.crt") - self.path("libsndfile-1.dll") - self.path("ortp.dll") - self.path("vivoxoal.dll") - self.path("vivoxplatform.dll") - self.path("vivoxsdk.dll") - self.path("zlib1.dll") - self.end_prefix() - - if 'extra_libraries' in self.args: - print self.args['extra_libraries'] - path_list = self.args['extra_libraries'].split('|') - for path in path_list: - path_pair = path.rsplit('/', 1) - if self.prefix(src=path_pair[0], dst=""): - self.path(path_pair[1]) - self.end_prefix() self.package_file = 'none' - def nsi_file_commands(self, install=True): def wpath(path): if path.endswith('/') or path.endswith(os.path.sep): @@ -356,7 +377,7 @@ class WindowsManifest(ViewerManifest): for pkg_file in dest_files: rel_file = os.path.normpath(pkg_file.replace(self.get_dst_prefix()+os.path.sep,'')) installed_dir = wpath(os.path.join('$INSTDIR', os.path.dirname(rel_file))) - pkg_file = wpath(os.path.normpath(pkg_file)) + pkg_file = wpath(os.path.join(os.pardir,os.path.normpath(pkg_file))) if installed_dir != out_path: if install: out_path = installed_dir @@ -391,22 +412,6 @@ class WindowsManifest(ViewerManifest): mask = "%s_%s_Setup.exe" return mask % (self.channel_oneword(), '-'.join(self.args['version'])) - - def sign_command(self, *argv): - return [ - "signtool.exe", - "sign", "/v", - "/f",os.environ['VIEWER_SIGNING_KEY'], - "/p",os.environ['VIEWER_SIGNING_PASSWORD'], - "/d","%s" % self.channel(), - "/du",os.environ['VIEWER_SIGNING_URL'], - "/t","http://timestamp.comodoca.com/authenticode" - ] + list(argv) - - - def sign(self, *argv): - subprocess.check_call(self.sign_command(*argv)) - def package_finish(self): # a standard map of strings for replacing in the templates substitution_strings = { @@ -453,20 +458,12 @@ class WindowsManifest(ViewerManifest): installer_file = installer_file % substitution_strings substitution_strings['installer_file'] = installer_file - # Sign the binaries - if 'VIEWER_SIGNING_PASSWORD' in os.environ: - try: - self.sign(self.args['configuration']+"\\"+self.final_exe()) - self.sign(self.args['configuration']+"\\SLPlugin.exe") - self.sign(self.args['configuration']+"\\SLVoice.exe") - except Exception, e: - print "Couldn't sign binaries. Tried to sign %s" % self.args['configuration'] + "\\" + self.final_exe() + "\nException: %s" % e tempfile = "secondlife_setup_tmp.nsi" # the following replaces strings in the nsi template # it also does python-style % substitution self.replace_in("installers/windows/installer_template.nsi", tempfile, { "%%VERSION%%":version_vars, - "%%SOURCE%%":self.get_src_prefix(), + "%%SOURCE%%":os.path.abspath(self.get_src_prefix()), "%%GRID_VARS%%":grid_vars_template % substitution_strings, "%%INSTALL_FILES%%":self.nsi_file_commands(True), "%%DELETE_FILES%%":self.nsi_file_commands(False), @@ -488,14 +485,14 @@ class WindowsManifest(ViewerManifest): NSIS_path = os.environ['ProgramFiles(X86)'] + '\\NSIS\\Unicode\\makensis.exe' self.run_command([proper_windows_path(NSIS_path),self.dst_path_of(tempfile)]) # self.remove(self.dst_path_of(tempfile)) - - # Sign the installer - if 'VIEWER_SIGNING_PASSWORD' in os.environ: - try: - self.sign(self.args['configuration'] + "\\" + substitution_strings['installer_file']) - except Exception, e: - print "Couldn't sign windows installer. Tried to sign %s" % self.args['configuration'] + "\\" + substitution_strings['installer_file'] + "\nException: %s" % e - + # If we're on a build machine, sign the code using our Authenticode certificate. JC + sign_py = os.path.expandvars("{SIGN_PY}") + if sign_py == "" or sign_py == "{SIGN_PY}": + sign_py = 'C:\\buildscripts\\code-signing\\sign.py' + if os.path.exists(sign_py): + self.run_command('python ' + sign_py + ' ' + self.dst_path_of(installer_file)) + else: + print "Skipping code signing,", sign_py, "does not exist" self.created_path(self.dst_path_of(installer_file)) self.package_file = installer_file @@ -506,9 +503,6 @@ class DarwinManifest(ViewerManifest): self.path(self.args['configuration'] + "/" + self.app_name() + ".app", dst="") if self.prefix(src="", dst="Contents"): # everything goes in Contents - # copy additional libs in /Contents/MacOS/ - self.path("../../libraries/universal-darwin/lib/release/libndofdev.dylib", dst="Resources/libndofdev.dylib") - self.path("../../libraries/universal-darwin/lib/release/libhunspell-1.3.0.dylib", dst="Resources/libhunspell-1.3.0.dylib") # most everything goes in the Resources directory if self.prefix(src="", dst="Resources"): @@ -522,7 +516,10 @@ class DarwinManifest(ViewerManifest): self.path("featuretable_mac.txt") self.path("SecondLife.nib") - self.path(("../newview/res/%s_icon.icns" % self.viewer_branding_id()), dst=("%s_icon.icns" % self.viewer_branding_id())) + icon_path = self.icon_path() + if self.prefix(src=icon_path, dst="") : + self.path("%s_icon.icns" % self.viewer_branding_id()) + self.end_prefix(icon_path) # Translations self.path("English.lproj") @@ -542,70 +539,79 @@ class DarwinManifest(ViewerManifest): self.path("uk.lproj") self.path("zh-Hans.lproj") - # SLVoice and vivox lols - self.path("vivox-runtime/universal-darwin/SLVoice", "SLVoice") - self.path("vivox-runtime/universal-darwin/ca-bundle.crt", "ca-bundle.crt") - self.path("vivox-runtime/universal-darwin/libortp.dylib", "libortp.dylib") - self.path("vivox-runtime/universal-darwin/libsndfile.dylib", "libsndfile.dylib") - self.path("vivox-runtime/universal-darwin/libvivoxoal.dylib", "libvivoxoal.dylib") - self.path("vivox-runtime/universal-darwin/libvivoxplatform.dylib", "libvivoxplatform.dylib") - self.path("vivox-runtime/universal-darwin/libvivoxsdk.dylib", "libvivoxsdk.dylib") + libdir = "../packages/lib/release" + alt_libdir = "../packages/libraries/universal-darwin/lib/release" + # dylibs is a list of all the .dylib files we expect to need + # in our bundled sub-apps. For each of these we'll create a + # symlink from sub-app/Contents/Resources to the real .dylib. + # Need to get the llcommon dll from any of the build directories as well. + + libfile = "libllcommon.dylib" - self.path("../llcommon/" + self.args['configuration'] + "/libllcommon.dylib", "libllcommon.dylib") + dylibs = self.path_optional(self.find_existing_file(os.path.join(os.pardir, + "llcommon", + self.args['configuration'], + libfile), + os.path.join(libdir, libfile)), + dst=libfile) - libfile = "lib%s.dylib" - libdir = "../../libraries/universal-darwin/lib/release" + if self.prefix(src=libdir, alt_build=alt_libdir, dst=""): + for libfile in ( + "libapr-1.0.dylib", + "libaprutil-1.0.dylib", + "libcollada14dom.dylib", + "libexpat.1.5.2.dylib", + "libexception_handler.dylib", + "libGLOD.dylib", + "libhunspell-1.3.0.dylib", + "libndofdev.dylib", + ): + dylibs += self.path_optional(libfile) - for libfile in ("libapr-1.0.dylib", - "libaprutil-1.0.dylib", - "libcollada14dom.dylib", - "libexpat.1.5.2.dylib", - "libGLOD.dylib", - "libexception_handler.dylib"): - self.path(os.path.join(libdir, libfile), libfile) + for libfile in ( + 'libortp.dylib', + 'libsndfile.dylib', + 'libvivoxoal.dylib', + 'libvivoxsdk.dylib', + 'libvivoxplatform.dylib', + 'ca-bundle.crt', + 'SLVoice' + ): + self.path(libfile) + + self.end_prefix() - # For using FMOD for sound...but, fmod is proprietary so some might not use it... - try: - self.path(self.args['configuration'] + "/libfmodwrapper.dylib", "libfmodwrapper.dylib") - pass - except: - print "Skipping libfmodwrapper.dylib - not found" - pass + if self.prefix(src= '' if self.args['configuration'].lower() == 'universal' else self.args['configuration'], alt_build=libdir): + dylibs += self.add_extra_libraries() + self.end_prefix() - # And now FMOD Ex! - try: - self.path("libfmodex.dylib", "libfmodex.dylib") - pass - except: - print "Skipping libfmodex.dylib - not found" - pass + # our apps + for app_bld_dir, app in (#("mac_crash_logger", "mac-crash-logger.app"), + # plugin launcher + (os.path.join("llplugin", "slplugin"), "SLPlugin.app"), + ): + self.path2basename(os.path.join(os.pardir, + app_bld_dir, self.args['configuration']), + app) - # plugin launcher - self.path("../llplugin/slplugin/" + self.args['configuration'] + "/SLPlugin.app", "SLPlugin.app") - - # dependencies on shared libs - slplugin_res_path = self.dst_path_of("SLPlugin.app/Contents/Resources") - for libfile in ("libllcommon.dylib", - "libapr-1.0.dylib", - "libaprutil-1.0.dylib", - "libexpat.1.5.2.dylib", - "libexception_handler.dylib"): - target_lib = os.path.join('../../..', libfile) - self.run_command("ln -sf %(target)r %(link)r" % - {'target': target_lib, - 'link' : os.path.join(slplugin_res_path, libfile)} - ) - #self.run_command("ln -sf %(target)r %(link)r" % - # {'target': target_lib, - # 'link' : os.path.join(mac_crash_logger_res_path, libfile)} - # ) + # our apps dependencies on shared libs + # for each app, for each dylib we collected in dylibs, + # create a symlink to the real copy of the dylib. + resource_path = self.dst_path_of(os.path.join(app, "Contents", "Resources")) + for libfile in dylibs: + symlinkf(os.path.join(os.pardir, os.pardir, os.pardir, os.path.basename(libfile)), + os.path.join(resource_path, os.path.basename(libfile))) # plugins if self.prefix(src="", dst="llplugin"): - self.path("../plugins/filepicker/" + self.args['configuration'] + "/basic_plugin_filepicker.dylib", "basic_plugin_filepicker.dylib") - self.path("../plugins/quicktime/" + self.args['configuration'] + "/media_plugin_quicktime.dylib", "media_plugin_quicktime.dylib") - self.path("../plugins/webkit/" + self.args['configuration'] + "/media_plugin_webkit.dylib", "media_plugin_webkit.dylib") - self.path("../../libraries/universal-darwin/lib/release/libllqtwebkit.dylib", "libllqtwebkit.dylib") + self.path2basename(os.path.join(os.pardir,"plugins", "filepicker", self.args['configuration']), + "basic_plugin_filepicker.dylib") + self.path2basename(os.path.join(os.pardir,"plugins", "quicktime", self.args['configuration']), + "media_plugin_quicktime.dylib") + self.path2basename(os.path.join(os.pardir,"plugins", "webkit", self.args['configuration']), + "media_plugin_webkit.dylib") + self.path2basename(os.path.join(os.pardir,"packages", "libraries", "universal-darwin", "lib", "release"), + "libllqtwebkit.dylib") self.end_prefix("llplugin") @@ -634,37 +640,6 @@ class DarwinManifest(ViewerManifest): if not self.default_channel_for_brand(): channel_standin = self.channel() - # Sign the app if we have a key. - try: - signing_password = os.environ['VIEWER_SIGNING_PASSWORD'] - except KeyError: - print "Skipping code signing" - pass - else: - home_path = os.environ['HOME'] - - self.run_command('security unlock-keychain -p "%s" "%s/Library/Keychains/viewer.keychain"' % (signing_password, home_path)) - signed=False - sign_attempts=3 - sign_retry_wait=15 - while (not signed) and (sign_attempts > 0): - try: - sign_attempts-=1; - self.run_command('codesign --verbose --force --timestamp --keychain "%(home_path)s/Library/Keychains/viewer.keychain" -s %(identity)r -f %(bundle)r' % { - 'home_path' : home_path, - 'identity': os.environ['VIEWER_SIGNING_KEY'], - 'bundle': self.get_dst_prefix() - }) - signed=True - except: - if sign_attempts: - print >> sys.stderr, "codesign failed, waiting %d seconds before retrying" % sign_retry_wait - time.sleep(sign_retry_wait) - sign_retry_wait*=2 - else: - print >> sys.stderr, "Maximum codesign attempts exceeded; giving up" - raise - imagename=self.installer_prefix() + '_'.join(self.args['version']) # See Ambroff's Hack comment further down if you want to create new bundles and dmg @@ -720,12 +695,13 @@ class DarwinManifest(ViewerManifest): if not os.path.exists (self.src_path_of(dmg_template)): dmg_template = os.path.join ('installers', 'darwin', 'release-dmg') - for s,d in {self.get_dst_prefix():app_name + ".app", - os.path.join(dmg_template, "_VolumeIcon.icns"): ".VolumeIcon.icns", - os.path.join(dmg_template, "background.jpg"): "background.jpg", - os.path.join(dmg_template, "_DS_Store"): ".DS_Store"}.items(): + + for s,d in {self.build_path_of(self.get_dst_prefix()):app_name + ".app", + self.src_path_of(os.path.join(dmg_template, "_VolumeIcon.icns")): ".VolumeIcon.icns", + self.src_path_of(os.path.join(dmg_template, "background.jpg")): "background.jpg", + self.src_path_of(os.path.join(dmg_template, "_DS_Store")): ".DS_Store"}.items(): print "Copying to dmg", s, d - self.copy_action(self.src_path_of(s), os.path.join(volpath, d)) + self.copy_action(s, os.path.join(volpath, d)) # Hide the background image, DS_Store file, and volume icon file (set their "visible" bit) self.run_command('SetFile -a V "' + os.path.join(volpath, ".VolumeIcon.icns") + '"') @@ -765,10 +741,12 @@ class LinuxManifest(ViewerManifest): self.path("client-readme-voice.txt","README-linux-voice.txt") self.path("client-readme-joystick.txt","README-linux-joystick.txt") self.path("wrapper.sh",self.wrapper_name()) - self.path("handle_secondlifeprotocol.sh") - self.path("register_secondlifeprotocol.sh") - self.path("refresh_desktop_app_entry.sh") - self.path("launch_url.sh") + if self.prefix(src="", dst="etc"): + self.path("handle_secondlifeprotocol.sh") + self.path("register_secondlifeprotocol.sh") + self.path("refresh_desktop_app_entry.sh") + self.path("launch_url.sh") + self.end_prefix("etc") self.path("install.sh") self.end_prefix("linux_tools") @@ -782,7 +760,10 @@ class LinuxManifest(ViewerManifest): # self.path("secondlife-bin","bin/"+self.binary_name()) self.path("secondlife-bin","bin/"+self.binary_name()) - self.path("../llplugin/slplugin/SLPlugin", "bin/SLPlugin") + if self.prefix(src="", dst="bin"): + self.path2basename("../llplugin/slplugin", "SLPlugin") + self.end_prefix("bin") + if self.prefix("res-sdl"): self.path("*") # recurse @@ -790,11 +771,15 @@ class LinuxManifest(ViewerManifest): # plugins if self.prefix(src="", dst="bin/llplugin"): - self.path("../plugins/filepicker/libbasic_plugin_filepicker.so", "libbasic_plugin_filepicker.so") - self.path("../plugins/webkit/libmedia_plugin_webkit.so", "libmedia_plugin_webkit.so") - self.path("../plugins/gstreamer010/libmedia_plugin_gstreamer010.so", "libmedia_plugin_gstreamer.so") + self.path2basename("../plugins/filepicker", "libbasic_plugin_filepicker.so") + self.path2basename("../plugins/webkit", "libmedia_plugin_webkit.so") + self.path("../plugins/gstreamer010", "libmedia_plugin_gstreamer.so") self.end_prefix("bin/llplugin") + # llcommon + if not self.path("../llcommon/libllcommon.so", "lib/libllcommon.so"): + print "Skipping llcommon.so (assuming llcommon was linked statically)" + self.path("featuretable_linux.txt") def wrapper_name(self): @@ -861,35 +846,29 @@ class Linux_i686Manifest(LinuxManifest): def construct(self): super(Linux_i686Manifest, self).construct() - self.path("../llcommon/libllcommon.so", "lib/libllcommon.so") - - if (not self.standalone()) and self.prefix("../../libraries/i686-linux/lib/release", dst="lib"): - - try: - self.path("libfmod-3.75.so") - pass - except: - print "Skipping libfmod-3.75.so - not found" - pass - - self.path("libELFIO.so") - self.path("libSDL-1.2.so*") + if (not self.standalone()) and self.prefix(src="../packages/lib/release", alt_build="../packages/libraries/i686-linux/lib/release", dst="lib"): self.path("libapr-1.so*") self.path("libaprutil-1.so*") - self.path("libcollada14dom.so.2.2", "libcollada14dom.so") - self.path("libcrypto.so*") + self.path("libdb*.so") - self.path("libdirect-1.*.so*") + self.path("libexpat.so*") + self.path("libglod.so") + self.path("libuuid.so*") + self.path("libSDL-1.2.so*") self.path("libdirectfb-1.*.so*") self.path("libfusion-1.*.so*") - self.path("libglod.so") + self.path("libdirect-1.*.so*") + self.path("libminizip.so.1.2.3", "libminizip.so"); - self.path("libexpat.so*") self.path("libhunspell-*.so.*") - self.path("libssl.so*") - self.path("libuuid.so*") + # OpenAL self.path("libalut.so") self.path("libopenal.so.1") + + self.path("libcollada14dom.so.2.2", "libcollada14dom.so") + self.path("libcrypto.so*") + self.path("libELFIO.so") + self.path("libssl.so*") self.path("libtcmalloc_minimal.so.0") self.path("libtcmalloc_minimal.so.0.2.2") @@ -902,44 +881,44 @@ class Linux_i686Manifest(LinuxManifest): self.path("libboost_system-mt.so.*") self.path("libboost_thread-mt.so.*") - if 'extra_libraries' in self.args: - path_list = self.args['extra_libraries'].split('|') - for path in path_list: - src_path = os.path.realpath(path) - dst_path = os.path.basename(path) - self.path(src_path, dst_path) - self.end_prefix("lib") - # Vivox runtimes - if self.prefix(src="vivox-runtime/i686-linux", dst="bin"): - self.path("SLVoice") - self.end_prefix() - if self.prefix(src="vivox-runtime/i686-linux", dst="lib"): - self.path("libortp.so") - self.path("libvivoxsdk.so") - self.end_prefix("lib") - + if (not self.standalone()) and self.prefix(src='', alt_build="../packages/lib/release", dst="lib"): + self.add_extra_libraries() + self.end_prefix() + + # Vivox runtimes + if self.prefix(src="../packages/lib/release", dst="bin"): + self.path("SLVoice") + self.end_prefix("bin") + if self.prefix(src="../packages/lib/release", dst="lib"): + self.path("libortp.so") + self.path("libvivoxsdk.so") + self.end_prefix("lib") class Linux_x86_64Manifest(LinuxManifest): def construct(self): super(Linux_x86_64Manifest, self).construct() - self.path("../llcommon/libllcommon.so", "lib64/libllcommon.so") - - if (not self.standalone()) and self.prefix("../../libraries/x86_64-linux/lib/release", dst="lib64"): + if (not self.standalone()) and self.prefix(src="../packages/lib/release", alt_build="../packages/libraries/x86_64-linux/lib/release", dst="lib"): self.path("libapr-1.so*") self.path("libaprutil-1.so*") - self.path("libcollada14dom.so.2.2", "libcollada14dom.so") + self.path("libdb-*.so*") - self.path("libcrypto.so.*") + self.path("libexpat.so*") self.path("libglod.so") - self.path("libhunspell-1.3.so*") - self.path("libminizip.so.1.2.3", "libminizip.so"); self.path("libssl.so*") self.path("libuuid.so*") self.path("libSDL-1.2.so*") + self.path("libminizip.so.1.2.3", "libminizip.so"); + self.path("libhunspell-1.3.so*") + # OpenAL + self.path("libalut.so*") + self.path("libopenal.so*") + + self.path("libcollada14dom.so.2.2", "libcollada14dom.so") + self.path("libcrypto.so.*") self.path("libELFIO.so") self.path("libjpeg.so*") self.path("libpng*.so*") @@ -954,32 +933,26 @@ class Linux_x86_64Manifest(LinuxManifest): self.path("libboost_system-mt.so.*") self.path("libboost_thread-mt.so.*") - # OpenAL - self.path("libopenal.so*") - self.path("libalut.so*") + self.end_prefix("lib") - if 'extra_libraries' in self.args: - path_list = self.args['extra_libraries'].split('|') - for path in path_list: - src_path = os.path.realpath(path) - dst_path = os.path.basename(path) - self.path(src_path, dst_path) + if (not self.standalone()) and self.prefix(src='', alt_build="../packages/lib/release", dst="lib"): + self.add_extra_libraries() + self.end_prefix() - self.end_prefix("lib64") - - # Vivox runtimes and libs - if self.prefix(src="vivox-runtime/i686-linux", dst="bin"): + # Vivox runtimes + if self.prefix(src="../packages/lib/release", dst="bin"): self.path("SLVoice") self.end_prefix("bin") - if self.prefix(src="vivox-runtime/i686-linux", dst="lib32"): + if self.prefix(src="../packages/lib/release", dst="lib32"): #self.path("libalut.so") self.path("libortp.so") self.path("libvivoxsdk.so") self.end_prefix("lib32") # 32bit libs needed for voice - if self.prefix("../../libraries/x86_64-linux/lib/release/32bit-compat", dst="lib32"): + if self.prefix(src="../packages/lib/release/32bit-compat", alt_build="../packages/libraries/x86_64-linux/lib/release/32bit-compat", dst="lib32"): + # Vivox libs self.path("libalut.so") self.path("libidn.so.11") self.path("libopenal.so.1") @@ -987,5 +960,27 @@ class Linux_x86_64Manifest(LinuxManifest): self.path("libuuid.so.1") self.end_prefix("lib32") +################################################################ + +def symlinkf(src, dst): + """ + Like ln -sf, but uses os.symlink() instead of running ln. + """ + try: + os.symlink(src, dst) + except OSError, err: + if err.errno != errno.EEXIST: + raise + # We could just blithely attempt to remove and recreate the target + # file, but that strategy doesn't work so well if we don't have + # permissions to remove it. Check to see if it's already the + # symlink we want, which is the usual reason for EEXIST. + if not (os.path.islink(dst) and os.readlink(dst) == src): + # Here either dst isn't a symlink or it's the wrong symlink. + # Remove and recreate. Caller will just have to deal with any + # exceptions at this stage. + os.remove(dst) + os.symlink(src, dst) + if __name__ == "__main__": main() diff --git a/indra/plugins/example_basic/CMakeLists.txt b/indra/plugins/example_basic/CMakeLists.txt index e97cd3243..616bda770 100644 --- a/indra/plugins/example_basic/CMakeLists.txt +++ b/indra/plugins/example_basic/CMakeLists.txt @@ -62,7 +62,7 @@ if (DARWIN) PREFIX "" BUILD_WITH_INSTALL_RPATH 1 INSTALL_NAME_DIR "@executable_path" - LINK_FLAGS "-exported_symbols_list ${CMAKE_CURRENT_SOURCE_DIR}/../base_basic/basic_plugin_base.exp" + LINK_FLAGS "-exported_symbols_list '${CMAKE_CURRENT_SOURCE_DIR}/../base_basic/basic_plugin_base.exp'" ) endif (DARWIN) diff --git a/indra/plugins/example_media/CMakeLists.txt b/indra/plugins/example_media/CMakeLists.txt index eefdd5251..7f9def1c9 100644 --- a/indra/plugins/example_media/CMakeLists.txt +++ b/indra/plugins/example_media/CMakeLists.txt @@ -75,7 +75,7 @@ if (DARWIN) PREFIX "" BUILD_WITH_INSTALL_RPATH 1 INSTALL_NAME_DIR "@executable_path" - LINK_FLAGS "-exported_symbols_list ${CMAKE_CURRENT_SOURCE_DIR}/../base_media/media_plugin_base.exp" + LINK_FLAGS "-exported_symbols_list '${CMAKE_CURRENT_SOURCE_DIR}/../base_media/media_plugin_base.exp'" ) endif (DARWIN) diff --git a/indra/plugins/filepicker/CMakeLists.txt b/indra/plugins/filepicker/CMakeLists.txt index c973954dd..ec896b69c 100644 --- a/indra/plugins/filepicker/CMakeLists.txt +++ b/indra/plugins/filepicker/CMakeLists.txt @@ -102,7 +102,7 @@ if (DARWIN) PREFIX "" BUILD_WITH_INSTALL_RPATH 1 INSTALL_NAME_DIR "@executable_path" - LINK_FLAGS "-exported_symbols_list ${CMAKE_CURRENT_SOURCE_DIR}/../base_basic/basic_plugin_base.exp" + LINK_FLAGS "-exported_symbols_list '${CMAKE_CURRENT_SOURCE_DIR}/../base_basic/basic_plugin_base.exp'" ) endif (DARWIN) diff --git a/indra/plugins/quicktime/CMakeLists.txt b/indra/plugins/quicktime/CMakeLists.txt index c827404c2..d1b17331c 100644 --- a/indra/plugins/quicktime/CMakeLists.txt +++ b/indra/plugins/quicktime/CMakeLists.txt @@ -76,7 +76,7 @@ if (QUICKTIME) PREFIX "" BUILD_WITH_INSTALL_RPATH 1 INSTALL_NAME_DIR "@executable_path" - LINK_FLAGS "-exported_symbols_list ${CMAKE_CURRENT_SOURCE_DIR}/../base_media/media_plugin_base.exp" + LINK_FLAGS "-exported_symbols_list '${CMAKE_CURRENT_SOURCE_DIR}/../base_media/media_plugin_base.exp'" ) # We use a bunch of deprecated system APIs. diff --git a/indra/plugins/webkit/CMakeLists.txt b/indra/plugins/webkit/CMakeLists.txt index 615333227..f135c8f78 100644 --- a/indra/plugins/webkit/CMakeLists.txt +++ b/indra/plugins/webkit/CMakeLists.txt @@ -117,15 +117,15 @@ if (DARWIN) PREFIX "" BUILD_WITH_INSTALL_RPATH 1 INSTALL_NAME_DIR "@executable_path" - LINK_FLAGS "-exported_symbols_list ${CMAKE_CURRENT_SOURCE_DIR}/../base_media/media_plugin_base.exp" + LINK_FLAGS "-exported_symbols_list '${CMAKE_CURRENT_SOURCE_DIR}/../base_media/media_plugin_base.exp'" ) # copy the webkit dylib to the build directory add_custom_command( TARGET media_plugin_webkit POST_BUILD # OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/libllqtwebkit.dylib - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/../libraries/universal-darwin/lib/release/libllqtwebkit.dylib ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/ - DEPENDS media_plugin_webkit ${CMAKE_SOURCE_DIR}/../libraries/universal-darwin/lib/release/libllqtwebkit.dylib + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/packages/libraries/universal-darwin/lib/release/libllqtwebkit.dylib ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/ + DEPENDS media_plugin_webkit ${CMAKE_BINARY_DIR}/packages/libraries/universal-darwin/lib/release/libllqtwebkit.dylib ) endif (DARWIN) diff --git a/indra/test/CMakeLists.txt b/indra/test/CMakeLists.txt index de440d2df..694121b87 100644 --- a/indra/test/CMakeLists.txt +++ b/indra/test/CMakeLists.txt @@ -129,7 +129,7 @@ if (WINDOWS) ) endif (WINDOWS) -get_target_property(TEST_EXE test LOCATION) +SET(TEST_EXE $) add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/cpp_tests_ok.txt diff --git a/indra/test_apps/llplugintest/CMakeLists.txt b/indra/test_apps/llplugintest/CMakeLists.txt index f226c139e..b3f1f72ad 100644 --- a/indra/test_apps/llplugintest/CMakeLists.txt +++ b/indra/test_apps/llplugintest/CMakeLists.txt @@ -330,33 +330,33 @@ else (DARWIN) ) endif (DARWIN) -get_target_property(BUILT_SLPLUGIN SLPlugin LOCATION) +SET(BUILT_SLPLUGIN $) add_custom_command(TARGET llmediaplugintest POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${BUILT_SLPLUGIN} ${PLUGINS_DESTINATION_DIR} DEPENDS ${BUILT_SLPLUGIN} ) if (DARWIN OR WINDOWS) - get_target_property(BUILT_WEBKIT_PLUGIN media_plugin_webkit LOCATION) + SET(BUILT_WEBKIT_PLUGIN $) add_custom_command(TARGET llmediaplugintest POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${BUILT_WEBKIT_PLUGIN} ${PLUGINS_DESTINATION_DIR} DEPENDS ${BUILT_WEBKIT_PLUGIN} ) - get_target_property(BUILT_QUICKTIME_PLUGIN media_plugin_quicktime LOCATION) + SET(BUILT_QUICKTIME_PLUGIN $) add_custom_command(TARGET llmediaplugintest POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${BUILT_QUICKTIME_PLUGIN} ${PLUGINS_DESTINATION_DIR} DEPENDS ${BUILT_QUICKTIME_PLUGIN} ) - get_target_property(BUILT_EXAMPLE_PLUGIN media_plugin_example LOCATION) + SET(BUILT_EXAMPLE_PLUGIN $) add_custom_command(TARGET llmediaplugintest POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${BUILT_EXAMPLE_PLUGIN} ${PLUGINS_DESTINATION_DIR} DEPENDS ${BUILT_EXAMPLE_PLUGIN} ) # copy over bookmarks file if llmediaplugintest gets built - get_target_property(BUILT_LLMEDIAPLUGINTEST llmediaplugintest LOCATION) + SET(BUILT_LLMEDIAPLUGINTEST $) add_custom_command(TARGET llmediaplugintest POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/bookmarks.txt ${CMAKE_CURRENT_BINARY_DIR}/ DEPENDS ${BUILT_LLMEDIAPLUGINTEST} diff --git a/indra/tools/vstool/VSTool.csproj b/indra/tools/vstool/VSTool.csproj index 5d8764b6b..6cd1890fe 100644 --- a/indra/tools/vstool/VSTool.csproj +++ b/indra/tools/vstool/VSTool.csproj @@ -1,4 +1,5 @@ - + + Local 8.0.50727 @@ -25,6 +26,8 @@ + v2.0 + 2.0 .\ diff --git a/indra/tools/vstool/VSTool.exe b/indra/tools/vstool/VSTool.exe index 7ded46ecd..1f0b88beb 100755 Binary files a/indra/tools/vstool/VSTool.exe and b/indra/tools/vstool/VSTool.exe differ diff --git a/indra/tools/vstool/VSTool.sln b/indra/tools/vstool/VSTool.sln index 543a0a2ef..4d83fac34 100644 --- a/indra/tools/vstool/VSTool.sln +++ b/indra/tools/vstool/VSTool.sln @@ -1,5 +1,7 @@ -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual Studio 2005 +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.30723.0 +MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VSTool", "VSTool.csproj", "{96943E2D-1373-4617-A117-D0F997A94919}" EndProject Global diff --git a/indra/tools/vstool/main.cs b/indra/tools/vstool/main.cs index ddf37e85c..be33ae98b 100644 --- a/indra/tools/vstool/main.cs +++ b/indra/tools/vstool/main.cs @@ -556,7 +556,7 @@ namespace VSTool break; case "12.00": - version = "VC110"; + version = "VC120"; break; default: throw new ApplicationException("Unknown .sln version: " + format); @@ -601,6 +601,11 @@ namespace VSTool case "VC110": progid = "VisualStudio.DTE.11.0"; break; + + case "VC120": + progid = "VisualStudio.DTE.12.0"; + break; + default: throw new ApplicationException("Can't handle VS version: " + version); } diff --git a/install.xml b/install.xml index c5b0a2f8b..055d6ca05 100644 --- a/install.xml +++ b/install.xml @@ -67,9 +67,9 @@ windows64 md5sum - c6d96cc9f6d993e2147710a5fb0b089a + 3ed28129c186d0f531701e1aad035d15 url - https://bitbucket.org/SingularityViewer/libraries/downloads/glod-1.0pre4-windows64-20131028.tar.bz2 + https://bitbucket.org/SingularityViewer/libraries/downloads/glod-1.0pre4-windows64-vs12-20140723.tar.bz2 @@ -136,9 +136,9 @@ windows64 md5sum - 7dcae03cad9bc04ac7e937284e6d102e + dddc81e3a8c3914510ae90af9b9a429d url - https://bitbucket.org/SingularityViewer/libraries/downloads/apr_suite-1.4.5-windows64-20131019.tar.bz2 + https://bitbucket.org/SingularityViewer/libraries/downloads/apr_suite-1.4.5-windows64-vs12-20140710.tar.bz2 @@ -183,9 +183,9 @@ windows64 md5sum - 2ca54250b59170f3e5342dacad529859 + 9af96e2c7a819d770146917afb4ff481 url - https://bitbucket.org/SingularityViewer/libraries/downloads/ares-1.9.1-windows64-20131019.tar.bz2 + https://bitbucket.org/SingularityViewer/libraries/downloads/ares-1.10.0-windows64-vs12-20140709.tar.bz2 @@ -230,9 +230,9 @@ windows64 md5sum - 68c056e920ba2b25c0acded6f482a2e4 + 2b33deae4df210c8bb9e1aea6174bc13 url - https://bitbucket.org/SingularityViewer/libraries/downloads/boost-1.53.0-windows64-20131019.tar.bz2 + https://bitbucket.org/SingularityViewer/libraries/downloads/boost-1.56.0-windows64-vs12-20140816.tar.bz2 @@ -277,9 +277,9 @@ windows64 md5sum - acbe863e1b3df636e1245cc27c280e7b + 53b5cd120718119b8a31b5073a49360e url - https://bitbucket.org/SingularityViewer/libraries/downloads/colladadom-2.2-windows64-20131020.tar.bz2 + https://bitbucket.org/SingularityViewer/libraries/downloads/colladadom-2.3-windows64-vs12-20140816.tar.bz2 @@ -324,9 +324,9 @@ windows64 md5sum - ffb31d596f41b650bed49ac13bb513de + 3820517a958655c31890eaf71bb284ba url - https://bitbucket.org/SingularityViewer/libraries/downloads/curl-7.24.0-windows64-20131019.tar.bz2 + https://bitbucket.org/SingularityViewer/libraries/downloads/curl-7.37.1-windows64-vs12-20140722.tar.bz2 @@ -445,11 +445,58 @@ windows64 md5sum - 3239d5c50d6f2c857cc1a95674dbd1f5 + fa21aba89409f5959a69c8cc5807103e url - https://bitbucket.org/SingularityViewer/libraries/downloads/expat-2.1.0-windows64-20131019.tar.bz2 + https://bitbucket.org/SingularityViewer/libraries/downloads/expat-2.1.0-windows64-vs12-20140709.tar.bz2 + + fmodstudio + + copyright + Copyright © 1994-2014 Firelight Technologies Pty, Ltd. + description + FMOD Studio programmer’s API's low level component. For simple sounds/channels/dsp/geometry. + license + fmod + packages + + darwin + + md5sum + 93ebcfcaf0572427593cdb38d7c7435b + url + https://bitbucket.org/SingularityViewer/libraries/downloads/fmodstudio-1.05.09-darwin-20150106.tar.bz2 + + linux + + md5sum + b75bcb905747b6aa9c288924379741d4 + url + https://bitbucket.org/SingularityViewer/libraries/downloads/fmodstudio-1.05.09-linux-20150106.tar.bz2 + + linux64 + + md5sum + 0d50965abbd4ed317f221761abc25b55 + url + https://bitbucket.org/SingularityViewer/libraries/downloads/fmodstudio-1.05.09-linux64-20150106.tar.bz2 + + windows + + md5sum + c24c02a6130cd9032077c08905e89e88 + url + https://bitbucket.org/SingularityViewer/libraries/downloads/fmodstudio-1.05.09-windows-20150106.tar.bz2 + + windows64 + + md5sum + 72065eb2a8ebb7d4ef12c320f1f85780 + url + https://bitbucket.org/SingularityViewer/libraries/downloads/fmodstudio-1.05.09-windows64-20150106.tar.bz2 + + fontconfig @@ -514,9 +561,9 @@ windows64 md5sum - bfde86bbd84536448ac2a717ed1646d8 + 3049465928bf2da496b19e53a03fcbde url - https://bitbucket.org/SingularityViewer/libraries/downloads/freetype-2.5.0.1-windows64-20131020.tar.bz2 + https://bitbucket.org/SingularityViewer/libraries/downloads/freetype-2.5.3-windows64-vs12-20140725.tar.bz2 @@ -607,9 +654,9 @@ windows64 md5sum - eeec9982df843043a18748276bbf39ce + 919c3fdfac84aaa69c84f1ce793cd9ff url - https://bitbucket.org/SingularityViewer/libraries/downloads/glui-2.36-windows-20110214.tar.bz2 + https://bitbucket.org/SingularityViewer/libraries/downloads/glui-2.36-windows64-vs12-20140710.tar.bz2 @@ -650,9 +697,9 @@ windows64 md5sum - f9072dda75012868d023c335ea5bcf88 + 69e360938a6a13d9b10edfe09dc1bd9d url - https://bitbucket.org/SingularityViewer/libraries/downloads/google_breakpad-0.0.0-rev1099-windows64-20140606.tar.bz2 + https://bitbucket.org/alchemyviewer/publiclibs-vs12/downloads/google_breakpad-1400-windows64-20141105.tar.bz2 @@ -771,9 +818,9 @@ windows64 md5sum - 22fd1388454117626c2477509d3e93be + b97500817a949b250820ca300014d2c6 url - https://bitbucket.org/SingularityViewer/libraries/downloads/libhunspell-1.3.2-windows64-20140605.tar.bz2 + https://bitbucket.org/SingularityViewer/libraries/downloads/libhunspell-1.3.2-windows64-vs12-20140709.tar.bz2 @@ -818,9 +865,9 @@ windows64 md5sum - 79e328b10fae2090262c0bf02c9c5f71 + c2326faf530ea31391843a8c5aa8ccfe url - https://bitbucket.org/SingularityViewer/libraries/downloads/jpeglib-8c-windows64-20131020.tar.bz2 + https://bitbucket.org/SingularityViewer/libraries/downloads/libjpeg_turbo-1.3.1-windows64-vs12-20140709.tar.bz2 @@ -865,9 +912,9 @@ windows64 md5sum - 8cf95eef2a95b71eb4a8ab59779bed52 + a6de6a8188a87ce8048847f37b4ecd8f url - https://bitbucket.org/SingularityViewer/libraries/downloads/jsoncpp-0.5.0-windows64-20131020.tar.bz2 + https://bitbucket.org/SingularityViewer/libraries/downloads/jsoncpp-0.5.0-windows64-vs12-20140709.tar.bz2 @@ -912,9 +959,9 @@ windows64 md5sum - 00fc7bcb4016ecc57def9e3b3223d977 + 82ac61f5d208b0c907217fc90bb835dd url - https://bitbucket.org/SingularityViewer/libraries/downloads/libpng-1.5.10-windows64-20131020.tar.bz2 + https://bitbucket.org/SingularityViewer/libraries/downloads/libpng-1.6.8-windows64-vs12-20140709.tar.bz2 @@ -964,6 +1011,13 @@ url https://bitbucket.org/SingularityViewer/libraries/downloads/libxml2-2.7.8-linux-x86_64-20120420.tar.bz2 + windows64 + + md5sum + 1c2effa8c26de72f6c92f65f83dd9e29 + url + https://bitbucket.org/SingularityViewer/libraries/downloads/libxml2-2.9.1-windows64-vs12-20140709.tar.bz2 + llqtwebkit @@ -1003,9 +1057,9 @@ windows64 md5sum - cf9e5d1d79531a7e4d45f78657da9c9b + a1c9564dbce8f3b0a296f9924e68a221 url - https://bitbucket.org/SingularityViewer/libraries/downloads/llqtwebkit-4.7.1-windows64-20131021.tar.bz2 + https://bitbucket.org/SingularityViewer/libraries/downloads/llqtwebkit-4.8.6-windows64-vs12-20140710.tar.bz2 @@ -1102,9 +1156,9 @@ windows64 md5sum - b59b4ddab26d4441829f50b48925baf0 + 10533b646d582b936b2f8d3cb32cd73c url - https://bitbucket.org/SingularityViewer/libraries/downloads/libndofdev-0.1-windows64-20131020.tar.bz2 + https://bitbucket.org/SingularityViewer/libraries/downloads/libndofdev-0.1-windows64-vs12-20140710.tar.bz2 @@ -1149,9 +1203,9 @@ windows64 md5sum - a8ca0eef3d74936d504dab52ecc61ced + a7c94d900a2a2551423efed99fa8e29d url - https://bitbucket.org/SingularityViewer/libraries/downloads/ogg_vorbis-1.2.2-1.3.2-windows64-20131020.tar.bz2 + https://bitbucket.org/SingularityViewer/libraries/downloads/ogg_vorbis-1.3.2-1.3.4-windows64-vs12-20140709.tar.bz2 @@ -1192,9 +1246,9 @@ windows64 md5sum - b50166f0b0a275c8ea0d3b11c578d792 + 66eba34f543bdd90e0656a9c97c8afae url - https://bitbucket.org/SingularityViewer/libraries/downloads/openssl-1.0.0g-windows64-20131019.tar.bz2 + https://bitbucket.org/SingularityViewer/libraries/downloads/openssl-1.0.1h-windows64-vs12-20140709.tar.bz2 @@ -1232,9 +1286,9 @@ windows64 md5sum - e75f1529adcaa6e508d1725f59d93a16 + 62f9844903ae76d2ae90d17ca5814060 url - https://bitbucket.org/SingularityViewer/libraries/downloads/openal-1.12.854-1.1.0-windows-20110301.tar.bz2 + https://bitbucket.org/SingularityViewer/libraries/downloads/openal-1.15.1-1.1.0-windows64-vs12-20140813.tar.bz2 @@ -1269,6 +1323,13 @@ url https://bitbucket.org/SingularityViewer/libraries/downloads/pcre-7.6-linux64-20130216.tar.bz2 + windows64 + + md5sum + ffdbc30ce4b9238070917073b6066b36 + url + https://bitbucket.org/SingularityViewer/libraries/downloads/pcre-8.35-windows64-vs12-20140816.tar.bz2 + pulseaudio @@ -1327,37 +1388,37 @@ darwin md5sum - 917a60e1b18dd0f5e6afb555623339a4 + 8eb5462ea9d469bce4b0d22bd8f0c33b url - https://bitbucket.org/SingularityViewer/libraries/downloads/slvoice-4.6.0009.20030-darwin-20140312.tar.bz2 + https://bitbucket.org/SingularityViewer/libraries/downloads/slvoice-4.6.0009.20030-darwin-20140312-rpk.tar.bz2 linux md5sum - 01573510dce7f380f44e561ef2f3dd9f + 1c8643e27023f1d9b1523ca5794b7475 url - https://bitbucket.org/SingularityViewer/libraries/downloads/vivox-2.1.3010.6270-linux-20090309.tar.bz2 + https://bitbucket.org/SingularityViewer/libraries/downloads/vivox-2.1.3010.6270-linux-20090309-rpk.tar.bz2 linux64 md5sum - 01573510dce7f380f44e561ef2f3dd9f + 1c8643e27023f1d9b1523ca5794b7475 url - https://bitbucket.org/SingularityViewer/libraries/downloads/vivox-2.1.3010.6270-linux-20090309.tar.bz2 + https://bitbucket.org/SingularityViewer/libraries/downloads/vivox-2.1.3010.6270-linux-20090309-rpk.tar.bz2 windows md5sum - d0befc33613c980a5a3580b8e2b02d11 + 4a6b9cf0f1e2767240de21af3338ffd7 url - https://bitbucket.org/SingularityViewer/libraries/downloads/slvoice-4.6.0009.20030-windows-20140312.tar.bz2 + https://bitbucket.org/SingularityViewer/libraries/downloads/slvoice-4.6.0009.20030-windows-20140312-rpk.tar.bz2 windows64 md5sum - d0befc33613c980a5a3580b8e2b02d11 + 4a6b9cf0f1e2767240de21af3338ffd7 url - https://bitbucket.org/SingularityViewer/libraries/downloads/slvoice-4.6.0009.20030-windows-20140312.tar.bz2 + https://bitbucket.org/SingularityViewer/libraries/downloads/slvoice-4.6.0009.20030-windows-20140312-rpk.tar.bz2 @@ -1402,9 +1463,9 @@ windows64 md5sum - 94c26b93b855f5816bb29f308d9997fb + 652a2034e8a2d4cb63f77eb3cc723351 url - https://bitbucket.org/SingularityViewer/libraries/downloads/xmlrpc_epi-0.54.1-windows64-20131019.tar.bz2 + https://bitbucket.org/SingularityViewer/libraries/downloads/xmlrpc_epi-0.54.1-windows64-vs12-20140709.tar.bz2 @@ -1449,9 +1510,9 @@ windows64 md5sum - 5aa50bd41d6cf0262a94760ef66bdbcf + 59deda6dde1e6f8cb90b2285890dce82 url - https://bitbucket.org/SingularityViewer/libraries/downloads/zlib-1.2.8-windows64-20131019.tar.bz2 + https://bitbucket.org/SingularityViewer/libraries/downloads/zlib-1.2.8-windows64-vs12-20140709.tar.bz2 @@ -1707,7 +1768,7 @@ your work. fmod url - http://www.fmod.org/ifmodlicense.html + http://www.fmod.com/files/public/LICENSE.TXT freetype diff --git a/scripts/automated_build_scripts/opensrc-build.sh b/scripts/automated_build_scripts/opensrc-build.sh deleted file mode 100755 index 568a1ba7f..000000000 --- a/scripts/automated_build_scripts/opensrc-build.sh +++ /dev/null @@ -1,472 +0,0 @@ -#!/bin/sh - -# This is the build script used by Linden Lab's automated build system. -# - -set -x - -export INSTALL_USE_HTTP_FOR_SCP=true -export PATH=/bin:/usr/bin:$PATH -arch=`uname | cut -b-6` -here=`echo $0 | sed 's:[^/]*$:.:'` -# Hack : in the case of Snowglobe 1.x trunk and releases, we continue to use 2009 as the year so to separate them from Snowglobe 2.x trunk and releases -#year=`date +%Y` -year="2009" -branch=`svn info | grep '^URL:' | sed 's:.*/::'` -revision=`svn info | grep '^Revision:' | sed 's/.*: //'` -top=`cd "$here/../../.." && pwd` - -[ x"$WGET_CACHE" = x ] && export WGET_CACHE=/var/tmp/parabuild/wget -[ x"$S3GET_URL" = x ] && export S3GET_URL=http://viewer-source-downloads.s3.amazonaws.com/$year -[ x"$S3PUT_URL" = x ] && export S3PUT_URL=https://s3.amazonaws.com/viewer-source-downloads/$year -[ x"$S3SYMBOL_URL" = x ] && export S3SYMBOL_URL=https://s3.amazonaws.com/automated-builds-secondlife-com/binaries -[ x"$PUBLIC_URL" = x ] && export PUBLIC_URL=http://secondlife.com/developers/opensource/downloads/$year -[ x"$PUBLIC_EMAIL" = x ] && export PUBLIC_EMAIL=sldev-commits@lists.secondlife.com - -# Make sure command worked and bail out if not, reporting failure to parabuild -fail() -{ - echo "BUILD FAILED" $@ - exit 1 -} - -pass() -{ - echo "BUILD SUCCESSFUL" - exit 0 -} - -# Locking to avoid contention with u-s-c -LOCK_PROCESS= - -locking_available() -{ - test -n "$LOCK_CREATE" -a -x "$LOCK_CREATE"\ - -a -n "$LOCK_TOUCH" -a -x "$LOCK_TOUCH"\ - -a -n "$LOCK_REMOVE" -a -x "$LOCK_REMOVE" -} - -acquire_lock() -{ - if locking_available - then - if "$LOCK_CREATE" /var/lock/update-system-config --retry 99 - then - "$LOCK_TOUCH" /var/lock/update-system-config & - LOCK_PROCESS="$!" - else - fail acquire lock - fi - else - true - fi -} - -release_lock() -{ - if locking_available - then - if test x"$LOCK_PROCESS" != x - then - kill "$LOCK_PROCESS" - "$LOCK_REMOVE" /var/lock/update-system-config - else - echo No Lock Acquired >&2 - fi - else - true - fi -} - -get_asset() -{ - mkdir -p "$WGET_CACHE" || fail creating WGET_CACHE - local tarball=`basename "$1"` - test -r "$WGET_CACHE/$tarball" || ( cd "$WGET_CACHE" && curl --location --remote-name "$1" || fail getting $1 ) - case "$tarball" in - *.zip) unzip -qq -d "$top" -o "$WGET_CACHE/$tarball" || fail unzip $tarball ;; - *.tar.gz|*.tgz) tar -C "$top" -xzf "$WGET_CACHE/$tarball" || fail untar $tarball ;; - *) fail unrecognized filetype: $tarball ;; - esac -} - -s3_available() -{ - test -x "$helpers/hg/bin/s3get.sh" -a -x "$helpers/hg/bin/s3put.sh" -a -r "$helpers/hg/bin/s3curl.py" -} - -build_dir_Darwin() -{ - echo build-darwin-i386 -} - -build_dir_Linux() -{ - echo viewer-linux-i686-`echo $1 | tr A-Z a-z` -} - -build_dir_CYGWIN() -{ - echo build-vc80 -} - -installer_Darwin() -{ - ls -1td "$(build_dir_Darwin Release)/newview/"*.dmg 2>/dev/null | sed 1q -} - -installer_Linux() -{ - ls -1td "$(build_dir_Linux Release)/newview/"*.tar.bz2 2>/dev/null | sed 1q -} - -installer_CYGWIN() -{ - d=$(build_dir_CYGWIN Release) - p=$(sed 's:.*=::' "$d/newview/Release/touched.bat") - echo "$d/newview/Release/$p" -} - -# deal with aborts etc.. -trap fail 1 2 3 14 15 - -# Check location -cd "$here/../.." - -test -x ../linden/scripts/automated_build_scripts/opensrc-build.sh\ - || fail 'The parent dir of your checkout needs to be named "linden"' - -. doc/asset_urls.txt -get_asset "$SLASSET_ART" - -update_version_files= - -# Set up platform specific stuff -case "$arch" in - -# Note that we can only build the "Release" variant for Darwin, because of a compiler bug: -# ld: bl out of range (-16777272 max is +/-16M) -# from __static_initialization_and_destruction_0(int, int)at 0x033D319C -# in __StaticInit of -# indra/build-darwin-universal/newview/SecondLife.build/Debug/Second Life.build/Objects-normal/ppc/llvoicevisualizer.o -# to ___cxa_atexit$island_2 at 0x023D50F8 -# in __text of -# indra/build-darwin-universal/newview/SecondLife.build/Debug/Second Life.build/Objects-normal/ppc/Second Life -# in __static_initialization_and_destruction_0(int, int) -# from indra/build-darwin-universal/newview/SecondLife.build/Debug/Second Life.build/Objects-normal/ppc/llvoicevisualizer.o - -Darwin) - helpers=/usr/local/buildscripts/shared/latest - variants="Release" - cmake_generator="Xcode" - fmod=fmodapi375mac - fmod_tar="$fmod.zip" - fmod_so=libfmod.a - fmod_lib=lib - target_dirs="libraries/universal-darwin/lib_debug - libraries/universal-darwin/lib_release - libraries/universal-darwin/lib_release_client" - other_archs="$S3GET_URL/$branch/$revision/CYGWIN $S3GET_URL/$branch/$revision/Linux" - symbolfiles= - mail="$helpers"/mail.py - all_done="$helpers"/all_done.py - test -r "$helpers/update_version_files.py" && update_version_files="$helpers/update_version_files.py" - libs_asset="$SLASSET_LIBS_DARWIN" - s3put="$helpers"/hg/bin/s3put.sh - ;; - -CYGWIN) - helpers=/cygdrive/c/buildscripts/shared/latest - variants="Debug RelWithDebInfo Release ReleaseSSE2" - #variants="Release" - cmake_generator="vc80" - fmod=fmodapi375win - fmod_tar=fmodapi375win.zip - fmod_so=fmodvc.lib - fmod_lib=lib - target_dirs="libraries/i686-win32/lib/debug - libraries/i686-win32/lib/release" - other_archs="$S3GET_URL/$branch/$revision/Darwin $S3GET_URL/$branch/$revision/Linux" - symbolfiles="newview/Release/secondlife-bin.pdb newview/Release/secondlife-bin.map newview/Release/secondlife-bin.exe" - export PATH="/cygdrive/c/Python25:/cygdrive/c/Program Files/Cmake 2.6/bin":$PATH - export PERL="/cygdrive/c/Perl/bin/perl.exe" - export S3CURL="C:\\buildscripts\\shared\\latest\\hg\\bin\\s3curl.py" - export SIGN_PY="C:\\buildscripts\\shared\\latest\\code-signing\\sign.py" - export CURL="C:\\cygwin\\bin\\curl.exe" - mail="C:\\buildscripts\\shared\\latest\\mail.py" - all_done="C:\\buildscripts\\shared\\latest\\all_done.py" - test -r "$helpers/update_version_files.py" && update_version_files="C:\\buildscripts\\shared\\latest\\update_version_files.py" - libs_asset="$SLASSET_LIBS_WIN32" - s3put="$helpers"/hg/bin/s3put.sh - ;; - -Linux) - helpers=/var/opt/parabuild/buildscripts/shared/latest - if [ x"$CXX" = x ] - then - if test -x /usr/bin/g++-4.1 - then - if test -x /usr/bin/distcc - then - export CXX="/usr/bin/distcc /usr/bin/g++-4.1" - else - export CXX=/usr/bin/g++-4.1 - fi - fi - fi - variants="Debug RelWithDebInfo Release ReleaseSSE2" - #variants="Release" - cmake_generator="Unix Makefiles" - fmod=fmodapi375linux - fmod_tar="$fmod".tar.gz - fmod_so=libfmod-3.75.so - fmod_lib=. - target_dirs="libraries/i686-linux/lib_debug - libraries/i686-linux/lib_release - libraries/i686-linux/lib_release_client" - other_archs="$S3GET_URL/$branch/$revision/Darwin $S3GET_URL/$branch/$revision/CYGWIN" - symbolfiles= - mail="$helpers"/mail.py - all_done="$helpers"/all_done.py - test -r "$helpers/update_version_files.py" && update_version_files="$helpers/update_version_files.py" - # Change the DISTCC_DIR to be somewhere that the parabuild process can write to - if test -r /etc/debian_version - then - [ x"$DISTCC_DIR" = x ] && export DISTCC_DIR=/var/tmp/parabuild - #case `cat /etc/debian_version` in - #3.*) [ x"$DISTCC_HOSTS" = x ]\ - # && export DISTCC_HOSTS="build-linux-1/3 - # station30/2,lzo" ;; - #4.*) [ x"$DISTCC_HOSTS" = x ]\ - # && export DISTCC_HOSTS="build-linux-6/2,lzo - # build-linux-2/2,lzo - # build-linux-3/2,lzo - # build-linux-4/2,lzo - # build-linux-5/2,lzo - # build-linux-7/2,lzo - # build-linux-8/2,lzo - # build-linux-9/2,lzo" ;; - #esac - # Temp fix for Linux so that parabuild passes: use the new Linux build farm - export hostname=`hostname -f` - export phx_DISTCC_HOSTS="build-linux0.phx.lindenlab.com/2 build-linux1.phx.lindenlab.com/2 build-linux2.phx.lindenlab.com/2 build-linux3.phx.lindenlab.com/2 build-linux5.phx.lindenlab.com/2 build-linux5.phx.lindenlab.com/2 build-linux6.phx.lindenlab.com/2 " - export dfw_DISTCC_HOSTS="build-linux7.dfw.lindenlab.com/2 build-linux8.dfw.lindenlab.com/2 build-linux9.dfw.lindenlab.com/2 build-linux10.dfw.lindenlab.com/2 build-linux11.dfw.lindenlab.com/2 build-linux12.dfw.lindenlab.com/2 build-linux13.dfw.lindenlab.com/2 build-linux14.dfw.lindenlab.com/2 build-linux15.dfw.lindenlab.com/2" - case "$hostname" in - *.dfw.*) export DISTCC_HOSTS="$dfw_DISTCC_HOSTS" ;; - *.phx.*) export DISTCC_HOSTS="$phx_DISTCC_HOSTS" ;; - esac - fi - - libs_asset="$SLASSET_LIBS_LINUXI386" - s3put="$helpers"/hg/bin/s3put.sh - ;; - -*) fail undefined $arch ;; -esac - -acquire_lock -trap release_lock EXIT - -get_asset "http://www.fmod.org/files/fmod3/$fmod_tar" - -case "$arch" in - -Darwin) - # Create fat binary on Mac... - if lipo -create -output "../$fmod"/api/$fmod_lib/libfmod-universal.a\ - "../$fmod"/api/$fmod_lib/libfmod.a\ - "../$fmod"/api/$fmod_lib/libfmodx86.a - then - mv "../$fmod"/api/$fmod_lib/libfmod.a "../$fmod"/api/$fmod_lib/libfmodppc.a - mv "../$fmod"/api/$fmod_lib/libfmod-universal.a "../$fmod"/api/$fmod_lib/libfmod.a - echo Created fat binary - else - fail running lipo - fi - ;; - -CYGWIN) - # install Quicktime. This will fail outside of Linden's network - scripts/install.py quicktime - ;; - -esac - -# Only run this if the script exists -if test x"$update_version_files" = x -then - echo "Private Build..." > indra/build.log - [ x"$VIEWER_CHANNEL" = x ] && export VIEWER_CHANNEL="CommunityDeveloper" -else - # By right, this should be in the branched source tree, but for now it will be a helper - python "$update_version_files" --verbose --src-root=. --viewer > indra/build.log - [ x"$VIEWER_CHANNEL" = x ] && export VIEWER_CHANNEL="Snowglobe Test Build" -fi - -# First, go into the directory where the code was checked out by Parabuild -cd indra - -# This is the way it works now, but it will soon work on a variant dependent way -for target_dir in $target_dirs -do - mkdir -p "../$target_dir" - cp -f "../../$fmod/api/$fmod_lib/$fmod_so" "../$target_dir" -done -mkdir -p "../libraries/include" -cp -f "../../$fmod/api/inc/"* "../libraries/include" - -# Special Windows case -test -r "../../$fmod/api/fmod.dll" && cp -f "../../$fmod/api/fmod.dll" newview - -# Now run the build command over all variants -succeeded=true - -### TEST CODE - remove when done -### variants= -### echo "Artificial build failure to test notifications" > build.log -### succeeded=false -### END TEST CODE - -for variant in $variants -do - build_dir=`build_dir_$arch $variant` - rm -rf "$build_dir" - get_asset "$libs_asset" # This plunks stuff into the build dir, so have to restore it now. - - # SNOW-713 : hack around a Darwin lib 1.23.4.0 tarball issue introduced by the move from universal to i386 - # Should be removed when libs are rebuilt cleanly - if test -r build-darwin-universal-Release - then - mv build-darwin-universal-Release/ "$build_dir/" - fi - # End SNOW-713 hack - - # This is the way it will work in future - #for target_dir in $target_dirs - #do - # mkdir -p "$build_dir/$target_dir" - # cp "../../$fmod/api/$fmod_lib/$fmod_so" "$build_dir/$target_dir" - #done - #mkdir -p "$build_dir/libraries/include" - #cp "../../$fmod/api/inc/"* "$build_dir/libraries/include" - echo "==== $variant ====" >> build.log - if ./develop.py \ - --unattended \ - --incredibuild \ - -t $variant \ - -G "$cmake_generator" \ - configure \ - -DVIEWER_CHANNEL:STRING="$VIEWER_CHANNEL"\ - -DVIEWER_LOGIN_CHANNEL:STRING="$VIEWER_CHANNEL"\ - -DPACKAGE:BOOL=ON >>build.log 2>&1 - then - if ./develop.py\ - --unattended\ - --incredibuild \ - -t $variant\ - -G "$cmake_generator" \ - build prepare >>build.log 2>&1 - then - if ./develop.py\ - --unattended\ - --incredibuild \ - -t $variant\ - -G "$cmake_generator" \ - build package >>build.log 2>&1 - then - # run tests if needed - true - else - succeeded=false - fi - else - succeeded=false - fi - else - succeeded=false - fi -done - -# Check status and upload results to S3 -subject= -if $succeeded -then - package=`installer_$arch` - test -r "$package" || fail not found: $package - package_file=`echo $package | sed 's:.*/::'` - if s3_available - then - # Create an empty token file and populate it with the usable URLs: this will be emailed when all_done... - cp /dev/null "$arch" - echo "$PUBLIC_URL/$branch/$revision/$package_file" >> "$arch" - echo "$PUBLIC_URL/$branch/$revision/good-build.$arch" >> "$arch" - "$s3put" "$package" "$S3PUT_URL/$branch/$revision/$package_file" binary/octet-stream public-read\ - || fail Uploading "$package" - "$s3put" build.log "$S3PUT_URL/$branch/$revision/good-build.$arch" text/plain public-read\ - || fail Uploading build.log - "$s3put" "$arch" "$S3PUT_URL/$branch/$revision/$arch" text/plain public-read\ - || fail Uploading token file - for symbolfile in $symbolfiles - do - targetfile="`echo $symbolfile | sed 's:.*/::'`" - "$s3put" "$build_dir/$symbolfile" "$S3SYMBOL_URL/$revision/$targetfile" binary/octet-stream public-read\ - || fail Uploading "$symbolfile" - done - if python "$all_done"\ - curl\ - "$S3GET_URL/$branch/$revision/$arch"\ - $other_archs > message - then - subject="Successful Build for $year/$branch ($revision)" - fi - else - true s3 is not available - fi -else - if s3_available - then - "$s3put" build.log "$S3PUT_URL/$branch/$revision/failed-build.$arch" text/plain public-read\ - || fail Uploading build.log - subject="Failed Build for $year/$branch ($revision) on $arch" - cat >message <> message - elif [ x"$PARABUILD_PREVIOUS_CHANGE_LIST_NUMBER" = x ] - then - ( cd .. && svn log --verbose --stop-on-copy --limit 50 ) >> message - else - if [ "$PARABUILD_PREVIOUS_CHANGE_LIST_NUMBER" -lt "$PARABUILD_CHANGE_LIST_NUMBER" ] - then - range=`expr 1 + "$PARABUILD_PREVIOUS_CHANGE_LIST_NUMBER"`:"$PARABUILD_CHANGE_LIST_NUMBER" - else - range="$PARABUILD_CHANGE_LIST_NUMBER" - fi - ( cd .. && svn log --verbose -r"$range" ) >> message - fi - # $PUBLIC_EMAIL can be a list, so no quotes - python "$mail" "$subject" $PUBLIC_EMAIL < message -fi - -if $succeeded -then - pass -else - fail -fi - diff --git a/scripts/install.py b/scripts/install.py index 288b19b90..f43bc8dae 100755 --- a/scripts/install.py +++ b/scripts/install.py @@ -101,8 +101,10 @@ class InstallFile(object): def _is_md5sum_match(self): hasher = md5(file(self.filename, 'rb').read()) - if hasher.hexdigest() == self.md5sum: + md5_sum = hasher.hexdigest() + if md5_sum == self.md5sum: return True + print "Got:", md5_sum, " Expected ", self.md5sum return False def is_match(self, platform): @@ -124,16 +126,20 @@ class InstallFile(object): return True def fetch_local(self): - #print "Looking for:",self.filename + cache_path, cache_file = os.path.split(self.filename) + cache_path, cache_folder = os.path.split(os.path.normpath(cache_path)) + cache_file = os.path.join(cache_path, cache_folder.rsplit('.',1)[0] + ".", cache_file) + #print "Looking for:",cache_file + if not os.path.exists(self.filename): pass elif self.md5sum and not self._is_md5sum_match(): - print "md5 mismatch:", self.filename + print "md5 mismatch:", cache_file os.remove(self.filename) else: - print "Found matching package:", self.filename + print "Found matching package:", cache_file return - print "Downloading",self.url,"to local file",self.filename + print "Downloading",self.url,"to local file",cache_file request = urllib2.Request(self.url) diff --git a/scripts/public_fetch_tarballs.py b/scripts/public_fetch_tarballs.py deleted file mode 100755 index 45eb4c5a8..000000000 --- a/scripts/public_fetch_tarballs.py +++ /dev/null @@ -1,280 +0,0 @@ -#!/usr/bin/python -"""\ -@file public_fetch_tarballs.py -@author Rob Lanphier -@date 2009-05-30 -@brief Fetch + extract tarballs and zipfiles listed in doc/asset_urls.txt - -$LicenseInfo:firstyear=2009&license=viewergpl$ -Copyright (c) 2009, Linden Research, Inc. - -Second Life Viewer Source Code -The source code in this file ("Source Code") is provided by Linden Lab -to you under the terms of the GNU General Public License, version 2.0 -("GPL"), unless you have obtained a separate licensing agreement -("Other License"), formally executed by you and Linden Lab. Terms of -the GPL can be found in doc/GPL-license.txt in this distribution, or -online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 - -There are special exceptions to the terms and conditions of the GPL as -it is applied to this Source Code. View the full text of the exception -in the file doc/FLOSS-exception.txt in this software distribution, or -online at -http://secondlifegrid.net/programs/open_source/licensing/flossexception - -By copying, modifying or distributing this software, you acknowledge -that you have read and understood your obligations described above, -and agree to abide by those obligations. - -ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO -WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, -COMPLETENESS OR PERFORMANCE. -$/LicenseInfo$ -""" - -import sys -import os.path - -# Look for indra/lib/python in all possible parent directories ... -# This is an improvement over the setup-path.py method used previously: -# * the script may blocated anywhere inside the source tree -# * it doesn't depend on the current directory -# * it doesn't depend on another file being present. - -def add_indra_lib_path(): - root = os.path.realpath(__file__) - # always insert the directory of the script in the search path - dir = os.path.dirname(root) - if dir not in sys.path: - sys.path.insert(0, dir) - - # Now go look for indra/lib/python in the parent dies - while root != os.path.sep: - root = os.path.dirname(root) - dir = os.path.join(root, 'indra', 'lib', 'python') - if os.path.isdir(dir): - if dir not in sys.path: - sys.path.insert(0, dir) - return root - else: - print >>sys.stderr, "This script is not inside a valid installation." - sys.exit(1) - -base_dir = add_indra_lib_path() -print base_dir - -import os -import sys -import re -import urllib -import zipfile -import tarfile -import optparse -import tempfile - -import indra.util.helpformatter - -# load + parse doc/asset_urls.txt -def get_asset_urls(): - asset_urls={} - f = open(os.path.join(base_dir,"doc", "asset_urls.txt")) - for line in f: - line=line.strip() - (name, value)=re.split("=", line, 1) - asset_urls[name]=value - return asset_urls - -# Filename from a URL -def get_asset_filename_from_url(asseturl, targetdir): - i = asseturl.rfind('/') - filename = os.path.join(targetdir, asseturl[i+1:]) - return filename - - -# Extract .zip file to targetdir. Called by extract_archive_sans_linden. -def extract_zipfile_sans_linden(filename, targetdir): - archive = zipfile.ZipFile(filename, 'r') - names = archive.namelist() - for path in names: - if(path=="linden/"): - pass - target = os.path.join(targetdir, re.sub("linden/", "", path)) - subdir = os.path.dirname(target) - if not os.path.exists(subdir): - os.makedirs(subdir) - if not os.path.exists(target): - fp = open(target, 'wb') - fp.write(archive.read(path)) - fp.close() - archive.close() - - -# Extract .tar.gz file to targetdir. Called by extract_archive_sans_linden. -def extract_tarball_sans_linden(filename, targetdir): - archive = tarfile.TarFile.open(filename, 'r') - # get a series of TarInfo objects - tarentries=archive.getmembers() - for tarentry in tarentries: - target = re.sub(r'^(\./)?(linden/?)?', "", tarentry.name) - if(target==""): - continue - fulltarget=os.path.join(targetdir, target) - subdir = os.path.dirname(fulltarget) - if not os.path.exists(subdir): - os.makedirs(subdir) - if not os.path.exists(fulltarget): - # Reset the name property on the TarInfo object, so it writes the - # file exactly where we want it. It's hard telling for sure if this - # property is intended to be written to, but it works for now. - tarentry.name=fulltarget - # Calling TarFile.extract with the "path" parameter doesn't work as - # we might hope, because the path components in the tarball get - # appended to the "path" parameter. Hence the reason for passing in - # the TarInfo object with the munged name property - archive.extract(tarentry) - archive.close() - -# Extract either .tar.gz file or .zip file to targetdir, stripping off the -# leading "linden" directory, but leaving the directory structure otherwise -# intact. -def extract_archive_sans_linden(filename, targetdir): - if(filename.endswith('.tar.gz')): - extract_tarball_sans_linden(filename, targetdir) - elif(filename.endswith('.zip')): - extract_zipfile_sans_linden(filename, targetdir) - else: - raise Exception, "Unhandled archive type" - -def get_assetnames_by_platform(platform): - assetnames=['SLASSET_ART'] - if(platform=='linux' or platform=='all'): - assetnames.append('SLASSET_LIBS_LINUXI386') - if(platform=='darwin' or platform=='all'): - assetnames.append('SLASSET_LIBS_DARWIN') - if(platform=='windows' or platform=='all'): - assetnames.append('SLASSET_LIBS_WIN32') - return assetnames - -# adapted from install.py -def _get_platform(): - "Return appropriate platform packages for the environment." - platform_map = { - 'darwin': 'darwin', - 'linux2': 'linux', - 'win32' : 'windows', - 'cygwin' : 'windows', - 'solaris' : 'solaris' - } - this_platform = platform_map[sys.platform] - return this_platform - -# copied from install.py -def _default_installable_cache(): - """In general, the installable files do not change much, so find a - host/user specific location to cache files.""" - user = _getuser() - cache_dir = "/var/tmp/%s/sg.install.cache" % user - if _get_platform() == 'windows': - cache_dir = os.path.join(tempfile.gettempdir(), \ - 'sg.install.cache.%s' % user) - return cache_dir - -# For status messages (e.g. "Loading..."). May come in handy if -# we implement a "quiet" mode. -def _report(string): - print string - - -# copied from install.py -def _getuser(): - "Get the user" - try: - # Unix-only. - import getpass - return getpass.getuser() - except ImportError: - import win32api - return win32api.GetUserName() - -# adapted from install.py -def _parse_args(): - parser = optparse.OptionParser( - usage="usage: %prog [options]", - formatter = indra.util.helpformatter.Formatter(), - description="""This script fetches and installs tarballs and \ -zipfiles ("asset bundles") listed in doc/asset_urls.txt - -If no asset bundles are specified on the command line, then the default \ -behavior is to install all known asset bundles appropriate for the platform \ -specified. You can specify more than one asset bundle on the command line. - -Example: - %prog SLASSET_ART - - This looks for the "SLASSET_ART" entry in doc/asset_urls.txt, and extracts - the corresponding asset bundle into your source tree. -""") - parser.add_option( - '-p', '--platform', - type='choice', - default=_get_platform(), - dest='platform', - choices=['windows', 'darwin', 'linux', 'solaris', 'all'], - help="""Override the automatically determined platform. \ -You can specify 'all' to get assets for all platforms. Choices: windows, \ -darwin, linux, solaris, or all. Default: autodetected (%s)""" % \ - _get_platform()) - parser.add_option( - '--cache-dir', - type='string', - default=_default_installable_cache(), - dest='cache_dir', - help='Where to download files. Default: %s'% \ - (_default_installable_cache())) - parser.add_option( - '--install-dir', - type='string', - default=base_dir, - dest='install_dir', - help='Where to unpack the installed files. Default: %s' % base_dir) - - return parser.parse_args() - -def main(argv): - options, args = _parse_args() - # 1. prepare cache dir - if not os.path.exists(options.cache_dir): - os.makedirs(options.cache_dir) - - # 2. read doc/asset_urls.txt - asseturls=get_asset_urls() - - # 3. figure out which asset bundles we'll be downloading - if len(args)>0: - assetnames=args - else: - assetnames=get_assetnames_by_platform(options.platform) - - # 4. download and extract each asset bundle - for asset in assetnames: - # 4a. get the URL for the asset bundle - try: - asseturl=asseturls[asset] - except: - print "No asset in doc/asset_urls.txt named %s" % asset - sys.exit(2) - # 4b. figure out where to put the downloaded asset bundle - filename=get_asset_filename_from_url(asseturl, options.cache_dir) - - # 4c. see if we have it, and if not, get it - if os.path.exists(filename): - _report("Using already downloaded "+filename+" ...") - else: - _report("Downloading "+filename+" ...") - urllib.urlretrieve(asseturl, filename) - # 4d. extract it into the tree - extract_archive_sans_linden(filename, options.install_dir) - -# execute main() only if invoked directly: -if __name__ == "__main__": - sys.exit(main(sys.argv))