WITH_SAMPLERATE option for cmake, without this playback wont behave right so this...
authorCampbell Barton <ideasman42@gmail.com>
Sun, 21 Nov 2010 14:32:55 +0000 (14:32 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sun, 21 Nov 2010 14:32:55 +0000 (14:32 +0000)
CMakeLists.txt
build_files/cmake/macros.cmake
intern/audaspace/CMakeLists.txt
intern/audaspace/SConscript
intern/audaspace/intern/AUD_DefaultMixer.cpp

index b50d49d..6a4e063 100644 (file)
@@ -112,6 +112,7 @@ ENDIF()
 OPTION(WITH_SDL           "Enable SDL for sound and joystick support" ON)
 OPTION(WITH_OPENAL        "Enable OpenAL Support (http://www.openal.org)" ON)
 OPTION(WITH_JACK          "Enable Jack Support (http://www.jackaudio.org)" OFF)
+OPTION(WITH_SAMPLERATE    "Enable samplerate conversion" ON)
 
 # Compression
 OPTION(WITH_LZO           "Enable fast LZO compression (used for pointcache)" ON)
@@ -279,10 +280,12 @@ IF(UNIX AND NOT APPLE)
                SET(FFTW3_LIBPATH ${FFTW3}/lib)
        ENDIF(WITH_FFTW3)
 
-       SET(LIBSAMPLERATE /usr)
-       SET(LIBSAMPLERATE_INC ${LIBSAMPLERATE}/include)
-       SET(LIBSAMPLERATE_LIB samplerate)
-       SET(LIBSAMPLERATE_LIBPATH ${LIBSAMPLERATE}/lib)
+       IF(WITH_SAMPLERATE)
+               SET(LIBSAMPLERATE /usr)
+               SET(LIBSAMPLERATE_INC ${LIBSAMPLERATE}/include)
+               SET(LIBSAMPLERATE_LIB samplerate)
+               SET(LIBSAMPLERATE_LIBPATH ${LIBSAMPLERATE}/lib)
+       ENDIF(WITH_SAMPLERATE)
 
        IF (WITH_OPENCOLLADA)
                SET(OPENCOLLADA /usr/local/opencollada CACHE FILEPATH "OpenCollada Directory")
@@ -375,10 +378,12 @@ ELSEIF(WIN32)
                SET(ICONV_LIBPATH ${ICONV}/lib)
        ENDIF(WITH_INTERNATIONAL)
 
-       SET(LIBSAMPLERATE ${LIBDIR}/samplerate)
-       SET(LIBSAMPLERATE_INC ${LIBSAMPLERATE}/include)
-       SET(LIBSAMPLERATE_LIB libsamplerate)
-       SET(LIBSAMPLERATE_LIBPATH ${LIBSAMPLERATE}/lib)
+       IF(WITH_SAMPLERATE)
+               SET(LIBSAMPLERATE ${LIBDIR}/samplerate)
+               SET(LIBSAMPLERATE_INC ${LIBSAMPLERATE}/include)
+               SET(LIBSAMPLERATE_LIB libsamplerate)
+               SET(LIBSAMPLERATE_LIBPATH ${LIBSAMPLERATE}/lib)
+       ENDIF(WITH_SAMPLERATE)
 
        SET(PNG "${LIBDIR}/png")
        SET(PNG_INC "${PNG}/include")
@@ -776,10 +781,12 @@ ELSEIF(APPLE)
                SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__STDC_CONSTANT_MACROS")
        ENDIF(WITH_FFMPEG)
 
-       SET(LIBSAMPLERATE ${LIBDIR}/samplerate)
-       SET(LIBSAMPLERATE_INC ${LIBSAMPLERATE}/include)
-       SET(LIBSAMPLERATE_LIB samplerate)
-       SET(LIBSAMPLERATE_LIBPATH ${LIBSAMPLERATE}/lib)
+       IF(WITH_SAMPLERATE)
+               SET(LIBSAMPLERATE ${LIBDIR}/samplerate)
+               SET(LIBSAMPLERATE_INC ${LIBSAMPLERATE}/include)
+               SET(LIBSAMPLERATE_LIB samplerate)
+               SET(LIBSAMPLERATE_LIBPATH ${LIBSAMPLERATE}/lib)
+       ENDIF(WITH_SAMPLERATE)
 
        SET(LLIBS stdc++ SystemStubs)
 
index 0da1d6c..9ee8361 100644 (file)
@@ -55,8 +55,8 @@ MACRO(SETUP_LIBDIRS)
                CMAKE_POLICY(SET CMP0003 NEW)
        endif(COMMAND cmake_policy)
        
-       LINK_DIRECTORIES(${JPEG_LIBPATH} ${PNG_LIBPATH} ${ZLIB_LIBPATH} ${FREETYPE_LIBPATH} ${LIBSAMPLERATE_LIBPATH})
-       
+       LINK_DIRECTORIES(${JPEG_LIBPATH} ${PNG_LIBPATH} ${ZLIB_LIBPATH} ${FREETYPE_LIBPATH})
+
        IF(WITH_PYTHON)
                LINK_DIRECTORIES(${PYTHON_LIBPATH})
        ENDIF(WITH_PYTHON)
@@ -91,6 +91,9 @@ MACRO(SETUP_LIBDIRS)
        IF(WITH_SNDFILE)
                LINK_DIRECTORIES(${SNDFILE_LIBPATH})
        ENDIF(WITH_SNDFILE)
+       IF(WITH_SAMPLERATE)
+               LINK_DIRECTORIES(${LIBSAMPLERATE_LIBPATH})
+       ENDIF(WITH_SAMPLERATE)
        IF(WITH_FFTW3)
                LINK_DIRECTORIES(${FFTW3_LIBPATH})
        ENDIF(WITH_FFTW3)
@@ -124,7 +127,7 @@ MACRO(SETUP_LIBLINKS
        ENDIF(WITH_PYTHON)
 
        TARGET_LINK_LIBRARIES(${target} ${OPENGL_glu_LIBRARY} ${JPEG_LIB} ${PNG_LIB} ${ZLIB_LIB})
-       TARGET_LINK_LIBRARIES(${target} ${FREETYPE_LIBRARY} ${LIBSAMPLERATE_LIB})
+       TARGET_LINK_LIBRARIES(${target} ${FREETYPE_LIBRARY})
 
        IF(WITH_INTERNATIONAL)
                TARGET_LINK_LIBRARIES(${target} ${GETTEXT_LIB})
@@ -146,6 +149,9 @@ MACRO(SETUP_LIBLINKS
        IF(WITH_SNDFILE)
                TARGET_LINK_LIBRARIES(${target} ${SNDFILE_LIB})
        ENDIF(WITH_SNDFILE)
+       IF(WITH_SAMPLERATE)
+               TARGET_LINK_LIBRARIES(${target} ${LIBSAMPLERATE_LIB})
+       ENDIF(WITH_SAMPLERATE)  
        IF(WITH_SDL)
                TARGET_LINK_LIBRARIES(${target} ${SDL_LIBRARY})
        ENDIF(WITH_SDL)
index be39a73..a476ea3 100644 (file)
@@ -61,8 +61,6 @@ SET(SRC
        FX/AUD_SuperposeFactory.cpp
        FX/AUD_SuperposeReader.cpp
        FX/AUD_VolumeFactory.cpp
-       SRC/AUD_SRCResampleFactory.cpp
-       SRC/AUD_SRCResampleReader.cpp
        intern/AUD_3DMath.h
        intern/AUD_Buffer.cpp
        intern/AUD_Buffer.h
@@ -164,6 +162,14 @@ IF(WITH_SNDFILE)
        )
 ENDIF(WITH_SNDFILE)
 
+IF(WITH_SAMPLERATE)
+       ADD_DEFINITIONS(-DWITH_SAMPLERATE)
+       SET(SRCFILESRC
+               SRC/AUD_SRCResampleFactory.cpp
+               SRC/AUD_SRCResampleReader.cpp
+       )
+ENDIF(WITH_SAMPLERATE)
+
 #IF(WITH_FFTW3)
 #      ADD_DEFINITIONS(-DWITH_FFTW3)
 #      LIST(APPEND INC fftw ${FFTW3_INC})
@@ -181,6 +187,6 @@ IF(WITH_PYTHON)
        ADD_DEFINITIONS(-DWITH_PYTHON)
 ENDIF(WITH_PYTHON)
 
-SET(SRC ${SRC} ${FFMPEGSRC} ${SNDFILESRC} ${FFTW3SRC} ${SDLSRC} ${OPENALSRC} ${JACKSRC} ${PYTHONSRC})
+SET(SRC ${SRC} ${FFMPEGSRC} ${SNDFILESRC} ${SRCFILESRC} ${FFTW3SRC} ${SDLSRC} ${OPENALSRC} ${JACKSRC} ${PYTHONSRC})
 
 BLENDERLIB(bf_intern_audaspace "${SRC}" "${INC}")
index 2c86849..ecc9498 100644 (file)
@@ -44,4 +44,7 @@ if env['WITH_BF_PYTHON']:
 if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc'):
     incs += ' ' + env['BF_PTHREADS_INC']
 
+# not optional with scons yet
+defs.append('WITH_SAMPLERATE')
+
 env.BlenderLib ('bf_intern_audaspace', sources, Split(incs), defs, libtype=['intern','player'], priority = [25,215] )
index 12faa10..2b641b6 100644 (file)
@@ -24,7 +24,9 @@
  */
 
 #include "AUD_DefaultMixer.h"
+#ifdef WITH_SAMPLERATE
 #include "AUD_SRCResampleReader.h"
+#endif
 #include "AUD_ChannelMapperReader.h"
 #include "AUD_ChannelMapperFactory.h"
 
@@ -50,10 +52,12 @@ AUD_IReader* AUD_DefaultMixer::prepare(AUD_IReader* reader)
                specs.channels = m_specs.channels;
        }
 
+#ifdef WITH_SAMPLERATE
        // resample
        if(specs.rate != m_specs.rate)
                reader = new AUD_SRCResampleReader(reader, m_specs.specs);
-
+#endif
+       
        // rechannel
        if(specs.channels != m_specs.channels)
                reader = new AUD_ChannelMapperReader(reader,