soxr cmake fixes

This commit is contained in:
Jack Andersen 2016-03-22 21:01:25 -10:00
parent f9d5b1bf5f
commit 5b275866a7
8 changed files with 94 additions and 71 deletions

View File

@ -162,13 +162,13 @@ endif()
add_subdirectory(glslang/glslang) add_subdirectory(glslang/glslang)
add_subdirectory(glslang/OGLCompilersDLL) add_subdirectory(glslang/OGLCompilersDLL)
add_subdirectory(glslang/SPIRV) add_subdirectory(glslang/SPIRV)
list(APPEND _BOO_SYS_LIBS glslang OSDependent OGLCompiler SPIRV) list(APPEND _BOO_SYS_LIBS glslang soxr OSDependent OGLCompiler SPIRV)
set(BOO_SYS_LIBS ${_BOO_SYS_LIBS} CACHE PATH "boo system libraries" FORCE) set(BOO_SYS_LIBS ${_BOO_SYS_LIBS} CACHE PATH "boo system libraries" FORCE)
set(BOO_SYS_DEFINES ${_BOO_SYS_DEFINES} CACHE PATH "boo system defines" FORCE) set(BOO_SYS_DEFINES ${_BOO_SYS_DEFINES} CACHE PATH "boo system defines" FORCE)
add_definitions(${_BOO_SYS_DEFINES}) add_definitions(${_BOO_SYS_DEFINES})
include_directories(include glslang) include_directories(include glslang soxr/src)
add_library(boo add_library(boo
lib/inputdev/CafeProPad.cpp include/boo/inputdev/CafeProPad.hpp lib/inputdev/CafeProPad.cpp include/boo/inputdev/CafeProPad.hpp
@ -180,6 +180,8 @@ add_library(boo
lib/inputdev/DeviceSignature.cpp include/boo/inputdev/DeviceSignature.hpp lib/inputdev/DeviceSignature.cpp include/boo/inputdev/DeviceSignature.hpp
lib/inputdev/IHIDDevice.hpp lib/inputdev/IHIDDevice.hpp
lib/audiodev/AudioMatrix.cpp lib/audiodev/AudioMatrix.cpp
lib/audiodev/AudioVoice.hpp
lib/audiodev/AudioVoice.cpp
include/boo/inputdev/IHIDListener.hpp include/boo/inputdev/IHIDListener.hpp
include/boo/IGraphicsContext.hpp include/boo/IGraphicsContext.hpp
include/boo/graphicsdev/IGraphicsDataFactory.hpp include/boo/graphicsdev/IGraphicsDataFactory.hpp

View File

@ -68,7 +68,8 @@ struct AQSAudioVoice : IAudioVoice
desc.mBitsPerChannel = 16; desc.mBitsPerChannel = 16;
OSStatus err; OSStatus err;
while ((err = AudioQueueNewOutput(&desc, AudioQueueOutputCallback(Callback), this, nullptr, nullptr, 0, &m_queue))) while ((err = AudioQueueNewOutput(&desc, AudioQueueOutputCallback(Callback),
this, nullptr, nullptr, 0, &m_queue)))
{ {
if (set == AudioChannelSet::Stereo) if (set == AudioChannelSet::Stereo)
break; break;
@ -144,7 +145,9 @@ struct AQSAudioVoice : IAudioVoice
m_map.m_channels[4] = AudioChannel::FrontCenter; m_map.m_channels[4] = AudioChannel::FrontCenter;
break; break;
default: default:
Log.report(logvisor::Fatal, "unknown channel layout %u; using stereo", layout.mChannelLayoutTag); Log.report(logvisor::Fatal,
"unknown channel layout %u; using stereo",
layout.mChannelLayoutTag);
m_map.m_channelCount = 2; m_map.m_channelCount = 2;
m_map.m_channels[0] = AudioChannel::FrontLeft; m_map.m_channels[0] = AudioChannel::FrontLeft;
m_map.m_channels[1] = AudioChannel::FrontRight; m_map.m_channels[1] = AudioChannel::FrontRight;
@ -188,14 +191,16 @@ struct AQSAudioVoice : IAudioVoice
{ {
if (m_callbackBuf) if (m_callbackBuf)
{ {
m_callbackBuf->mAudioDataByteSize = std::min(UInt32(frames * m_frameSize), m_callbackBuf->mAudioDataBytesCapacity); m_callbackBuf->mAudioDataByteSize =
std::min(UInt32(frames * m_frameSize), m_callbackBuf->mAudioDataBytesCapacity);
memcpy(m_callbackBuf->mAudioData, data, m_callbackBuf->mAudioDataByteSize); memcpy(m_callbackBuf->mAudioData, data, m_callbackBuf->mAudioDataByteSize);
AudioQueueEnqueueBuffer(m_queue, m_callbackBuf, 0, nullptr); AudioQueueEnqueueBuffer(m_queue, m_callbackBuf, 0, nullptr);
} }
else else
{ {
AudioQueueBufferRef buf = m_buffers[m_primeBuf]; AudioQueueBufferRef buf = m_buffers[m_primeBuf];
buf->mAudioDataByteSize = std::min(UInt32(frames * m_frameSize), buf->mAudioDataBytesCapacity); buf->mAudioDataByteSize =
std::min(UInt32(frames * m_frameSize), buf->mAudioDataBytesCapacity);
memcpy(buf->mAudioData, data, buf->mAudioDataByteSize); memcpy(buf->mAudioData, data, buf->mAudioDataByteSize);
AudioQueueEnqueueBuffer(m_queue, buf, 0, nullptr); AudioQueueEnqueueBuffer(m_queue, buf, 0, nullptr);
} }

View File

View File

@ -0,0 +1,16 @@
#ifndef BOO_AUDIOVOICE_HPP
#define BOO_AUDIOVOICE_HPP
#include <soxr.h>
namespace boo
{
class AudioVoice
{
soxr_t m_voice;
};
}
#endif // BOO_AUDIOVOICE_HPP

View File

@ -3,8 +3,8 @@
cmake_minimum_required (VERSION 2.8 FATAL_ERROR) cmake_minimum_required (VERSION 2.8 FATAL_ERROR)
project (soxr C) #project (soxr C)
set (DESCRIPTION_SUMMARY "High quality, one-dimensional sample-rate conversion library") #set (DESCRIPTION_SUMMARY "High quality, one-dimensional sample-rate conversion library")
@ -34,9 +34,9 @@ if (NOT CMAKE_BUILD_TYPE)
set (CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." FORCE) set (CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." FORCE)
endif () endif ()
option (BUILD_TESTS "Build sanity-tests." ON) #option (BUILD_TESTS "Build sanity-tests." ON)
option (BUILD_SHARED_LIBS "Build shared libraries." ON) #option (BUILD_SHARED_LIBS "Build shared libraries." ON)
option (BUILD_EXAMPLES "Build examples." OFF) #option (BUILD_EXAMPLES "Build examples." OFF)
option (WITH_OPENMP "Include OpenMP threading." ON) option (WITH_OPENMP "Include OpenMP threading." ON)
option (WITH_LSR_BINDINGS "Include a `libsamplerate'-like interface." ON) option (WITH_LSR_BINDINGS "Include a `libsamplerate'-like interface." ON)
cmake_dependent_option (WITH_SINGLE_PRECISION "Build with single precision (for up to 20-bit accuracy)." ON cmake_dependent_option (WITH_SINGLE_PRECISION "Build with single precision (for up to 20-bit accuracy)." ON
@ -50,7 +50,7 @@ cmake_dependent_option (WITH_AVFFT "Use libavcodec (LGPL) for SIMD DFT." OFF
cmake_dependent_option (WITH_PFFFT "Use PFFFT (BSD-like licence) for SIMD DFT." ON cmake_dependent_option (WITH_PFFFT "Use PFFFT (BSD-like licence) for SIMD DFT." ON
"WITH_SIMD;NOT WITH_AVFFT" OFF) "WITH_SIMD;NOT WITH_AVFFT" OFF)
if (UNIX) if (UNIX)
if (EXISTS ${PROJECT_SOURCE_DIR}/lsr-tests) if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/lsr-tests)
cmake_dependent_option (BUILD_LSR_TESTS "Build LSR tests." OFF cmake_dependent_option (BUILD_LSR_TESTS "Build LSR tests." OFF
"WITH_LSR_BINDINGS" OFF) "WITH_LSR_BINDINGS" OFF)
endif () endif ()
@ -157,7 +157,7 @@ endif ()
# Build configuration: # Build configuration:
if (${BUILD_SHARED_LIBS} AND ${CMAKE_SYSTEM_NAME} STREQUAL Windows) # Allow exes to find dlls: if (${BUILD_SHARED_LIBS} AND ${CMAKE_SYSTEM_NAME} STREQUAL Windows) # Allow exes to find dlls:
set (BIN ${PROJECT_BINARY_DIR}/bin/) set (BIN ${CMAKE_CURRENT_BINARY_DIR}/bin/)
set (EXAMPLES_BIN ${BIN}) set (EXAMPLES_BIN ${BIN})
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${BIN}) set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${BIN})
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${BIN}) set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${BIN})
@ -189,7 +189,7 @@ if (NOT DEFINED INCLUDE_INSTALL_DIR)
endif () endif ()
if (NOT DEFINED DOC_INSTALL_DIR) if (NOT DEFINED DOC_INSTALL_DIR)
if (UNIX) if (UNIX)
set (DOC_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/share/doc/lib${PROJECT_NAME}") set (DOC_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/share/doc/libsoxr")
else () else ()
set (DOC_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/doc") set (DOC_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/doc")
endif () endif ()
@ -211,9 +211,9 @@ math (EXPR SO_VERSION_PATCH "${SO_VERSION_REVISION}")
set (SO_VERSION ${SO_VERSION_MAJOR}.${SO_VERSION_MINOR}.${SO_VERSION_PATCH}) set (SO_VERSION ${SO_VERSION_MAJOR}.${SO_VERSION_MINOR}.${SO_VERSION_PATCH})
configure_file ( configure_file (
${PROJECT_SOURCE_DIR}/${PROJECT_NAME}-config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/soxr-config.h.in
${PROJECT_BINARY_DIR}/${PROJECT_NAME}-config.h) ${CMAKE_CURRENT_BINARY_DIR}/soxr-config.h)
include_directories (${PROJECT_BINARY_DIR}) include_directories (${CMAKE_CURRENT_BINARY_DIR})
if (BUILD_TESTS OR BUILD_LSR_TESTS) if (BUILD_TESTS OR BUILD_LSR_TESTS)
enable_testing () enable_testing ()
@ -229,7 +229,7 @@ install (FILES
# Subdirectories: # Subdirectories:
include_directories (${PROJECT_SOURCE_DIR}/src) include_directories (${CMAKE_CURRENT_SOURCE_DIR}/src)
add_subdirectory (src) add_subdirectory (src)
if (BUILD_TESTS) if (BUILD_TESTS)
@ -246,53 +246,53 @@ endif ()
# Rough-and-ready distclean for anyone still doing in-tree builds: # Rough-and-ready distclean for anyone still doing in-tree builds:
if (UNIX) #if (UNIX)
add_custom_target (distclean # add_custom_target (distclean
COMMAND make clean && rm -rf # COMMAND make clean && rm -rf
CMakeCache.txt # CMakeCache.txt
CMakeFiles # CMakeFiles
cmake_install.cmake # cmake_install.cmake
CPackConfig.cmake # CPackConfig.cmake
CPackSourceConfig.cmake # CPackSourceConfig.cmake
deinstall.cmake # deinstall.cmake
Makefile # Makefile
soxr-config.h # soxr-config.h
src/CMakeFiles # src/CMakeFiles
src/cmake_install.cmake # src/cmake_install.cmake
src/libsoxr-dev.src # src/libsoxr-dev.src
src/libsoxr-lsr.pc # src/libsoxr-lsr.pc
src/libsoxr.pc # src/libsoxr.pc
src/libsoxr.src # src/libsoxr.src
src/Makefile) # src/Makefile)
endif () #endif ()
# Deinstallation: # Deinstallation:
configure_file ( #configure_file (
"${CMAKE_CURRENT_SOURCE_DIR}/deinstall.cmake.in" # "${CMAKE_CURRENT_SOURCE_DIR}/deinstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/deinstall.cmake" # "${CMAKE_CURRENT_BINARY_DIR}/deinstall.cmake"
IMMEDIATE @ONLY) # IMMEDIATE @ONLY)
add_custom_target (deinstall #add_custom_target (deinstall
COMMAND ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_BINARY_DIR}/deinstall.cmake") # COMMAND ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_BINARY_DIR}/deinstall.cmake")
# Packaging: # Packaging:
if (UNIX) #if (UNIX)
set (CPACK_PACKAGE_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}") # set (CPACK_PACKAGE_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}")
set (CPACK_PACKAGE_VERSION_MINOR "${PROJECT_VERSION_MINOR}") # set (CPACK_PACKAGE_VERSION_MINOR "${PROJECT_VERSION_MINOR}")
set (CPACK_PACKAGE_VERSION_PATCH "${PROJECT_VERSION_PATCH}") # set (CPACK_PACKAGE_VERSION_PATCH "${PROJECT_VERSION_PATCH}")
#
set (CPACK_SOURCE_GENERATOR "TGZ") # set (CPACK_SOURCE_GENERATOR "TGZ")
set (CPACK_SOURCE_IGNORE_FILES "dist;/lsr-tests/;/Debug/;/Release/;/cpack/;\\\\.swp$;\\\\.gitignore;/\\\\.git/") # set (CPACK_SOURCE_IGNORE_FILES "dist;/lsr-tests/;/Debug/;/Release/;/cpack/;\\\\.swp$;\\\\.gitignore;/\\\\.git/")
#
include (CPack) # include (CPack)
#
if (IS_DIRECTORY ${PROJECT_SOURCE_DIR}/cpack) # if (IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/cpack)
add_subdirectory (cpack) # add_subdirectory (cpack)
endif () # endif ()
endif () #endif ()

View File

@ -19,7 +19,7 @@ if (NOT BUILD_SHARED_LIBS AND OPENMP_FOUND)
endif () endif ()
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PROJECT_C_FLAGS}") set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PROJECT_C_FLAGS}")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PROJECT_CXX_FLAGS}") set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PROJECT_CXX_FLAGS}")
link_libraries (${PROJECT_NAME}) link_libraries (soxr)
foreach (fe ${SOURCES} ${LSR_SOURCES}) foreach (fe ${SOURCES} ${LSR_SOURCES})
get_filename_component (f ${fe} NAME_WE) get_filename_component (f ${fe} NAME_WE)

