diff options
Diffstat (limited to '3rdparty/portaudio/bindings/cpp')
49 files changed, 2874 insertions, 2620 deletions
diff --git a/3rdparty/portaudio/bindings/cpp/CMakeLists.txt b/3rdparty/portaudio/bindings/cpp/CMakeLists.txt new file mode 100644 index 00000000000..488bac82cd0 --- /dev/null +++ b/3rdparty/portaudio/bindings/cpp/CMakeLists.txt @@ -0,0 +1,122 @@ +cmake_minimum_required(VERSION 3.13) +cmake_policy(VERSION 3.13) + +project(PortAudioCpp VERSION 19.8 LANGUAGES CXX) +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules") + +# Todo (multi-generator): Add support for multiple generators like: - {Debug, +# Release} x {Static, Dynamic} x {MT, MD (Windows only)} + +# ############################################################################## +# sources and headers +# ############################################################################## + +set(portaudiocpp-sources + source/portaudiocpp/BlockingStream.cxx + source/portaudiocpp/CFunCallbackStream.cxx + source/portaudiocpp/CallbackInterface.cxx + source/portaudiocpp/CallbackStream.cxx + source/portaudiocpp/CppFunCallbackStream.cxx + source/portaudiocpp/Device.cxx + source/portaudiocpp/DirectionSpecificStreamParameters.cxx + source/portaudiocpp/Exception.cxx + source/portaudiocpp/HostApi.cxx + source/portaudiocpp/InterfaceCallbackStream.cxx + source/portaudiocpp/MemFunCallbackStream.cxx + source/portaudiocpp/Stream.cxx + source/portaudiocpp/StreamParameters.cxx + source/portaudiocpp/System.cxx + source/portaudiocpp/SystemDeviceIterator.cxx + source/portaudiocpp/SystemHostApiIterator.cxx) + +# since we don't GLOBing this variable must be kept up to date otherwise user +# installations are broken. +set(portaudiocpp-header-files + include/portaudiocpp/AutoSystem.hxx + include/portaudiocpp/BlockingStream.hxx + include/portaudiocpp/CFunCallbackStream.hxx + include/portaudiocpp/CallbackInterface.hxx + include/portaudiocpp/CallbackStream.hxx + include/portaudiocpp/CppFunCallbackStream.hxx + include/portaudiocpp/Device.hxx + include/portaudiocpp/DirectionSpecificStreamParameters.hxx + include/portaudiocpp/Exception.hxx + include/portaudiocpp/HostApi.hxx + include/portaudiocpp/InterfaceCallbackStream.hxx + include/portaudiocpp/MemFunCallbackStream.hxx + include/portaudiocpp/PortAudioCpp.hxx + include/portaudiocpp/SampleDataFormat.hxx + include/portaudiocpp/Stream.hxx + include/portaudiocpp/StreamParameters.hxx + include/portaudiocpp/System.hxx + include/portaudiocpp/SystemDeviceIterator.hxx + include/portaudiocpp/SystemHostApiIterator.hxx) + +if(WIN32) + find_package(ASIO MODULE) + if(ASIO_FOUND) + list(APPEND portaudiocpp-sources source/portaudiocpp/AsioDeviceAdapter.cxx) + list(APPEND portaudiocpp-header-files + include/portaudiocpp/AsioDeviceAdapter.hxx) + endif() +endif() + +# ############################################################################## +# portaudiocpp-targets +# ############################################################################## + +add_library(portaudiocpp ${portaudiocpp-sources}) +add_library(PortAudio::portaudiocpp ALIAS portaudiocpp) # For subdirectory build + +find_package(PortAudio MODULE REQUIRED) + +target_link_libraries(portaudiocpp PUBLIC PortAudio::portaudio) +target_include_directories( + portaudiocpp PUBLIC $<INSTALL_INTERFACE:include> + $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>) +set_target_properties(portaudiocpp PROPERTIES SOVERSION 2) +# Todo (modernize): update the code at least to c++14 +# target_compile_features(portaudiocpp PUBLIC cxx_std_14) + +# ## Export ### +include(GNUInstallDirs) + +install( + TARGETS portaudiocpp + EXPORT PortAudioCppTargets + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + INCLUDES + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/portaudiocpp) + +install(FILES ${portaudiocpp-header-files} + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/portaudiocpp) + +install( + EXPORT PortAudioCppTargets + FILE PortAudioCppTargets.cmake + NAMESPACE PortAudio:: + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/PortAudio) + +include(CMakePackageConfigHelpers) +configure_package_config_file( + ${CMAKE_CURRENT_SOURCE_DIR}/cmake/PortAudioCppConfig.cmake.in + "${CMAKE_CURRENT_BINARY_DIR}/PortAudioCppConfig.cmake" + INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/PortAudio) + +write_basic_package_version_file( + "${CMAKE_CURRENT_BINARY_DIR}/PortAudioCppConfigVersion.cmake" + COMPATIBILITY SameMajorVersion +) + +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/PortAudioCppConfig.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/PortAudioCppConfigVersion.cmake" + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/PortAudio) + +#use relative path, since CMAKE can't reconfigure on install with different prefix path +set(PC_PREFIX "\${pcfiledir}/../..") +configure_file(cmake/portaudiocpp.pc.in "${CMAKE_CURRENT_BINARY_DIR}/portaudiocpp.pc" @ONLY) +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/portaudiocpp.pc" + CONFIGURATIONS Release RelWithDebInfo + DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) diff --git a/3rdparty/portaudio/bindings/cpp/ChangeLog b/3rdparty/portaudio/bindings/cpp/ChangeLog index 6b0b02700d9..1e96618ec6b 100644 --- a/3rdparty/portaudio/bindings/cpp/ChangeLog +++ b/3rdparty/portaudio/bindings/cpp/ChangeLog @@ -12,7 +12,7 @@ PortAudioCpp v19 revision 15 (unknown release date): mblaauw: - Changed some exception handling code in HostApi's constructor. - - Added accessors to PortAudio PaStream from PortAudioCpp Stream (their absense being pointed out + - Added accessors to PortAudio PaStream from PortAudioCpp Stream (their absence being pointed out by Tom Jordan). - Fixed a bug/typo in MemFunToCallbackInterfaceAdapter::init() thanks to Fredrik Viklund. - Fixed issue with concrete Stream classes possibly throwing an exception and fixed documentation w.r.t. this. @@ -37,14 +37,14 @@ PortAudioCpp v19 revision 13 03/10/19: the std::exception base class's what() member function (which had throw(), i.e. no-throw guarantee). - Changed the iterators so that they have a set of public typedefs instead of deriving the C++ standard library std::iterator<> struct. G++ 2.95 doesn't support std::exception<> and composition-by-aggregation - is prefered over composition-by-inheritance in this case. + is preferred over composition-by-inheritance in this case. - Changed some minor things to avoid G++ warning messages. mblaauw: - Renamed this file (/WHATSNEW.txt) to /CHANGELOG. - Renamed /PA_ISSUES.txt to /PA_ISSUES. - Added /INSTALL file with some build info for GNU/Linux and VC6. - - Added MSVC 6.0 projects for building PortAudioCpp as a staticly or dynamically linkable library. + - Added MSVC 6.0 projects for building PortAudioCpp as a statically or dynamically linkable library. - Moved build files to /build/(gnu/ or vc6/). - Moved Doxygen configuration files to /doc/ and output to /doc/api_reference/. - Added a /doc/README with some info how to generate Doxygen documentation. @@ -82,7 +82,7 @@ PortAudioCpp v19 revision 09 03/06/25: mblaauw: - Changed some things in SingleDirectionStreamParameters to ease it's usage. - Placed all SingleDirectionStreamParameters stuff into a separate file. - + Totally redid the callback stuff, now it's less ackward and supports C++ functions. + + Totally redid the callback stuff, now it's less awkward and supports C++ functions. PortAudioCpp v19 revision 08 03/06/20: diff --git a/3rdparty/portaudio/bindings/cpp/INSTALL b/3rdparty/portaudio/bindings/cpp/INSTALL index 2099840756e..cde9b495c59 100644 --- a/3rdparty/portaudio/bindings/cpp/INSTALL +++ b/3rdparty/portaudio/bindings/cpp/INSTALL @@ -124,7 +124,7 @@ architecture at a time in the source code directory. After you have installed the package for one architecture, use `make distclean' before reconfiguring for another architecture. - On MacOS X 10.5 and later systems, you can create libraries and + On MacOS X 10.6 and later systems, you can create libraries and executables that work on multiple system types--known as "fat" or "universal" binaries--by specifying multiple `-arch' options to the compiler but only a single `-arch' option to the preprocessor. Like diff --git a/3rdparty/portaudio/bindings/cpp/aclocal.m4 b/3rdparty/portaudio/bindings/cpp/aclocal.m4 index 68c908fbabe..f5dec8f78e0 100644 --- a/3rdparty/portaudio/bindings/cpp/aclocal.m4 +++ b/3rdparty/portaudio/bindings/cpp/aclocal.m4 @@ -657,7 +657,7 @@ configured by $[0], generated by m4_PACKAGE_STRING. Copyright (C) 2011 Free Software Foundation, Inc. This config.lt script is free software; the Free Software Foundation -gives unlimited permision to copy, distribute and modify it." +gives unlimited permission to copy, distribute and modify it." while test $[#] != 0 do diff --git a/3rdparty/portaudio/bindings/cpp/build/gnu/config.guess b/3rdparty/portaudio/bindings/cpp/build/gnu/config.guess index 297e5c30f41..d5128acaf10 100644 --- a/3rdparty/portaudio/bindings/cpp/build/gnu/config.guess +++ b/3rdparty/portaudio/bindings/cpp/build/gnu/config.guess @@ -129,7 +129,7 @@ UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or - # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, + # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # switched to ELF, *-*-netbsd* would select the old # object file format. This provides both forward diff --git a/3rdparty/portaudio/bindings/cpp/cmake/PortAudioCppConfig.cmake.in b/3rdparty/portaudio/bindings/cpp/cmake/PortAudioCppConfig.cmake.in new file mode 100644 index 00000000000..37540c0431e --- /dev/null +++ b/3rdparty/portaudio/bindings/cpp/cmake/PortAudioCppConfig.cmake.in @@ -0,0 +1,5 @@ +@PACKAGE_INIT@ + +include("${CMAKE_CURRENT_LIST_DIR}/PortAudioCppTargets.cmake") + +check_required_components(PortAudioCpp) diff --git a/3rdparty/portaudio/bindings/cpp/cmake/modules/FindASIO.cmake b/3rdparty/portaudio/bindings/cpp/cmake/modules/FindASIO.cmake new file mode 100644 index 00000000000..4a8d10d0507 --- /dev/null +++ b/3rdparty/portaudio/bindings/cpp/cmake/modules/FindASIO.cmake @@ -0,0 +1,81 @@ +#[=======================================================================[.rst: +FindASIO +-------- + +Finds the ASIO SDK by searching for the SDK ZIP in CMAKE_PREFIX_PATH and +CMAKE_CURRENT_BINARY_DIR. Alternatively, you may manually specify the path of +the SDK ZIP with the ASIO_SDK_ZIP_PATH variable, which can be used for caching +in CI scripts. + +If the ZIP is found, this module extracts it. +The ZIP extraction is skipped if the unzipped SDK is found. + +This module provides an `ASIO::host` IMPORT library target for building host +applications which use ASIO drivers. If you want to build an ASIO driver, this +module may serve as a useful start but you will need to modify it. + +#]=======================================================================] + +if(NOT WIN32) + message(WARNING "ASIO is only supported on Windows.") + set(ASIO_FOUND OFF) + return() +endif() + +file(GLOB HEADER_FILE + "${CMAKE_CURRENT_BINARY_DIR}/asiosdk*/common/asio.h" + "${CMAKE_PREFIX_PATH}/asiosdk*/common/asio.h" + # The old build systems before PortAudio 19.8 used to look for the ASIO SDK + # in the same parent directory as the source code repository. This is no + # longer advised or documented but kept for backwards compatibility. + "${CMAKE_CURRENT_SOURCE_DIR}/../asiosdk*/common/asio.h" +) +if(NOT EXISTS "${HEADER_FILE}") + # The file(ARCHIVE_EXTRACT) command was added in CMake 3.18, so if using an + # older version of CMake, the user needs to extract it themselves. + if(CMAKE_VERSION VERSION_LESS 3.18) + message(STATUS "ASIO SDK NOT found. Download the ASIO SDK ZIP from " + "https://www.steinberg.net/asiosdk and extract it to " + "${CMAKE_PREFIX_PATH} or ${CMAKE_CURRENT_BINARY_DIR}" + ) + return() + endif() + file(GLOB results + "${ASIO_SDK_ZIP_PATH}" + "${CMAKE_CURRENT_BINARY_DIR}/asiosdk*.zip" + "${CMAKE_PREFIX_PATH}/asiosdk*.zip" + "${CMAKE_CURRENT_SOURCE_DIR}/../asiosdk*.zip" + ) + foreach(f ${results}) + if(EXISTS "${f}") + message(STATUS "Extracting ASIO SDK ZIP archive: ${f}") + file(ARCHIVE_EXTRACT INPUT "${f}" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}") + endif() + endforeach() + file(GLOB HEADER_FILE "${CMAKE_CURRENT_BINARY_DIR}/asiosdk*/common/asio.h") +endif() + +get_filename_component(HEADER_DIR "${HEADER_FILE}" DIRECTORY) +get_filename_component(ASIO_ROOT "${HEADER_DIR}" DIRECTORY) + +if(ASIO_ROOT) + set(ASIO_FOUND TRUE) + message(STATUS "Found ASIO SDK: ${ASIO_ROOT}") + + if(ASIO_FOUND AND NOT TARGET ASIO::host) + add_library(ASIO::host INTERFACE IMPORTED) + target_sources(ASIO::host INTERFACE + "${ASIO_ROOT}/common/asio.cpp" + "${ASIO_ROOT}/host/asiodrivers.cpp" + "${ASIO_ROOT}/host/pc/asiolist.cpp" + ) + target_include_directories(ASIO::host INTERFACE + "${ASIO_ROOT}/common" + "${ASIO_ROOT}/host" + "${ASIO_ROOT}/host/pc" + ) + target_link_libraries(ASIO::host INTERFACE ole32 uuid) + endif() +else() + message(STATUS "ASIO SDK NOT found") +endif() diff --git a/3rdparty/portaudio/bindings/cpp/cmake/modules/FindPortAudio.cmake b/3rdparty/portaudio/bindings/cpp/cmake/modules/FindPortAudio.cmake new file mode 100644 index 00000000000..5d58c158bed --- /dev/null +++ b/3rdparty/portaudio/bindings/cpp/cmake/modules/FindPortAudio.cmake @@ -0,0 +1,39 @@ + +macro(handle_default) + +endmacro() + +if(TARGET PortAudio::portaudio) + # nothing to do + return() +endif() +# search for portaudio as cmake module +find_package(PortAudio CONFIG QUIET) +if(PortAudio_FOUND) + if(TARGET PortAudio::portaudio) + return() + elseif(TARGET portaudio) + # vcpkg and old portaudio installations do not provide the same targets + add_library(PortAudio::portaudio ALIAS portaudio) + return() + else() + message(FATAL_ERROR "PortAudio_FOUND but not target PortAudio::portaudio") + endif() +endif() + +# search for portaudio via pkg-config + +message(STATUS "portaudio could not be found via cmake, specify PortAudio_DIR.\n Searching for it via pkg-config") +find_package(PkgConfig REQUIRED) +pkg_check_modules(portaudio REQUIRED QUIET IMPORTED_TARGET GLOBAL portaudio-2.0) +add_library(PortAudio::portaudio ALIAS PkgConfig::portaudio) +return() + +# include(FindPackageHandleStandardArgs) +# find_package_handle_standard_args(Foo +# FOUND_VAR Foo_FOUND +# REQUIRED_VARS +# Foo_LIBRARY +# Foo_INCLUDE_DIR +# VERSION_VAR Foo_VERSION +# ) diff --git a/3rdparty/portaudio/bindings/cpp/cmake/portaudiocpp.pc.in b/3rdparty/portaudio/bindings/cpp/cmake/portaudiocpp.pc.in new file mode 100644 index 00000000000..69333b278d5 --- /dev/null +++ b/3rdparty/portaudio/bindings/cpp/cmake/portaudiocpp.pc.in @@ -0,0 +1,12 @@ +prefix=@PC_PREFIX@ +exec_prefix=${prefix} +libdir=${prefix}/lib +includedir=${prefix}/include + +Name: PortAudioCpp +Description: Portable audio I/O C++ bindings +Version: 12 +Requires: portaudio-2.0 + +Libs: -L${libdir} -lportaudiocpp +Cflags: -I${includedir} diff --git a/3rdparty/portaudio/bindings/cpp/example/devs.cxx b/3rdparty/portaudio/bindings/cpp/example/devs.cxx index 31a560f884e..218042f14c4 100644 --- a/3rdparty/portaudio/bindings/cpp/example/devs.cxx +++ b/3rdparty/portaudio/bindings/cpp/example/devs.cxx @@ -8,44 +8,44 @@ // --------------------------------------------------------------------------------------- void printSupportedStandardSampleRates( - const portaudio::DirectionSpecificStreamParameters &inputParameters, - const portaudio::DirectionSpecificStreamParameters &outputParameters) + const portaudio::DirectionSpecificStreamParameters &inputParameters, + const portaudio::DirectionSpecificStreamParameters &outputParameters) { - static double STANDARD_SAMPLE_RATES[] = { - 8000.0, 9600.0, 11025.0, 12000.0, 16000.0, 22050.0, 24000.0, 32000.0, - 44100.0, 48000.0, 88200.0, 96000.0, -1 }; // negative terminated list - - int printCount = 0; - - for (int i = 0; STANDARD_SAMPLE_RATES[i] > 0; ++i) - { - portaudio::StreamParameters tmp = portaudio::StreamParameters(inputParameters, outputParameters, STANDARD_SAMPLE_RATES[i], 0, paNoFlag); - - if (tmp.isSupported()) - { - if (printCount == 0) - { - std::cout << " " << STANDARD_SAMPLE_RATES[i]; // 8.2 - printCount = 1; - } - else if (printCount == 4) - { - std::cout << "," << std::endl; - std::cout << " " << STANDARD_SAMPLE_RATES[i]; // 8.2 - printCount = 1; - } - else - { - std::cout << ", " << STANDARD_SAMPLE_RATES[i]; // 8.2 - ++printCount; - } - } - } - - if (printCount == 0) - std::cout << "None" << std::endl; - else - std::cout << std::endl; + static double STANDARD_SAMPLE_RATES[] = { + 8000.0, 9600.0, 11025.0, 12000.0, 16000.0, 22050.0, 24000.0, 32000.0, + 44100.0, 48000.0, 88200.0, 96000.0, -1 }; // negative terminated list + + int printCount = 0; + + for (int i = 0; STANDARD_SAMPLE_RATES[i] > 0; ++i) + { + portaudio::StreamParameters tmp = portaudio::StreamParameters(inputParameters, outputParameters, STANDARD_SAMPLE_RATES[i], 0, paNoFlag); + + if (tmp.isSupported()) + { + if (printCount == 0) + { + std::cout << " " << STANDARD_SAMPLE_RATES[i]; // 8.2 + printCount = 1; + } + else if (printCount == 4) + { + std::cout << "," << std::endl; + std::cout << " " << STANDARD_SAMPLE_RATES[i]; // 8.2 + printCount = 1; + } + else + { + std::cout << ", " << STANDARD_SAMPLE_RATES[i]; // 8.2 + ++printCount; + } + } + } + + if (printCount == 0) + std::cout << "None" << std::endl; + else + std::cout << std::endl; } // --------------------------------------------------------------------------------------- @@ -53,125 +53,125 @@ void printSupportedStandardSampleRates( int main(int, char*[]); int main(int, char*[]) { - try - { - portaudio::AutoSystem autoSys; - - portaudio::System &sys = portaudio::System::instance(); - - std::cout << "PortAudio version number = " << sys.version() << std::endl; - std::cout << "PortAudio version text = '" << sys.versionText() << "'" << std::endl; - - int numDevices = sys.deviceCount(); - std::cout << "Number of devices = " << numDevices << std::endl; - - for (portaudio::System::DeviceIterator i = sys.devicesBegin(); i != sys.devicesEnd(); ++i) - { - std::cout << "--------------------------------------- device #" << (*i).index() << std::endl; - - // Mark global and API specific default devices: - bool defaultDisplayed = false; - - if ((*i).isSystemDefaultInputDevice()) - { - std::cout << "[ Default Input"; - defaultDisplayed = true; - } - else if ((*i).isHostApiDefaultInputDevice()) - { - std::cout << "[ Default " << (*i).hostApi().name() << " Input"; - defaultDisplayed = true; - } - - if ((*i).isSystemDefaultOutputDevice()) - { - std::cout << (defaultDisplayed ? "," : "["); - std::cout << " Default Output"; - defaultDisplayed = true; - } - else if ((*i).isHostApiDefaultOutputDevice()) - { - std::cout << (defaultDisplayed ? "," : "["); - std::cout << " Default " << (*i).hostApi().name() << " Output"; - defaultDisplayed = true; - } - - if (defaultDisplayed) - std::cout << " ]" << std::endl; - - // Print device info: - std::cout << "Name = " << (*i).name() << std::endl; - std::cout << "Host API = " << (*i).hostApi().name() << std::endl; - std::cout << "Max inputs = " << (*i).maxInputChannels() << ", Max outputs = " << (*i).maxOutputChannels() << std::endl; - - std::cout << "Default low input latency = " << (*i).defaultLowInputLatency() << std::endl; // 8.3 - std::cout << "Default low output latency = " << (*i).defaultLowOutputLatency() << std::endl; // 8.3 - std::cout << "Default high input latency = " << (*i).defaultHighInputLatency() << std::endl; // 8.3 - std::cout << "Default high output latency = " << (*i).defaultHighOutputLatency() << std::endl; // 8.3 + try + { + portaudio::AutoSystem autoSys; + + portaudio::System &sys = portaudio::System::instance(); + + std::cout << "PortAudio version number = " << sys.version() << std::endl; + std::cout << "PortAudio version text = '" << sys.versionText() << "'" << std::endl; + + int numDevices = sys.deviceCount(); + std::cout << "Number of devices = " << numDevices << std::endl; + + for (portaudio::System::DeviceIterator i = sys.devicesBegin(); i != sys.devicesEnd(); ++i) + { + std::cout << "--------------------------------------- device #" << (*i).index() << std::endl; + + // Mark global and API specific default devices: + bool defaultDisplayed = false; + + if ((*i).isSystemDefaultInputDevice()) + { + std::cout << "[ Default Input"; + defaultDisplayed = true; + } + else if ((*i).isHostApiDefaultInputDevice()) + { + std::cout << "[ Default " << (*i).hostApi().name() << " Input"; + defaultDisplayed = true; + } + + if ((*i).isSystemDefaultOutputDevice()) + { + std::cout << (defaultDisplayed ? "," : "["); + std::cout << " Default Output"; + defaultDisplayed = true; + } + else if ((*i).isHostApiDefaultOutputDevice()) + { + std::cout << (defaultDisplayed ? "," : "["); + std::cout << " Default " << (*i).hostApi().name() << " Output"; + defaultDisplayed = true; + } + + if (defaultDisplayed) + std::cout << " ]" << std::endl; + + // Print device info: + std::cout << "Name = " << (*i).name() << std::endl; + std::cout << "Host API = " << (*i).hostApi().name() << std::endl; + std::cout << "Max inputs = " << (*i).maxInputChannels() << ", Max outputs = " << (*i).maxOutputChannels() << std::endl; + + std::cout << "Default low input latency = " << (*i).defaultLowInputLatency() << std::endl; // 8.3 + std::cout << "Default low output latency = " << (*i).defaultLowOutputLatency() << std::endl; // 8.3 + std::cout << "Default high input latency = " << (*i).defaultHighInputLatency() << std::endl; // 8.3 + std::cout << "Default high output latency = " << (*i).defaultHighOutputLatency() << std::endl; // 8.3 #ifdef WIN32 - // ASIO specific latency information: - if ((*i).hostApi().typeId() == paASIO) - { - portaudio::AsioDeviceAdapter asioDevice((*i)); - - std::cout << "ASIO minimum buffer size = " << asioDevice.minBufferSize() << std::endl; - std::cout << "ASIO maximum buffer size = " << asioDevice.maxBufferSize() << std::endl; - std::cout << "ASIO preferred buffer size = " << asioDevice.preferredBufferSize() << std::endl; - - if (asioDevice.granularity() == -1) - std::cout << "ASIO buffer granularity = power of 2" << std::endl; - else - std::cout << "ASIO buffer granularity = " << asioDevice.granularity() << std::endl; - } + // ASIO specific latency information: + if ((*i).hostApi().typeId() == paASIO) + { + portaudio::AsioDeviceAdapter asioDevice((*i)); + + std::cout << "ASIO minimum buffer size = " << asioDevice.minBufferSize() << std::endl; + std::cout << "ASIO maximum buffer size = " << asioDevice.maxBufferSize() << std::endl; + std::cout << "ASIO preferred buffer size = " << asioDevice.preferredBufferSize() << std::endl; + + if (asioDevice.granularity() == -1) + std::cout << "ASIO buffer granularity = power of 2" << std::endl; + else + std::cout << "ASIO buffer granularity = " << asioDevice.granularity() << std::endl; + } #endif // WIN32 - std::cout << "Default sample rate = " << (*i).defaultSampleRate() << std::endl; // 8.2 - - // Poll for standard sample rates: - portaudio::DirectionSpecificStreamParameters inputParameters((*i), (*i).maxInputChannels(), portaudio::INT16, true, 0.0, NULL); - portaudio::DirectionSpecificStreamParameters outputParameters((*i), (*i).maxOutputChannels(), portaudio::INT16, true, 0.0, NULL); - - if (inputParameters.numChannels() > 0) - { - std::cout << "Supported standard sample rates" << std::endl; - std::cout << " for half-duplex 16 bit " << inputParameters.numChannels() << " channel input = " << std::endl; - printSupportedStandardSampleRates(inputParameters, portaudio::DirectionSpecificStreamParameters::null()); - } - - if (outputParameters.numChannels() > 0) - { - std::cout << "Supported standard sample rates" << std::endl; - std::cout << " for half-duplex 16 bit " << outputParameters.numChannels() << " channel output = " << std::endl; - printSupportedStandardSampleRates(portaudio::DirectionSpecificStreamParameters::null(), outputParameters); - } - - if (inputParameters.numChannels() > 0 && outputParameters.numChannels() > 0) - { - std::cout << "Supported standard sample rates" << std::endl; - std::cout << " for full-duplex 16 bit " << inputParameters.numChannels() << " channel input, " << outputParameters.numChannels() << " channel output = " << std::endl; - printSupportedStandardSampleRates(inputParameters, outputParameters); - } - } - - std::cout << "----------------------------------------------" << std::endl; - } - catch (const portaudio::PaException &e) - { - std::cout << "A PortAudio error occured: " << e.paErrorText() << std::endl; - } - catch (const portaudio::PaCppException &e) - { - std::cout << "A PortAudioCpp error occured: " << e.what() << std::endl; - } - catch (const std::exception &e) - { - std::cout << "A generic exception occured: " << e.what() << std::endl; - } - catch (...) - { - std::cout << "An unknown exception occured." << std::endl; - } - - return 0; + std::cout << "Default sample rate = " << (*i).defaultSampleRate() << std::endl; // 8.2 + + // Poll for standard sample rates: + portaudio::DirectionSpecificStreamParameters inputParameters((*i), (*i).maxInputChannels(), portaudio::INT16, true, 0.0, NULL); + portaudio::DirectionSpecificStreamParameters outputParameters((*i), (*i).maxOutputChannels(), portaudio::INT16, true, 0.0, NULL); + + if (inputParameters.numChannels() > 0) + { + std::cout << "Supported standard sample rates" << std::endl; + std::cout << " for half-duplex 16 bit " << inputParameters.numChannels() << " channel input = " << std::endl; + printSupportedStandardSampleRates(inputParameters, portaudio::DirectionSpecificStreamParameters::null()); + } + + if (outputParameters.numChannels() > 0) + { + std::cout << "Supported standard sample rates" << std::endl; + std::cout << " for half-duplex 16 bit " << outputParameters.numChannels() << " channel output = " << std::endl; + printSupportedStandardSampleRates(portaudio::DirectionSpecificStreamParameters::null(), outputParameters); + } + + if (inputParameters.numChannels() > 0 && outputParameters.numChannels() > 0) + { + std::cout << "Supported standard sample rates" << std::endl; + std::cout << " for full-duplex 16 bit " << inputParameters.numChannels() << " channel input, " << outputParameters.numChannels() << " channel output = " << std::endl; + printSupportedStandardSampleRates(inputParameters, outputParameters); + } + } + + std::cout << "----------------------------------------------" << std::endl; + } + catch (const portaudio::PaException &e) + { + std::cout << "A PortAudio error occurred: " << e.paErrorText() << std::endl; + } + catch (const portaudio::PaCppException &e) + { + std::cout << "A PortAudioCpp error occurred: " << e.what() << std::endl; + } + catch (const std::exception &e) + { + std::cout << "A generic exception occurred: " << e.what() << std::endl; + } + catch (...) + { + std::cout << "An unknown exception occurred." << std::endl; + } + + return 0; } diff --git a/3rdparty/portaudio/bindings/cpp/example/sine.cxx b/3rdparty/portaudio/bindings/cpp/example/sine.cxx index 0676e3e76ca..acd01e613b1 100644 --- a/3rdparty/portaudio/bindings/cpp/example/sine.cxx +++ b/3rdparty/portaudio/bindings/cpp/example/sine.cxx @@ -20,50 +20,50 @@ const int TABLE_SIZE = 200; class SineGenerator { public: - SineGenerator(int tableSize) : tableSize_(tableSize), leftPhase_(0), rightPhase_(0) - { - const double PI = 3.14159265; - table_ = new float[tableSize]; - for (int i = 0; i < tableSize; ++i) - { - table_[i] = 0.125f * (float)sin(((double)i/(double)tableSize)*PI*2.); - } - } - - ~SineGenerator() - { - delete[] table_; - } - - int generate(const void *inputBuffer, void *outputBuffer, unsigned long framesPerBuffer, - const PaStreamCallbackTimeInfo *timeInfo, PaStreamCallbackFlags statusFlags) - { - assert(outputBuffer != NULL); - - float **out = static_cast<float **>(outputBuffer); - - for (unsigned int i = 0; i < framesPerBuffer; ++i) - { - out[0][i] = table_[leftPhase_]; - out[1][i] = table_[rightPhase_]; - - leftPhase_ += 1; - if (leftPhase_ >= tableSize_) - leftPhase_ -= tableSize_; - - rightPhase_ += 3; - if (rightPhase_ >= tableSize_) - rightPhase_ -= tableSize_; - } - - return paContinue; - } + SineGenerator(int tableSize) : tableSize_(tableSize), leftPhase_(0), rightPhase_(0) + { + const double PI = 3.14159265; + table_ = new float[tableSize]; + for (int i = 0; i < tableSize; ++i) + { + table_[i] = 0.125f * (float)sin(((double)i/(double)tableSize)*PI*2.); + } + } + + ~SineGenerator() + { + delete[] table_; + } + + int generate(const void *inputBuffer, void *outputBuffer, unsigned long framesPerBuffer, + const PaStreamCallbackTimeInfo *timeInfo, PaStreamCallbackFlags statusFlags) + { + assert(outputBuffer != NULL); + + float **out = static_cast<float **>(outputBuffer); + + for (unsigned int i = 0; i < framesPerBuffer; ++i) + { + out[0][i] = table_[leftPhase_]; + out[1][i] = table_[rightPhase_]; + + leftPhase_ += 1; + if (leftPhase_ >= tableSize_) + leftPhase_ -= tableSize_; + + rightPhase_ += 3; + if (rightPhase_ >= tableSize_) + rightPhase_ -= tableSize_; + } + + return paContinue; + } private: - float *table_; - int tableSize_; - int leftPhase_; - int rightPhase_; + float *table_; + int tableSize_; + int leftPhase_; + int rightPhase_; }; // --------------------------------------------------------------------------------------- @@ -72,66 +72,64 @@ private: int main(int, char *[]); int main(int, char *[]) { - try - { - // Create a SineGenerator object: - SineGenerator sineGenerator(TABLE_SIZE); - - std::cout << "Setting up PortAudio..." << std::endl; - - // Set up the System: - portaudio::AutoSystem autoSys; - portaudio::System &sys = portaudio::System::instance(); - - // Set up the parameters required to open a (Callback)Stream: - portaudio::DirectionSpecificStreamParameters outParams(sys.defaultOutputDevice(), 2, portaudio::FLOAT32, false, sys.defaultOutputDevice().defaultLowOutputLatency(), NULL); - portaudio::StreamParameters params(portaudio::DirectionSpecificStreamParameters::null(), outParams, SAMPLE_RATE, FRAMES_PER_BUFFER, paClipOff); - - std::cout << "Opening stereo output stream..." << std::endl; - - // Create (and open) a new Stream, using the SineGenerator::generate function as a callback: - portaudio::MemFunCallbackStream<SineGenerator> stream(params, sineGenerator, &SineGenerator::generate); - - std::cout << "Starting playback for " << NUM_SECONDS << " seconds." << std::endl; - - // Start the Stream (audio playback starts): - stream.start(); - - // Wait for 5 seconds: - sys.sleep(NUM_SECONDS * 1000); - - std::cout << "Closing stream..." <<std::endl; - - // Stop the Stream (not strictly needed as termintating the System will also stop all open Streams): - stream.stop(); - - // Close the Stream (not strictly needed as terminating the System will also close all open Streams): - stream.close(); - - // Terminate the System (not strictly needed as the AutoSystem will also take care of this when it - // goes out of scope): - sys.terminate(); - - std::cout << "Test finished." << std::endl; - } - catch (const portaudio::PaException &e) - { - std::cout << "A PortAudio error occured: " << e.paErrorText() << std::endl; - } - catch (const portaudio::PaCppException &e) - { - std::cout << "A PortAudioCpp error occured: " << e.what() << std::endl; - } - catch (const std::exception &e) - { - std::cout << "A generic exception occured: " << e.what() << std::endl; - } - catch (...) - { - std::cout << "An unknown exception occured." << std::endl; - } - - return 0; + try + { + // Create a SineGenerator object: + SineGenerator sineGenerator(TABLE_SIZE); + + std::cout << "Setting up PortAudio..." << std::endl; + + // Set up the System: + portaudio::AutoSystem autoSys; + portaudio::System &sys = portaudio::System::instance(); + + // Set up the parameters required to open a (Callback)Stream: + portaudio::DirectionSpecificStreamParameters outParams(sys.defaultOutputDevice(), 2, portaudio::FLOAT32, false, sys.defaultOutputDevice().defaultLowOutputLatency(), NULL); + portaudio::StreamParameters params(portaudio::DirectionSpecificStreamParameters::null(), outParams, SAMPLE_RATE, FRAMES_PER_BUFFER, paClipOff); + + std::cout << "Opening stereo output stream..." << std::endl; + + // Create (and open) a new Stream, using the SineGenerator::generate function as a callback: + portaudio::MemFunCallbackStream<SineGenerator> stream(params, sineGenerator, &SineGenerator::generate); + + std::cout << "Starting playback for " << NUM_SECONDS << " seconds." << std::endl; + + // Start the Stream (audio playback starts): + stream.start(); + + // Wait for 5 seconds: + sys.sleep(NUM_SECONDS * 1000); + + std::cout << "Closing stream..." <<std::endl; + + // Stop the Stream (not strictly needed as termintating the System will also stop all open Streams): + stream.stop(); + + // Close the Stream (not strictly needed as terminating the System will also close all open Streams): + stream.close(); + + // Terminate the System (not strictly needed as the AutoSystem will also take care of this when it + // goes out of scope): + sys.terminate(); + + std::cout << "Test finished." << std::endl; + } + catch (const portaudio::PaException &e) + { + std::cout << "A PortAudio error occurred: " << e.paErrorText() << std::endl; + } + catch (const portaudio::PaCppException &e) + { + std::cout << "A PortAudioCpp error occurred: " << e.what() << std::endl; + } + catch (const std::exception &e) + { + std::cout << "A generic exception occurred: " << e.what() << std::endl; + } + catch (...) + { + std::cout << "An unknown exception occurred." << std::endl; + } + + return 0; } - - diff --git a/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/AsioDeviceAdapter.hxx b/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/AsioDeviceAdapter.hxx index 26957c4f35b..ba40481ae9d 100644 --- a/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/AsioDeviceAdapter.hxx +++ b/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/AsioDeviceAdapter.hxx @@ -4,41 +4,41 @@ namespace portaudio { - // Forward declaration(s): - class Device; - - // Declaration(s): - ////// - /// @brief Adapts the given Device to an ASIO specific extension. - /// - /// Deleting the AsioDeviceAdapter does not affect the underlaying - /// Device. - ////// - class AsioDeviceAdapter - { - public: - AsioDeviceAdapter(Device &device); - - Device &device(); - - long minBufferSize() const; - long maxBufferSize() const; - long preferredBufferSize() const; - long granularity() const; - - void showControlPanel(void *systemSpecific); - - const char *inputChannelName(int channelIndex) const; - const char *outputChannelName(int channelIndex) const; - - private: - Device *device_; - - long minBufferSize_; - long maxBufferSize_; - long preferredBufferSize_; - long granularity_; - }; + // Forward declaration(s): + class Device; + + // Declaration(s): + ////// + /// @brief Adapts the given Device to an ASIO specific extension. + /// + /// Deleting the AsioDeviceAdapter does not affect the underlying + /// Device. + ////// + class AsioDeviceAdapter + { + public: + AsioDeviceAdapter(Device &device); + + Device &device(); + + long minBufferSize() const; + long maxBufferSize() const; + long preferredBufferSize() const; + long granularity() const; + + void showControlPanel(void *systemSpecific); + + const char *inputChannelName(int channelIndex) const; + const char *outputChannelName(int channelIndex) const; + + private: + Device *device_; + + long minBufferSize_; + long maxBufferSize_; + long preferredBufferSize_; + long granularity_; + }; } #endif // INCLUDED_PORTAUDIO_ASIODEVICEADAPTER_HXX diff --git a/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/AutoSystem.hxx b/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/AutoSystem.hxx index 47e2ec1d53b..be4da1a06ff 100644 --- a/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/AutoSystem.hxx +++ b/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/AutoSystem.hxx @@ -11,48 +11,48 @@ namespace portaudio { - ////// - /// @brief A RAII idiom class to ensure automatic clean-up when an exception is - /// raised. - /// - /// A simple helper class which uses the 'Resource Acquisition is Initialization' - /// idiom (RAII). Use this class to initialize/terminate the System rather than - /// using System directly. AutoSystem must be created on stack and must be valid - /// throughout the time you wish to use PortAudioCpp. Your 'main' function might be - /// a good place for it. - /// - /// To avoid having to type portaudio::System::instance().xyz() all the time, it's usually - /// a good idea to make a reference to the System which can be accessed directly. - /// @verbatim - /// portaudio::AutoSys autoSys; - /// portaudio::System &sys = portaudio::System::instance(); - /// @endverbatim - ////// - class AutoSystem - { - public: - AutoSystem(bool initialize = true) - { - if (initialize) - System::initialize(); - } - - ~AutoSystem() - { - if (System::exists()) - System::terminate(); - } - - void initialize() - { - System::initialize(); - } - - void terminate() - { - System::terminate(); - } - }; + ////// + /// @brief A RAII idiom class to ensure automatic clean-up when an exception is + /// raised. + /// + /// A simple helper class which uses the 'Resource Acquisition is Initialization' + /// idiom (RAII). Use this class to initialize/terminate the System rather than + /// using System directly. AutoSystem must be created on stack and must be valid + /// throughout the time you wish to use PortAudioCpp. Your 'main' function might be + /// a good place for it. + /// + /// To avoid having to type portaudio::System::instance().xyz() all the time, it's usually + /// a good idea to make a reference to the System which can be accessed directly. + /// @verbatim + /// portaudio::AutoSys autoSys; + /// portaudio::System &sys = portaudio::System::instance(); + /// @endverbatim + ////// + class AutoSystem + { + public: + AutoSystem(bool initialize = true) + { + if (initialize) + System::initialize(); + } + + ~AutoSystem() + { + if (System::exists()) + System::terminate(); + } + + void initialize() + { + System::initialize(); + } + + void terminate() + { + System::terminate(); + } + }; } // namespace portaudio diff --git a/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/BlockingStream.hxx b/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/BlockingStream.hxx index 158dfa08ded..c1bcac7d9ce 100644 --- a/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/BlockingStream.hxx +++ b/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/BlockingStream.hxx @@ -12,28 +12,28 @@ namespace portaudio - ////// - /// @brief Stream class for blocking read/write-style input and output. - ////// - class BlockingStream : public Stream - { - public: - BlockingStream(); - BlockingStream(const StreamParameters ¶meters); - ~BlockingStream(); + ////// + /// @brief Stream class for blocking read/write-style input and output. + ////// + class BlockingStream : public Stream + { + public: + BlockingStream(); + BlockingStream(const StreamParameters ¶meters); + ~BlockingStream(); - void open(const StreamParameters ¶meters); + void open(const StreamParameters ¶meters); - void read(void *buffer, unsigned long numFrames); - void write(const void *buffer, unsigned long numFrames); + void read(void *buffer, unsigned long numFrames); + void write(const void *buffer, unsigned long numFrames); - signed long availableReadSize() const; - signed long availableWriteSize() const; + signed long availableReadSize() const; + signed long availableWriteSize() const; - private: - BlockingStream(const BlockingStream &); // non-copyable - BlockingStream &operator=(const BlockingStream &); // non-copyable - }; + private: + BlockingStream(const BlockingStream &); // non-copyable + BlockingStream &operator=(const BlockingStream &); // non-copyable + }; @@ -42,4 +42,3 @@ namespace portaudio // --------------------------------------------------------------------------------------- #endif // INCLUDED_PORTAUDIO_BLOCKINGSTREAM_HXX - diff --git a/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/CFunCallbackStream.hxx b/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/CFunCallbackStream.hxx index 1c7faa8684f..d66996c9e7e 100644 --- a/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/CFunCallbackStream.hxx +++ b/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/CFunCallbackStream.hxx @@ -12,7 +12,7 @@ // Forward declaration(s) namespace portaudio { - class StreamParameters; + class StreamParameters; } // --------------------------------------------------------------------------------------- @@ -20,30 +20,29 @@ namespace portaudio // Declaration(s): namespace portaudio { - // ----------------------------------------------------------------------------------- - - ////// - /// @brief Callback stream using a free function with C linkage. It's important that the function - /// the passed function pointer points to is declared ``extern "C"''. - ////// - class CFunCallbackStream : public CallbackStream - { - public: - CFunCallbackStream(); - CFunCallbackStream(const StreamParameters ¶meters, PaStreamCallback *funPtr, void *userData); - ~CFunCallbackStream(); - - void open(const StreamParameters ¶meters, PaStreamCallback *funPtr, void *userData); - - private: - CFunCallbackStream(const CFunCallbackStream &); // non-copyable - CFunCallbackStream &operator=(const CFunCallbackStream &); // non-copyable - }; - - // ----------------------------------------------------------------------------------- + // ----------------------------------------------------------------------------------- + + ////// + /// @brief Callback stream using a free function with C linkage. It's important that the function + /// the passed function pointer points to is declared ``extern "C"''. + ////// + class CFunCallbackStream : public CallbackStream + { + public: + CFunCallbackStream(); + CFunCallbackStream(const StreamParameters ¶meters, PaStreamCallback *funPtr, void *userData); + ~CFunCallbackStream(); + + void open(const StreamParameters ¶meters, PaStreamCallback *funPtr, void *userData); + + private: + CFunCallbackStream(const CFunCallbackStream &); // non-copyable + CFunCallbackStream &operator=(const CFunCallbackStream &); // non-copyable + }; + + // ----------------------------------------------------------------------------------- } // portaudio // --------------------------------------------------------------------------------------- #endif // INCLUDED_PORTAUDIO_MEMFUNCALLBACKSTREAM_HXX - diff --git a/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/CallbackInterface.hxx b/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/CallbackInterface.hxx index b30614899da..9cf3fad51b9 100644 --- a/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/CallbackInterface.hxx +++ b/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/CallbackInterface.hxx @@ -9,34 +9,34 @@ namespace portaudio { - // ----------------------------------------------------------------------------------- - - ////// - /// @brief Interface for an object that's callable as a PortAudioCpp callback object (ie that implements the - /// paCallbackFun method). - ////// - class CallbackInterface - { - public: - virtual ~CallbackInterface() {} - - virtual int paCallbackFun(const void *inputBuffer, void *outputBuffer, unsigned long numFrames, - const PaStreamCallbackTimeInfo *timeInfo, PaStreamCallbackFlags statusFlags) = 0; - }; - - // ----------------------------------------------------------------------------------- - - namespace impl - { - extern "C" - { - int callbackInterfaceToPaCallbackAdapter(const void *inputBuffer, void *outputBuffer, unsigned long numFrames, - const PaStreamCallbackTimeInfo *timeInfo, PaStreamCallbackFlags statusFlags, - void *userData); - } // extern "C" - } - - // ----------------------------------------------------------------------------------- + // ----------------------------------------------------------------------------------- + + ////// + /// @brief Interface for an object that's callable as a PortAudioCpp callback object (ie that implements the + /// paCallbackFun method). + ////// + class CallbackInterface + { + public: + virtual ~CallbackInterface() {} + + virtual int paCallbackFun(const void *inputBuffer, void *outputBuffer, unsigned long numFrames, + const PaStreamCallbackTimeInfo *timeInfo, PaStreamCallbackFlags statusFlags) = 0; + }; + + // ----------------------------------------------------------------------------------- + + namespace impl + { + extern "C" + { + int callbackInterfaceToPaCallbackAdapter(const void *inputBuffer, void *outputBuffer, unsigned long numFrames, + const PaStreamCallbackTimeInfo *timeInfo, PaStreamCallbackFlags statusFlags, + void *userData); + } // extern "C" + } + + // ----------------------------------------------------------------------------------- } // namespace portaudio diff --git a/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/CallbackStream.hxx b/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/CallbackStream.hxx index 7268b14d3a8..bb8f3810c24 100644 --- a/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/CallbackStream.hxx +++ b/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/CallbackStream.hxx @@ -14,23 +14,23 @@ namespace portaudio { - ////// - /// @brief Base class for all Streams which use a callback-based mechanism. - ////// - class CallbackStream : public Stream - { - protected: - CallbackStream(); - virtual ~CallbackStream(); - - public: - // stream info (time-varying) - double cpuLoad() const; - - private: - CallbackStream(const CallbackStream &); // non-copyable - CallbackStream &operator=(const CallbackStream &); // non-copyable - }; + ////// + /// @brief Base class for all Streams which use a callback-based mechanism. + ////// + class CallbackStream : public Stream + { + protected: + CallbackStream(); + virtual ~CallbackStream(); + + public: + // stream info (time-varying) + double cpuLoad() const; + + private: + CallbackStream(const CallbackStream &); // non-copyable + CallbackStream &operator=(const CallbackStream &); // non-copyable + }; } // namespace portaudio diff --git a/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/CppFunCallbackStream.hxx b/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/CppFunCallbackStream.hxx index 3f219eef87f..c43b64316d1 100644 --- a/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/CppFunCallbackStream.hxx +++ b/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/CppFunCallbackStream.hxx @@ -12,7 +12,7 @@ // Forward declaration(s): namespace portaudio { - class StreamParameters; + class StreamParameters; } // --------------------------------------------------------------------------------------- @@ -22,61 +22,61 @@ namespace portaudio { - namespace impl - { - extern "C" - { - int cppCallbackToPaCallbackAdapter(const void *inputBuffer, void *outputBuffer, unsigned long numFrames, - const PaStreamCallbackTimeInfo *timeInfo, PaStreamCallbackFlags statusFlags, - void *userData); - } // extern "C" - } - - // ----------------------------------------------------------------------------------- - - ////// - /// @brief Callback stream using a C++ function (either a free function or a static function) - /// callback. - ////// - class FunCallbackStream : public CallbackStream - { - public: - typedef int (*CallbackFunPtr)(const void *inputBuffer, void *outputBuffer, unsigned long numFrames, - const PaStreamCallbackTimeInfo *timeInfo, PaStreamCallbackFlags statusFlags, - void *userData); - - // ------------------------------------------------------------------------------- - - ////// - /// @brief Simple structure containing a function pointer to the C++ callback function and a - /// (void) pointer to the user supplied data. - ////// - struct CppToCCallbackData - { - CppToCCallbackData(); - CppToCCallbackData(CallbackFunPtr funPtr, void *userData); - void init(CallbackFunPtr funPtr, void *userData); - - CallbackFunPtr funPtr; - void *userData; - }; - - // ------------------------------------------------------------------------------- - - FunCallbackStream(); - FunCallbackStream(const StreamParameters ¶meters, CallbackFunPtr funPtr, void *userData); - ~FunCallbackStream(); - - void open(const StreamParameters ¶meters, CallbackFunPtr funPtr, void *userData); - - private: - FunCallbackStream(const FunCallbackStream &); // non-copyable - FunCallbackStream &operator=(const FunCallbackStream &); // non-copyable - - CppToCCallbackData adapterData_; - - void open(const StreamParameters ¶meters); - }; + namespace impl + { + extern "C" + { + int cppCallbackToPaCallbackAdapter(const void *inputBuffer, void *outputBuffer, unsigned long numFrames, + const PaStreamCallbackTimeInfo *timeInfo, PaStreamCallbackFlags statusFlags, + void *userData); + } // extern "C" + } + + // ----------------------------------------------------------------------------------- + + ////// + /// @brief Callback stream using a C++ function (either a free function or a static function) + /// callback. + ////// + class FunCallbackStream : public CallbackStream + { + public: + typedef int (*CallbackFunPtr)(const void *inputBuffer, void *outputBuffer, unsigned long numFrames, + const PaStreamCallbackTimeInfo *timeInfo, PaStreamCallbackFlags statusFlags, + void *userData); + + // ------------------------------------------------------------------------------- + + ////// + /// @brief Simple structure containing a function pointer to the C++ callback function and a + /// (void) pointer to the user supplied data. + ////// + struct CppToCCallbackData + { + CppToCCallbackData(); + CppToCCallbackData(CallbackFunPtr funPtr, void *userData); + void init(CallbackFunPtr funPtr, void *userData); + + CallbackFunPtr funPtr; + void *userData; + }; + + // ------------------------------------------------------------------------------- + + FunCallbackStream(); + FunCallbackStream(const StreamParameters ¶meters, CallbackFunPtr funPtr, void *userData); + ~FunCallbackStream(); + + void open(const StreamParameters ¶meters, CallbackFunPtr funPtr, void *userData); + + private: + FunCallbackStream(const FunCallbackStream &); // non-copyable + FunCallbackStream &operator=(const FunCallbackStream &); // non-copyable + + CppToCCallbackData adapterData_; + + void open(const StreamParameters ¶meters); + }; } // portaudio diff --git a/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/Device.hxx b/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/Device.hxx index 3c6c3c0c74f..2b21361beeb 100644 --- a/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/Device.hxx +++ b/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/Device.hxx @@ -14,8 +14,8 @@ // Forward declaration(s): namespace portaudio { - class System; - class HostApi; + class System; + class HostApi; } // --------------------------------------------------------------------------------------- @@ -24,68 +24,67 @@ namespace portaudio namespace portaudio { - ////// - /// @brief Class which represents a PortAudio device in the System. - /// - /// A single physical device in the system may have multiple PortAudio - /// Device representations using different HostApi 's though. A Device - /// can be half-duplex or full-duplex. A half-duplex Device can be used - /// to create a half-duplex Stream. A full-duplex Device can be used to - /// create a full-duplex Stream. If supported by the HostApi, two - /// half-duplex Devices can even be used to create a full-duplex Stream. - /// - /// Note that Device objects are very light-weight and can be passed around - /// by-value. - ////// - class Device - { - public: - // query info: name, max in channels, max out channels, - // default low/hight input/output latency, default sample rate - PaDeviceIndex index() const; - const char *name() const; - int maxInputChannels() const; - int maxOutputChannels() const; - PaTime defaultLowInputLatency() const; - PaTime defaultHighInputLatency() const; - PaTime defaultLowOutputLatency() const; - PaTime defaultHighOutputLatency() const; - double defaultSampleRate() const; - - bool isInputOnlyDevice() const; // extended - bool isOutputOnlyDevice() const; // extended - bool isFullDuplexDevice() const; // extended - bool isSystemDefaultInputDevice() const; // extended - bool isSystemDefaultOutputDevice() const; // extended - bool isHostApiDefaultInputDevice() const; // extended - bool isHostApiDefaultOutputDevice() const; // extended - - bool operator==(const Device &rhs) const; - bool operator!=(const Device &rhs) const; - - // host api reference - HostApi &hostApi(); - const HostApi &hostApi() const; - - private: - PaDeviceIndex index_; - const PaDeviceInfo *info_; - - private: - friend class System; - - explicit Device(PaDeviceIndex index); - ~Device(); - - Device(const Device &); // non-copyable - Device &operator=(const Device &); // non-copyable - }; - - // ----------------------------------------------------------------------------------- + ////// + /// @brief Class which represents a PortAudio device in the System. + /// + /// A single physical device in the system may have multiple PortAudio + /// Device representations using different HostApi 's though. A Device + /// can be half-duplex or full-duplex. A half-duplex Device can be used + /// to create a half-duplex Stream. A full-duplex Device can be used to + /// create a full-duplex Stream. If supported by the HostApi, two + /// half-duplex Devices can even be used to create a full-duplex Stream. + /// + /// Note that Device objects are very light-weight and can be passed around + /// by-value. + ////// + class Device + { + public: + // query info: name, max in channels, max out channels, + // default low/high input/output latency, default sample rate + PaDeviceIndex index() const; + const char *name() const; + int maxInputChannels() const; + int maxOutputChannels() const; + PaTime defaultLowInputLatency() const; + PaTime defaultHighInputLatency() const; + PaTime defaultLowOutputLatency() const; + PaTime defaultHighOutputLatency() const; + double defaultSampleRate() const; + + bool isInputOnlyDevice() const; // extended + bool isOutputOnlyDevice() const; // extended + bool isFullDuplexDevice() const; // extended + bool isSystemDefaultInputDevice() const; // extended + bool isSystemDefaultOutputDevice() const; // extended + bool isHostApiDefaultInputDevice() const; // extended + bool isHostApiDefaultOutputDevice() const; // extended + + bool operator==(const Device &rhs) const; + bool operator!=(const Device &rhs) const; + + // host api reference + HostApi &hostApi(); + const HostApi &hostApi() const; + + private: + PaDeviceIndex index_; + const PaDeviceInfo *info_; + + private: + friend class System; + + explicit Device(PaDeviceIndex index); + ~Device(); + + Device(const Device &); // non-copyable + Device &operator=(const Device &); // non-copyable + }; + + // ----------------------------------------------------------------------------------- } // namespace portaudio // --------------------------------------------------------------------------------------- #endif // INCLUDED_PORTAUDIO_DEVICE_HXX - diff --git a/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/DirectionSpecificStreamParameters.hxx b/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/DirectionSpecificStreamParameters.hxx index bc2474269e1..d09a7c58544 100644 --- a/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/DirectionSpecificStreamParameters.hxx +++ b/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/DirectionSpecificStreamParameters.hxx @@ -15,7 +15,7 @@ // Forward declaration(s): namespace portaudio { - class Device; + class Device; } // --------------------------------------------------------------------------------------- @@ -24,50 +24,50 @@ namespace portaudio namespace portaudio { - ////// - /// @brief All parameters for one direction (either in or out) of a Stream. Together with - /// parameters common to both directions, two DirectionSpecificStreamParameters can make up - /// a StreamParameters object which contains all parameters for a Stream. - ////// - class DirectionSpecificStreamParameters - { - public: - static DirectionSpecificStreamParameters null(); + ////// + /// @brief All parameters for one direction (either in or out) of a Stream. Together with + /// parameters common to both directions, two DirectionSpecificStreamParameters can make up + /// a StreamParameters object which contains all parameters for a Stream. + ////// + class DirectionSpecificStreamParameters + { + public: + static DirectionSpecificStreamParameters null(); - DirectionSpecificStreamParameters(); - DirectionSpecificStreamParameters(const Device &device, int numChannels, SampleDataFormat format, - bool interleaved, PaTime suggestedLatency, void *hostApiSpecificStreamInfo); + DirectionSpecificStreamParameters(); + DirectionSpecificStreamParameters(const Device &device, int numChannels, SampleDataFormat format, + bool interleaved, PaTime suggestedLatency, void *hostApiSpecificStreamInfo); - // Set up methods: - void setDevice(const Device &device); - void setNumChannels(int numChannels); + // Set up methods: + void setDevice(const Device &device); + void setNumChannels(int numChannels); - void setSampleFormat(SampleDataFormat format, bool interleaved = true); - void setHostApiSpecificSampleFormat(PaSampleFormat format, bool interleaved = true); + void setSampleFormat(SampleDataFormat format, bool interleaved = true); + void setHostApiSpecificSampleFormat(PaSampleFormat format, bool interleaved = true); - void setSuggestedLatency(PaTime latency); + void setSuggestedLatency(PaTime latency); - void setHostApiSpecificStreamInfo(void *streamInfo); + void setHostApiSpecificStreamInfo(void *streamInfo); - // Accessor methods: - PaStreamParameters *paStreamParameters(); - const PaStreamParameters *paStreamParameters() const; + // Accessor methods: + PaStreamParameters *paStreamParameters(); + const PaStreamParameters *paStreamParameters() const; - Device &device() const; - int numChannels() const; + Device &device() const; + int numChannels() const; - SampleDataFormat sampleFormat() const; - bool isSampleFormatInterleaved() const; - bool isSampleFormatHostApiSpecific() const; - PaSampleFormat hostApiSpecificSampleFormat() const; + SampleDataFormat sampleFormat() const; + bool isSampleFormatInterleaved() const; + bool isSampleFormatHostApiSpecific() const; + PaSampleFormat hostApiSpecificSampleFormat() const; - PaTime suggestedLatency() const; + PaTime suggestedLatency() const; - void *hostApiSpecificStreamInfo() const; - - private: - PaStreamParameters paStreamParameters_; - }; + void *hostApiSpecificStreamInfo() const; + + private: + PaStreamParameters paStreamParameters_; + }; } // namespace portaudio diff --git a/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/Exception.hxx b/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/Exception.hxx index f5249c97942..908de4cc1f0 100644 --- a/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/Exception.hxx +++ b/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/Exception.hxx @@ -12,92 +12,92 @@ namespace portaudio { - ////// - /// @brief Base class for all exceptions PortAudioCpp can throw. - /// - /// Class is derived from std::exception. - ////// - class Exception : public std::exception - { - public: - virtual ~Exception() throw() {} - - virtual const char *what() const throw() = 0; - }; - - // ----------------------------------------------------------------------------------- - - ////// - /// @brief Wrapper for PortAudio error codes to C++ exceptions. - /// - /// It wraps up PortAudio's error handling mechanism using - /// C++ exceptions and is derived from std::exception for - /// easy exception handling and to ease integration with - /// other code. - /// - /// To know what exceptions each function may throw, look up - /// the errors that can occure in the PortAudio documentation - /// for the equivalent functions. - /// - /// Some functions are likely to throw an exception (such as - /// Stream::open(), etc) and these should always be called in - /// try{} catch{} blocks and the thrown exceptions should be - /// handled properly (ie. the application shouldn't just abort, - /// but merely display a warning dialog to the user or something). - /// However nearly all functions in PortAudioCpp are capable - /// of throwing exceptions. When a function like Stream::isStopped() - /// throws an exception, it's such an exceptional state that it's - /// not likely that it can be recovered. PaExceptions such as these - /// can ``safely'' be left to be handled by some outer catch-all-like - /// mechanism for unrecoverable errors. - ////// - class PaException : public Exception - { - public: - explicit PaException(PaError error); - - const char *what() const throw(); - - PaError paError() const; - const char *paErrorText() const; - - bool isHostApiError() const; // extended - long lastHostApiError() const; - const char *lastHostApiErrorText() const; - - bool operator==(const PaException &rhs) const; - bool operator!=(const PaException &rhs) const; - - private: - PaError error_; - }; - - // ----------------------------------------------------------------------------------- - - ////// - /// @brief Exceptions specific to PortAudioCpp (ie. exceptions which do not have an - /// equivalent PortAudio error code). - ////// - class PaCppException : public Exception - { - public: - enum ExceptionSpecifier - { - UNABLE_TO_ADAPT_DEVICE - }; - - PaCppException(ExceptionSpecifier specifier); - - const char *what() const throw(); - - ExceptionSpecifier specifier() const; - - bool operator==(const PaCppException &rhs) const; - bool operator!=(const PaCppException &rhs) const; - - private: - ExceptionSpecifier specifier_; - }; + ////// + /// @brief Base class for all exceptions PortAudioCpp can throw. + /// + /// Class is derived from std::exception. + ////// + class Exception : public std::exception + { + public: + virtual ~Exception() throw() {} + + virtual const char *what() const throw() = 0; + }; + + // ----------------------------------------------------------------------------------- + + ////// + /// @brief Wrapper for PortAudio error codes to C++ exceptions. + /// + /// It wraps up PortAudio's error handling mechanism using + /// C++ exceptions and is derived from std::exception for + /// easy exception handling and to ease integration with + /// other code. + /// + /// To know what exceptions each function may throw, look up + /// the errors that can occur in the PortAudio documentation + /// for the equivalent functions. + /// + /// Some functions are likely to throw an exception (such as + /// Stream::open(), etc) and these should always be called in + /// try{} catch{} blocks and the thrown exceptions should be + /// handled properly (ie. the application shouldn't just abort, + /// but merely display a warning dialog to the user or something). + /// However nearly all functions in PortAudioCpp are capable + /// of throwing exceptions. When a function like Stream::isStopped() + /// throws an exception, it's such an exceptional state that it's + /// not likely that it can be recovered. PaExceptions such as these + /// can ``safely'' be left to be handled by some outer catch-all-like + /// mechanism for unrecoverable errors. + ////// + class PaException : public Exception + { + public: + explicit PaException(PaError error); + + const char *what() const throw(); + + PaError paError() const; + const char *paErrorText() const; + + bool isHostApiError() const; // extended + long lastHostApiError() const; + const char *lastHostApiErrorText() const; + + bool operator==(const PaException &rhs) const; + bool operator!=(const PaException &rhs) const; + + private: + PaError error_; + }; + + // ----------------------------------------------------------------------------------- + + ////// + /// @brief Exceptions specific to PortAudioCpp (ie. exceptions which do not have an + /// equivalent PortAudio error code). + ////// + class PaCppException : public Exception + { + public: + enum ExceptionSpecifier + { + UNABLE_TO_ADAPT_DEVICE + }; + + PaCppException(ExceptionSpecifier specifier); + + const char *what() const throw(); + + ExceptionSpecifier specifier() const; + + bool operator==(const PaCppException &rhs) const; + bool operator!=(const PaCppException &rhs) const; + + private: + ExceptionSpecifier specifier_; + }; } // namespace portaudio @@ -105,4 +105,3 @@ namespace portaudio // --------------------------------------------------------------------------------------- #endif // INCLUDED_PORTAUDIO_EXCEPTION_HXX - diff --git a/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/HostApi.hxx b/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/HostApi.hxx index ce397ca6c75..5020793b9a2 100644 --- a/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/HostApi.hxx +++ b/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/HostApi.hxx @@ -12,7 +12,7 @@ // Forward declaration(s): namespace portaudio { - class Device; + class Device; } // --------------------------------------------------------------------------------------- @@ -22,50 +22,50 @@ namespace portaudio { - ////// - /// @brief HostApi represents a host API (usually type of driver) in the System. - /// - /// A single System can support multiple HostApi's each one typically having - /// a set of Devices using that HostApi (usually driver type). All Devices in - /// the HostApi can be enumerated and the default input/output Device for this - /// HostApi can be retreived. - ////// - class HostApi - { - public: - typedef System::DeviceIterator DeviceIterator; + ////// + /// @brief HostApi represents a host API (usually type of driver) in the System. + /// + /// A single System can support multiple HostApi's each one typically having + /// a set of Devices using that HostApi (usually driver type). All Devices in + /// the HostApi can be enumerated and the default input/output Device for this + /// HostApi can be retrieved. + ////// + class HostApi + { + public: + typedef System::DeviceIterator DeviceIterator; - // query info: id, name, numDevices - PaHostApiTypeId typeId() const; - PaHostApiIndex index() const; - const char *name() const; - int deviceCount() const; + // query info: id, name, numDevices + PaHostApiTypeId typeId() const; + PaHostApiIndex index() const; + const char *name() const; + int deviceCount() const; - // iterate devices - DeviceIterator devicesBegin(); - DeviceIterator devicesEnd(); + // iterate devices + DeviceIterator devicesBegin(); + DeviceIterator devicesEnd(); - // default devices - Device &defaultInputDevice() const; - Device &defaultOutputDevice() const; + // default devices + Device &defaultInputDevice() const; + Device &defaultOutputDevice() const; - // comparison operators - bool operator==(const HostApi &rhs) const; - bool operator!=(const HostApi &rhs) const; + // comparison operators + bool operator==(const HostApi &rhs) const; + bool operator!=(const HostApi &rhs) const; - private: - const PaHostApiInfo *info_; - Device **devices_; + private: + const PaHostApiInfo *info_; + Device **devices_; - private: - friend class System; + private: + friend class System; - explicit HostApi(PaHostApiIndex index); - ~HostApi(); + explicit HostApi(PaHostApiIndex index); + ~HostApi(); - HostApi(const HostApi &); // non-copyable - HostApi &operator=(const HostApi &); // non-copyable - }; + HostApi(const HostApi &); // non-copyable + HostApi &operator=(const HostApi &); // non-copyable + }; } @@ -73,4 +73,3 @@ namespace portaudio // --------------------------------------------------------------------------------------- #endif // INCLUDED_PORTAUDIO_HOSTAPI_HXX - diff --git a/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/InterfaceCallbackStream.hxx b/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/InterfaceCallbackStream.hxx index 5aa49e741cf..63ebf40b596 100644 --- a/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/InterfaceCallbackStream.hxx +++ b/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/InterfaceCallbackStream.hxx @@ -12,8 +12,8 @@ // Forward declaration(s) namespace portaudio { - class StreamParameters; - class CallbackInterface; + class StreamParameters; + class CallbackInterface; } // --------------------------------------------------------------------------------------- @@ -23,23 +23,23 @@ namespace portaudio { - ////// - /// @brief Callback stream using an instance of an object that's derived from the CallbackInterface - /// interface. - ////// - class InterfaceCallbackStream : public CallbackStream - { - public: - InterfaceCallbackStream(); - InterfaceCallbackStream(const StreamParameters ¶meters, CallbackInterface &instance); - ~InterfaceCallbackStream(); - - void open(const StreamParameters ¶meters, CallbackInterface &instance); - - private: - InterfaceCallbackStream(const InterfaceCallbackStream &); // non-copyable - InterfaceCallbackStream &operator=(const InterfaceCallbackStream &); // non-copyable - }; + ////// + /// @brief Callback stream using an instance of an object that's derived from the CallbackInterface + /// interface. + ////// + class InterfaceCallbackStream : public CallbackStream + { + public: + InterfaceCallbackStream(); + InterfaceCallbackStream(const StreamParameters ¶meters, CallbackInterface &instance); + ~InterfaceCallbackStream(); + + void open(const StreamParameters ¶meters, CallbackInterface &instance); + + private: + InterfaceCallbackStream(const InterfaceCallbackStream &); // non-copyable + InterfaceCallbackStream &operator=(const InterfaceCallbackStream &); // non-copyable + }; } // portaudio diff --git a/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/MemFunCallbackStream.hxx b/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/MemFunCallbackStream.hxx index 01cf37b2016..7ef1d4a3c36 100644 --- a/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/MemFunCallbackStream.hxx +++ b/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/MemFunCallbackStream.hxx @@ -17,87 +17,87 @@ namespace portaudio { - ////// - /// @brief Callback stream using a class's member function as a callback. Template argument T is the type of the - /// class of which a member function is going to be used. - /// - /// Example usage: - /// @verbatim MemFunCallback<MyClass> stream = MemFunCallbackStream(parameters, *this, &MyClass::myCallbackFunction); @endverbatim - ////// - template<typename T> - class MemFunCallbackStream : public CallbackStream - { - public: - typedef int (T::*CallbackFunPtr)(const void *, void *, unsigned long, const PaStreamCallbackTimeInfo *, - PaStreamCallbackFlags); - - // ------------------------------------------------------------------------------- - - MemFunCallbackStream() - { - } - - MemFunCallbackStream(const StreamParameters ¶meters, T &instance, CallbackFunPtr memFun) : adapter_(instance, memFun) - { - open(parameters); - } - - ~MemFunCallbackStream() - { - close(); - } - - void open(const StreamParameters ¶meters, T &instance, CallbackFunPtr memFun) - { - // XXX: need to check if already open? - - adapter_.init(instance, memFun); - open(parameters); - } - - private: - MemFunCallbackStream(const MemFunCallbackStream &); // non-copyable - MemFunCallbackStream &operator=(const MemFunCallbackStream &); // non-copyable - - ////// - /// @brief Inner class which adapts a member function callback to a CallbackInterface compliant - /// class (so it can be adapted using the paCallbackAdapter function). - ////// - class MemFunToCallbackInterfaceAdapter : public CallbackInterface - { - public: - MemFunToCallbackInterfaceAdapter() {} - MemFunToCallbackInterfaceAdapter(T &instance, CallbackFunPtr memFun) : instance_(&instance), memFun_(memFun) {} - - void init(T &instance, CallbackFunPtr memFun) - { - instance_ = &instance; - memFun_ = memFun; - } - - int paCallbackFun(const void *inputBuffer, void *outputBuffer, unsigned long numFrames, - const PaStreamCallbackTimeInfo *timeInfo, PaStreamCallbackFlags statusFlags) - { - return (instance_->*memFun_)(inputBuffer, outputBuffer, numFrames, timeInfo, statusFlags); - } - - private: - T *instance_; - CallbackFunPtr memFun_; - }; - - MemFunToCallbackInterfaceAdapter adapter_; - - void open(const StreamParameters ¶meters) - { - PaError err = Pa_OpenStream(&stream_, parameters.inputParameters().paStreamParameters(), parameters.outputParameters().paStreamParameters(), - parameters.sampleRate(), parameters.framesPerBuffer(), parameters.flags(), &impl::callbackInterfaceToPaCallbackAdapter, - static_cast<void *>(&adapter_)); - - if (err != paNoError) - throw PaException(err); - } - }; + ////// + /// @brief Callback stream using a class's member function as a callback. Template argument T is the type of the + /// class of which a member function is going to be used. + /// + /// Example usage: + /// @verbatim MemFunCallback<MyClass> stream = MemFunCallbackStream(parameters, *this, &MyClass::myCallbackFunction); @endverbatim + ////// + template<typename T> + class MemFunCallbackStream : public CallbackStream + { + public: + typedef int (T::*CallbackFunPtr)(const void *, void *, unsigned long, const PaStreamCallbackTimeInfo *, + PaStreamCallbackFlags); + + // ------------------------------------------------------------------------------- + + MemFunCallbackStream() + { + } + + MemFunCallbackStream(const StreamParameters ¶meters, T &instance, CallbackFunPtr memFun) : adapter_(instance, memFun) + { + open(parameters); + } + + ~MemFunCallbackStream() + { + close(); + } + + void open(const StreamParameters ¶meters, T &instance, CallbackFunPtr memFun) + { + // XXX: need to check if already open? + + adapter_.init(instance, memFun); + open(parameters); + } + + private: + MemFunCallbackStream(const MemFunCallbackStream &); // non-copyable + MemFunCallbackStream &operator=(const MemFunCallbackStream &); // non-copyable + + ////// + /// @brief Inner class which adapts a member function callback to a CallbackInterface compliant + /// class (so it can be adapted using the paCallbackAdapter function). + ////// + class MemFunToCallbackInterfaceAdapter : public CallbackInterface + { + public: + MemFunToCallbackInterfaceAdapter() {} + MemFunToCallbackInterfaceAdapter(T &instance, CallbackFunPtr memFun) : instance_(&instance), memFun_(memFun) {} + + void init(T &instance, CallbackFunPtr memFun) + { + instance_ = &instance; + memFun_ = memFun; + } + + int paCallbackFun(const void *inputBuffer, void *outputBuffer, unsigned long numFrames, + const PaStreamCallbackTimeInfo *timeInfo, PaStreamCallbackFlags statusFlags) + { + return (instance_->*memFun_)(inputBuffer, outputBuffer, numFrames, timeInfo, statusFlags); + } + + private: + T *instance_; + CallbackFunPtr memFun_; + }; + + MemFunToCallbackInterfaceAdapter adapter_; + + void open(const StreamParameters ¶meters) + { + PaError err = Pa_OpenStream(&stream_, parameters.inputParameters().paStreamParameters(), parameters.outputParameters().paStreamParameters(), + parameters.sampleRate(), parameters.framesPerBuffer(), parameters.flags(), &impl::callbackInterfaceToPaCallbackAdapter, + static_cast<void *>(&adapter_)); + + if (err != paNoError) + throw PaException(err); + } + }; } // portaudio diff --git a/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/PortAudioCpp.hxx b/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/PortAudioCpp.hxx index 96df96e7248..2c4df8f068f 100644 --- a/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/PortAudioCpp.hxx +++ b/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/PortAudioCpp.hxx @@ -6,23 +6,23 @@ ////// /// @mainpage PortAudioCpp /// -/// <h1>PortAudioCpp - A Native C++ Binding of PortAudio V19</h1> +/// <h1>PortAudioCpp - A Native C++ Binding of PortAudio V19</h1> /// <h2>PortAudio</h2> /// <p> -/// PortAudio is a portable and mature C API for accessing audio hardware. It offers both callback-based and blocking -/// style input and output, deals with sample data format conversions, dithering and much more. There are a large number -/// of implementations available for various platforms including Windows MME, Windows DirectX, Windows and MacOS (Classic) -/// ASIO, MacOS Classic SoundManager, MacOS X CoreAudio, OSS (Linux), Linux ALSA, JACK (MacOS X and Linux) and SGI Irix -/// AL. Note that, currently not all of these implementations are equally complete or up-to-date (as PortAudio V19 is -/// still in development). Because PortAudio has a C API, it can easily be called from a variety of other programming +/// PortAudio is a portable and mature C API for accessing audio hardware. It offers both callback-based and blocking +/// style input and output, deals with sample data format conversions, dithering and much more. There are a large number +/// of implementations available for various platforms including Windows MME, Windows DirectX, Windows and MacOS (Classic) +/// ASIO, MacOS Classic SoundManager, MacOS X CoreAudio, OSS (Linux), Linux ALSA, JACK (MacOS X and Linux) and SGI Irix +/// AL. Note that, currently not all of these implementations are equally complete or up-to-date (as PortAudio V19 is +/// still in development). Because PortAudio has a C API, it can easily be called from a variety of other programming /// languages. /// </p> /// <h2>PortAudioCpp</h2> /// <p> -/// Although, it is possible to use PortAudio's C API from within a C++ program, this is usually a little awkward -/// as procedural and object-oriented paradigms need to be mixed. PortAudioCpp aims to resolve this by encapsulating -/// PortAudio's C API to form an equivalent object-oriented C++ API. It provides a more natural integration of PortAudio -/// into C++ programs as well as a more structured interface. PortAudio's concepts were preserved as much as possible and +/// Although, it is possible to use PortAudio's C API from within a C++ program, this is usually a little awkward +/// as procedural and object-oriented paradigms need to be mixed. PortAudioCpp aims to resolve this by encapsulating +/// PortAudio's C API to form an equivalent object-oriented C++ API. It provides a more natural integration of PortAudio +/// into C++ programs as well as a more structured interface. PortAudio's concepts were preserved as much as possible and /// no additional features were added except for some `convenience methods'. /// </p> /// <p> @@ -30,15 +30,15 @@ /// <ul> /// <li>Structured object model.</li> /// <li>C++ exception handling instead of C-style error return codes.</li> -/// <li>Handling of callbacks using free functions (C and C++), static functions, member functions or instances of classes +/// <li>Handling of callbacks using free functions (C and C++), static functions, member functions or instances of classes /// derived from a given interface.</li> /// <li>STL compliant iterators to host APIs and devices.</li> /// <li>Some additional convenience functions to more easily set up and use PortAudio.</li> /// </ul> /// </p> /// <p> -/// PortAudioCpp requires a recent version of the PortAudio V19 source code. This can be obtained from CVS or as a snapshot -/// from the website. The examples also require the ASIO 2 SDK which can be obtained from the Steinberg website. Alternatively, the +/// PortAudioCpp requires a recent version of the PortAudio V19 source code. This can be obtained from CVS or as a snapshot +/// from the website. The examples also require the ASIO 2 SDK which can be obtained from the Steinberg website. Alternatively, the /// examples can easily be modified to compile without needing ASIO. /// </p> /// <p> @@ -50,12 +50,12 @@ /// Other platforms should be easily supported as PortAudioCpp is platform-independent and (reasonably) C++ standard compliant. /// </p> /// <p> -/// This documentation mainly provides information specific to PortAudioCpp. For a more complete explaination of all of the +/// This documentation mainly provides information specific to PortAudioCpp. For a more complete explanation of all of the /// concepts used, please consult the PortAudio documentation. /// </p> /// <p> -/// PortAudioCpp was developed by Merlijn Blaauw with many great suggestions and help from Ross Bencina. Ludwig Schwardt provided -/// GNU/Linux build files and checked G++ compatibility. PortAudioCpp may be used under the same licensing, conditions and +/// PortAudioCpp was developed by Merlijn Blaauw with many great suggestions and help from Ross Bencina. Ludwig Schwardt provided +/// GNU/Linux build files and checked G++ compatibility. PortAudioCpp may be used under the same licensing, conditions and /// warranty as PortAudio. See <a href="http://www.portaudio.com/license.html">the PortAudio license</a> for more details. /// </p> /// <h2>Links</h2> @@ -69,8 +69,8 @@ ////// /// @namespace portaudio /// -/// To avoid name collision, everything in PortAudioCpp is in the portaudio -/// namespace. If this name is too long it's usually pretty safe to use an +/// To avoid name collision, everything in PortAudioCpp is in the portaudio +/// namespace. If this name is too long it's usually pretty safe to use an /// alias like ``namespace pa = portaudio;''. ////// diff --git a/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/SampleDataFormat.hxx b/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/SampleDataFormat.hxx index 1d3a1d9ea6c..a15d367adc6 100644 --- a/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/SampleDataFormat.hxx +++ b/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/SampleDataFormat.hxx @@ -11,21 +11,21 @@ namespace portaudio { - ////// - /// @brief PortAudio sample data formats. - /// - /// Small helper enum to wrap the PortAudio defines. - ////// - enum SampleDataFormat - { - INVALID_FORMAT = 0, - FLOAT32 = paFloat32, - INT32 = paInt32, - INT24 = paInt24, - INT16 = paInt16, - INT8 = paInt8, - UINT8 = paUInt8 - }; + ////// + /// @brief PortAudio sample data formats. + /// + /// Small helper enum to wrap the PortAudio defines. + ////// + enum SampleDataFormat + { + INVALID_FORMAT = 0, + FLOAT32 = paFloat32, + INT32 = paInt32, + INT24 = paInt24, + INT16 = paInt16, + INT8 = paInt8, + UINT8 = paUInt8 + }; } // namespace portaudio diff --git a/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/Stream.hxx b/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/Stream.hxx index 1aed747e5f6..2725ba7499b 100644 --- a/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/Stream.hxx +++ b/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/Stream.hxx @@ -8,7 +8,7 @@ // Forward declaration(s): namespace portaudio { - class StreamParameters; + class StreamParameters; } // --------------------------------------------------------------------------------------- @@ -18,65 +18,64 @@ namespace portaudio { - ////// - /// @brief A Stream represents an active or inactive input and/or output data - /// stream in the System. - /// - /// Concrete Stream classes should ensure themselves being in a closed state at - /// destruction (i.e. by calling their own close() method in their deconstructor). - /// Following good C++ programming practices, care must be taken to ensure no - /// exceptions are thrown by the deconstructor of these classes. As a consequence, - /// clients need to explicitly call close() to ensure the stream closed successfully. - /// - /// The Stream object can be used to manipulate the Stream's state. Also, time-constant - /// and time-varying information about the Stream can be retreived. - ////// - class Stream - { - public: - // Opening/closing: - virtual ~Stream(); + ////// + /// @brief A Stream represents an active or inactive input and/or output data + /// stream in the System. + /// + /// Concrete Stream classes should ensure themselves being in a closed state at + /// destruction (i.e. by calling their own close() method in their deconstructor). + /// Following good C++ programming practices, care must be taken to ensure no + /// exceptions are thrown by the deconstructor of these classes. As a consequence, + /// clients need to explicitly call close() to ensure the stream closed successfully. + /// + /// The Stream object can be used to manipulate the Stream's state. Also, time-constant + /// and time-varying information about the Stream can be retrieved. + ////// + class Stream + { + public: + // Opening/closing: + virtual ~Stream(); - virtual void close(); - bool isOpen() const; + virtual void close(); + bool isOpen() const; - // Additional set up: - void setStreamFinishedCallback(PaStreamFinishedCallback *callback); + // Additional set up: + void setStreamFinishedCallback(PaStreamFinishedCallback *callback); - // State management: - void start(); - void stop(); - void abort(); + // State management: + void start(); + void stop(); + void abort(); - bool isStopped() const; - bool isActive() const; + bool isStopped() const; + bool isActive() const; - // Stream info (time-constant, but might become time-variant soon): - PaTime inputLatency() const; - PaTime outputLatency() const; - double sampleRate() const; + // Stream info (time-constant, but might become time-variant soon): + PaTime inputLatency() const; + PaTime outputLatency() const; + double sampleRate() const; - // Stream info (time-varying): - PaTime time() const; + // Stream info (time-varying): + PaTime time() const; - // Accessors for PortAudio PaStream, useful for interfacing - // with PortAudio add-ons (such as PortMixer) for instance: - const PaStream *paStream() const; - PaStream *paStream(); + // Accessors for PortAudio PaStream, useful for interfacing + // with PortAudio add-ons (such as PortMixer) for instance: + const PaStream *paStream() const; + PaStream *paStream(); - protected: - Stream(); // abstract class + protected: + Stream(); // abstract class - PaStream *stream_; + PaStream *stream_; - private: - Stream(const Stream &); // non-copyable - Stream &operator=(const Stream &); // non-copyable - }; + private: + Stream(const Stream &); // non-copyable + Stream &operator=(const Stream &); // non-copyable + }; } // namespace portaudio #endif // INCLUDED_PORTAUDIO_STREAM_HXX - diff --git a/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/StreamParameters.hxx b/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/StreamParameters.hxx index c0ec9a9aeb0..32f5f21a22e 100644 --- a/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/StreamParameters.hxx +++ b/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/StreamParameters.hxx @@ -13,61 +13,61 @@ namespace portaudio { - ////// - /// @brief The entire set of parameters needed to configure and open - /// a Stream. - /// - /// It contains parameters of input, output and shared parameters. - /// Using the isSupported() method, the StreamParameters can be - /// checked if opening a Stream using this StreamParameters would - /// succeed or not. Accessors are provided to higher-level parameters - /// aswell as the lower-level parameters which are mainly intended for - /// internal use. - ////// - class StreamParameters - { - public: - StreamParameters(); - StreamParameters(const DirectionSpecificStreamParameters &inputParameters, - const DirectionSpecificStreamParameters &outputParameters, double sampleRate, - unsigned long framesPerBuffer, PaStreamFlags flags); - - // Set up for direction-specific: - void setInputParameters(const DirectionSpecificStreamParameters ¶meters); - void setOutputParameters(const DirectionSpecificStreamParameters ¶meters); - - // Set up for common parameters: - void setSampleRate(double sampleRate); - void setFramesPerBuffer(unsigned long framesPerBuffer); - void setFlag(PaStreamFlags flag); - void unsetFlag(PaStreamFlags flag); - void clearFlags(); - - // Validation: - bool isSupported() const; - - // Accessors (direction-specific): - DirectionSpecificStreamParameters &inputParameters(); - const DirectionSpecificStreamParameters &inputParameters() const; - DirectionSpecificStreamParameters &outputParameters(); - const DirectionSpecificStreamParameters &outputParameters() const; - - // Accessors (common): - double sampleRate() const; - unsigned long framesPerBuffer() const; - PaStreamFlags flags() const; - bool isFlagSet(PaStreamFlags flag) const; - - private: - // Half-duplex specific parameters: - DirectionSpecificStreamParameters inputParameters_; - DirectionSpecificStreamParameters outputParameters_; - - // Common parameters: - double sampleRate_; - unsigned long framesPerBuffer_; - PaStreamFlags flags_; - }; + ////// + /// @brief The entire set of parameters needed to configure and open + /// a Stream. + /// + /// It contains parameters of input, output and shared parameters. + /// Using the isSupported() method, the StreamParameters can be + /// checked if opening a Stream using this StreamParameters would + /// succeed or not. Accessors are provided to higher-level parameters + /// aswell as the lower-level parameters which are mainly intended for + /// internal use. + ////// + class StreamParameters + { + public: + StreamParameters(); + StreamParameters(const DirectionSpecificStreamParameters &inputParameters, + const DirectionSpecificStreamParameters &outputParameters, double sampleRate, + unsigned long framesPerBuffer, PaStreamFlags flags); + + // Set up for direction-specific: + void setInputParameters(const DirectionSpecificStreamParameters ¶meters); + void setOutputParameters(const DirectionSpecificStreamParameters ¶meters); + + // Set up for common parameters: + void setSampleRate(double sampleRate); + void setFramesPerBuffer(unsigned long framesPerBuffer); + void setFlag(PaStreamFlags flag); + void unsetFlag(PaStreamFlags flag); + void clearFlags(); + + // Validation: + bool isSupported() const; + + // Accessors (direction-specific): + DirectionSpecificStreamParameters &inputParameters(); + const DirectionSpecificStreamParameters &inputParameters() const; + DirectionSpecificStreamParameters &outputParameters(); + const DirectionSpecificStreamParameters &outputParameters() const; + + // Accessors (common): + double sampleRate() const; + unsigned long framesPerBuffer() const; + PaStreamFlags flags() const; + bool isFlagSet(PaStreamFlags flag) const; + + private: + // Half-duplex specific parameters: + DirectionSpecificStreamParameters inputParameters_; + DirectionSpecificStreamParameters outputParameters_; + + // Common parameters: + double sampleRate_; + unsigned long framesPerBuffer_; + PaStreamFlags flags_; + }; } // namespace portaudio diff --git a/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/System.hxx b/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/System.hxx index d5ff9dd2b3c..bdd966ebfa2 100644 --- a/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/System.hxx +++ b/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/System.hxx @@ -10,9 +10,9 @@ // Forward declaration(s): namespace portaudio { - class Device; - class Stream; - class HostApi; + class Device; + class Stream; + class HostApi; } // --------------------------------------------------------------------------------------- @@ -22,86 +22,85 @@ namespace portaudio { - ////// - /// @brief System singleton which represents the PortAudio system. - /// - /// The System is used to initialize/terminate PortAudio and provide - /// a single acccess point to the PortAudio System (instance()). - /// It can be used to iterate through all HostApi 's in the System as - /// well as all devices in the System. It also provides some utility - /// functionality of PortAudio. - /// - /// Terminating the System will also abort and close the open streams. - /// The Stream objects will need to be deallocated by the client though - /// (it's usually a good idea to have them cleaned up automatically). - ////// - class System - { - public: - class HostApiIterator; // forward declaration - class DeviceIterator; // forward declaration + ////// + /// @brief System singleton which represents the PortAudio system. + /// + /// The System is used to initialize/terminate PortAudio and provide + /// a single access point to the PortAudio System (instance()). + /// It can be used to iterate through all HostApi 's in the System as + /// well as all devices in the System. It also provides some utility + /// functionality of PortAudio. + /// + /// Terminating the System will also abort and close the open streams. + /// The Stream objects will need to be deallocated by the client though + /// (it's usually a good idea to have them cleaned up automatically). + ////// + class System + { + public: + class HostApiIterator; // forward declaration + class DeviceIterator; // forward declaration - // ------------------------------------------------------------------------------- + // ------------------------------------------------------------------------------- - static int version(); - static const char *versionText(); + static int version(); + static const char *versionText(); - static void initialize(); - static void terminate(); + static void initialize(); + static void terminate(); - static System &instance(); - static bool exists(); + static System &instance(); + static bool exists(); - // ------------------------------------------------------------------------------- + // ------------------------------------------------------------------------------- - // host apis: - HostApiIterator hostApisBegin(); - HostApiIterator hostApisEnd(); + // host apis: + HostApiIterator hostApisBegin(); + HostApiIterator hostApisEnd(); - HostApi &defaultHostApi(); + HostApi &defaultHostApi(); - HostApi &hostApiByTypeId(PaHostApiTypeId type); - HostApi &hostApiByIndex(PaHostApiIndex index); + HostApi &hostApiByTypeId(PaHostApiTypeId type); + HostApi &hostApiByIndex(PaHostApiIndex index); - int hostApiCount(); + int hostApiCount(); - // ------------------------------------------------------------------------------- + // ------------------------------------------------------------------------------- - // devices: - DeviceIterator devicesBegin(); - DeviceIterator devicesEnd(); + // devices: + DeviceIterator devicesBegin(); + DeviceIterator devicesEnd(); - Device &defaultInputDevice(); - Device &defaultOutputDevice(); + Device &defaultInputDevice(); + Device &defaultOutputDevice(); - Device &deviceByIndex(PaDeviceIndex index); + Device &deviceByIndex(PaDeviceIndex index); - int deviceCount(); + int deviceCount(); - static Device &nullDevice(); + static Device &nullDevice(); - // ------------------------------------------------------------------------------- + // ------------------------------------------------------------------------------- - // misc: - void sleep(long msec); - int sizeOfSample(PaSampleFormat format); + // misc: + void sleep(long msec); + int sizeOfSample(PaSampleFormat format); - private: - System(); - ~System(); + private: + System(); + ~System(); - static System *instance_; - static int initCount_; + static System *instance_; + static int initCount_; - static HostApi **hostApis_; - static Device **devices_; + static HostApi **hostApis_; + static Device **devices_; - static Device *nullDevice_; - }; + static Device *nullDevice_; + }; } // namespace portaudio #endif // INCLUDED_PORTAUDIO_SYSTEM_HXX - diff --git a/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/SystemDeviceIterator.hxx b/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/SystemDeviceIterator.hxx index ffa195d2872..d5ae31eba34 100644 --- a/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/SystemDeviceIterator.hxx +++ b/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/SystemDeviceIterator.hxx @@ -13,8 +13,8 @@ // Forward declaration(s): namespace portaudio { - class Device; - class HostApi; + class Device; + class HostApi; } // --------------------------------------------------------------------------------------- @@ -23,39 +23,39 @@ namespace portaudio namespace portaudio { - - ////// - /// @brief Iterator class for iterating through all Devices in a System. - /// - /// Devices will be iterated by iterating all Devices in each - /// HostApi in the System. Compliant with the STL bidirectional - /// iterator concept. - ////// - class System::DeviceIterator - { - public: - typedef std::bidirectional_iterator_tag iterator_category; - typedef Device value_type; - typedef ptrdiff_t difference_type; - typedef Device * pointer; - typedef Device & reference; - - Device &operator*() const; - Device *operator->() const; - - DeviceIterator &operator++(); - DeviceIterator operator++(int); - DeviceIterator &operator--(); - DeviceIterator operator--(int); - - bool operator==(const DeviceIterator &rhs) const; - bool operator!=(const DeviceIterator &rhs) const; - - private: - friend class System; - friend class HostApi; - Device **ptr_; - }; + + ////// + /// @brief Iterator class for iterating through all Devices in a System. + /// + /// Devices will be iterated by iterating all Devices in each + /// HostApi in the System. Compliant with the STL bidirectional + /// iterator concept. + ////// + class System::DeviceIterator + { + public: + typedef std::bidirectional_iterator_tag iterator_category; + typedef Device value_type; + typedef ptrdiff_t difference_type; + typedef Device * pointer; + typedef Device & reference; + + Device &operator*() const; + Device *operator->() const; + + DeviceIterator &operator++(); + DeviceIterator operator++(int); + DeviceIterator &operator--(); + DeviceIterator operator--(int); + + bool operator==(const DeviceIterator &rhs) const; + bool operator!=(const DeviceIterator &rhs) const; + + private: + friend class System; + friend class HostApi; + Device **ptr_; + }; } // namespace portaudio @@ -63,4 +63,3 @@ namespace portaudio // --------------------------------------------------------------------------------------- #endif // INCLUDED_PORTAUDIO_SYSTEMDEVICEITERATOR_HXX - diff --git a/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/SystemHostApiIterator.hxx b/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/SystemHostApiIterator.hxx index 3e6a978a326..a3e2f4b3c23 100644 --- a/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/SystemHostApiIterator.hxx +++ b/3rdparty/portaudio/bindings/cpp/include/portaudiocpp/SystemHostApiIterator.hxx @@ -13,7 +13,7 @@ // Forward declaration(s): namespace portaudio { - class HostApi; + class HostApi; } // --------------------------------------------------------------------------------------- @@ -23,35 +23,35 @@ namespace portaudio { - ////// - /// @brief Iterator class for iterating through all HostApis in a System. - /// - /// Compliant with the STL bidirectional iterator concept. - ////// - class System::HostApiIterator - { - public: - typedef std::bidirectional_iterator_tag iterator_category; - typedef Device value_type; - typedef ptrdiff_t difference_type; - typedef HostApi * pointer; - typedef HostApi & reference; - - HostApi &operator*() const; - HostApi *operator->() const; - - HostApiIterator &operator++(); - HostApiIterator operator++(int); - HostApiIterator &operator--(); - HostApiIterator operator--(int); - - bool operator==(const HostApiIterator &rhs) const; - bool operator!=(const HostApiIterator &rhs) const; - - private: - friend class System; - HostApi **ptr_; - }; + ////// + /// @brief Iterator class for iterating through all HostApis in a System. + /// + /// Compliant with the STL bidirectional iterator concept. + ////// + class System::HostApiIterator + { + public: + typedef std::bidirectional_iterator_tag iterator_category; + typedef Device value_type; + typedef ptrdiff_t difference_type; + typedef HostApi * pointer; + typedef HostApi & reference; + + HostApi &operator*() const; + HostApi *operator->() const; + + HostApiIterator &operator++(); + HostApiIterator operator++(int); + HostApiIterator &operator--(); + HostApiIterator operator--(int); + + bool operator==(const HostApiIterator &rhs) const; + bool operator!=(const HostApiIterator &rhs) const; + + private: + friend class System; + HostApi **ptr_; + }; } // namespace portaudio diff --git a/3rdparty/portaudio/bindings/cpp/source/portaudiocpp/AsioDeviceAdapter.cxx b/3rdparty/portaudio/bindings/cpp/source/portaudiocpp/AsioDeviceAdapter.cxx index 3efc100f62f..e7fd1ee5fa9 100644 --- a/3rdparty/portaudio/bindings/cpp/source/portaudiocpp/AsioDeviceAdapter.cxx +++ b/3rdparty/portaudio/bindings/cpp/source/portaudiocpp/AsioDeviceAdapter.cxx @@ -9,75 +9,73 @@ namespace portaudio { - AsioDeviceAdapter::AsioDeviceAdapter(Device &device) - { - if (device.hostApi().typeId() != paASIO) - throw PaCppException(PaCppException::UNABLE_TO_ADAPT_DEVICE); + AsioDeviceAdapter::AsioDeviceAdapter(Device &device) + { + if (device.hostApi().typeId() != paASIO) + throw PaCppException(PaCppException::UNABLE_TO_ADAPT_DEVICE); - device_ = &device; + device_ = &device; - PaError err = PaAsio_GetAvailableLatencyValues(device_->index(), &minBufferSize_, &maxBufferSize_, - &preferredBufferSize_, &granularity_); + PaError err = PaAsio_GetAvailableLatencyValues(device_->index(), &minBufferSize_, &maxBufferSize_, + &preferredBufferSize_, &granularity_); - if (err != paNoError) - throw PaException(err); + if (err != paNoError) + throw PaException(err); - } + } - Device &AsioDeviceAdapter::device() - { - return *device_; - } + Device &AsioDeviceAdapter::device() + { + return *device_; + } - long AsioDeviceAdapter::minBufferSize() const - { - return minBufferSize_; - } + long AsioDeviceAdapter::minBufferSize() const + { + return minBufferSize_; + } - long AsioDeviceAdapter::maxBufferSize() const - { - return maxBufferSize_; - } + long AsioDeviceAdapter::maxBufferSize() const + { + return maxBufferSize_; + } - long AsioDeviceAdapter::preferredBufferSize() const - { - return preferredBufferSize_; - } + long AsioDeviceAdapter::preferredBufferSize() const + { + return preferredBufferSize_; + } - long AsioDeviceAdapter::granularity() const - { - return granularity_; - } + long AsioDeviceAdapter::granularity() const + { + return granularity_; + } - void AsioDeviceAdapter::showControlPanel(void *systemSpecific) - { - PaError err = PaAsio_ShowControlPanel(device_->index(), systemSpecific); + void AsioDeviceAdapter::showControlPanel(void *systemSpecific) + { + PaError err = PaAsio_ShowControlPanel(device_->index(), systemSpecific); - if (err != paNoError) - throw PaException(err); - } + if (err != paNoError) + throw PaException(err); + } - const char *AsioDeviceAdapter::inputChannelName(int channelIndex) const - { - const char *channelName; - PaError err = PaAsio_GetInputChannelName(device_->index(), channelIndex, &channelName); + const char *AsioDeviceAdapter::inputChannelName(int channelIndex) const + { + const char *channelName; + PaError err = PaAsio_GetInputChannelName(device_->index(), channelIndex, &channelName); - if (err != paNoError) - throw PaException(err); + if (err != paNoError) + throw PaException(err); - return channelName; - } + return channelName; + } - const char *AsioDeviceAdapter::outputChannelName(int channelIndex) const - { - const char *channelName; - PaError err = PaAsio_GetOutputChannelName(device_->index(), channelIndex, &channelName); + const char *AsioDeviceAdapter::outputChannelName(int channelIndex) const + { + const char *channelName; + PaError err = PaAsio_GetOutputChannelName(device_->index(), channelIndex, &channelName); - if (err != paNoError) - throw PaException(err); + if (err != paNoError) + throw PaException(err); - return channelName; - } + return channelName; + } } - - diff --git a/3rdparty/portaudio/bindings/cpp/source/portaudiocpp/BlockingStream.cxx b/3rdparty/portaudio/bindings/cpp/source/portaudiocpp/BlockingStream.cxx index b26b9e81a4f..751e1f21b7e 100644 --- a/3rdparty/portaudio/bindings/cpp/source/portaudiocpp/BlockingStream.cxx +++ b/3rdparty/portaudio/bindings/cpp/source/portaudiocpp/BlockingStream.cxx @@ -8,93 +8,90 @@ namespace portaudio { - // -------------------------------------------------------------------------------------- - - BlockingStream::BlockingStream() - { - } - - BlockingStream::BlockingStream(const StreamParameters ¶meters) - { - open(parameters); - } - - BlockingStream::~BlockingStream() - { - try - { - close(); - } - catch (...) - { - // ignore all errors - } - } - - // -------------------------------------------------------------------------------------- - - void BlockingStream::open(const StreamParameters ¶meters) - { - PaError err = Pa_OpenStream(&stream_, parameters.inputParameters().paStreamParameters(), parameters.outputParameters().paStreamParameters(), - parameters.sampleRate(), parameters.framesPerBuffer(), parameters.flags(), NULL, NULL); - - if (err != paNoError) - { - throw PaException(err); - } - } - - // -------------------------------------------------------------------------------------- - - void BlockingStream::read(void *buffer, unsigned long numFrames) - { - PaError err = Pa_ReadStream(stream_, buffer, numFrames); - - if (err != paNoError) - { - throw PaException(err); - } - } - - void BlockingStream::write(const void *buffer, unsigned long numFrames) - { - PaError err = Pa_WriteStream(stream_, buffer, numFrames); - - if (err != paNoError) - { - throw PaException(err); - } - } - - // -------------------------------------------------------------------------------------- - - signed long BlockingStream::availableReadSize() const - { - signed long avail = Pa_GetStreamReadAvailable(stream_); - - if (avail < 0) - { - throw PaException(avail); - } - - return avail; - } - - signed long BlockingStream::availableWriteSize() const - { - signed long avail = Pa_GetStreamWriteAvailable(stream_); - - if (avail < 0) - { - throw PaException(avail); - } - - return avail; - } - - // -------------------------------------------------------------------------------------- + // -------------------------------------------------------------------------------------- + + BlockingStream::BlockingStream() + { + } + + BlockingStream::BlockingStream(const StreamParameters ¶meters) + { + open(parameters); + } + + BlockingStream::~BlockingStream() + { + try + { + close(); + } + catch (...) + { + // ignore all errors + } + } + + // -------------------------------------------------------------------------------------- + + void BlockingStream::open(const StreamParameters ¶meters) + { + PaError err = Pa_OpenStream(&stream_, parameters.inputParameters().paStreamParameters(), parameters.outputParameters().paStreamParameters(), + parameters.sampleRate(), parameters.framesPerBuffer(), parameters.flags(), NULL, NULL); + + if (err != paNoError) + { + throw PaException(err); + } + } + + // -------------------------------------------------------------------------------------- + + void BlockingStream::read(void *buffer, unsigned long numFrames) + { + PaError err = Pa_ReadStream(stream_, buffer, numFrames); + + if (err != paNoError) + { + throw PaException(err); + } + } + + void BlockingStream::write(const void *buffer, unsigned long numFrames) + { + PaError err = Pa_WriteStream(stream_, buffer, numFrames); + + if (err != paNoError) + { + throw PaException(err); + } + } + + // -------------------------------------------------------------------------------------- + + signed long BlockingStream::availableReadSize() const + { + signed long avail = Pa_GetStreamReadAvailable(stream_); + + if (avail < 0) + { + throw PaException(avail); + } + + return avail; + } + + signed long BlockingStream::availableWriteSize() const + { + signed long avail = Pa_GetStreamWriteAvailable(stream_); + + if (avail < 0) + { + throw PaException(avail); + } + + return avail; + } + + // -------------------------------------------------------------------------------------- } // portaudio - - - diff --git a/3rdparty/portaudio/bindings/cpp/source/portaudiocpp/CFunCallbackStream.cxx b/3rdparty/portaudio/bindings/cpp/source/portaudiocpp/CFunCallbackStream.cxx index 9cceda9ab9e..7dcc751d121 100644 --- a/3rdparty/portaudio/bindings/cpp/source/portaudiocpp/CFunCallbackStream.cxx +++ b/3rdparty/portaudio/bindings/cpp/source/portaudiocpp/CFunCallbackStream.cxx @@ -5,37 +5,37 @@ namespace portaudio { - CFunCallbackStream::CFunCallbackStream() - { - } + CFunCallbackStream::CFunCallbackStream() + { + } - CFunCallbackStream::CFunCallbackStream(const StreamParameters ¶meters, PaStreamCallback *funPtr, void *userData) - { - open(parameters, funPtr, userData); - } + CFunCallbackStream::CFunCallbackStream(const StreamParameters ¶meters, PaStreamCallback *funPtr, void *userData) + { + open(parameters, funPtr, userData); + } - CFunCallbackStream::~CFunCallbackStream() - { - try - { - close(); - } - catch (...) - { - // ignore all errors - } - } + CFunCallbackStream::~CFunCallbackStream() + { + try + { + close(); + } + catch (...) + { + // ignore all errors + } + } - // ---------------------------------------------------------------------------------== + // ---------------------------------------------------------------------------------== - void CFunCallbackStream::open(const StreamParameters ¶meters, PaStreamCallback *funPtr, void *userData) - { - PaError err = Pa_OpenStream(&stream_, parameters.inputParameters().paStreamParameters(), parameters.outputParameters().paStreamParameters(), - parameters.sampleRate(), parameters.framesPerBuffer(), parameters.flags(), funPtr, userData); + void CFunCallbackStream::open(const StreamParameters ¶meters, PaStreamCallback *funPtr, void *userData) + { + PaError err = Pa_OpenStream(&stream_, parameters.inputParameters().paStreamParameters(), parameters.outputParameters().paStreamParameters(), + parameters.sampleRate(), parameters.framesPerBuffer(), parameters.flags(), funPtr, userData); - if (err != paNoError) - { - throw PaException(err); - } - } + if (err != paNoError) + { + throw PaException(err); + } + } } diff --git a/3rdparty/portaudio/bindings/cpp/source/portaudiocpp/CMakeLists.txt b/3rdparty/portaudio/bindings/cpp/source/portaudiocpp/CMakeLists.txt new file mode 100644 index 00000000000..cd4954191d9 --- /dev/null +++ b/3rdparty/portaudio/bindings/cpp/source/portaudiocpp/CMakeLists.txt @@ -0,0 +1,26 @@ +find_package(ASIO) +if(ASIO_FOUND) + set(portaudio-cpp-sources-asio AsioDeviceAdapter.cxx PARENT_SCOPE) +else() + set(portaudio-cpp-sources-asio PARENT_SCOPE) +endif() + +set(portaudio-cpp-sources + ${CMAKE_CURRENT_SOURCE_DIR}/BlockingStream.cxx + ${CMAKE_CURRENT_SOURCE_DIR}/CFunCallbackStream.cxx + ${CMAKE_CURRENT_SOURCE_DIR}/CallbackInterface.cxx + ${CMAKE_CURRENT_SOURCE_DIR}/CallbackStream.cxx + ${CMAKE_CURRENT_SOURCE_DIR}/CppFunCallbackStream.cxx + ${CMAKE_CURRENT_SOURCE_DIR}/Device.cxx + ${CMAKE_CURRENT_SOURCE_DIR}/DirectionSpecificStreamParameters.cxx + ${CMAKE_CURRENT_SOURCE_DIR}/Exception.cxx + ${CMAKE_CURRENT_SOURCE_DIR}/HostApi.cxx + ${CMAKE_CURRENT_SOURCE_DIR}/InterfaceCallbackStream.cxx + ${CMAKE_CURRENT_SOURCE_DIR}/MemFunCallbackStream.cxx + ${CMAKE_CURRENT_SOURCE_DIR}/Stream.cxx + ${CMAKE_CURRENT_SOURCE_DIR}/StreamParameters.cxx + ${CMAKE_CURRENT_SOURCE_DIR}/System.cxx + ${CMAKE_CURRENT_SOURCE_DIR}/SystemDeviceIterator.cxx + ${CMAKE_CURRENT_SOURCE_DIR}/SystemHostApiIterator.cxx + PARENT_SCOPE +) diff --git a/3rdparty/portaudio/bindings/cpp/source/portaudiocpp/CallbackInterface.cxx b/3rdparty/portaudio/bindings/cpp/source/portaudiocpp/CallbackInterface.cxx index 01372612e49..30ad933126e 100644 --- a/3rdparty/portaudio/bindings/cpp/source/portaudiocpp/CallbackInterface.cxx +++ b/3rdparty/portaudio/bindings/cpp/source/portaudiocpp/CallbackInterface.cxx @@ -3,23 +3,21 @@ namespace portaudio { - namespace impl - { + namespace impl + { - ////// - /// Adapts any CallbackInterface object to a C-callable function (ie this function). A - /// pointer to the object should be passed as ``userData'' when setting up the callback. - ////// - int callbackInterfaceToPaCallbackAdapter(const void *inputBuffer, void *outputBuffer, unsigned long numFrames, - const PaStreamCallbackTimeInfo *timeInfo, PaStreamCallbackFlags statusFlags, void *userData) - { - CallbackInterface *cb = static_cast<CallbackInterface *>(userData); - return cb->paCallbackFun(inputBuffer, outputBuffer, numFrames, timeInfo, statusFlags); - } + ////// + /// Adapts any CallbackInterface object to a C-callable function (ie this function). A + /// pointer to the object should be passed as ``userData'' when setting up the callback. + ////// + int callbackInterfaceToPaCallbackAdapter(const void *inputBuffer, void *outputBuffer, unsigned long numFrames, + const PaStreamCallbackTimeInfo *timeInfo, PaStreamCallbackFlags statusFlags, void *userData) + { + CallbackInterface *cb = static_cast<CallbackInterface *>(userData); + return cb->paCallbackFun(inputBuffer, outputBuffer, numFrames, timeInfo, statusFlags); + } - } // namespace impl + } // namespace impl } // namespace portaudio - - diff --git a/3rdparty/portaudio/bindings/cpp/source/portaudiocpp/CallbackStream.cxx b/3rdparty/portaudio/bindings/cpp/source/portaudiocpp/CallbackStream.cxx index b6c8e1d03ee..d295a0a5ae0 100644 --- a/3rdparty/portaudio/bindings/cpp/source/portaudiocpp/CallbackStream.cxx +++ b/3rdparty/portaudio/bindings/cpp/source/portaudiocpp/CallbackStream.cxx @@ -2,19 +2,19 @@ namespace portaudio { - CallbackStream::CallbackStream() - { - } + CallbackStream::CallbackStream() + { + } - CallbackStream::~CallbackStream() - { - } + CallbackStream::~CallbackStream() + { + } - // ----------------------------------------------------------------------------------- - - double CallbackStream::cpuLoad() const - { - return Pa_GetStreamCpuLoad(stream_); - } + // ----------------------------------------------------------------------------------- + + double CallbackStream::cpuLoad() const + { + return Pa_GetStreamCpuLoad(stream_); + } } // namespace portaudio diff --git a/3rdparty/portaudio/bindings/cpp/source/portaudiocpp/CppFunCallbackStream.cxx b/3rdparty/portaudio/bindings/cpp/source/portaudiocpp/CppFunCallbackStream.cxx index fe0b4ab0cd5..19a76ee6ee6 100644 --- a/3rdparty/portaudio/bindings/cpp/source/portaudiocpp/CppFunCallbackStream.cxx +++ b/3rdparty/portaudio/bindings/cpp/source/portaudiocpp/CppFunCallbackStream.cxx @@ -5,77 +5,77 @@ namespace portaudio { - namespace impl - { - ////// - /// Adapts any a C++ callback to a C-callable function (ie this function). A - /// pointer to a struct with the C++ function pointer and the actual user data should be - /// passed as the ``userData'' parameter when setting up the callback. - ////// - int cppCallbackToPaCallbackAdapter(const void *inputBuffer, void *outputBuffer, unsigned long numFrames, - const PaStreamCallbackTimeInfo *timeInfo, PaStreamCallbackFlags statusFlags, void *userData) - { - FunCallbackStream::CppToCCallbackData *data = static_cast<FunCallbackStream::CppToCCallbackData *>(userData); - return data->funPtr(inputBuffer, outputBuffer, numFrames, timeInfo, statusFlags, data->userData); - } - } + namespace impl + { + ////// + /// Adapts any a C++ callback to a C-callable function (ie this function). A + /// pointer to a struct with the C++ function pointer and the actual user data should be + /// passed as the ``userData'' parameter when setting up the callback. + ////// + int cppCallbackToPaCallbackAdapter(const void *inputBuffer, void *outputBuffer, unsigned long numFrames, + const PaStreamCallbackTimeInfo *timeInfo, PaStreamCallbackFlags statusFlags, void *userData) + { + FunCallbackStream::CppToCCallbackData *data = static_cast<FunCallbackStream::CppToCCallbackData *>(userData); + return data->funPtr(inputBuffer, outputBuffer, numFrames, timeInfo, statusFlags, data->userData); + } + } - // ----------------------------------------------------------------------------------- + // ----------------------------------------------------------------------------------- - FunCallbackStream::CppToCCallbackData::CppToCCallbackData() - { - } + FunCallbackStream::CppToCCallbackData::CppToCCallbackData() + { + } - FunCallbackStream::CppToCCallbackData::CppToCCallbackData(CallbackFunPtr funPtr, void *userData) : funPtr(funPtr), userData(userData) - { - } + FunCallbackStream::CppToCCallbackData::CppToCCallbackData(CallbackFunPtr funPtr, void *userData) : funPtr(funPtr), userData(userData) + { + } - void FunCallbackStream::CppToCCallbackData::init(CallbackFunPtr funPtr, void *userData) - { - this->funPtr = funPtr; - this->userData = userData; - } + void FunCallbackStream::CppToCCallbackData::init(CallbackFunPtr funPtr, void *userData) + { + this->funPtr = funPtr; + this->userData = userData; + } - // ----------------------------------------------------------------------------------- + // ----------------------------------------------------------------------------------- - FunCallbackStream::FunCallbackStream() - { - } + FunCallbackStream::FunCallbackStream() + { + } - FunCallbackStream::FunCallbackStream(const StreamParameters ¶meters, CallbackFunPtr funPtr, void *userData) : adapterData_(funPtr, userData) - { - open(parameters); - } + FunCallbackStream::FunCallbackStream(const StreamParameters ¶meters, CallbackFunPtr funPtr, void *userData) : adapterData_(funPtr, userData) + { + open(parameters); + } - FunCallbackStream::~FunCallbackStream() - { - try - { - close(); - } - catch (...) - { - // ignore all errors - } - } + FunCallbackStream::~FunCallbackStream() + { + try + { + close(); + } + catch (...) + { + // ignore all errors + } + } - void FunCallbackStream::open(const StreamParameters ¶meters, CallbackFunPtr funPtr, void *userData) - { - adapterData_.init(funPtr, userData); - open(parameters); - } + void FunCallbackStream::open(const StreamParameters ¶meters, CallbackFunPtr funPtr, void *userData) + { + adapterData_.init(funPtr, userData); + open(parameters); + } - void FunCallbackStream::open(const StreamParameters ¶meters) - { - PaError err = Pa_OpenStream(&stream_, parameters.inputParameters().paStreamParameters(), parameters.outputParameters().paStreamParameters(), - parameters.sampleRate(), parameters.framesPerBuffer(), parameters.flags(), &impl::cppCallbackToPaCallbackAdapter, - static_cast<void *>(&adapterData_)); + void FunCallbackStream::open(const StreamParameters ¶meters) + { + PaError err = Pa_OpenStream(&stream_, parameters.inputParameters().paStreamParameters(), parameters.outputParameters().paStreamParameters(), + parameters.sampleRate(), parameters.framesPerBuffer(), parameters.flags(), &impl::cppCallbackToPaCallbackAdapter, + static_cast<void *>(&adapterData_)); - if (err != paNoError) - { - throw PaException(err); - } - } + if (err != paNoError) + { + throw PaException(err); + } + } - // ----------------------------------------------------------------------------------- + // ----------------------------------------------------------------------------------- } diff --git a/3rdparty/portaudio/bindings/cpp/source/portaudiocpp/Device.cxx b/3rdparty/portaudio/bindings/cpp/source/portaudiocpp/Device.cxx index 7b21b03ca52..727b7214480 100644 --- a/3rdparty/portaudio/bindings/cpp/source/portaudiocpp/Device.cxx +++ b/3rdparty/portaudio/bindings/cpp/source/portaudiocpp/Device.cxx @@ -9,160 +9,158 @@ namespace portaudio { - // ------------------------------------------------------------------------------- - - Device::Device(PaDeviceIndex index) : index_(index) - { - if (index == paNoDevice) - info_ = NULL; - else - info_ = Pa_GetDeviceInfo(index); - } - - Device::~Device() - { - } - - PaDeviceIndex Device::index() const - { - return index_; - } - - const char *Device::name() const - { - if (info_ == NULL) - return ""; - - return info_->name; - } - - int Device::maxInputChannels() const - { - if (info_ == NULL) - return 0; - - return info_->maxInputChannels; - } - - int Device::maxOutputChannels() const - { - if (info_ == NULL) - return 0; - - return info_->maxOutputChannels; - } - - PaTime Device::defaultLowInputLatency() const - { - if (info_ == NULL) - return static_cast<PaTime>(0.0); - - return info_->defaultLowInputLatency; - } - - PaTime Device::defaultHighInputLatency() const - { - if (info_ == NULL) - return static_cast<PaTime>(0.0); - - return info_->defaultHighInputLatency; - } - - PaTime Device::defaultLowOutputLatency() const - { - if (info_ == NULL) - return static_cast<PaTime>(0.0); - - return info_->defaultLowOutputLatency; - } - - PaTime Device::defaultHighOutputLatency() const - { - if (info_ == NULL) - return static_cast<PaTime>(0.0); - - return info_->defaultHighOutputLatency; - } - - double Device::defaultSampleRate() const - { - if (info_ == NULL) - return 0.0; - - return info_->defaultSampleRate; - } - - // ------------------------------------------------------------------------------- - - bool Device::isInputOnlyDevice() const - { - return (maxOutputChannels() == 0); - } - - bool Device::isOutputOnlyDevice() const - { - return (maxInputChannels() == 0); - } - - bool Device::isFullDuplexDevice() const - { - return (maxInputChannels() > 0 && maxOutputChannels() > 0); - } - - bool Device::isSystemDefaultInputDevice() const - { - return (System::instance().defaultInputDevice() == *this); - } - - bool Device::isSystemDefaultOutputDevice() const - { - return (System::instance().defaultOutputDevice() == *this); - } + // ------------------------------------------------------------------------------- + + Device::Device(PaDeviceIndex index) : index_(index) + { + if (index == paNoDevice) + info_ = NULL; + else + info_ = Pa_GetDeviceInfo(index); + } + + Device::~Device() + { + } + + PaDeviceIndex Device::index() const + { + return index_; + } + + const char *Device::name() const + { + if (info_ == NULL) + return ""; + + return info_->name; + } + + int Device::maxInputChannels() const + { + if (info_ == NULL) + return 0; + + return info_->maxInputChannels; + } + + int Device::maxOutputChannels() const + { + if (info_ == NULL) + return 0; + + return info_->maxOutputChannels; + } + + PaTime Device::defaultLowInputLatency() const + { + if (info_ == NULL) + return static_cast<PaTime>(0.0); + + return info_->defaultLowInputLatency; + } + + PaTime Device::defaultHighInputLatency() const + { + if (info_ == NULL) + return static_cast<PaTime>(0.0); + + return info_->defaultHighInputLatency; + } + + PaTime Device::defaultLowOutputLatency() const + { + if (info_ == NULL) + return static_cast<PaTime>(0.0); + + return info_->defaultLowOutputLatency; + } + + PaTime Device::defaultHighOutputLatency() const + { + if (info_ == NULL) + return static_cast<PaTime>(0.0); + + return info_->defaultHighOutputLatency; + } + + double Device::defaultSampleRate() const + { + if (info_ == NULL) + return 0.0; + + return info_->defaultSampleRate; + } + + // ------------------------------------------------------------------------------- + + bool Device::isInputOnlyDevice() const + { + return (maxOutputChannels() == 0); + } + + bool Device::isOutputOnlyDevice() const + { + return (maxInputChannels() == 0); + } + + bool Device::isFullDuplexDevice() const + { + return (maxInputChannels() > 0 && maxOutputChannels() > 0); + } + + bool Device::isSystemDefaultInputDevice() const + { + return (System::instance().defaultInputDevice() == *this); + } + + bool Device::isSystemDefaultOutputDevice() const + { + return (System::instance().defaultOutputDevice() == *this); + } - bool Device::isHostApiDefaultInputDevice() const - { - return (hostApi().defaultInputDevice() == *this); - } - - bool Device::isHostApiDefaultOutputDevice() const - { - return (hostApi().defaultOutputDevice() == *this); - } + bool Device::isHostApiDefaultInputDevice() const + { + return (hostApi().defaultInputDevice() == *this); + } + + bool Device::isHostApiDefaultOutputDevice() const + { + return (hostApi().defaultOutputDevice() == *this); + } - // ------------------------------------------------------------------------------- + // ------------------------------------------------------------------------------- - bool Device::operator==(const Device &rhs) const - { - return (index_ == rhs.index_); - } + bool Device::operator==(const Device &rhs) const + { + return (index_ == rhs.index_); + } - bool Device::operator!=(const Device &rhs) const - { - return !(*this == rhs); - } + bool Device::operator!=(const Device &rhs) const + { + return !(*this == rhs); + } - // ------------------------------------------------------------------------------- + // ------------------------------------------------------------------------------- - HostApi &Device::hostApi() - { - // NOTE: will cause an exception when called for the null device - if (info_ == NULL) - throw PaException(paInternalError); + HostApi &Device::hostApi() + { + // NOTE: will cause an exception when called for the null device + if (info_ == NULL) + throw PaException(paInternalError); - return System::instance().hostApiByIndex(info_->hostApi); - } + return System::instance().hostApiByIndex(info_->hostApi); + } - const HostApi &Device::hostApi() const - { - // NOTE; will cause an exception when called for the null device - if (info_ == NULL) - throw PaException(paInternalError); + const HostApi &Device::hostApi() const + { + // NOTE; will cause an exception when called for the null device + if (info_ == NULL) + throw PaException(paInternalError); - return System::instance().hostApiByIndex(info_->hostApi); - } + return System::instance().hostApiByIndex(info_->hostApi); + } - // ------------------------------------------------------------------------------- + // ------------------------------------------------------------------------------- } // namespace portaudio - - diff --git a/3rdparty/portaudio/bindings/cpp/source/portaudiocpp/DirectionSpecificStreamParameters.cxx b/3rdparty/portaudio/bindings/cpp/source/portaudiocpp/DirectionSpecificStreamParameters.cxx index 68453d02121..558f2e2bb92 100644 --- a/3rdparty/portaudio/bindings/cpp/source/portaudiocpp/DirectionSpecificStreamParameters.cxx +++ b/3rdparty/portaudio/bindings/cpp/source/portaudiocpp/DirectionSpecificStreamParameters.cxx @@ -5,159 +5,159 @@ namespace portaudio { - // ----------------------------------------------------------------------------------- - - ////// - /// Returns a `nil' DirectionSpecificStreamParameters object. This can be used to - /// specify that one direction of a Stream is not required (i.e. when creating - /// a half-duplex Stream). All fields of the null DirectionSpecificStreamParameters - /// object are invalid except for the device and the number of channel, which are set - /// to paNoDevice and 0 respectively. - ////// - DirectionSpecificStreamParameters DirectionSpecificStreamParameters::null() - { - DirectionSpecificStreamParameters tmp; - tmp.paStreamParameters_.device = paNoDevice; - tmp.paStreamParameters_.channelCount = 0; - return tmp; - } - - // ----------------------------------------------------------------------------------- - - ////// - /// Default constructor -- all parameters will be uninitialized. - ////// - DirectionSpecificStreamParameters::DirectionSpecificStreamParameters() - { - } - - ////// - /// Constructor which sets all required fields. - ////// - DirectionSpecificStreamParameters::DirectionSpecificStreamParameters(const Device &device, int numChannels, - SampleDataFormat format, bool interleaved, PaTime suggestedLatency, void *hostApiSpecificStreamInfo) - { - setDevice(device); - setNumChannels(numChannels); - setSampleFormat(format, interleaved); - setSuggestedLatency(suggestedLatency); - setHostApiSpecificStreamInfo(hostApiSpecificStreamInfo); - } - - // ----------------------------------------------------------------------------------- - - void DirectionSpecificStreamParameters::setDevice(const Device &device) - { - paStreamParameters_.device = device.index(); - } - - void DirectionSpecificStreamParameters::setNumChannels(int numChannels) - { - paStreamParameters_.channelCount = numChannels; - } - - void DirectionSpecificStreamParameters::setSampleFormat(SampleDataFormat format, bool interleaved) - { - paStreamParameters_.sampleFormat = static_cast<PaSampleFormat>(format); - - if (!interleaved) - paStreamParameters_.sampleFormat |= paNonInterleaved; - } - - void DirectionSpecificStreamParameters::setHostApiSpecificSampleFormat(PaSampleFormat format, bool interleaved) - { - paStreamParameters_.sampleFormat = format; - - paStreamParameters_.sampleFormat |= paCustomFormat; - - if (!interleaved) - paStreamParameters_.sampleFormat |= paNonInterleaved; - } - - void DirectionSpecificStreamParameters::setSuggestedLatency(PaTime latency) - { - paStreamParameters_.suggestedLatency = latency; - } - - void DirectionSpecificStreamParameters::setHostApiSpecificStreamInfo(void *streamInfo) - { - paStreamParameters_.hostApiSpecificStreamInfo = streamInfo; - } - - // ----------------------------------------------------------------------------------- - - PaStreamParameters *DirectionSpecificStreamParameters::paStreamParameters() - { - if (paStreamParameters_.channelCount > 0 && paStreamParameters_.device != paNoDevice) - return &paStreamParameters_; - else - return NULL; - } - - const PaStreamParameters *DirectionSpecificStreamParameters::paStreamParameters() const - { - if (paStreamParameters_.channelCount > 0 && paStreamParameters_.device != paNoDevice) - return &paStreamParameters_; - else - return NULL; - } - - Device &DirectionSpecificStreamParameters::device() const - { - return System::instance().deviceByIndex(paStreamParameters_.device); - } - - int DirectionSpecificStreamParameters::numChannels() const - { - return paStreamParameters_.channelCount; - } - - ////// - /// Returns the (non host api-specific) sample format, without including - /// the paNonInterleaved flag. If the sample format is host api-spefific, - /// INVALID_FORMAT (0) will be returned. - ////// - SampleDataFormat DirectionSpecificStreamParameters::sampleFormat() const - { - if (isSampleFormatHostApiSpecific()) - return INVALID_FORMAT; - else - return static_cast<SampleDataFormat>(paStreamParameters_.sampleFormat & ~paNonInterleaved); - } - - bool DirectionSpecificStreamParameters::isSampleFormatInterleaved() const - { - return ((paStreamParameters_.sampleFormat & paNonInterleaved) == 0); - } - - bool DirectionSpecificStreamParameters::isSampleFormatHostApiSpecific() const - { - return ((paStreamParameters_.sampleFormat & paCustomFormat) == 0); - } - - ////// - /// Returns the host api-specific sample format, without including any - /// paCustomFormat or paNonInterleaved flags. Will return 0 if the sample format is - /// not host api-specific. - ////// - PaSampleFormat DirectionSpecificStreamParameters::hostApiSpecificSampleFormat() const - { - if (isSampleFormatHostApiSpecific()) - return paStreamParameters_.sampleFormat & ~paCustomFormat & ~paNonInterleaved; - else - return 0; - } - - PaTime DirectionSpecificStreamParameters::suggestedLatency() const - { - return paStreamParameters_.suggestedLatency; - } - - void *DirectionSpecificStreamParameters::hostApiSpecificStreamInfo() const - { - return paStreamParameters_.hostApiSpecificStreamInfo; - } - - // ----------------------------------------------------------------------------------- + // ----------------------------------------------------------------------------------- + + ////// + /// Returns a `nil' DirectionSpecificStreamParameters object. This can be used to + /// specify that one direction of a Stream is not required (i.e. when creating + /// a half-duplex Stream). All fields of the null DirectionSpecificStreamParameters + /// object are invalid except for the device and the number of channel, which are set + /// to paNoDevice and 0 respectively. + ////// + DirectionSpecificStreamParameters DirectionSpecificStreamParameters::null() + { + DirectionSpecificStreamParameters tmp; + tmp.paStreamParameters_.device = paNoDevice; + tmp.paStreamParameters_.channelCount = 0; + return tmp; + } + + // ----------------------------------------------------------------------------------- + + ////// + /// Default constructor -- all parameters will be uninitialized. + ////// + DirectionSpecificStreamParameters::DirectionSpecificStreamParameters() + { + } + + ////// + /// Constructor which sets all required fields. + ////// + DirectionSpecificStreamParameters::DirectionSpecificStreamParameters(const Device &device, int numChannels, + SampleDataFormat format, bool interleaved, PaTime suggestedLatency, void *hostApiSpecificStreamInfo) + { + setDevice(device); + setNumChannels(numChannels); + setSampleFormat(format, interleaved); + setSuggestedLatency(suggestedLatency); + setHostApiSpecificStreamInfo(hostApiSpecificStreamInfo); + } + + // ----------------------------------------------------------------------------------- + + void DirectionSpecificStreamParameters::setDevice(const Device &device) + { + paStreamParameters_.device = device.index(); + } + + void DirectionSpecificStreamParameters::setNumChannels(int numChannels) + { + paStreamParameters_.channelCount = numChannels; + } + + void DirectionSpecificStreamParameters::setSampleFormat(SampleDataFormat format, bool interleaved) + { + paStreamParameters_.sampleFormat = static_cast<PaSampleFormat>(format); + + if (!interleaved) + paStreamParameters_.sampleFormat |= paNonInterleaved; + } + + void DirectionSpecificStreamParameters::setHostApiSpecificSampleFormat(PaSampleFormat format, bool interleaved) + { + paStreamParameters_.sampleFormat = format; + + paStreamParameters_.sampleFormat |= paCustomFormat; + + if (!interleaved) + paStreamParameters_.sampleFormat |= paNonInterleaved; + } + + void DirectionSpecificStreamParameters::setSuggestedLatency(PaTime latency) + { + paStreamParameters_.suggestedLatency = latency; + } + + void DirectionSpecificStreamParameters::setHostApiSpecificStreamInfo(void *streamInfo) + { + paStreamParameters_.hostApiSpecificStreamInfo = streamInfo; + } + + // ----------------------------------------------------------------------------------- + + PaStreamParameters *DirectionSpecificStreamParameters::paStreamParameters() + { + if (paStreamParameters_.channelCount > 0 && paStreamParameters_.device != paNoDevice) + return &paStreamParameters_; + else + return NULL; + } + + const PaStreamParameters *DirectionSpecificStreamParameters::paStreamParameters() const + { + if (paStreamParameters_.channelCount > 0 && paStreamParameters_.device != paNoDevice) + return &paStreamParameters_; + else + return NULL; + } + + Device &DirectionSpecificStreamParameters::device() const + { + return System::instance().deviceByIndex(paStreamParameters_.device); + } + + int DirectionSpecificStreamParameters::numChannels() const + { + return paStreamParameters_.channelCount; + } + + ////// + /// Returns the (non host api-specific) sample format, without including + /// the paNonInterleaved flag. If the sample format is host api-spefific, + /// INVALID_FORMAT (0) will be returned. + ////// + SampleDataFormat DirectionSpecificStreamParameters::sampleFormat() const + { + if (isSampleFormatHostApiSpecific()) + return INVALID_FORMAT; + else + return static_cast<SampleDataFormat>(paStreamParameters_.sampleFormat & ~paNonInterleaved); + } + + bool DirectionSpecificStreamParameters::isSampleFormatInterleaved() const + { + return ((paStreamParameters_.sampleFormat & paNonInterleaved) == 0); + } + + bool DirectionSpecificStreamParameters::isSampleFormatHostApiSpecific() const + { + return ((paStreamParameters_.sampleFormat & paCustomFormat) == 0); + } + + ////// + /// Returns the host api-specific sample format, without including any + /// paCustomFormat or paNonInterleaved flags. Will return 0 if the sample format is + /// not host api-specific. + ////// + PaSampleFormat DirectionSpecificStreamParameters::hostApiSpecificSampleFormat() const + { + if (isSampleFormatHostApiSpecific()) + return paStreamParameters_.sampleFormat & ~paCustomFormat & ~paNonInterleaved; + else + return 0; + } + + PaTime DirectionSpecificStreamParameters::suggestedLatency() const + { + return paStreamParameters_.suggestedLatency; + } + + void *DirectionSpecificStreamParameters::hostApiSpecificStreamInfo() const + { + return paStreamParameters_.hostApiSpecificStreamInfo; + } + + // ----------------------------------------------------------------------------------- } // namespace portaudio diff --git a/3rdparty/portaudio/bindings/cpp/source/portaudiocpp/Exception.cxx b/3rdparty/portaudio/bindings/cpp/source/portaudiocpp/Exception.cxx index 98945c81724..de8724d6745 100644 --- a/3rdparty/portaudio/bindings/cpp/source/portaudiocpp/Exception.cxx +++ b/3rdparty/portaudio/bindings/cpp/source/portaudiocpp/Exception.cxx @@ -2,122 +2,120 @@ namespace portaudio { - // ----------------------------------------------------------------------------------- - // PaException: - // ----------------------------------------------------------------------------------- - - ////// - /// Wraps a PortAudio error into a PortAudioCpp PaException. - ////// - PaException::PaException(PaError error) : error_(error) - { - } - - // ----------------------------------------------------------------------------------- - - ////// - /// Alias for paErrorText(), to have std::exception compliance. - ////// - const char *PaException::what() const throw() - { - return paErrorText(); - } - - // ----------------------------------------------------------------------------------- - - ////// - /// Returns the PortAudio error code (PaError). - ////// - PaError PaException::paError() const - { - return error_; - } - - ////// - /// Returns the error as a (zero-terminated) text string. - ////// - const char *PaException::paErrorText() const - { - return Pa_GetErrorText(error_); - } - - ////// - /// Returns true is the error is a HostApi error. - ////// - bool PaException::isHostApiError() const - { - return (error_ == paUnanticipatedHostError); - } - - ////// - /// Returns the last HostApi error (which is the current one if - /// isHostApiError() returns true) as an error code. - ////// - long PaException::lastHostApiError() const - { - return Pa_GetLastHostErrorInfo()->errorCode; - } - - ////// - /// Returns the last HostApi error (which is the current one if - /// isHostApiError() returns true) as a (zero-terminated) text - /// string, if it's available. - ////// - const char *PaException::lastHostApiErrorText() const - { - return Pa_GetLastHostErrorInfo()->errorText; - } - - // ----------------------------------------------------------------------------------- - - bool PaException::operator==(const PaException &rhs) const - { - return (error_ == rhs.error_); - } - - bool PaException::operator!=(const PaException &rhs) const - { - return !(*this == rhs); - } - - // ----------------------------------------------------------------------------------- - // PaCppException: - // ----------------------------------------------------------------------------------- - - PaCppException::PaCppException(ExceptionSpecifier specifier) : specifier_(specifier) - { - } - - const char *PaCppException::what() const throw() - { - switch (specifier_) - { - case UNABLE_TO_ADAPT_DEVICE: - { - return "Unable to adapt the given device to the specified host api specific device extension"; - } - } - - return "Unknown exception"; - } - - PaCppException::ExceptionSpecifier PaCppException::specifier() const - { - return specifier_; - } - - bool PaCppException::operator==(const PaCppException &rhs) const - { - return (specifier_ == rhs.specifier_); - } - - bool PaCppException::operator!=(const PaCppException &rhs) const - { - return !(*this == rhs); - } - - // ----------------------------------------------------------------------------------- + // ----------------------------------------------------------------------------------- + // PaException: + // ----------------------------------------------------------------------------------- + + ////// + /// Wraps a PortAudio error into a PortAudioCpp PaException. + ////// + PaException::PaException(PaError error) : error_(error) + { + } + + // ----------------------------------------------------------------------------------- + + ////// + /// Alias for paErrorText(), to have std::exception compliance. + ////// + const char *PaException::what() const throw() + { + return paErrorText(); + } + + // ----------------------------------------------------------------------------------- + + ////// + /// Returns the PortAudio error code (PaError). + ////// + PaError PaException::paError() const + { + return error_; + } + + ////// + /// Returns the error as a (zero-terminated) text string. + ////// + const char *PaException::paErrorText() const + { + return Pa_GetErrorText(error_); + } + + ////// + /// Returns true is the error is a HostApi error. + ////// + bool PaException::isHostApiError() const + { + return (error_ == paUnanticipatedHostError); + } + + ////// + /// Returns the last HostApi error (which is the current one if + /// isHostApiError() returns true) as an error code. + ////// + long PaException::lastHostApiError() const + { + return Pa_GetLastHostErrorInfo()->errorCode; + } + + ////// + /// Returns the last HostApi error (which is the current one if + /// isHostApiError() returns true) as a (zero-terminated) text + /// string, if it's available. + ////// + const char *PaException::lastHostApiErrorText() const + { + return Pa_GetLastHostErrorInfo()->errorText; + } + + // ----------------------------------------------------------------------------------- + + bool PaException::operator==(const PaException &rhs) const + { + return (error_ == rhs.error_); + } + + bool PaException::operator!=(const PaException &rhs) const + { + return !(*this == rhs); + } + + // ----------------------------------------------------------------------------------- + // PaCppException: + // ----------------------------------------------------------------------------------- + + PaCppException::PaCppException(ExceptionSpecifier specifier) : specifier_(specifier) + { + } + + const char *PaCppException::what() const throw() + { + switch (specifier_) + { + case UNABLE_TO_ADAPT_DEVICE: + { + return "Unable to adapt the given device to the specified host api specific device extension"; + } + } + + return "Unknown exception"; + } + + PaCppException::ExceptionSpecifier PaCppException::specifier() const + { + return specifier_; + } + + bool PaCppException::operator==(const PaCppException &rhs) const + { + return (specifier_ == rhs.specifier_); + } + + bool PaCppException::operator!=(const PaCppException &rhs) const + { + return !(*this == rhs); + } + + // ----------------------------------------------------------------------------------- } // namespace portaudio - - diff --git a/3rdparty/portaudio/bindings/cpp/source/portaudiocpp/HostApi.cxx b/3rdparty/portaudio/bindings/cpp/source/portaudiocpp/HostApi.cxx index 6a09670c002..ecc235376c8 100644 --- a/3rdparty/portaudio/bindings/cpp/source/portaudiocpp/HostApi.cxx +++ b/3rdparty/portaudio/bindings/cpp/source/portaudiocpp/HostApi.cxx @@ -8,114 +8,114 @@ namespace portaudio { - // ----------------------------------------------------------------------------------- - - HostApi::HostApi(PaHostApiIndex index) : devices_(NULL) - { - try - { - info_ = Pa_GetHostApiInfo(index); - - // Create and populate devices array: - int numDevices = deviceCount(); - - devices_ = new Device*[numDevices]; - - for (int i = 0; i < numDevices; ++i) - { - PaDeviceIndex deviceIndex = Pa_HostApiDeviceIndexToDeviceIndex(index, i); - - if (deviceIndex < 0) - { - throw PaException(deviceIndex); - } - - devices_[i] = &System::instance().deviceByIndex(deviceIndex); - } - } - catch (const std::exception &e) - { - // Delete any (partially) constructed objects (deconstructor isn't called): - delete[] devices_; // devices_ is either NULL or valid - - // Re-throw exception: - throw e; - } - } - - HostApi::~HostApi() - { - // Destroy devices array: - delete[] devices_; - } - - // ----------------------------------------------------------------------------------- - - PaHostApiTypeId HostApi::typeId() const - { - return info_->type; - } - - PaHostApiIndex HostApi::index() const - { - PaHostApiIndex index = Pa_HostApiTypeIdToHostApiIndex(typeId()); - - if (index < 0) - throw PaException(index); - - return index; - } - - const char *HostApi::name() const - { - return info_->name; - } - - int HostApi::deviceCount() const - { - return info_->deviceCount; - } - - // ----------------------------------------------------------------------------------- - - HostApi::DeviceIterator HostApi::devicesBegin() - { - DeviceIterator tmp; - tmp.ptr_ = &devices_[0]; // begin (first element) - return tmp; - } - - HostApi::DeviceIterator HostApi::devicesEnd() - { - DeviceIterator tmp; - tmp.ptr_ = &devices_[deviceCount()]; // end (one past last element) - return tmp; - } - - // ----------------------------------------------------------------------------------- - - Device &HostApi::defaultInputDevice() const - { - return System::instance().deviceByIndex(info_->defaultInputDevice); - } - - Device &HostApi::defaultOutputDevice() const - { - return System::instance().deviceByIndex(info_->defaultOutputDevice); - } - - // ----------------------------------------------------------------------------------- - - bool HostApi::operator==(const HostApi &rhs) const - { - return (typeId() == rhs.typeId()); - } - - bool HostApi::operator!=(const HostApi &rhs) const - { - return !(*this == rhs); - } - - // ----------------------------------------------------------------------------------- + // ----------------------------------------------------------------------------------- + + HostApi::HostApi(PaHostApiIndex index) : devices_(NULL) + { + try + { + info_ = Pa_GetHostApiInfo(index); + + // Create and populate devices array: + int numDevices = deviceCount(); + + devices_ = new Device*[numDevices]; + + for (int i = 0; i < numDevices; ++i) + { + PaDeviceIndex deviceIndex = Pa_HostApiDeviceIndexToDeviceIndex(index, i); + + if (deviceIndex < 0) + { + throw PaException(deviceIndex); + } + + devices_[i] = &System::instance().deviceByIndex(deviceIndex); + } + } + catch (const std::exception &e) + { + // Delete any (partially) constructed objects (deconstructor isn't called): + delete[] devices_; // devices_ is either NULL or valid + + // Re-throw exception: + throw e; + } + } + + HostApi::~HostApi() + { + // Destroy devices array: + delete[] devices_; + } + + // ----------------------------------------------------------------------------------- + + PaHostApiTypeId HostApi::typeId() const + { + return info_->type; + } + + PaHostApiIndex HostApi::index() const + { + PaHostApiIndex index = Pa_HostApiTypeIdToHostApiIndex(typeId()); + + if (index < 0) + throw PaException(index); + + return index; + } + + const char *HostApi::name() const + { + return info_->name; + } + + int HostApi::deviceCount() const + { + return info_->deviceCount; + } + + // ----------------------------------------------------------------------------------- + + HostApi::DeviceIterator HostApi::devicesBegin() + { + DeviceIterator tmp; + tmp.ptr_ = &devices_[0]; // begin (first element) + return tmp; + } + + HostApi::DeviceIterator HostApi::devicesEnd() + { + DeviceIterator tmp; + tmp.ptr_ = &devices_[deviceCount()]; // end (one past last element) + return tmp; + } + + // ----------------------------------------------------------------------------------- + + Device &HostApi::defaultInputDevice() const + { + return System::instance().deviceByIndex(info_->defaultInputDevice); + } + + Device &HostApi::defaultOutputDevice() const + { + return System::instance().deviceByIndex(info_->defaultOutputDevice); + } + + // ----------------------------------------------------------------------------------- + + bool HostApi::operator==(const HostApi &rhs) const + { + return (typeId() == rhs.typeId()); + } + + bool HostApi::operator!=(const HostApi &rhs) const + { + return !(*this == rhs); + } + + // ----------------------------------------------------------------------------------- } // namespace portaudio diff --git a/3rdparty/portaudio/bindings/cpp/source/portaudiocpp/InterfaceCallbackStream.cxx b/3rdparty/portaudio/bindings/cpp/source/portaudiocpp/InterfaceCallbackStream.cxx index 5433fa37321..fa761aa4d21 100644 --- a/3rdparty/portaudio/bindings/cpp/source/portaudiocpp/InterfaceCallbackStream.cxx +++ b/3rdparty/portaudio/bindings/cpp/source/portaudiocpp/InterfaceCallbackStream.cxx @@ -7,39 +7,39 @@ namespace portaudio { - // ---------------------------------------------------------------------------------== - - InterfaceCallbackStream::InterfaceCallbackStream() - { - } - - InterfaceCallbackStream::InterfaceCallbackStream(const StreamParameters ¶meters, CallbackInterface &instance) - { - open(parameters, instance); - } - - InterfaceCallbackStream::~InterfaceCallbackStream() - { - try - { - close(); - } - catch (...) - { - // ignore all errors - } - } - - // ---------------------------------------------------------------------------------== - - void InterfaceCallbackStream::open(const StreamParameters ¶meters, CallbackInterface &instance) - { - PaError err = Pa_OpenStream(&stream_, parameters.inputParameters().paStreamParameters(), parameters.outputParameters().paStreamParameters(), - parameters.sampleRate(), parameters.framesPerBuffer(), parameters.flags(), &impl::callbackInterfaceToPaCallbackAdapter, static_cast<void *>(&instance)); - - if (err != paNoError) - { - throw PaException(err); - } - } + // ---------------------------------------------------------------------------------== + + InterfaceCallbackStream::InterfaceCallbackStream() + { + } + + InterfaceCallbackStream::InterfaceCallbackStream(const StreamParameters ¶meters, CallbackInterface &instance) + { + open(parameters, instance); + } + + InterfaceCallbackStream::~InterfaceCallbackStream() + { + try + { + close(); + } + catch (...) + { + // ignore all errors + } + } + + // ---------------------------------------------------------------------------------== + + void InterfaceCallbackStream::open(const StreamParameters ¶meters, CallbackInterface &instance) + { + PaError err = Pa_OpenStream(&stream_, parameters.inputParameters().paStreamParameters(), parameters.outputParameters().paStreamParameters(), + parameters.sampleRate(), parameters.framesPerBuffer(), parameters.flags(), &impl::callbackInterfaceToPaCallbackAdapter, static_cast<void *>(&instance)); + + if (err != paNoError) + { + throw PaException(err); + } + } } diff --git a/3rdparty/portaudio/bindings/cpp/source/portaudiocpp/MemFunCallbackStream.cxx b/3rdparty/portaudio/bindings/cpp/source/portaudiocpp/MemFunCallbackStream.cxx index 5141de2aba0..4f955641eed 100644 --- a/3rdparty/portaudio/bindings/cpp/source/portaudiocpp/MemFunCallbackStream.cxx +++ b/3rdparty/portaudio/bindings/cpp/source/portaudiocpp/MemFunCallbackStream.cxx @@ -1,4 +1,3 @@ #include "portaudiocpp/MemFunCallbackStream.hxx" // (... template class ...) - diff --git a/3rdparty/portaudio/bindings/cpp/source/portaudiocpp/Stream.cxx b/3rdparty/portaudio/bindings/cpp/source/portaudiocpp/Stream.cxx index ba16e0335f9..c16a13c6f40 100644 --- a/3rdparty/portaudio/bindings/cpp/source/portaudiocpp/Stream.cxx +++ b/3rdparty/portaudio/bindings/cpp/source/portaudiocpp/Stream.cxx @@ -8,188 +8,188 @@ namespace portaudio { - // ----------------------------------------------------------------------------------- - - Stream::Stream() : stream_(NULL) - { - } - - Stream::~Stream() - { - // (can't call close here, - // the derived class should atleast call - // close() in it's deconstructor) - } - - // ----------------------------------------------------------------------------------- - - ////// - /// Closes the Stream if it's open, else does nothing. - ////// - void Stream::close() - { - if (isOpen() && System::exists()) - { - PaError err = Pa_CloseStream(stream_); - stream_ = NULL; - - if (err != paNoError) - throw PaException(err); - } - } - - ////// - /// Returns true if the Stream is open. - ////// - bool Stream::isOpen() const - { - return (stream_ != NULL); - } - - // ----------------------------------------------------------------------------------- - - void Stream::setStreamFinishedCallback(PaStreamFinishedCallback *callback) - { - PaError err = Pa_SetStreamFinishedCallback(stream_, callback); - - if (err != paNoError) - throw PaException(err); - } - - // ----------------------------------------------------------------------------------- - - void Stream::start() - { - PaError err = Pa_StartStream(stream_); - - if (err != paNoError) - throw PaException(err); - } - - void Stream::stop() - { - PaError err = Pa_StopStream(stream_); - - if (err != paNoError) - throw PaException(err); - } - - void Stream::abort() - { - PaError err = Pa_AbortStream(stream_); - - if (err != paNoError) - throw PaException(err); - } - - bool Stream::isStopped() const - { - PaError ret = Pa_IsStreamStopped(stream_); - - if (ret < 0) - throw PaException(ret); - - return (ret == 1); - } - - bool Stream::isActive() const - { - PaError ret = Pa_IsStreamActive(stream_); - - if (ret < 0) - throw PaException(ret); - - return (ret == 1); - } - - // ----------------------------------------------------------------------------------- - - ////// - /// Returns the best known input latency for the Stream. This value may differ from the - /// suggested input latency set in the StreamParameters. Includes all sources of - /// latency known to PortAudio such as internal buffering, and Host API reported latency. - /// Doesn't include any estimates of unknown latency. - ////// - PaTime Stream::inputLatency() const - { - const PaStreamInfo *info = Pa_GetStreamInfo(stream_); - if (info == NULL) - { - throw PaException(paInternalError); - return PaTime(0.0); - } - - return info->inputLatency; - } - - ////// - /// Returns the best known output latency for the Stream. This value may differ from the - /// suggested output latency set in the StreamParameters. Includes all sources of - /// latency known to PortAudio such as internal buffering, and Host API reported latency. - /// Doesn't include any estimates of unknown latency. - ////// - PaTime Stream::outputLatency() const - { - const PaStreamInfo *info = Pa_GetStreamInfo(stream_); - if (info == NULL) - { - throw PaException(paInternalError); - return PaTime(0.0); - } - - return info->outputLatency; - } - - ////// - /// Returns the sample rate of the Stream. Usually this will be the - /// best known estimate of the used sample rate. For instance when opening a - /// Stream setting 44100.0 Hz in the StreamParameters, the actual sample - /// rate might be something like 44103.2 Hz (due to imperfections in the - /// sound card hardware). - ////// - double Stream::sampleRate() const - { - const PaStreamInfo *info = Pa_GetStreamInfo(stream_); - if (info == NULL) - { - throw PaException(paInternalError); - return 0.0; - } - - return info->sampleRate; - } - - // ----------------------------------------------------------------------------------- - - PaTime Stream::time() const - { - return Pa_GetStreamTime(stream_); - } - - // ----------------------------------------------------------------------------------- - - ////// - /// Accessor (const) for PortAudio PaStream pointer, useful for interfacing with - /// PortAudio add-ons such as PortMixer for instance. Normally accessing this - /// pointer should not be needed as PortAudioCpp aims to provide all of PortAudio's - /// functionality. - ////// - const PaStream *Stream::paStream() const - { - return stream_; - } - - ////// - /// Accessor (non-const) for PortAudio PaStream pointer, useful for interfacing with - /// PortAudio add-ons such as PortMixer for instance. Normally accessing this - /// pointer should not be needed as PortAudioCpp aims to provide all of PortAudio's - /// functionality. - ////// - PaStream *Stream::paStream() - { - return stream_; - } - - // ----------------------------------------------------------------------------------- + // ----------------------------------------------------------------------------------- + + Stream::Stream() : stream_(NULL) + { + } + + Stream::~Stream() + { + // (can't call close here, + // the derived class should atleast call + // close() in it's deconstructor) + } + + // ----------------------------------------------------------------------------------- + + ////// + /// Closes the Stream if it's open, else does nothing. + ////// + void Stream::close() + { + if (isOpen() && System::exists()) + { + PaError err = Pa_CloseStream(stream_); + stream_ = NULL; + + if (err != paNoError) + throw PaException(err); + } + } + + ////// + /// Returns true if the Stream is open. + ////// + bool Stream::isOpen() const + { + return (stream_ != NULL); + } + + // ----------------------------------------------------------------------------------- + + void Stream::setStreamFinishedCallback(PaStreamFinishedCallback *callback) + { + PaError err = Pa_SetStreamFinishedCallback(stream_, callback); + + if (err != paNoError) + throw PaException(err); + } + + // ----------------------------------------------------------------------------------- + + void Stream::start() + { + PaError err = Pa_StartStream(stream_); + + if (err != paNoError) + throw PaException(err); + } + + void Stream::stop() + { + PaError err = Pa_StopStream(stream_); + + if (err != paNoError) + throw PaException(err); + } + + void Stream::abort() + { + PaError err = Pa_AbortStream(stream_); + + if (err != paNoError) + throw PaException(err); + } + + bool Stream::isStopped() const + { + PaError ret = Pa_IsStreamStopped(stream_); + + if (ret < 0) + throw PaException(ret); + + return (ret == 1); + } + + bool Stream::isActive() const + { + PaError ret = Pa_IsStreamActive(stream_); + + if (ret < 0) + throw PaException(ret); + + return (ret == 1); + } + + // ----------------------------------------------------------------------------------- + + ////// + /// Returns the best known input latency for the Stream. This value may differ from the + /// suggested input latency set in the StreamParameters. Includes all sources of + /// latency known to PortAudio such as internal buffering, and Host API reported latency. + /// Doesn't include any estimates of unknown latency. + ////// + PaTime Stream::inputLatency() const + { + const PaStreamInfo *info = Pa_GetStreamInfo(stream_); + if (info == NULL) + { + throw PaException(paInternalError); + return PaTime(0.0); + } + + return info->inputLatency; + } + + ////// + /// Returns the best known output latency for the Stream. This value may differ from the + /// suggested output latency set in the StreamParameters. Includes all sources of + /// latency known to PortAudio such as internal buffering, and Host API reported latency. + /// Doesn't include any estimates of unknown latency. + ////// + PaTime Stream::outputLatency() const + { + const PaStreamInfo *info = Pa_GetStreamInfo(stream_); + if (info == NULL) + { + throw PaException(paInternalError); + return PaTime(0.0); + } + + return info->outputLatency; + } + + ////// + /// Returns the sample rate of the Stream. Usually this will be the + /// best known estimate of the used sample rate. For instance when opening a + /// Stream setting 44100.0 Hz in the StreamParameters, the actual sample + /// rate might be something like 44103.2 Hz (due to imperfections in the + /// sound card hardware). + ////// + double Stream::sampleRate() const + { + const PaStreamInfo *info = Pa_GetStreamInfo(stream_); + if (info == NULL) + { + throw PaException(paInternalError); + return 0.0; + } + + return info->sampleRate; + } + + // ----------------------------------------------------------------------------------- + + PaTime Stream::time() const + { + return Pa_GetStreamTime(stream_); + } + + // ----------------------------------------------------------------------------------- + + ////// + /// Accessor (const) for PortAudio PaStream pointer, useful for interfacing with + /// PortAudio add-ons such as PortMixer for instance. Normally accessing this + /// pointer should not be needed as PortAudioCpp aims to provide all of PortAudio's + /// functionality. + ////// + const PaStream *Stream::paStream() const + { + return stream_; + } + + ////// + /// Accessor (non-const) for PortAudio PaStream pointer, useful for interfacing with + /// PortAudio add-ons such as PortMixer for instance. Normally accessing this + /// pointer should not be needed as PortAudioCpp aims to provide all of PortAudio's + /// functionality. + ////// + PaStream *Stream::paStream() + { + return stream_; + } + + // ----------------------------------------------------------------------------------- } // namespace portaudio diff --git a/3rdparty/portaudio/bindings/cpp/source/portaudiocpp/StreamParameters.cxx b/3rdparty/portaudio/bindings/cpp/source/portaudiocpp/StreamParameters.cxx index 5b9e89716a2..11de3094d52 100644 --- a/3rdparty/portaudio/bindings/cpp/source/portaudiocpp/StreamParameters.cxx +++ b/3rdparty/portaudio/bindings/cpp/source/portaudiocpp/StreamParameters.cxx @@ -6,160 +6,155 @@ namespace portaudio { - // ----------------------------------------------------------------------------------- - - ////// - /// Default constructor; does nothing. - ////// - StreamParameters::StreamParameters() - { - } - - ////// - /// Sets up the all parameters needed to open either a half-duplex or full-duplex Stream. - /// - /// @param inputParameters The parameters for the input direction of the to-be opened - /// Stream or DirectionSpecificStreamParameters::null() for an output-only Stream. - /// @param outputParameters The parameters for the output direction of the to-be opened - /// Stream or DirectionSpecificStreamParameters::null() for an input-only Stream. - /// @param sampleRate The to-be opened Stream's sample rate in Hz. - /// @param framesPerBuffer The number of frames per buffer for a CallbackStream, or - /// the preferred buffer granularity for a BlockingStream. - /// @param flags The flags for the to-be opened Stream; default paNoFlag. - ////// - StreamParameters::StreamParameters(const DirectionSpecificStreamParameters &inputParameters, - const DirectionSpecificStreamParameters &outputParameters, double sampleRate, unsigned long framesPerBuffer, - PaStreamFlags flags) : inputParameters_(inputParameters), outputParameters_(outputParameters), - sampleRate_(sampleRate), framesPerBuffer_(framesPerBuffer), flags_(flags) - { - } - - // ----------------------------------------------------------------------------------- - - ////// - /// Sets the requested sample rate. If this sample rate isn't supported by the hardware, the - /// Stream will fail to open. The real-life sample rate used might differ slightly due to - /// imperfections in the sound card hardware; use Stream::sampleRate() to retreive the - /// best known estimate for this value. - ////// - void StreamParameters::setSampleRate(double sampleRate) - { - sampleRate_ = sampleRate; - } - - ////// - /// Either the number of frames per buffer for a CallbackStream, or - /// the preferred buffer granularity for a BlockingStream. See PortAudio - /// documentation. - ////// - void StreamParameters::setFramesPerBuffer(unsigned long framesPerBuffer) - { - framesPerBuffer_ = framesPerBuffer; - } - - ////// - /// Sets the specified flag or does nothing when the flag is already set. Doesn't - /// `unset' any previously existing flags (use clearFlags() for that). - ////// - void StreamParameters::setFlag(PaStreamFlags flag) - { - flags_ |= flag; - } - - ////// - /// Unsets the specified flag or does nothing if the flag isn't set. Doesn't affect - /// any other flags. - ////// - void StreamParameters::unsetFlag(PaStreamFlags flag) - { - flags_ &= ~flag; - } - - ////// - /// Clears or `unsets' all set flags. - ////// - void StreamParameters::clearFlags() - { - flags_ = paNoFlag; - } - - // ----------------------------------------------------------------------------------- - - void StreamParameters::setInputParameters(const DirectionSpecificStreamParameters ¶meters) - { - inputParameters_ = parameters; - } - - void StreamParameters::setOutputParameters(const DirectionSpecificStreamParameters ¶meters) - { - outputParameters_ = parameters; - } - - // ----------------------------------------------------------------------------------- - - bool StreamParameters::isSupported() const - { - return (Pa_IsFormatSupported(inputParameters_.paStreamParameters(), - outputParameters_.paStreamParameters(), sampleRate_) == paFormatIsSupported); - } - - // ----------------------------------------------------------------------------------- - - double StreamParameters::sampleRate() const - { - return sampleRate_; - } - - unsigned long StreamParameters::framesPerBuffer() const - { - return framesPerBuffer_; - } - - ////// - /// Returns all currently set flags as a binary combined - /// integer value (PaStreamFlags). Use isFlagSet() to - /// avoid dealing with the bitmasks. - ////// - PaStreamFlags StreamParameters::flags() const - { - return flags_; - } - - ////// - /// Returns true if the specified flag is currently set - /// or false if it isn't. - ////// - bool StreamParameters::isFlagSet(PaStreamFlags flag) const - { - return ((flags_ & flag) != 0); - } - - // ----------------------------------------------------------------------------------- - - DirectionSpecificStreamParameters &StreamParameters::inputParameters() - { - return inputParameters_; - } - - const DirectionSpecificStreamParameters &StreamParameters::inputParameters() const - { - return inputParameters_; - } - - DirectionSpecificStreamParameters &StreamParameters::outputParameters() - { - return outputParameters_; - } - - const DirectionSpecificStreamParameters &StreamParameters::outputParameters() const - { - return outputParameters_; - } - - // ----------------------------------------------------------------------------------- + // ----------------------------------------------------------------------------------- + + ////// + /// Default constructor; does nothing. + ////// + StreamParameters::StreamParameters() + { + } + + ////// + /// Sets up the all parameters needed to open either a half-duplex or full-duplex Stream. + /// + /// @param inputParameters The parameters for the input direction of the to-be opened + /// Stream or DirectionSpecificStreamParameters::null() for an output-only Stream. + /// @param outputParameters The parameters for the output direction of the to-be opened + /// Stream or DirectionSpecificStreamParameters::null() for an input-only Stream. + /// @param sampleRate The to-be opened Stream's sample rate in Hz. + /// @param framesPerBuffer The number of frames per buffer for a CallbackStream, or + /// the preferred buffer granularity for a BlockingStream. + /// @param flags The flags for the to-be opened Stream; default paNoFlag. + ////// + StreamParameters::StreamParameters(const DirectionSpecificStreamParameters &inputParameters, + const DirectionSpecificStreamParameters &outputParameters, double sampleRate, unsigned long framesPerBuffer, + PaStreamFlags flags) : inputParameters_(inputParameters), outputParameters_(outputParameters), + sampleRate_(sampleRate), framesPerBuffer_(framesPerBuffer), flags_(flags) + { + } + + // ----------------------------------------------------------------------------------- + + ////// + /// Sets the requested sample rate. If this sample rate isn't supported by the hardware, the + /// Stream will fail to open. The real-life sample rate used might differ slightly due to + /// imperfections in the sound card hardware; use Stream::sampleRate() to retrieve the + /// best known estimate for this value. + ////// + void StreamParameters::setSampleRate(double sampleRate) + { + sampleRate_ = sampleRate; + } + + ////// + /// Either the number of frames per buffer for a CallbackStream, or + /// the preferred buffer granularity for a BlockingStream. See PortAudio + /// documentation. + ////// + void StreamParameters::setFramesPerBuffer(unsigned long framesPerBuffer) + { + framesPerBuffer_ = framesPerBuffer; + } + + ////// + /// Sets the specified flag or does nothing when the flag is already set. Doesn't + /// `unset' any previously existing flags (use clearFlags() for that). + ////// + void StreamParameters::setFlag(PaStreamFlags flag) + { + flags_ |= flag; + } + + ////// + /// Unsets the specified flag or does nothing if the flag isn't set. Doesn't affect + /// any other flags. + ////// + void StreamParameters::unsetFlag(PaStreamFlags flag) + { + flags_ &= ~flag; + } + + ////// + /// Clears or `unsets' all set flags. + ////// + void StreamParameters::clearFlags() + { + flags_ = paNoFlag; + } + + // ----------------------------------------------------------------------------------- + + void StreamParameters::setInputParameters(const DirectionSpecificStreamParameters ¶meters) + { + inputParameters_ = parameters; + } + + void StreamParameters::setOutputParameters(const DirectionSpecificStreamParameters ¶meters) + { + outputParameters_ = parameters; + } + + // ----------------------------------------------------------------------------------- + + bool StreamParameters::isSupported() const + { + return (Pa_IsFormatSupported(inputParameters_.paStreamParameters(), + outputParameters_.paStreamParameters(), sampleRate_) == paFormatIsSupported); + } + + // ----------------------------------------------------------------------------------- + + double StreamParameters::sampleRate() const + { + return sampleRate_; + } + + unsigned long StreamParameters::framesPerBuffer() const + { + return framesPerBuffer_; + } + + ////// + /// Returns all currently set flags as a binary combined + /// integer value (PaStreamFlags). Use isFlagSet() to + /// avoid dealing with the bitmasks. + ////// + PaStreamFlags StreamParameters::flags() const + { + return flags_; + } + + ////// + /// Returns true if the specified flag is currently set + /// or false if it isn't. + ////// + bool StreamParameters::isFlagSet(PaStreamFlags flag) const + { + return ((flags_ & flag) != 0); + } + + // ----------------------------------------------------------------------------------- + + DirectionSpecificStreamParameters &StreamParameters::inputParameters() + { + return inputParameters_; + } + + const DirectionSpecificStreamParameters &StreamParameters::inputParameters() const + { + return inputParameters_; + } + + DirectionSpecificStreamParameters &StreamParameters::outputParameters() + { + return outputParameters_; + } + + const DirectionSpecificStreamParameters &StreamParameters::outputParameters() const + { + return outputParameters_; + } + + // ----------------------------------------------------------------------------------- } // namespace portaudio - - - - - diff --git a/3rdparty/portaudio/bindings/cpp/source/portaudiocpp/System.cxx b/3rdparty/portaudio/bindings/cpp/source/portaudiocpp/System.cxx index acb419d4aa8..1e03dc884a7 100644 --- a/3rdparty/portaudio/bindings/cpp/source/portaudiocpp/System.cxx +++ b/3rdparty/portaudio/bindings/cpp/source/portaudiocpp/System.cxx @@ -12,297 +12,296 @@ namespace portaudio { - // ----------------------------------------------------------------------------------- - - // Static members: - System *System::instance_ = NULL; - int System::initCount_ = 0; - HostApi **System::hostApis_ = NULL; - Device **System::devices_ = NULL; - Device *System::nullDevice_ = NULL; - - // ----------------------------------------------------------------------------------- - - int System::version() - { - return Pa_GetVersion(); - } - - const char *System::versionText() - { - return Pa_GetVersionText(); - } - - void System::initialize() - { - ++initCount_; - - if (initCount_ == 1) - { - // Create singleton: - assert(instance_ == NULL); - instance_ = new System(); - - // Initialize the PortAudio system: - { - PaError err = Pa_Initialize(); - - if (err != paNoError) - throw PaException(err); - } - - // Create and populate device array: - { - int numDevices = instance().deviceCount(); - - devices_ = new Device*[numDevices]; - - for (int i = 0; i < numDevices; ++i) - devices_[i] = new Device(i); - } - - // Create and populate host api array: - { - int numHostApis = instance().hostApiCount(); - - hostApis_ = new HostApi*[numHostApis]; - - for (int i = 0; i < numHostApis; ++i) - hostApis_[i] = new HostApi(i); - } - - // Create null device: - nullDevice_ = new Device(paNoDevice); - } - } - - void System::terminate() - { - PaError err = paNoError; - - if (initCount_ == 1) - { - // Destroy null device: - delete nullDevice_; - - // Destroy host api array: - { - if (hostApis_ != NULL) - { - int numHostApis = instance().hostApiCount(); - - for (int i = 0; i < numHostApis; ++i) - delete hostApis_[i]; - - delete[] hostApis_; - hostApis_ = NULL; - } - } + // ----------------------------------------------------------------------------------- + + // Static members: + System *System::instance_ = NULL; + int System::initCount_ = 0; + HostApi **System::hostApis_ = NULL; + Device **System::devices_ = NULL; + Device *System::nullDevice_ = NULL; + + // ----------------------------------------------------------------------------------- + + int System::version() + { + return Pa_GetVersion(); + } + + const char *System::versionText() + { + return Pa_GetVersionText(); + } + + void System::initialize() + { + ++initCount_; - // Destroy device array: - { - if (devices_ != NULL) - { - int numDevices = instance().deviceCount(); + if (initCount_ == 1) + { + // Create singleton: + assert(instance_ == NULL); + instance_ = new System(); - for (int i = 0; i < numDevices; ++i) - delete devices_[i]; + // Initialize the PortAudio system: + { + PaError err = Pa_Initialize(); - delete[] devices_; - devices_ = NULL; - } - } + if (err != paNoError) + throw PaException(err); + } - // Terminate the PortAudio system: - assert(instance_ != NULL); - err = Pa_Terminate(); + // Create and populate device array: + { + int numDevices = instance().deviceCount(); - // Destroy singleton: - delete instance_; - instance_ = NULL; - } + devices_ = new Device*[numDevices]; + + for (int i = 0; i < numDevices; ++i) + devices_[i] = new Device(i); + } + + // Create and populate host api array: + { + int numHostApis = instance().hostApiCount(); + + hostApis_ = new HostApi*[numHostApis]; - if (initCount_ > 0) - --initCount_; - - if (err != paNoError) - throw PaException(err); - } - - - System &System::instance() - { - assert(exists()); - - return *instance_; - } - - bool System::exists() - { - return (instance_ != NULL); - } - - // ----------------------------------------------------------------------------------- - - System::HostApiIterator System::hostApisBegin() - { - System::HostApiIterator tmp; - tmp.ptr_ = &hostApis_[0]; // begin (first element) - return tmp; - } - - System::HostApiIterator System::hostApisEnd() - { - int count = hostApiCount(); - - System::HostApiIterator tmp; - tmp.ptr_ = &hostApis_[count]; // end (one past last element) - return tmp; - } - - HostApi &System::defaultHostApi() - { - PaHostApiIndex defaultHostApi = Pa_GetDefaultHostApi(); - - if (defaultHostApi < 0) - throw PaException(defaultHostApi); - - return *hostApis_[defaultHostApi]; - } - - HostApi &System::hostApiByTypeId(PaHostApiTypeId type) - { - PaHostApiIndex index = Pa_HostApiTypeIdToHostApiIndex(type); - - if (index < 0) - throw PaException(index); - - return *hostApis_[index]; - } - - HostApi &System::hostApiByIndex(PaHostApiIndex index) - { - if (index < 0 || index >= hostApiCount()) - throw PaException(paInternalError); - - return *hostApis_[index]; - } - - int System::hostApiCount() - { - PaHostApiIndex count = Pa_GetHostApiCount(); - - if (count < 0) - throw PaException(count); - - return count; - } - - // ----------------------------------------------------------------------------------- - - System::DeviceIterator System::devicesBegin() - { - DeviceIterator tmp; - tmp.ptr_ = &devices_[0]; - - return tmp; - } - - System::DeviceIterator System::devicesEnd() - { - int count = deviceCount(); - - DeviceIterator tmp; - tmp.ptr_ = &devices_[count]; - - return tmp; - } - - ////// - /// Returns the System's default input Device, or the null Device if none - /// was available. - ////// - Device &System::defaultInputDevice() - { - PaDeviceIndex index = Pa_GetDefaultInputDevice(); - return deviceByIndex(index); - } - - ////// - /// Returns the System's default output Device, or the null Device if none - /// was available. - ////// - Device &System::defaultOutputDevice() - { - PaDeviceIndex index = Pa_GetDefaultOutputDevice(); - return deviceByIndex(index); - } - - ////// - /// Returns the Device for the given index. - /// Will throw a paInternalError equivalent PaException if the given index - /// is out of range. - ////// - Device &System::deviceByIndex(PaDeviceIndex index) - { - if (index < -1 || index >= deviceCount()) - { - throw PaException(paInternalError); - } - - if (index == -1) - return System::instance().nullDevice(); - - return *devices_[index]; - } - - int System::deviceCount() - { - PaDeviceIndex count = Pa_GetDeviceCount(); - - if (count < 0) - throw PaException(count); - - return count; - } - - Device &System::nullDevice() - { - return *nullDevice_; - } - - // ----------------------------------------------------------------------------------- - - void System::sleep(long msec) - { - Pa_Sleep(msec); - } - - int System::sizeOfSample(PaSampleFormat format) - { - PaError err = Pa_GetSampleSize(format); - if (err < 0) - { - throw PaException(err); - return 0; - } - - return err; - } - - // ----------------------------------------------------------------------------------- - - System::System() - { - // (left blank intentionally) - } - - System::~System() - { - // (left blank intentionally) - } - - // ----------------------------------------------------------------------------------- + for (int i = 0; i < numHostApis; ++i) + hostApis_[i] = new HostApi(i); + } -} // namespace portaudio + // Create null device: + nullDevice_ = new Device(paNoDevice); + } + } + + void System::terminate() + { + PaError err = paNoError; + + if (initCount_ == 1) + { + // Destroy null device: + delete nullDevice_; + + // Destroy host api array: + { + if (hostApis_ != NULL) + { + int numHostApis = instance().hostApiCount(); + + for (int i = 0; i < numHostApis; ++i) + delete hostApis_[i]; + + delete[] hostApis_; + hostApis_ = NULL; + } + } + + // Destroy device array: + { + if (devices_ != NULL) + { + int numDevices = instance().deviceCount(); + + for (int i = 0; i < numDevices; ++i) + delete devices_[i]; + + delete[] devices_; + devices_ = NULL; + } + } + // Terminate the PortAudio system: + assert(instance_ != NULL); + err = Pa_Terminate(); + + // Destroy singleton: + delete instance_; + instance_ = NULL; + } + + if (initCount_ > 0) + --initCount_; + + if (err != paNoError) + throw PaException(err); + } + + + System &System::instance() + { + assert(exists()); + + return *instance_; + } + + bool System::exists() + { + return (instance_ != NULL); + } + + // ----------------------------------------------------------------------------------- + + System::HostApiIterator System::hostApisBegin() + { + System::HostApiIterator tmp; + tmp.ptr_ = &hostApis_[0]; // begin (first element) + return tmp; + } + + System::HostApiIterator System::hostApisEnd() + { + int count = hostApiCount(); + + System::HostApiIterator tmp; + tmp.ptr_ = &hostApis_[count]; // end (one past last element) + return tmp; + } + + HostApi &System::defaultHostApi() + { + PaHostApiIndex defaultHostApi = Pa_GetDefaultHostApi(); + + if (defaultHostApi < 0) + throw PaException(defaultHostApi); + + return *hostApis_[defaultHostApi]; + } + + HostApi &System::hostApiByTypeId(PaHostApiTypeId type) + { + PaHostApiIndex index = Pa_HostApiTypeIdToHostApiIndex(type); + + if (index < 0) + throw PaException(index); + + return *hostApis_[index]; + } + + HostApi &System::hostApiByIndex(PaHostApiIndex index) + { + if (index < 0 || index >= hostApiCount()) + throw PaException(paInternalError); + + return *hostApis_[index]; + } + + int System::hostApiCount() + { + PaHostApiIndex count = Pa_GetHostApiCount(); + + if (count < 0) + throw PaException(count); + + return count; + } + + // ----------------------------------------------------------------------------------- + + System::DeviceIterator System::devicesBegin() + { + DeviceIterator tmp; + tmp.ptr_ = &devices_[0]; + + return tmp; + } + + System::DeviceIterator System::devicesEnd() + { + int count = deviceCount(); + + DeviceIterator tmp; + tmp.ptr_ = &devices_[count]; + + return tmp; + } + + ////// + /// Returns the System's default input Device, or the null Device if none + /// was available. + ////// + Device &System::defaultInputDevice() + { + PaDeviceIndex index = Pa_GetDefaultInputDevice(); + return deviceByIndex(index); + } + + ////// + /// Returns the System's default output Device, or the null Device if none + /// was available. + ////// + Device &System::defaultOutputDevice() + { + PaDeviceIndex index = Pa_GetDefaultOutputDevice(); + return deviceByIndex(index); + } + + ////// + /// Returns the Device for the given index. + /// Will throw a paInternalError equivalent PaException if the given index + /// is out of range. + ////// + Device &System::deviceByIndex(PaDeviceIndex index) + { + if (index < -1 || index >= deviceCount()) + { + throw PaException(paInternalError); + } + + if (index == -1) + return System::instance().nullDevice(); + + return *devices_[index]; + } + + int System::deviceCount() + { + PaDeviceIndex count = Pa_GetDeviceCount(); + + if (count < 0) + throw PaException(count); + + return count; + } + + Device &System::nullDevice() + { + return *nullDevice_; + } + + // ----------------------------------------------------------------------------------- + + void System::sleep(long msec) + { + Pa_Sleep(msec); + } + + int System::sizeOfSample(PaSampleFormat format) + { + PaError err = Pa_GetSampleSize(format); + if (err < 0) + { + throw PaException(err); + return 0; + } + + return err; + } + + // ----------------------------------------------------------------------------------- + + System::System() + { + // (left blank intentionally) + } + + System::~System() + { + // (left blank intentionally) + } + + // ----------------------------------------------------------------------------------- + +} // namespace portaudio diff --git a/3rdparty/portaudio/bindings/cpp/source/portaudiocpp/SystemDeviceIterator.cxx b/3rdparty/portaudio/bindings/cpp/source/portaudiocpp/SystemDeviceIterator.cxx index f94cf10aab2..72dddbc32e2 100644 --- a/3rdparty/portaudio/bindings/cpp/source/portaudiocpp/SystemDeviceIterator.cxx +++ b/3rdparty/portaudio/bindings/cpp/source/portaudiocpp/SystemDeviceIterator.cxx @@ -2,59 +2,57 @@ namespace portaudio { - // ----------------------------------------------------------------------------------- - - Device &System::DeviceIterator::operator*() const - { - return **ptr_; - } - - Device *System::DeviceIterator::operator->() const - { - return &**this; - } - - // ----------------------------------------------------------------------------------- - - System::DeviceIterator &System::DeviceIterator::operator++() - { - ++ptr_; - return *this; - } - - System::DeviceIterator System::DeviceIterator::operator++(int) - { - System::DeviceIterator prev = *this; - ++*this; - return prev; - } - - System::DeviceIterator &System::DeviceIterator::operator--() - { - --ptr_; - return *this; - } - - System::DeviceIterator System::DeviceIterator::operator--(int) - { - System::DeviceIterator prev = *this; - --*this; - return prev; - } - - // ----------------------------------------------------------------------------------- - - bool System::DeviceIterator::operator==(const System::DeviceIterator &rhs) const - { - return (ptr_ == rhs.ptr_); - } - - bool System::DeviceIterator::operator!=(const System::DeviceIterator &rhs) const - { - return !(*this == rhs); - } - - // ----------------------------------------------------------------------------------- + // ----------------------------------------------------------------------------------- + + Device &System::DeviceIterator::operator*() const + { + return **ptr_; + } + + Device *System::DeviceIterator::operator->() const + { + return &**this; + } + + // ----------------------------------------------------------------------------------- + + System::DeviceIterator &System::DeviceIterator::operator++() + { + ++ptr_; + return *this; + } + + System::DeviceIterator System::DeviceIterator::operator++(int) + { + System::DeviceIterator prev = *this; + ++*this; + return prev; + } + + System::DeviceIterator &System::DeviceIterator::operator--() + { + --ptr_; + return *this; + } + + System::DeviceIterator System::DeviceIterator::operator--(int) + { + System::DeviceIterator prev = *this; + --*this; + return prev; + } + + // ----------------------------------------------------------------------------------- + + bool System::DeviceIterator::operator==(const System::DeviceIterator &rhs) const + { + return (ptr_ == rhs.ptr_); + } + + bool System::DeviceIterator::operator!=(const System::DeviceIterator &rhs) const + { + return !(*this == rhs); + } + + // ----------------------------------------------------------------------------------- } // namespace portaudio - - diff --git a/3rdparty/portaudio/bindings/cpp/source/portaudiocpp/SystemHostApiIterator.cxx b/3rdparty/portaudio/bindings/cpp/source/portaudiocpp/SystemHostApiIterator.cxx index 03f2d6e47bd..bca25fc1d49 100644 --- a/3rdparty/portaudio/bindings/cpp/source/portaudiocpp/SystemHostApiIterator.cxx +++ b/3rdparty/portaudio/bindings/cpp/source/portaudiocpp/SystemHostApiIterator.cxx @@ -2,58 +2,57 @@ namespace portaudio { - // ----------------------------------------------------------------------------------- - - HostApi &System::HostApiIterator::operator*() const - { - return **ptr_; - } - - HostApi *System::HostApiIterator::operator->() const - { - return &**this; - } - - // ----------------------------------------------------------------------------------- - - System::HostApiIterator &System::HostApiIterator::operator++() - { - ++ptr_; - return *this; - } - - System::HostApiIterator System::HostApiIterator::operator++(int) - { - System::HostApiIterator prev = *this; - ++*this; - return prev; - } - - System::HostApiIterator &System::HostApiIterator::operator--() - { - --ptr_; - return *this; - } - - System::HostApiIterator System::HostApiIterator::operator--(int) - { - System::HostApiIterator prev = *this; - --*this; - return prev; - } - - // ----------------------------------------------------------------------------------- - - bool System::HostApiIterator::operator==(const System::HostApiIterator &rhs) const - { - return (ptr_ == rhs.ptr_); - } - - bool System::HostApiIterator::operator!=(const System::HostApiIterator &rhs) const - { - return !(*this == rhs); - } - - // ----------------------------------------------------------------------------------- + // ----------------------------------------------------------------------------------- + + HostApi &System::HostApiIterator::operator*() const + { + return **ptr_; + } + + HostApi *System::HostApiIterator::operator->() const + { + return &**this; + } + + // ----------------------------------------------------------------------------------- + + System::HostApiIterator &System::HostApiIterator::operator++() + { + ++ptr_; + return *this; + } + + System::HostApiIterator System::HostApiIterator::operator++(int) + { + System::HostApiIterator prev = *this; + ++*this; + return prev; + } + + System::HostApiIterator &System::HostApiIterator::operator--() + { + --ptr_; + return *this; + } + + System::HostApiIterator System::HostApiIterator::operator--(int) + { + System::HostApiIterator prev = *this; + --*this; + return prev; + } + + // ----------------------------------------------------------------------------------- + + bool System::HostApiIterator::operator==(const System::HostApiIterator &rhs) const + { + return (ptr_ == rhs.ptr_); + } + + bool System::HostApiIterator::operator!=(const System::HostApiIterator &rhs) const + { + return !(*this == rhs); + } + + // ----------------------------------------------------------------------------------- } // namespace portaudio - |