View File

@ -52,20 +52,20 @@ endif ()
# Libsoxr: # Libsoxr:
add_library (${PROJECT_NAME} ${LIB_TYPE} ${PROJECT_NAME}.c data-io dbesi0 filter fft4g64 add_library (soxr ${LIB_TYPE} soxr.c data-io dbesi0 filter fft4g64
${SP_SOURCES} vr32 ${DP_SOURCES} ${SIMD_SOURCES}) ${SP_SOURCES} vr32 ${DP_SOURCES} ${SIMD_SOURCES})
set_target_properties (${PROJECT_NAME} PROPERTIES set_target_properties (soxr PROPERTIES
VERSION "${SO_VERSION}" VERSION "${SO_VERSION}"
SOVERSION ${SO_VERSION_MAJOR} SOVERSION ${SO_VERSION_MAJOR}
INSTALL_NAME_DIR ${LIB_INSTALL_DIR} INSTALL_NAME_DIR ${LIB_INSTALL_DIR}
LINK_INTERFACE_LIBRARIES "" LINK_INTERFACE_LIBRARIES ""
PUBLIC_HEADER "${PROJECT_NAME}.h") PUBLIC_HEADER "soxr.h")
if (BUILD_FRAMEWORK) if (BUILD_FRAMEWORK)
set_target_properties (${PROJECT_NAME} PROPERTIES FRAMEWORK TRUE) set_target_properties (soxr PROPERTIES FRAMEWORK TRUE)
elseif (NOT WIN32) elseif (NOT WIN32)
set (TARGET_PCS ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc) set (TARGET_PCS ${CMAKE_CURRENT_BINARY_DIR}/soxr.pc)
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.pc.in ${TARGET_PCS}) configure_file (${CMAKE_CURRENT_SOURCE_DIR}/soxr.pc.in ${TARGET_PCS})
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig) install (FILES ${CMAKE_CURRENT_BINARY_DIR}/soxr.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
endif () endif ()
@ -73,11 +73,11 @@ endif ()
# LSR bindings: # LSR bindings:
if (WITH_LSR_BINDINGS) if (WITH_LSR_BINDINGS)
set (LSR ${PROJECT_NAME}-lsr) set (LSR soxr-lsr)
set (LSR_SO_VERSION 0.1.9) set (LSR_SO_VERSION 0.1.9)
set (LSR_SO_VERSION_MAJOR 0) set (LSR_SO_VERSION_MAJOR 0)
add_library (${LSR} ${LIB_TYPE} lsr) add_library (${LSR} ${LIB_TYPE} lsr)
target_link_libraries (${LSR} ${PROJECT_NAME}) target_link_libraries (${LSR} soxr)
set_target_properties (${LSR} PROPERTIES set_target_properties (${LSR} PROPERTIES
VERSION "${LSR_SO_VERSION}" VERSION "${LSR_SO_VERSION}"
SOVERSION ${LSR_SO_VERSION_MAJOR} SOVERSION ${LSR_SO_VERSION_MAJOR}
@ -97,7 +97,7 @@ endif ()
# Installation (from build from source): # Installation (from build from source):
install (TARGETS ${PROJECT_NAME} ${LSR} install (TARGETS soxr ${LSR}
FRAMEWORK DESTINATION ${FRAMEWORK_INSTALL_DIR} FRAMEWORK DESTINATION ${FRAMEWORK_INSTALL_DIR}
LIBRARY DESTINATION ${LIB_INSTALL_DIR} LIBRARY DESTINATION ${LIB_INSTALL_DIR}
RUNTIME DESTINATION ${BIN_INSTALL_DIR} RUNTIME DESTINATION ${BIN_INSTALL_DIR}
@ -108,11 +108,11 @@ install (TARGETS ${PROJECT_NAME} ${LSR}
# Packaging (for unix-like distributions): # Packaging (for unix-like distributions):
#get_property (LIB1 TARGET ${PROJECT_NAME} PROPERTY LOCATION) #get_property (LIB1 TARGET soxr PROPERTY LOCATION)
#if (BUILD_SHARED_LIBS) #if (BUILD_SHARED_LIBS)
# set (LIB1 ${LIB1}.${SO_VERSION_MAJOR} ${LIB1}.${SO_VERSION}) # set (LIB1 ${LIB1}.${SO_VERSION_MAJOR} ${LIB1}.${SO_VERSION})
#endif () #endif ()
#list (APPEND TARGET_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.h") #list (APPEND TARGET_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/soxr.h")
#if (WITH_LSR_BINDINGS) #if (WITH_LSR_BINDINGS)
# get_property (LIB2 TARGET ${LSR} PROPERTY LOCATION) # get_property (LIB2 TARGET ${LSR} PROPERTY LOCATION)
# if (BUILD_SHARED_LIBS) # if (BUILD_SHARED_LIBS)

View File

@ -2,7 +2,7 @@
# Licence for this file: LGPL v2.1 See LICENCE for details. # Licence for this file: LGPL v2.1 See LICENCE for details.
add_definitions (${PROJECT_C_FLAGS}) add_definitions (${PROJECT_C_FLAGS})
link_libraries (${PROJECT_NAME}) link_libraries (soxr)
file (GLOB SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/*.c) file (GLOB SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/*.c)
foreach (fe ${SOURCES}) foreach (fe ${SOURCES})