mirror of
https://github.com/SysRay/psOff_public.git
synced 2024-12-13 17:16:07 +00:00
Merge remote-tracking branch 'origin/main' into feature
This commit is contained in:
commit
adc31d05ce
92
.github/workflows/build.yml
vendored
Normal file
92
.github/workflows/build.yml
vendored
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
name: build
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
types: [opened, reopened, synchronize]
|
||||||
|
paths:
|
||||||
|
- '.github/workflows/build.yml'
|
||||||
|
- '**/CMakeLists.txt'
|
||||||
|
- 'CMakeLists.txt'
|
||||||
|
- '**.cmake'
|
||||||
|
- '**.cpp'
|
||||||
|
- '**.cxx'
|
||||||
|
- '**.cc'
|
||||||
|
- '**.c'
|
||||||
|
- '**.hpp'
|
||||||
|
- '**.hh'
|
||||||
|
- '**.h'
|
||||||
|
|
||||||
|
push:
|
||||||
|
paths:
|
||||||
|
- '.github/workflows/build.yml'
|
||||||
|
- '**/CMakeLists.txt'
|
||||||
|
- 'CMakeLists.txt'
|
||||||
|
- '**.cmake'
|
||||||
|
- '**.cpp'
|
||||||
|
- '**.cxx'
|
||||||
|
- '**.cc'
|
||||||
|
- '**.c'
|
||||||
|
- '**.hpp'
|
||||||
|
- '**.hh'
|
||||||
|
- '**.h'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
formatting-check:
|
||||||
|
name: Formatting check
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Run clang-format
|
||||||
|
uses: jidicula/clang-format-action@v4.11.0
|
||||||
|
with:
|
||||||
|
clang-format-version: 17
|
||||||
|
exclude-regex: (third_party|vk_mem_alloc)
|
||||||
|
|
||||||
|
build:
|
||||||
|
needs: formatting-check
|
||||||
|
name: Emulator
|
||||||
|
runs-on: windows-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Restore cached deps
|
||||||
|
uses: actions/cache@v4
|
||||||
|
id: cache-thirdparty
|
||||||
|
with:
|
||||||
|
path: third_party
|
||||||
|
key: ${{ runner.os }}-submodules
|
||||||
|
|
||||||
|
- name: Update submodules
|
||||||
|
if: steps.cache-thirdparty.outputs.cache-hit != 'true'
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
submodules: recursive
|
||||||
|
|
||||||
|
- name: Detect MSVC
|
||||||
|
uses: ilammy/msvc-dev-cmd@v1
|
||||||
|
with:
|
||||||
|
arch: x86_64
|
||||||
|
|
||||||
|
- name: Prepare Vulkan SDK
|
||||||
|
uses: humbletim/install-vulkan-sdk@c2aa128094d42ba02959a660f03e0a4e012192f9
|
||||||
|
with:
|
||||||
|
version: 1.3.275.0
|
||||||
|
cache: true
|
||||||
|
|
||||||
|
- name: Configure
|
||||||
|
run: cmake.exe -S. -B_build/_Release -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=_build/_Install -DCMAKE_C_COMPILER=clang-cl.exe -DCMAKE_CXX_COMPILER=clang-cl.exe
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
run: cmake --build _build/_Release -j4
|
||||||
|
|
||||||
|
- name: Install
|
||||||
|
run: cmake.exe --install _build/_Release
|
||||||
|
|
||||||
|
- name: Upload artifacts
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: psOff-libs
|
||||||
|
path: _build/_Install/*
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,3 +1,5 @@
|
|||||||
_*/
|
_*/
|
||||||
.*/
|
.*/
|
||||||
!.vscode
|
!.vscode
|
||||||
|
!.github
|
||||||
|
.vscode/c_cpp_properties.json
|
||||||
|
7
.gitmodules
vendored
7
.gitmodules
vendored
@ -1,12 +1,13 @@
|
|||||||
[submodule "third_party/optick"]
|
[submodule "third_party/optick"]
|
||||||
path = third_party/optick
|
path = third_party/optick
|
||||||
url = https://github.com/bombomby/optick.git
|
url = https://github.com/bombomby/optick.git
|
||||||
[submodule "third_party/glfw"]
|
|
||||||
path = third_party/glfw
|
|
||||||
url = https://github.com/glfw/glfw.git
|
|
||||||
[submodule "third_party/magic_enum"]
|
[submodule "third_party/magic_enum"]
|
||||||
path = third_party/magic_enum
|
path = third_party/magic_enum
|
||||||
url = https://github.com/Neargye/magic_enum.git
|
url = https://github.com/Neargye/magic_enum.git
|
||||||
[submodule "third_party/boost"]
|
[submodule "third_party/boost"]
|
||||||
path = third_party/boost
|
path = third_party/boost
|
||||||
url = https://github.com/boostorg/boost.git
|
url = https://github.com/boostorg/boost.git
|
||||||
|
[submodule "third_party/SDL2"]
|
||||||
|
path = third_party/SDL2
|
||||||
|
url = https://github.com/libsdl-org/SDL.git
|
||||||
|
branch = SDL2
|
||||||
|
16
.vscode/launch.json
vendored
Normal file
16
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "(Windows) Launch",
|
||||||
|
"type": "cppvsdbg",
|
||||||
|
"request": "launch",
|
||||||
|
"program": "${config:psoff.root-path}/emulator.exe",
|
||||||
|
"args": ["--file", "${config:psoff.game-path}/eboot.bin"],
|
||||||
|
"stopAtEntry": false,
|
||||||
|
"cwd": "${config:psoff.root-path}",
|
||||||
|
"environment": [],
|
||||||
|
"console": "integratedTerminal"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
15
.vscode/settings.json
vendored
15
.vscode/settings.json
vendored
@ -16,11 +16,18 @@
|
|||||||
"ccls.index.threads": 0,
|
"ccls.index.threads": 0,
|
||||||
|
|
||||||
"cmake.buildDirectory": "${workspaceFolder}/_build",
|
"cmake.buildDirectory": "${workspaceFolder}/_build",
|
||||||
|
"cmake.installPrefix": "_Install",
|
||||||
|
"cmake.sourceDirectory": "${workspaceFolder}",
|
||||||
|
"C_Cpp.default.intelliSenseMode": "windows-clang-x64",
|
||||||
|
"C_Cpp.default.cppStandard": "c++20",
|
||||||
|
"C_Cpp.autoAddFileAssociations": false,
|
||||||
|
"cmake.generator": "Ninja",
|
||||||
"editor.tabSize": 2,
|
"editor.tabSize": 2,
|
||||||
|
"editor.insertSpaces": true,
|
||||||
"git.ignoredRepositories": [
|
"git.ignoredRepositories": [
|
||||||
"third_party/boost",
|
"third_party/boost",
|
||||||
"third_party/optick",
|
"third_party/optick",
|
||||||
"third_party/glfw",
|
"third_party/magic_enum",
|
||||||
"third_party/magic_enum"
|
"third_part/SDL2"
|
||||||
],
|
]
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,7 @@ file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/lib) # Move all libs here post-build, ex
|
|||||||
#
|
#
|
||||||
include_directories(BEFORE
|
include_directories(BEFORE
|
||||||
${CMAKE_INSTALL_PREFIX}/development/include
|
${CMAKE_INSTALL_PREFIX}/development/include
|
||||||
|
${PRJ_SRC_DIR}/third_party/SDL2/include
|
||||||
${PRJ_SRC_DIR}/modules_include
|
${PRJ_SRC_DIR}/modules_include
|
||||||
${PRJ_SRC_DIR}/tools/logging
|
${PRJ_SRC_DIR}/tools/logging
|
||||||
${PRJ_SRC_DIR}
|
${PRJ_SRC_DIR}
|
||||||
@ -75,4 +76,4 @@ install(DIRECTORY "${CMAKE_BINARY_DIR}/third_party/bin/" DESTINATION ${CMAKE_INS
|
|||||||
)
|
)
|
||||||
install(DIRECTORY "${CMAKE_BINARY_DIR}/third_party/install/bin/" DESTINATION ${CMAKE_INSTALL_PREFIX}
|
install(DIRECTORY "${CMAKE_BINARY_DIR}/third_party/install/bin/" DESTINATION ${CMAKE_INSTALL_PREFIX}
|
||||||
FILES_MATCHING PATTERN "*.dll"
|
FILES_MATCHING PATTERN "*.dll"
|
||||||
)
|
)
|
||||||
|
@ -27,12 +27,12 @@ add_library(core SHARED
|
|||||||
$<TARGET_OBJECTS:dmem>
|
$<TARGET_OBJECTS:dmem>
|
||||||
)
|
)
|
||||||
|
|
||||||
add_dependencies(core logging)
|
add_dependencies(core logging boost)
|
||||||
target_link_libraries(core PRIVATE
|
target_link_libraries(core PRIVATE
|
||||||
libboost_thread
|
libboost_thread
|
||||||
libboost_chrono
|
libboost_chrono
|
||||||
libboost_program_options
|
libboost_program_options
|
||||||
glfw3
|
sdl2
|
||||||
OptickCore
|
OptickCore
|
||||||
psOff_utility
|
psOff_utility
|
||||||
${Vulkan_LIBRARIES}
|
${Vulkan_LIBRARIES}
|
||||||
@ -44,4 +44,4 @@ ADD_CUSTOM_COMMAND(TARGET core POST_BUILD
|
|||||||
${CMAKE_BINARY_DIR}/lib)
|
${CMAKE_BINARY_DIR}/lib)
|
||||||
|
|
||||||
install(FILES $<TARGET_PDB_FILE:core> DESTINATION debug OPTIONAL)
|
install(FILES $<TARGET_PDB_FILE:core> DESTINATION debug OPTIONAL)
|
||||||
install(TARGETS core LIBRARY DESTINATION .)
|
install(TARGETS core LIBRARY DESTINATION .)
|
||||||
|
@ -2,4 +2,4 @@ add_library(initParams OBJECT
|
|||||||
initParams.cpp
|
initParams.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
add_dependencies(initParams third_party)
|
add_dependencies(initParams third_party boost)
|
||||||
|
@ -7,4 +7,4 @@ add_library(kernel OBJECT
|
|||||||
semaphore.cpp
|
semaphore.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
add_dependencies(kernel third_party)
|
add_dependencies(kernel third_party boost)
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
#include <queue>
|
#include <queue>
|
||||||
|
|
||||||
#include <GLFW/glfw3.h>
|
#include <SDL.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
@ -114,7 +114,7 @@ struct Context {
|
|||||||
FlipRate fliprate = FlipRate::_60Hz;
|
FlipRate fliprate = FlipRate::_60Hz;
|
||||||
|
|
||||||
VideoOutConfig config;
|
VideoOutConfig config;
|
||||||
GLFWwindow* window;
|
SDL_Window* window;
|
||||||
VkSurfaceKHR surface;
|
VkSurfaceKHR surface;
|
||||||
|
|
||||||
std::list<EventQueue::IKernelEqueue_t> eventFlip;
|
std::list<EventQueue::IKernelEqueue_t> eventFlip;
|
||||||
@ -151,8 +151,8 @@ class VideoOut: public IVideoOut, private IEventsGraphics {
|
|||||||
vulkan::VulkanObj* m_vulkanObj = nullptr;
|
vulkan::VulkanObj* m_vulkanObj = nullptr;
|
||||||
|
|
||||||
std::unique_ptr<IGraphics> m_graphics;
|
std::unique_ptr<IGraphics> m_graphics;
|
||||||
std::thread m_threadGlfw;
|
std::thread m_threadSDL2;
|
||||||
std::condition_variable m_condGlfw;
|
std::condition_variable m_condSDL2;
|
||||||
std::condition_variable m_condDone;
|
std::condition_variable m_condDone;
|
||||||
bool m_stop = false;
|
bool m_stop = false;
|
||||||
std::queue<Message> m_messages;
|
std::queue<Message> m_messages;
|
||||||
@ -183,14 +183,14 @@ class VideoOut: public IVideoOut, private IEventsGraphics {
|
|||||||
|
|
||||||
m_messages.push({MessageType::flip, handle - 1, nullptr, setIndex});
|
m_messages.push({MessageType::flip, handle - 1, nullptr, setIndex});
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
m_condGlfw.notify_one();
|
m_condSDL2.notify_one();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<VkQueue, uint32_t> getQueue(vulkan::QueueType type) final;
|
std::pair<VkQueue, uint32_t> getQueue(vulkan::QueueType type) final;
|
||||||
// -
|
// -
|
||||||
void transferDisplay(int handle, int index, VkSemaphore waitSema, size_t waitValue); // -> Renderer
|
void transferDisplay(int handle, int index, VkSemaphore waitSema, size_t waitValue); // -> Renderer
|
||||||
|
|
||||||
std::thread createGlfwThread();
|
std::thread createSDLThread();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
VideoOut() = default;
|
VideoOut() = default;
|
||||||
@ -244,7 +244,7 @@ class VideoOut: public IVideoOut, private IEventsGraphics {
|
|||||||
return m_graphics.get();
|
return m_graphics.get();
|
||||||
};
|
};
|
||||||
|
|
||||||
std::unique_lock<std::mutex> getGlfwLock() const final { return std::unique_lock(m_mutexInt); }
|
std::unique_lock<std::mutex> getSDLLock() const final { return std::unique_lock(m_mutexInt); }
|
||||||
};
|
};
|
||||||
|
|
||||||
IVideoOut& accessVideoOut() {
|
IVideoOut& accessVideoOut() {
|
||||||
@ -254,14 +254,14 @@ IVideoOut& accessVideoOut() {
|
|||||||
|
|
||||||
void VideoOut::init() {
|
void VideoOut::init() {
|
||||||
LOG_USE_MODULE(VideoOut);
|
LOG_USE_MODULE(VideoOut);
|
||||||
LOG_DEBUG(L"createGlfwThread()");
|
LOG_DEBUG(L"createSDLThread()");
|
||||||
m_threadGlfw = createGlfwThread();
|
m_threadSDL2 = createSDLThread();
|
||||||
|
|
||||||
std::unique_lock lock(m_mutexInt);
|
std::unique_lock lock(m_mutexInt);
|
||||||
static bool done = false;
|
static bool done = false;
|
||||||
m_messages.push(Message {MessageType::open, 0, &done});
|
m_messages.push(Message {MessageType::open, 0, &done});
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
m_condGlfw.notify_one();
|
m_condSDL2.notify_one();
|
||||||
|
|
||||||
lock.lock();
|
lock.lock();
|
||||||
m_condDone.wait(lock, [=] { return done; });
|
m_condDone.wait(lock, [=] { return done; });
|
||||||
@ -294,7 +294,7 @@ int VideoOut::open(int userId) {
|
|||||||
static bool done = false;
|
static bool done = false;
|
||||||
m_messages.push(Message {MessageType::open, windowIndex, &done});
|
m_messages.push(Message {MessageType::open, windowIndex, &done});
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
m_condGlfw.notify_one();
|
m_condSDL2.notify_one();
|
||||||
|
|
||||||
lock.lock();
|
lock.lock();
|
||||||
m_condDone.wait(lock, [=] { return done; });
|
m_condDone.wait(lock, [=] { return done; });
|
||||||
@ -326,7 +326,7 @@ void VideoOut::close(int handle) {
|
|||||||
static bool done = false;
|
static bool done = false;
|
||||||
m_messages.push(Message {MessageType::close, handle, &done});
|
m_messages.push(Message {MessageType::close, handle, &done});
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
m_condGlfw.notify_one();
|
m_condSDL2.notify_one();
|
||||||
|
|
||||||
lock.lock();
|
lock.lock();
|
||||||
m_condDone.wait(lock, [=] { return done; });
|
m_condDone.wait(lock, [=] { return done; });
|
||||||
@ -431,7 +431,7 @@ void VideoOut::submitFlip(int handle, int index, int64_t flipArg) {
|
|||||||
|
|
||||||
m_messages.push({MessageType::flip, handle - 1, nullptr, setIndex});
|
m_messages.push({MessageType::flip, handle - 1, nullptr, setIndex});
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
m_condGlfw.notify_one();
|
m_condSDL2.notify_one();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoOut::getFlipStatus(int handle, void* status) {
|
void VideoOut::getFlipStatus(int handle, void* status) {
|
||||||
@ -554,13 +554,13 @@ std::pair<VkQueue, uint32_t> VideoOut::getQueue(vulkan::QueueType type) {
|
|||||||
return std::make_pair(bestIt->queue, bestIt->family);
|
return std::make_pair(bestIt->queue, bestIt->family);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cbWindow_close(GLFWwindow* window) {
|
void cbWindow_close(SDL_Window* window) {
|
||||||
// glfwDestroyWindow(window.window);
|
// SDL_DestroyWindow(window.window);
|
||||||
// Todo submit close event, cleanup
|
// Todo submit close event, cleanup
|
||||||
// m_stop = true;
|
// m_stop = true;
|
||||||
// lock.unlock();
|
// lock.unlock();
|
||||||
// m_condGlfw.notify_one();
|
// m_condSDL2.notify_one();
|
||||||
// m_threadGlfw.join();
|
// m_threadSDL2.join();
|
||||||
// // accessGraphics().stop();
|
// // accessGraphics().stop();
|
||||||
// m_graphics.reset();
|
// m_graphics.reset();
|
||||||
// deinitVulkan(m_vulkanObj);
|
// deinitVulkan(m_vulkanObj);
|
||||||
@ -569,25 +569,50 @@ void cbWindow_close(GLFWwindow* window) {
|
|||||||
// todo clean shutdown (file syncs etc.)
|
// todo clean shutdown (file syncs etc.)
|
||||||
}
|
}
|
||||||
|
|
||||||
std::thread VideoOut::createGlfwThread() {
|
std::thread VideoOut::createSDLThread() {
|
||||||
return std::thread([this] {
|
return std::thread([this] {
|
||||||
util::setThreadName("VideoOut");
|
util::setThreadName("VideoOut");
|
||||||
OPTICK_THREAD("VideoOut");
|
OPTICK_THREAD("VideoOut");
|
||||||
|
|
||||||
LOG_USE_MODULE(VideoOut);
|
LOG_USE_MODULE(VideoOut);
|
||||||
LOG_DEBUG(L"Init glfw");
|
LOG_DEBUG(L"Init SDL2 video");
|
||||||
|
|
||||||
glfwInit();
|
SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS);
|
||||||
|
|
||||||
|
// SDL polling helper
|
||||||
|
auto func_pollSDL = [](auto& window) {
|
||||||
|
SDL_Event event;
|
||||||
|
while (SDL_PollEvent(&event)) {
|
||||||
|
switch (event.type) {
|
||||||
|
case SDL_WINDOWEVENT:
|
||||||
|
switch (event.window.event) {
|
||||||
|
case SDL_WINDOWEVENT_CLOSE: cbWindow_close(window); break;
|
||||||
|
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case SDL_KEYUP:
|
||||||
|
if (event.key.keysym.scancode == SDL_SCANCODE_ESCAPE) {
|
||||||
|
cbWindow_close(window);
|
||||||
|
}
|
||||||
|
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
// -
|
||||||
|
|
||||||
while (!m_stop) {
|
while (!m_stop) {
|
||||||
std::unique_lock lock(m_mutexInt);
|
std::unique_lock lock(m_mutexInt);
|
||||||
m_condGlfw.wait_for(lock, std::chrono::microseconds(m_vblankTime), [this] { return m_stop || !m_messages.empty(); });
|
m_condSDL2.wait_for(lock, std::chrono::microseconds(m_vblankTime), [this] { return m_stop || !m_messages.empty(); });
|
||||||
if (m_stop) break;
|
if (m_stop) break;
|
||||||
|
|
||||||
// Handle VBlank
|
// Handle VBlank
|
||||||
if (m_messages.empty()) {
|
if (m_messages.empty()) {
|
||||||
using namespace std::chrono;
|
using namespace std::chrono;
|
||||||
|
|
||||||
|
func_pollSDL(m_windows[0].window); // check only main for now
|
||||||
|
|
||||||
auto& timer = accessTimer();
|
auto& timer = accessTimer();
|
||||||
auto const curTime = (uint64_t)(1e6 * timer.getTimeS());
|
auto const curTime = (uint64_t)(1e6 * timer.getTimeS());
|
||||||
auto const procTime = timer.queryPerformance();
|
auto const procTime = timer.queryPerformance();
|
||||||
@ -608,15 +633,10 @@ std::thread VideoOut::createGlfwThread() {
|
|||||||
|
|
||||||
auto const title = getTitle(index, 0, 0, window.fliprate);
|
auto const title = getTitle(index, 0, 0, window.fliprate);
|
||||||
|
|
||||||
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
|
window.window = SDL_CreateWindow(title.c_str(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, m_widthTotal, m_heightTotal,
|
||||||
glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE);
|
SDL_WINDOW_VULKAN | SDL_WINDOW_SHOWN);
|
||||||
glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE);
|
|
||||||
window.window = glfwCreateWindow(m_widthTotal, m_heightTotal, title.c_str(), nullptr, nullptr);
|
|
||||||
|
|
||||||
glfwMakeContextCurrent(window.window);
|
SDL_GetWindowSize(window.window, (int*)(&window.config.resolution.paneWidth), (int*)(&window.config.resolution.paneHeight));
|
||||||
glfwShowWindow(window.window);
|
|
||||||
|
|
||||||
glfwGetWindowSize(window.window, (int*)(&window.config.resolution.paneWidth), (int*)(&window.config.resolution.paneHeight));
|
|
||||||
|
|
||||||
LOG_INFO(L"--> VideoOut Open(%S)| %d:%d", title.c_str(), window.config.resolution.paneWidth, window.config.resolution.paneHeight);
|
LOG_INFO(L"--> VideoOut Open(%S)| %d:%d", title.c_str(), window.config.resolution.paneWidth, window.config.resolution.paneHeight);
|
||||||
if (m_vulkanObj == nullptr) {
|
if (m_vulkanObj == nullptr) {
|
||||||
@ -628,13 +648,11 @@ std::thread VideoOut::createGlfwThread() {
|
|||||||
vulkan::createSurface(m_vulkanObj, window.window, window.surface);
|
vulkan::createSurface(m_vulkanObj, window.window, window.surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
glfwSetWindowCloseCallback(window.window, cbWindow_close);
|
|
||||||
|
|
||||||
*item.done = true;
|
*item.done = true;
|
||||||
m_condDone.notify_one();
|
m_condDone.notify_one();
|
||||||
} break;
|
} break;
|
||||||
case MessageType::close: {
|
case MessageType::close: {
|
||||||
glfwDestroyWindow(window.window);
|
SDL_DestroyWindow(window.window);
|
||||||
*item.done = true;
|
*item.done = true;
|
||||||
m_condDone.notify_one();
|
m_condDone.notify_one();
|
||||||
} break;
|
} break;
|
||||||
@ -674,14 +692,15 @@ std::thread VideoOut::createGlfwThread() {
|
|||||||
|
|
||||||
window.config.fps = fps;
|
window.config.fps = fps;
|
||||||
|
|
||||||
glfwSetWindowTitle(window.window, title.c_str());
|
SDL_SetWindowTitle(window.window, title.c_str());
|
||||||
glfwPollEvents();
|
func_pollSDL(window.window);
|
||||||
|
|
||||||
LOG_TRACE(L"<- flip(%d) set:%u buffer:%u", index, item.index, window.config.flipStatus.currentBuffer);
|
LOG_TRACE(L"<- flip(%d) set:%u buffer:%u", index, item.index, window.config.flipStatus.currentBuffer);
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
m_messages.pop();
|
m_messages.pop();
|
||||||
}
|
}
|
||||||
glfwTerminate();
|
SDL_Quit();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,8 +12,6 @@ struct SwapchainData;
|
|||||||
constexpr int VIDEO_OUT_EVENT_FLIP = 0;
|
constexpr int VIDEO_OUT_EVENT_FLIP = 0;
|
||||||
constexpr int VIDEO_OUT_EVENT_VBLANK = 1;
|
constexpr int VIDEO_OUT_EVENT_VBLANK = 1;
|
||||||
|
|
||||||
class IGLFW {};
|
|
||||||
|
|
||||||
class IGraphics;
|
class IGraphics;
|
||||||
|
|
||||||
class IVideoOut {
|
class IVideoOut {
|
||||||
@ -148,11 +146,11 @@ class IVideoOut {
|
|||||||
virtual IGraphics* getGraphics() = 0;
|
virtual IGraphics* getGraphics() = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief locks the glfwpoll
|
* @brief locks the sdlpoll
|
||||||
*
|
*
|
||||||
* @return std::unique_lock<std::mutex>
|
* @return std::unique_lock<std::mutex>
|
||||||
*/
|
*/
|
||||||
virtual std::unique_lock<std::mutex> getGlfwLock() const = 0;
|
virtual std::unique_lock<std::mutex> getSDLLock() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#if defined(__APICALL_EXTERN)
|
#if defined(__APICALL_EXTERN)
|
||||||
@ -164,4 +162,4 @@ class IVideoOut {
|
|||||||
#endif
|
#endif
|
||||||
__APICALL IVideoOut& accessVideoOut();
|
__APICALL IVideoOut& accessVideoOut();
|
||||||
|
|
||||||
#undef __APICALL
|
#undef __APICALL
|
||||||
|
@ -4,7 +4,8 @@
|
|||||||
#include "logging.h"
|
#include "logging.h"
|
||||||
#include "utility/utility.h"
|
#include "utility/utility.h"
|
||||||
|
|
||||||
#include <GLFW/glfw3.h>
|
#include <SDL.h>
|
||||||
|
#include <SDL_vulkan.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
@ -21,9 +22,9 @@ LOG_DEFINE_MODULE(vulkanHelper);
|
|||||||
|
|
||||||
namespace vulkan {
|
namespace vulkan {
|
||||||
|
|
||||||
void createSurface(VulkanObj* obj, GLFWwindow* window, VkSurfaceKHR& surfaceOut) {
|
void createSurface(VulkanObj* obj, SDL_Window* window, VkSurfaceKHR& surfaceOut) {
|
||||||
LOG_USE_MODULE(vulkanHelper);
|
LOG_USE_MODULE(vulkanHelper);
|
||||||
if (glfwCreateWindowSurface(obj->deviceInfo.instance, window, NULL, &surfaceOut)) {
|
if (SDL_Vulkan_CreateSurface(window, obj->deviceInfo.instance, &surfaceOut)) {
|
||||||
LOG_CRIT(L"Couldn't create surface");
|
LOG_CRIT(L"Couldn't create surface");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -467,4 +468,4 @@ VKAPI_ATTR void VKAPI_CALL vkCmdSetAlphaToCoverageEnableEXT(VkCommandBuffer comm
|
|||||||
VKAPI_ATTR void VKAPI_CALL vkCmdSetAlphaToOneEnableEXT(VkCommandBuffer commandBuffer, VkBool32 alphaToOneEnable) {
|
VKAPI_ATTR void VKAPI_CALL vkCmdSetAlphaToOneEnableEXT(VkCommandBuffer commandBuffer, VkBool32 alphaToOneEnable) {
|
||||||
static auto fn = (PFN_vkCmdSetAlphaToOneEnableEXT)vkGetInstanceProcAddr(vulkan::getVkInstance(), "vkCmdSetAlphaToOneEnableEXT");
|
static auto fn = (PFN_vkCmdSetAlphaToOneEnableEXT)vkGetInstanceProcAddr(vulkan::getVkInstance(), "vkCmdSetAlphaToOneEnableEXT");
|
||||||
fn(commandBuffer, alphaToOneEnable);
|
fn(commandBuffer, alphaToOneEnable);
|
||||||
}
|
}
|
||||||
|
@ -2,13 +2,12 @@
|
|||||||
|
|
||||||
#include "logging.h"
|
#include "logging.h"
|
||||||
|
|
||||||
|
#include <SDL.h>
|
||||||
|
#include <SDL_vulkan.h>
|
||||||
#include <format>
|
#include <format>
|
||||||
#include <utility/utility.h>
|
#include <utility/utility.h>
|
||||||
#include <vulkan/vk_enum_string_helper.h>
|
#include <vulkan/vk_enum_string_helper.h>
|
||||||
|
|
||||||
#define GLFW_INCLUDE_VULKAN
|
|
||||||
#include <GLFW/glfw3.h>
|
|
||||||
|
|
||||||
LOG_DEFINE_MODULE(vulkanSetup);
|
LOG_DEFINE_MODULE(vulkanSetup);
|
||||||
|
|
||||||
constexpr std::array<VkValidationFeatureDisableEXT, 0> disabledValidationFeatures {};
|
constexpr std::array<VkValidationFeatureDisableEXT, 0> disabledValidationFeatures {};
|
||||||
@ -109,7 +108,7 @@ VKAPI_ATTR VkBool32 VKAPI_CALL debugMessengerCallback(VkDebugUtilsMessageSeverit
|
|||||||
return VK_FALSE;
|
return VK_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
VulkanExtensions getExtensions(bool enableValidation) {
|
VulkanExtensions getExtensions(SDL_Window* window, bool enableValidation) {
|
||||||
LOG_USE_MODULE(vulkanSetup);
|
LOG_USE_MODULE(vulkanSetup);
|
||||||
|
|
||||||
uint32_t countAvailableExtensions = 0;
|
uint32_t countAvailableExtensions = 0;
|
||||||
@ -118,10 +117,13 @@ VulkanExtensions getExtensions(bool enableValidation) {
|
|||||||
|
|
||||||
VulkanExtensions r = {.enableValidationLayers = enableValidation};
|
VulkanExtensions r = {.enableValidationLayers = enableValidation};
|
||||||
|
|
||||||
auto res = glfwGetRequiredInstanceExtensions(&countRequiredExtensions);
|
SDL_Vulkan_GetInstanceExtensions(window, &countRequiredExtensions, NULL);
|
||||||
|
auto extensions = static_cast<const char**>(SDL_malloc(sizeof(char*) * countRequiredExtensions));
|
||||||
|
SDL_Vulkan_GetInstanceExtensions(window, &countRequiredExtensions, extensions);
|
||||||
for (size_t n = 0; n < countRequiredExtensions; n++) {
|
for (size_t n = 0; n < countRequiredExtensions; n++) {
|
||||||
r.requiredExtensions.push_back(res[n]);
|
r.requiredExtensions.push_back(extensions[n]);
|
||||||
}
|
}
|
||||||
|
SDL_free(extensions);
|
||||||
|
|
||||||
vkEnumerateInstanceExtensionProperties(nullptr, &countAvailableExtensions, nullptr);
|
vkEnumerateInstanceExtensionProperties(nullptr, &countAvailableExtensions, nullptr);
|
||||||
r.availableExtensions = std::vector<VkExtensionProperties>(countAvailableExtensions, VkExtensionProperties {});
|
r.availableExtensions = std::vector<VkExtensionProperties>(countAvailableExtensions, VkExtensionProperties {});
|
||||||
@ -135,7 +137,7 @@ VulkanExtensions getExtensions(bool enableValidation) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (size_t n = 0; n < r.requiredExtensions.size(); ++n) {
|
for (size_t n = 0; n < r.requiredExtensions.size(); ++n) {
|
||||||
LOG_INFO(L"GLFW required extension: %S", r.requiredExtensions[n]);
|
LOG_INFO(L"SDL2 required extension: %S", r.requiredExtensions[n]);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto& ext: r.availableExtensions) {
|
for (const auto& ext: r.availableExtensions) {
|
||||||
@ -655,7 +657,7 @@ VkDevice createDevice(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, Vul
|
|||||||
static VkPhysicalDeviceProperties g_PhysicalDeviceProperties;
|
static VkPhysicalDeviceProperties g_PhysicalDeviceProperties;
|
||||||
static VkInstance g_VkInstance;
|
static VkInstance g_VkInstance;
|
||||||
|
|
||||||
VulkanObj* initVulkan(GLFWwindow* window, VkSurfaceKHR& surface, bool enableValidation) {
|
VulkanObj* initVulkan(SDL_Window* window, VkSurfaceKHR& surface, bool enableValidation) {
|
||||||
LOG_USE_MODULE(vulkanSetup);
|
LOG_USE_MODULE(vulkanSetup);
|
||||||
auto obj = new VulkanObj;
|
auto obj = new VulkanObj;
|
||||||
|
|
||||||
@ -684,7 +686,7 @@ VulkanObj* initVulkan(GLFWwindow* window, VkSurfaceKHR& surface, bool enableVali
|
|||||||
.apiVersion = VK_API_VERSION_1_3,
|
.apiVersion = VK_API_VERSION_1_3,
|
||||||
};
|
};
|
||||||
|
|
||||||
auto extensions = getExtensions(enableValidation);
|
auto extensions = getExtensions(window, enableValidation);
|
||||||
|
|
||||||
VkInstanceCreateInfo const instInfo {
|
VkInstanceCreateInfo const instInfo {
|
||||||
.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO,
|
||||||
@ -713,8 +715,8 @@ VulkanObj* initVulkan(GLFWwindow* window, VkSurfaceKHR& surface, bool enableVali
|
|||||||
}
|
}
|
||||||
// -
|
// -
|
||||||
|
|
||||||
if (auto result = glfwCreateWindowSurface(obj->deviceInfo.instance, window, NULL, &surface); result != VK_SUCCESS) {
|
if (auto result = SDL_Vulkan_CreateSurface(window, obj->deviceInfo.instance, &surface); result != true) {
|
||||||
LOG_CRIT(L"glfwCreateWindowSurface() Error:%S", string_VkResult(result));
|
LOG_CRIT(L"SDL_Vulkan_CreateSurface() Error:%S", SDL_GetError());
|
||||||
}
|
}
|
||||||
|
|
||||||
VulkanQueues queues;
|
VulkanQueues queues;
|
||||||
@ -768,4 +770,4 @@ std::string_view const getGPUName() {
|
|||||||
void deinitVulkan(VulkanObj* obj) {
|
void deinitVulkan(VulkanObj* obj) {
|
||||||
delete obj;
|
delete obj;
|
||||||
}
|
}
|
||||||
} // namespace vulkan
|
} // namespace vulkan
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <vulkan/vulkan_core.h>
|
#include <vulkan/vulkan_core.h>
|
||||||
|
|
||||||
struct GLFWwindow;
|
struct SDL_Window;
|
||||||
|
|
||||||
namespace vulkan {
|
namespace vulkan {
|
||||||
|
|
||||||
@ -83,10 +83,10 @@ struct VulkanObj {
|
|||||||
Queues queues;
|
Queues queues;
|
||||||
};
|
};
|
||||||
|
|
||||||
VulkanObj* initVulkan(GLFWwindow* window, VkSurfaceKHR& surface, bool useValidation);
|
VulkanObj* initVulkan(SDL_Window* window, VkSurfaceKHR& surface, bool useValidation);
|
||||||
void deinitVulkan(VulkanObj* obj);
|
void deinitVulkan(VulkanObj* obj);
|
||||||
|
|
||||||
void createSurface(VulkanObj* obj, GLFWwindow* window, VkSurfaceKHR& surfaceOut);
|
void createSurface(VulkanObj* obj, SDL_Window* window, VkSurfaceKHR& surfaceOut);
|
||||||
|
|
||||||
VkPhysicalDeviceLimits const* getPhysicalLimits();
|
VkPhysicalDeviceLimits const* getPhysicalLimits();
|
||||||
|
|
||||||
@ -96,4 +96,4 @@ std::string_view const getGPUName();
|
|||||||
|
|
||||||
std::pair<VkFormat, VkColorSpaceKHR> getDisplayFormat(VulkanObj* obj);
|
std::pair<VkFormat, VkColorSpaceKHR> getDisplayFormat(VulkanObj* obj);
|
||||||
uint32_t createData(VulkanObj* obj, VkSurfaceKHR surface, SwapchainData& swapchainData, uint32_t width, uint32_t height, bool enableVsync); // Swapchain
|
uint32_t createData(VulkanObj* obj, VkSurfaceKHR surface, SwapchainData& swapchainData, uint32_t width, uint32_t height, bool enableVsync); // Swapchain
|
||||||
} // namespace vulkan
|
} // namespace vulkan
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
#include "../libSceNpManager/types.h"
|
#include "../libSceNpManager/types.h"
|
||||||
#include "codes.h"
|
#include "codes.h"
|
||||||
|
|
||||||
|
|
||||||
typedef uint32_t SceAppContentMediaType;
|
typedef uint32_t SceAppContentMediaType;
|
||||||
typedef uint32_t SceAppContentBootAttribute;
|
typedef uint32_t SceAppContentBootAttribute;
|
||||||
typedef uint32_t SceAppContentAppParamId;
|
typedef uint32_t SceAppContentAppParamId;
|
||||||
@ -43,4 +42,4 @@ struct SceAppContentEntitlementKey {
|
|||||||
struct SceAppContentAddcontDownloadProgress {
|
struct SceAppContentAddcontDownloadProgress {
|
||||||
uint64_t dataSize;
|
uint64_t dataSize;
|
||||||
uint64_t downloadedSize;
|
uint64_t downloadedSize;
|
||||||
};
|
};
|
||||||
|
@ -5,14 +5,9 @@ set(libName libSceAudioOut)
|
|||||||
project(${libName})
|
project(${libName})
|
||||||
|
|
||||||
add_library(${libName} SHARED entry.cpp)
|
add_library(${libName} SHARED entry.cpp)
|
||||||
target_include_directories(${libName} PRIVATE
|
|
||||||
${PRJ_SRC_DIR}/third_party/portAudio/include
|
|
||||||
)
|
|
||||||
|
|
||||||
add_dependencies(${libName} third_party)
|
add_dependencies(${libName} third_party)
|
||||||
|
|
||||||
target_link_libraries(${libName} PUBLIC
|
target_link_libraries(${libName} PRIVATE SDL2)
|
||||||
portaudio_static_x64
|
|
||||||
)
|
|
||||||
|
|
||||||
setupModule(${libName})
|
setupModule(${libName})
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "logging.h"
|
#include "logging.h"
|
||||||
#include "portaudio.h"
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
|
#include <SDL.h>
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
@ -14,13 +14,14 @@ struct PortOut {
|
|||||||
bool open = false;
|
bool open = false;
|
||||||
int userId = 0;
|
int userId = 0;
|
||||||
SceAudioOutPortType type = SceAudioOutPortType::MAIN;
|
SceAudioOutPortType type = SceAudioOutPortType::MAIN;
|
||||||
|
uint8_t sampleSize = 0;
|
||||||
uint32_t samplesNum = 0;
|
uint32_t samplesNum = 0;
|
||||||
uint32_t freq = 0;
|
uint32_t freq = 0;
|
||||||
SceAudioOutParamFormat format = SceAudioOutParamFormat::FLOAT_MONO;
|
SceAudioOutParamFormat format = SceAudioOutParamFormat::FLOAT_MONO;
|
||||||
uint64_t lastOutputTime = 0;
|
uint64_t lastOutputTime = 0;
|
||||||
int channelsNum = 0;
|
int channelsNum = 0;
|
||||||
int volume[8] = {};
|
int volume[8] = {};
|
||||||
PaStream* stream = nullptr;
|
SDL_AudioDeviceID device = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Pimpl {
|
struct Pimpl {
|
||||||
@ -34,13 +35,18 @@ Pimpl* getData() {
|
|||||||
return &obj;
|
return &obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
PaError writeOut(Pimpl* pimpl, int32_t handle, const void* ptr) {
|
int writeOut(Pimpl* pimpl, int32_t handle, const void* ptr) {
|
||||||
auto& port = pimpl->portsOut[handle - 1];
|
auto& port = pimpl->portsOut[handle - 1];
|
||||||
if (!port.open) return 0;
|
if (!port.open || ptr == nullptr) return 0;
|
||||||
|
|
||||||
port.lastOutputTime = std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now().time_since_epoch()).count();
|
port.lastOutputTime = std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now().time_since_epoch()).count();
|
||||||
if (Pa_IsStreamActive(port.stream) != 1) Pa_StartStream(port.stream);
|
|
||||||
return Pa_WriteStream(port.stream, ptr, port.samplesNum);
|
if (SDL_GetAudioDeviceStatus(port.device) != SDL_AUDIO_PLAYING) SDL_PauseAudioDevice(port.device, 0);
|
||||||
|
|
||||||
|
while (SDL_GetQueuedAudioSize(port.device) > 0)
|
||||||
|
SDL_Delay(0);
|
||||||
|
|
||||||
|
return SDL_QueueAudio(port.device, ptr, port.samplesNum * port.sampleSize * port.channelsNum);
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
@ -50,8 +56,7 @@ EXPORT const char* MODULE_NAME = "libSceAudioOut";
|
|||||||
|
|
||||||
EXPORT SYSV_ABI int32_t sceAudioOutInit(void) {
|
EXPORT SYSV_ABI int32_t sceAudioOutInit(void) {
|
||||||
(void)getData();
|
(void)getData();
|
||||||
Pa_Initialize();
|
return SDL_InitSubSystem(SDL_INIT_AUDIO) == 0 ? Ok : Err::NOT_INIT;
|
||||||
return Ok;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT SYSV_ABI int32_t sceAudioOutOpen(int32_t userId, SceAudioOutPortType type, int32_t index, uint32_t len, uint32_t freq, SceAudioOutParamFormat format) {
|
EXPORT SYSV_ABI int32_t sceAudioOutOpen(int32_t userId, SceAudioOutPortType type, int32_t index, uint32_t len, uint32_t freq, SceAudioOutParamFormat format) {
|
||||||
@ -73,39 +78,47 @@ EXPORT SYSV_ABI int32_t sceAudioOutOpen(int32_t userId, SceAudioOutPortType type
|
|||||||
port.format = format;
|
port.format = format;
|
||||||
port.lastOutputTime = 0;
|
port.lastOutputTime = 0;
|
||||||
|
|
||||||
PaSampleFormat sampleFormat;
|
SDL_AudioFormat sampleFormat;
|
||||||
switch (format) {
|
switch (format) {
|
||||||
case SceAudioOutParamFormat::S16_MONO:
|
case SceAudioOutParamFormat::S16_MONO:
|
||||||
sampleFormat = paInt16;
|
sampleFormat = AUDIO_S16SYS;
|
||||||
port.channelsNum = 1;
|
port.channelsNum = 1;
|
||||||
|
port.sampleSize = 2;
|
||||||
break;
|
break;
|
||||||
case SceAudioOutParamFormat::FLOAT_MONO:
|
case SceAudioOutParamFormat::FLOAT_MONO:
|
||||||
sampleFormat = paFloat32;
|
sampleFormat = AUDIO_F32SYS;
|
||||||
port.channelsNum = 1;
|
port.channelsNum = 1;
|
||||||
|
port.sampleSize = 4;
|
||||||
break;
|
break;
|
||||||
case SceAudioOutParamFormat::S16_STEREO:
|
case SceAudioOutParamFormat::S16_STEREO:
|
||||||
sampleFormat = paInt16;
|
sampleFormat = AUDIO_S16SYS;
|
||||||
port.channelsNum = 2;
|
port.channelsNum = 2;
|
||||||
|
port.sampleSize = 2;
|
||||||
break;
|
break;
|
||||||
case SceAudioOutParamFormat::FLOAT_STEREO:
|
case SceAudioOutParamFormat::FLOAT_STEREO:
|
||||||
sampleFormat = paFloat32;
|
sampleFormat = AUDIO_F32SYS;
|
||||||
port.channelsNum = 2;
|
port.channelsNum = 2;
|
||||||
|
port.sampleSize = 4;
|
||||||
break;
|
break;
|
||||||
case SceAudioOutParamFormat::S16_8CH:
|
case SceAudioOutParamFormat::S16_8CH:
|
||||||
sampleFormat = paInt16;
|
sampleFormat = AUDIO_S16SYS;
|
||||||
port.channelsNum = 8;
|
port.channelsNum = 8;
|
||||||
|
port.sampleSize = 2;
|
||||||
break;
|
break;
|
||||||
case SceAudioOutParamFormat::FLOAT_8CH:
|
case SceAudioOutParamFormat::FLOAT_8CH:
|
||||||
sampleFormat = paFloat32;
|
sampleFormat = AUDIO_F32SYS;
|
||||||
port.channelsNum = 8;
|
port.channelsNum = 8;
|
||||||
|
port.sampleSize = 4;
|
||||||
break;
|
break;
|
||||||
case SceAudioOutParamFormat::S16_8CH_STD:
|
case SceAudioOutParamFormat::S16_8CH_STD:
|
||||||
sampleFormat = paInt16;
|
sampleFormat = AUDIO_S16SYS;
|
||||||
port.channelsNum = 8;
|
port.channelsNum = 8;
|
||||||
|
port.sampleSize = 2;
|
||||||
break;
|
break;
|
||||||
case SceAudioOutParamFormat::FLOAT_8CH_STD:
|
case SceAudioOutParamFormat::FLOAT_8CH_STD:
|
||||||
sampleFormat = paFloat32;
|
sampleFormat = AUDIO_F32SYS;
|
||||||
port.channelsNum = 8;
|
port.channelsNum = 8;
|
||||||
|
port.sampleSize = 4;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,17 +126,21 @@ EXPORT SYSV_ABI int32_t sceAudioOutOpen(int32_t userId, SceAudioOutPortType type
|
|||||||
port.volume[i] = 32768;
|
port.volume[i] = 32768;
|
||||||
}
|
}
|
||||||
|
|
||||||
PaStreamParameters const outParams {
|
SDL_AudioSpec fmt {.freq = static_cast<int>(freq),
|
||||||
.device = Pa_GetDefaultOutputDevice(), /* default output device */
|
.format = sampleFormat,
|
||||||
.channelCount = port.channelsNum,
|
.channels = static_cast<uint8_t>(port.channelsNum),
|
||||||
.sampleFormat = sampleFormat,
|
.samples = static_cast<uint16_t>(port.samplesNum),
|
||||||
.suggestedLatency = Pa_GetDeviceInfo(outParams.device)->defaultLowOutputLatency,
|
.callback = nullptr,
|
||||||
.hostApiSpecificStreamInfo = NULL,
|
.userdata = nullptr};
|
||||||
};
|
|
||||||
|
|
||||||
if (auto err = Pa_OpenStream(&port.stream, NULL, &outParams, freq, port.samplesNum, paNoFlag, NULL, NULL); err != Ok) {
|
char* dname;
|
||||||
return err;
|
SDL_AudioSpec fmt_curr;
|
||||||
}
|
SDL_GetDefaultAudioInfo(&dname, &fmt_curr, 0);
|
||||||
|
LOG_INFO(L"Opening audio device: %S\n", dname);
|
||||||
|
auto devId = SDL_OpenAudioDevice(dname, 0, &fmt, NULL, 0);
|
||||||
|
if (devId <= 0) return devId;
|
||||||
|
SDL_PauseAudioDevice(devId, 0);
|
||||||
|
port.device = devId;
|
||||||
|
|
||||||
return id + 1;
|
return id + 1;
|
||||||
}
|
}
|
||||||
@ -140,8 +157,9 @@ EXPORT SYSV_ABI int32_t sceAudioOutClose(int32_t handle) {
|
|||||||
auto& port = pimpl->portsOut[handle - 1];
|
auto& port = pimpl->portsOut[handle - 1];
|
||||||
if (port.open) {
|
if (port.open) {
|
||||||
port.open = false;
|
port.open = false;
|
||||||
if (Pa_IsStreamActive(port.stream) == 1) {
|
|
||||||
Pa_CloseStream(port.stream);
|
if (port.device > 0) {
|
||||||
|
SDL_CloseAudioDevice(port.device);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Ok;
|
return Ok;
|
||||||
@ -188,7 +206,7 @@ EXPORT SYSV_ABI int32_t sceAudioOutOutputs(SceAudioOutOutputParam* param, uint32
|
|||||||
|
|
||||||
// std::unique_lock const lock(pimpl->mutexInt); // dont block, causes audio artifacts
|
// std::unique_lock const lock(pimpl->mutexInt); // dont block, causes audio artifacts
|
||||||
for (uint32_t i = 0; i < num; i++) {
|
for (uint32_t i = 0; i < num; i++) {
|
||||||
if (auto err = writeOut(pimpl, param[i].handle, param[i].ptr); err != paNoError) return err;
|
if (auto err = writeOut(pimpl, param[i].handle, param[i].ptr); err != 0) return err;
|
||||||
}
|
}
|
||||||
return Ok;
|
return Ok;
|
||||||
}
|
}
|
||||||
@ -229,4 +247,4 @@ EXPORT SYSV_ABI int32_t sceAudioOutGetSystemState(SceAudioOutSystemState* state)
|
|||||||
EXPORT SYSV_ABI int32_t sceAudioOutSetSystemDebugState(SceAudioOutSystemDebugStateElement elem, SceAudioOutSystemDebugStateParam* param) {
|
EXPORT SYSV_ABI int32_t sceAudioOutSetSystemDebugState(SceAudioOutSystemDebugStateElement elem, SceAudioOutSystemDebugStateParam* param) {
|
||||||
return Ok;
|
return Ok;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,6 +53,7 @@ struct SceAvPlayerDecoderInit {
|
|||||||
SceAvPlayerAudioDecoderType audioType;
|
SceAvPlayerAudioDecoderType audioType;
|
||||||
uint8_t reserved[4];
|
uint8_t reserved[4];
|
||||||
} decoderType;
|
} decoderType;
|
||||||
|
|
||||||
union {
|
union {
|
||||||
struct {
|
struct {
|
||||||
int32_t cpuAffinityMask;
|
int32_t cpuAffinityMask;
|
||||||
@ -67,10 +68,12 @@ struct SceAvPlayerDecoderInit {
|
|||||||
|
|
||||||
uint8_t reserved[16];
|
uint8_t reserved[16];
|
||||||
} avcSw2;
|
} avcSw2;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
uint8_t audioChannelOrder;
|
uint8_t audioChannelOrder;
|
||||||
uint8_t reserved[27];
|
uint8_t reserved[27];
|
||||||
} aac;
|
} aac;
|
||||||
|
|
||||||
uint8_t reserved[28];
|
uint8_t reserved[28];
|
||||||
} decoderParams;
|
} decoderParams;
|
||||||
};
|
};
|
||||||
|
@ -57,6 +57,7 @@ struct SceAvPlayerVideoEx {
|
|||||||
|
|
||||||
uint8_t reserved1[37];
|
uint8_t reserved1[37];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SceAvPlayerTimedTextEx {
|
struct SceAvPlayerTimedTextEx {
|
||||||
uint8_t languageCode[4];
|
uint8_t languageCode[4];
|
||||||
uint8_t reserved[12];
|
uint8_t reserved[12];
|
||||||
|
@ -8,7 +8,7 @@ add_library(${libName} SHARED
|
|||||||
entry.cpp
|
entry.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
add_dependencies(${libName} third_party)
|
add_dependencies(${libName} third_party boost)
|
||||||
|
|
||||||
target_compile_definitions(${libName} PRIVATE BOOST_ALL_NO_LIB)
|
target_compile_definitions(${libName} PRIVATE BOOST_ALL_NO_LIB)
|
||||||
target_link_libraries(${libName} PRIVATE libboost_thread psOff_utility)
|
target_link_libraries(${libName} PRIVATE libboost_thread psOff_utility)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "common.h"
|
|
||||||
#include "codes.h"
|
#include "codes.h"
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
enum class SCE_IME_MAX {
|
enum class SCE_IME_MAX {
|
||||||
PREEDIT_LENGTH = 30,
|
PREEDIT_LENGTH = 30,
|
||||||
@ -433,6 +433,7 @@ struct SceImeParamExtended {
|
|||||||
uint32_t extKeyboardMode;
|
uint32_t extKeyboardMode;
|
||||||
int8_t reserved[60];
|
int8_t reserved[60];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SceImeKeyboardParam {
|
struct SceImeKeyboardParam {
|
||||||
uint32_t option;
|
uint32_t option;
|
||||||
int8_t reserved1[4];
|
int8_t reserved1[4];
|
||||||
|
@ -20,8 +20,8 @@ enum class SceNpPlatformType : int {
|
|||||||
enum class SceNpState { UNKNOWN = 0, SIGNED_OUT, SIGNED_IN };
|
enum class SceNpState { UNKNOWN = 0, SIGNED_OUT, SIGNED_IN };
|
||||||
enum class SceNpGamePresenceStatus { OFFLINE, ONLINE };
|
enum class SceNpGamePresenceStatus { OFFLINE, ONLINE };
|
||||||
enum class SceNpReachabilityState { UNAVAILABLE = 0, AVAILABLE, REACHABLE };
|
enum class SceNpReachabilityState { UNAVAILABLE = 0, AVAILABLE, REACHABLE };
|
||||||
|
|
||||||
enum class SceNpServiceLabel : uint32_t { DEFAULT = 0x00000000, INVALID = 0xFFFFFFFF };
|
enum class SceNpServiceLabel : uint32_t { DEFAULT = 0x00000000, INVALID = 0xFFFFFFFF };
|
||||||
|
|
||||||
struct SceNpTitleId {
|
struct SceNpTitleId {
|
||||||
char id[SCE_NP_TITLE_ID_LEN + 1];
|
char id[SCE_NP_TITLE_ID_LEN + 1];
|
||||||
};
|
};
|
||||||
@ -151,4 +151,4 @@ struct SceNpCreateAsyncRequestParameter {
|
|||||||
size_t size;
|
size_t size;
|
||||||
uint64_t cpuAffinityMask;
|
uint64_t cpuAffinityMask;
|
||||||
int threadPriority;
|
int threadPriority;
|
||||||
};
|
};
|
||||||
|
@ -28,9 +28,9 @@ typedef struct SceNpTrophyFlagArray {
|
|||||||
SceNpTrophyFlagMask flagBits[SCE_NP_TROPHY_FLAG_SETSIZE >> SCE_NP_TROPHY_FLAG_BITS_SHIFT];
|
SceNpTrophyFlagMask flagBits[SCE_NP_TROPHY_FLAG_SETSIZE >> SCE_NP_TROPHY_FLAG_BITS_SHIFT];
|
||||||
} SceNpTrophyFlagArray;
|
} SceNpTrophyFlagArray;
|
||||||
|
|
||||||
#define SCE_NP_TROPHY_FLAG_SET(n, p) ((p)->flagBits[(n) >> SCE_NP_TROPHY_FLAG_BITS_SHIFT] |= (1 << ((n)&SCE_NP_TROPHY_FLAG_BITS_MASK)))
|
#define SCE_NP_TROPHY_FLAG_SET(n, p) ((p)->flagBits[(n) >> SCE_NP_TROPHY_FLAG_BITS_SHIFT] |= (1 << ((n) & SCE_NP_TROPHY_FLAG_BITS_MASK)))
|
||||||
#define SCE_NP_TROPHY_FLAG_CLR(n, p) ((p)->flagBits[(n) >> SCE_NP_TROPHY_FLAG_BITS_SHIFT] &= ~(1 << ((n)&SCE_NP_TROPHY_FLAG_BITS_MASK)))
|
#define SCE_NP_TROPHY_FLAG_CLR(n, p) ((p)->flagBits[(n) >> SCE_NP_TROPHY_FLAG_BITS_SHIFT] &= ~(1 << ((n) & SCE_NP_TROPHY_FLAG_BITS_MASK)))
|
||||||
#define SCE_NP_TROPHY_FLAG_ISSET(n, p) ((p)->flagBits[(n) >> SCE_NP_TROPHY_FLAG_BITS_SHIFT] & (1 << ((n)&SCE_NP_TROPHY_FLAG_BITS_MASK)))
|
#define SCE_NP_TROPHY_FLAG_ISSET(n, p) ((p)->flagBits[(n) >> SCE_NP_TROPHY_FLAG_BITS_SHIFT] & (1 << ((n) & SCE_NP_TROPHY_FLAG_BITS_MASK)))
|
||||||
#define SCE_NP_TROPHY_FLAG_ZERO(p) \
|
#define SCE_NP_TROPHY_FLAG_ZERO(p) \
|
||||||
do { \
|
do { \
|
||||||
SceNpTrophyFlagArray* __fa = (p); \
|
SceNpTrophyFlagArray* __fa = (p); \
|
||||||
|
@ -7,6 +7,6 @@ project(${libName})
|
|||||||
add_library(${libName} SHARED entry.cpp)
|
add_library(${libName} SHARED entry.cpp)
|
||||||
|
|
||||||
add_dependencies(${libName} core)
|
add_dependencies(${libName} core)
|
||||||
target_link_libraries(${libName} PRIVATE glfw3 ${Vulkan_LIBRARIES} core.lib)
|
target_link_libraries(${libName} PRIVATE SDL2 ${Vulkan_LIBRARIES} core.lib)
|
||||||
|
|
||||||
setupModule(${libName})
|
setupModule(${libName})
|
||||||
|
@ -4,8 +4,7 @@
|
|||||||
#include "logging.h"
|
#include "logging.h"
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
#define GLFW_INCLUDE_NONE
|
#include <SDL.h>
|
||||||
#include <GLFW/glfw3.h>
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <bitset>
|
#include <bitset>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
@ -17,14 +16,15 @@ struct Controller {
|
|||||||
int32_t userId = -1;
|
int32_t userId = -1;
|
||||||
uint8_t countConnect = 0;
|
uint8_t countConnect = 0;
|
||||||
|
|
||||||
ScePadData prePadData;
|
SDL_GameController* padPtr;
|
||||||
|
ScePadData prePadData;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Pimpl {
|
struct Pimpl {
|
||||||
Pimpl() = default;
|
Pimpl() = default;
|
||||||
std::mutex m_mutexInt;
|
std::mutex m_mutexInt;
|
||||||
|
|
||||||
std::array<Controller, GLFW_JOYSTICK_LAST - GLFW_JOYSTICK_1> controller;
|
std::array<Controller, 16 /* Define? */> controller;
|
||||||
};
|
};
|
||||||
|
|
||||||
static auto* getData() {
|
static auto* getData() {
|
||||||
@ -32,60 +32,79 @@ static auto* getData() {
|
|||||||
return &obj;
|
return &obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t getButtons(GLFWgamepadstate const& state) {
|
static SDL_GameController* setupPad(int n, int userId) {
|
||||||
|
auto pData = getData();
|
||||||
|
auto padPtr = SDL_GameControllerOpen(n);
|
||||||
|
if (padPtr == nullptr) return nullptr;
|
||||||
|
|
||||||
|
SDL_GameControllerSetPlayerIndex(padPtr, userId - 1);
|
||||||
|
if (userId > 0) pData->controller[n].userId = userId;
|
||||||
|
pData->controller[n].prePadData = ScePadData();
|
||||||
|
pData->controller[n].padPtr = padPtr;
|
||||||
|
++pData->controller[n].countConnect;
|
||||||
|
return padPtr;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t getButtons(SDL_GameController* pad) {
|
||||||
std::bitset<32> bits;
|
std::bitset<32> bits;
|
||||||
bits[(uint32_t)ScePadButtonDataOffset::L3] = state.buttons[GLFW_GAMEPAD_BUTTON_LEFT_THUMB];
|
bits[(uint32_t)ScePadButtonDataOffset::L3] = SDL_GameControllerGetButton(pad, SDL_CONTROLLER_BUTTON_LEFTSTICK);
|
||||||
bits[(uint32_t)ScePadButtonDataOffset::R3] = state.buttons[GLFW_GAMEPAD_BUTTON_RIGHT_THUMB];
|
bits[(uint32_t)ScePadButtonDataOffset::R3] = SDL_GameControllerGetButton(pad, SDL_CONTROLLER_BUTTON_RIGHTSTICK);
|
||||||
bits[(uint32_t)ScePadButtonDataOffset::OPTIONS] = state.buttons[GLFW_GAMEPAD_BUTTON_START];
|
bits[(uint32_t)ScePadButtonDataOffset::OPTIONS] = SDL_GameControllerGetButton(pad, SDL_CONTROLLER_BUTTON_START);
|
||||||
bits[(uint32_t)ScePadButtonDataOffset::UP] = state.buttons[GLFW_GAMEPAD_BUTTON_DPAD_UP];
|
bits[(uint32_t)ScePadButtonDataOffset::UP] = SDL_GameControllerGetButton(pad, SDL_CONTROLLER_BUTTON_DPAD_UP);
|
||||||
bits[(uint32_t)ScePadButtonDataOffset::RIGHT] = state.buttons[GLFW_GAMEPAD_BUTTON_DPAD_RIGHT];
|
bits[(uint32_t)ScePadButtonDataOffset::RIGHT] = SDL_GameControllerGetButton(pad, SDL_CONTROLLER_BUTTON_DPAD_RIGHT);
|
||||||
bits[(uint32_t)ScePadButtonDataOffset::DOWN] = state.buttons[GLFW_GAMEPAD_BUTTON_DPAD_DOWN];
|
bits[(uint32_t)ScePadButtonDataOffset::DOWN] = SDL_GameControllerGetButton(pad, SDL_CONTROLLER_BUTTON_DPAD_DOWN);
|
||||||
bits[(uint32_t)ScePadButtonDataOffset::LEFT] = state.buttons[GLFW_GAMEPAD_BUTTON_DPAD_LEFT];
|
bits[(uint32_t)ScePadButtonDataOffset::LEFT] = SDL_GameControllerGetButton(pad, SDL_CONTROLLER_BUTTON_DPAD_LEFT);
|
||||||
bits[(uint32_t)ScePadButtonDataOffset::L1] = state.buttons[GLFW_GAMEPAD_BUTTON_LEFT_BUMPER];
|
bits[(uint32_t)ScePadButtonDataOffset::L1] = SDL_GameControllerGetButton(pad, SDL_CONTROLLER_BUTTON_LEFTSHOULDER);
|
||||||
bits[(uint32_t)ScePadButtonDataOffset::R1] = state.buttons[GLFW_GAMEPAD_BUTTON_RIGHT_BUMPER];
|
bits[(uint32_t)ScePadButtonDataOffset::R1] = SDL_GameControllerGetButton(pad, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER);
|
||||||
bits[(uint32_t)ScePadButtonDataOffset::TRIANGLE] = state.buttons[GLFW_GAMEPAD_BUTTON_TRIANGLE];
|
bits[(uint32_t)ScePadButtonDataOffset::TRIANGLE] = SDL_GameControllerGetButton(pad, SDL_CONTROLLER_BUTTON_Y);
|
||||||
bits[(uint32_t)ScePadButtonDataOffset::CIRCLE] = state.buttons[GLFW_GAMEPAD_BUTTON_CIRCLE];
|
bits[(uint32_t)ScePadButtonDataOffset::CIRCLE] = SDL_GameControllerGetButton(pad, SDL_CONTROLLER_BUTTON_B);
|
||||||
bits[(uint32_t)ScePadButtonDataOffset::CROSS] = state.buttons[GLFW_GAMEPAD_BUTTON_CROSS];
|
bits[(uint32_t)ScePadButtonDataOffset::CROSS] = SDL_GameControllerGetButton(pad, SDL_CONTROLLER_BUTTON_A);
|
||||||
bits[(uint32_t)ScePadButtonDataOffset::SQUARE] = state.buttons[GLFW_GAMEPAD_BUTTON_SQUARE];
|
bits[(uint32_t)ScePadButtonDataOffset::SQUARE] = SDL_GameControllerGetButton(pad, SDL_CONTROLLER_BUTTON_X);
|
||||||
bits[(uint32_t)ScePadButtonDataOffset::TOUCH_PAD] = state.buttons[GLFW_GAMEPAD_BUTTON_BACK];
|
bits[(uint32_t)ScePadButtonDataOffset::TOUCH_PAD] = SDL_GameControllerGetButton(pad, SDL_CONTROLLER_BUTTON_TOUCHPAD);
|
||||||
return bits.to_ulong();
|
return bits.to_ulong();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t convertAnalog(float value) {
|
uint8_t scaleAnalogStick(Sint16 value) {
|
||||||
// todo: windows uses 255 ps4 256
|
// input -32768 (up/left) to 32767 (down/right).
|
||||||
int32_t v = (256.0f + 255.0f * value) / 2.0f;
|
// return 0..255
|
||||||
// int32_t v = (255.0f * (value + 1.0f)) / 2.0f;
|
|
||||||
return std::clamp(v, 0, 255);
|
return 255 * (32768 + value) / (32768 + 32767);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t scaleAnalogButton(Sint16 value) {
|
||||||
|
// input 0 when released to 32767
|
||||||
|
// return 0..255
|
||||||
|
|
||||||
|
return 255 * value / 32767;
|
||||||
}
|
}
|
||||||
|
|
||||||
ScePadData getPadData(int handle) {
|
ScePadData getPadData(int handle) {
|
||||||
LOG_USE_MODULE(libScePad);
|
LOG_USE_MODULE(libScePad);
|
||||||
ScePadData data;
|
ScePadData data;
|
||||||
|
|
||||||
GLFWgamepadstate state;
|
auto pData = getData();
|
||||||
if (auto res = glfwGetGamepadState(handle, &state); res < 0) {
|
auto pController = pData->controller[handle].padPtr;
|
||||||
LOG_ERR(L"glfwGetGamepadState err:%d", res);
|
|
||||||
return ScePadData();
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pData = getData();
|
if (pController == nullptr) return ScePadData();
|
||||||
auto lockGlfw = accessVideoOut().getGlfwLock();
|
auto lockSDL2 = accessVideoOut().getSDLLock();
|
||||||
return ScePadData {
|
// SDL_GameControllerTouch
|
||||||
.buttons = getButtons(state),
|
|
||||||
|
data = ScePadData {
|
||||||
|
.buttons = getButtons(pController),
|
||||||
.leftStick =
|
.leftStick =
|
||||||
{
|
{
|
||||||
.x = convertAnalog(state.axes[GLFW_GAMEPAD_AXIS_LEFT_X]),
|
.x = scaleAnalogStick(SDL_GameControllerGetAxis(pController, SDL_CONTROLLER_AXIS_LEFTX)),
|
||||||
.y = convertAnalog(state.axes[GLFW_GAMEPAD_AXIS_LEFT_Y]),
|
.y = scaleAnalogStick(SDL_GameControllerGetAxis(pController, SDL_CONTROLLER_AXIS_LEFTY)),
|
||||||
},
|
},
|
||||||
.rightStick =
|
.rightStick =
|
||||||
{
|
{
|
||||||
.x = convertAnalog(state.axes[GLFW_GAMEPAD_AXIS_RIGHT_X]),
|
.x = scaleAnalogStick(SDL_GameControllerGetAxis(pController, SDL_CONTROLLER_AXIS_RIGHTX)),
|
||||||
.y = convertAnalog(state.axes[GLFW_GAMEPAD_AXIS_RIGHT_Y]),
|
.y = scaleAnalogStick(SDL_GameControllerGetAxis(pController, SDL_CONTROLLER_AXIS_RIGHTY)),
|
||||||
},
|
},
|
||||||
.analogButtons =
|
.analogButtons =
|
||||||
{
|
{
|
||||||
.l2 = convertAnalog(state.axes[GLFW_GAMEPAD_AXIS_LEFT_TRIGGER]),
|
.l2 = scaleAnalogButton(SDL_GameControllerGetAxis(pController, SDL_CONTROLLER_AXIS_TRIGGERLEFT)),
|
||||||
.r2 = convertAnalog(state.axes[GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER]),
|
.r2 = scaleAnalogButton(SDL_GameControllerGetAxis(pController, SDL_CONTROLLER_AXIS_TRIGGERRIGHT)),
|
||||||
},
|
},
|
||||||
.orientation =
|
.orientation =
|
||||||
{
|
{
|
||||||
@ -122,11 +141,26 @@ ScePadData getPadData(int handle) {
|
|||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
.connected = glfwJoystickIsGamepad(handle) == GLFW_TRUE,
|
.connected = SDL_GameControllerGetAttached(pController) == true,
|
||||||
.timestamp = accessTimer().getTicks(),
|
.timestamp = accessTimer().getTicks(),
|
||||||
.connectedCount = pData->controller[handle].countConnect,
|
.connectedCount = pData->controller[handle].countConnect,
|
||||||
.deviceUniqueDataLen = 0,
|
.deviceUniqueDataLen = 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
data.touchData.touchNum = 0;
|
||||||
|
for (int f = 0; f < SDL_GameControllerGetNumTouchpadFingers(pController, 0); f++) {
|
||||||
|
uint8_t s = 0;
|
||||||
|
float x = 0.0f, y = 0.0f;
|
||||||
|
auto& touch = data.touchData.touch[f];
|
||||||
|
|
||||||
|
SDL_GameControllerGetTouchpadFinger(pController, 0, f, &s, &x, &y, NULL);
|
||||||
|
if (s > 0) {
|
||||||
|
touch.x = x * 0xFFFF, touch.y = y * 0xFFFF;
|
||||||
|
++data.touchData.touchNum;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return data;
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
@ -135,30 +169,34 @@ extern "C" {
|
|||||||
EXPORT const char* MODULE_NAME = "libScePad";
|
EXPORT const char* MODULE_NAME = "libScePad";
|
||||||
|
|
||||||
EXPORT SYSV_ABI int scePadInit(void) {
|
EXPORT SYSV_ABI int scePadInit(void) {
|
||||||
glfwInit();
|
LOG_USE_MODULE(libScePad);
|
||||||
return glfwInit() ? Ok : Err::FATAL;
|
|
||||||
|
int32_t ret = SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER | SDL_INIT_HAPTIC) == 0 ? Ok : Err::FATAL;
|
||||||
|
if (SDL_GameControllerAddMappingsFromFile("gamecontrollerdb.txt") < 0) {
|
||||||
|
LOG_WARN(L"Failed to load game controller mappings");
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT SYSV_ABI int scePadOpen(int32_t userId, PadPortType type, int32_t index, const void* pParam) {
|
EXPORT SYSV_ABI int scePadOpen(int32_t userId, PadPortType type, int32_t index, const void* pParam) {
|
||||||
LOG_USE_MODULE(libScePad);
|
LOG_USE_MODULE(libScePad);
|
||||||
|
|
||||||
auto pData = getData();
|
auto pData = getData();
|
||||||
|
|
||||||
std::unique_lock const lock(pData->m_mutexInt);
|
std::unique_lock const lock(pData->m_mutexInt);
|
||||||
|
|
||||||
// Check already opened
|
// Check already opened
|
||||||
for (size_t n = GLFW_JOYSTICK_1; n <= GLFW_JOYSTICK_LAST; ++n) {
|
for (size_t n = 0; n < 16; ++n) {
|
||||||
if (pData->controller[n].userId == userId) return Err::ALREADY_OPENED;
|
if (pData->controller[n].userId == userId) return Err::ALREADY_OPENED;
|
||||||
}
|
}
|
||||||
// - already open
|
// - already open
|
||||||
|
|
||||||
auto lockGlfw = accessVideoOut().getGlfwLock();
|
auto lockSDL2 = accessVideoOut().getSDLLock();
|
||||||
for (size_t n = GLFW_JOYSTICK_1; n <= GLFW_JOYSTICK_LAST; ++n) {
|
for (size_t n = 0; n < 16; ++n) {
|
||||||
if (pData->controller[n].userId >= 0) continue;
|
if (pData->controller[n].userId >= 0) continue;
|
||||||
pData->controller[n].userId = userId;
|
setupPad(n, userId);
|
||||||
++pData->controller[n].countConnect;
|
|
||||||
pData->controller[n].prePadData = ScePadData();
|
|
||||||
|
|
||||||
LOG_INFO(L"-> Pad[%llu]: userId:%d name:%S", n, userId, glfwGetJoystickName(n));
|
LOG_INFO(L"-> Pad[%llu]: userId:%d name:%S", n, userId, SDL_GameControllerNameForIndex(n));
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
return Err::NO_HANDLE;
|
return Err::NO_HANDLE;
|
||||||
@ -174,6 +212,8 @@ EXPORT SYSV_ABI int scePadClose(int32_t handle) {
|
|||||||
std::unique_lock const lock(pData->m_mutexInt);
|
std::unique_lock const lock(pData->m_mutexInt);
|
||||||
LOG_INFO(L"<- Pad[%d]", handle);
|
LOG_INFO(L"<- Pad[%d]", handle);
|
||||||
pData->controller[handle].userId = -1;
|
pData->controller[handle].userId = -1;
|
||||||
|
SDL_GameControllerClose(pData->controller[handle].padPtr);
|
||||||
|
pData->controller[handle].padPtr = nullptr;
|
||||||
|
|
||||||
return Ok;
|
return Ok;
|
||||||
}
|
}
|
||||||
@ -184,7 +224,7 @@ EXPORT SYSV_ABI int scePadGetHandle(int32_t userId, PadPortType type, int32_t in
|
|||||||
LOG_DEBUG(L"");
|
LOG_DEBUG(L"");
|
||||||
std::unique_lock const lock(pData->m_mutexInt);
|
std::unique_lock const lock(pData->m_mutexInt);
|
||||||
|
|
||||||
for (size_t n = GLFW_JOYSTICK_1; n <= GLFW_JOYSTICK_LAST; ++n) {
|
for (size_t n = 0; n < 16; ++n) {
|
||||||
if (pData->controller[n].userId == userId) {
|
if (pData->controller[n].userId == userId) {
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
@ -196,14 +236,21 @@ EXPORT SYSV_ABI int scePadRead(int32_t handle, ScePadData* pPadData, int32_t num
|
|||||||
LOG_USE_MODULE(libScePad);
|
LOG_USE_MODULE(libScePad);
|
||||||
if (handle < 0) return Err::INVALID_HANDLE;
|
if (handle < 0) return Err::INVALID_HANDLE;
|
||||||
|
|
||||||
auto pData = getData();
|
auto pData = getData();
|
||||||
|
auto pController = &pData->controller[handle];
|
||||||
|
auto pSDLController = pController->padPtr;
|
||||||
|
if (SDL_GameControllerGetAttached(pSDLController) == false) {
|
||||||
|
SDL_GameControllerClose(pSDLController);
|
||||||
|
if ((pSDLController = setupPad(handle, 0)) == nullptr) return Err::DEVICE_NOT_CONNECTED;
|
||||||
|
}
|
||||||
|
|
||||||
std::unique_lock const lock(pData->m_mutexInt);
|
std::unique_lock const lock(pData->m_mutexInt);
|
||||||
|
|
||||||
*pPadData = getPadData(handle);
|
*pPadData = getPadData(handle);
|
||||||
|
|
||||||
int retVal = std::memcmp((uint8_t*)&pData->controller[handle].prePadData, (uint8_t*)pPadData, offsetof(ScePadData, connected));
|
int retVal = std::memcmp((uint8_t*)&pData->controller[handle].prePadData, (uint8_t*)pPadData, offsetof(ScePadData, connected));
|
||||||
LOG_DEBUG(L"buttons 0x%lx diff:%d", pPadData->buttons, retVal);
|
LOG_DEBUG(L"buttons 0x%lx leftStick:%u/%u rightStick:%u/%u diff:%d", pPadData->buttons, pPadData->leftStick.x, pPadData->leftStick.y, pPadData->rightStick.x,
|
||||||
|
pPadData->rightStick.y, retVal);
|
||||||
|
|
||||||
pData->controller[handle].prePadData = *pPadData;
|
pData->controller[handle].prePadData = *pPadData;
|
||||||
return abs(retVal);
|
return abs(retVal);
|
||||||
@ -236,22 +283,39 @@ EXPORT SYSV_ABI int scePadResetOrientation(int32_t handle) {
|
|||||||
|
|
||||||
EXPORT SYSV_ABI int scePadSetVibration(int32_t handle, const ScePadVibrationParam* pParam) {
|
EXPORT SYSV_ABI int scePadSetVibration(int32_t handle, const ScePadVibrationParam* pParam) {
|
||||||
if (handle < 0) return Err::INVALID_HANDLE;
|
if (handle < 0) return Err::INVALID_HANDLE;
|
||||||
|
|
||||||
|
auto pData = getData();
|
||||||
|
auto pController = pData->controller[handle].padPtr;
|
||||||
|
|
||||||
|
SDL_GameControllerRumble(pController, ((float)pParam->smallMotor / 255.0f) * 0xFFFF, ((float)pParam->largeMotor / 255.0f) * 0xFFFF, -1);
|
||||||
return Ok;
|
return Ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT SYSV_ABI int scePadSetLightBar(int32_t handle, const ScePadColor* pParam) {
|
EXPORT SYSV_ABI int scePadSetLightBar(int32_t handle, const ScePadColor* pParam) {
|
||||||
if (handle < 0) return Err::INVALID_HANDLE;
|
if (handle < 0) return Err::INVALID_HANDLE;
|
||||||
|
|
||||||
|
auto pData = getData();
|
||||||
|
auto pController = pData->controller[handle].padPtr;
|
||||||
|
|
||||||
|
if (SDL_GameControllerHasLED(pController) == false) return Err::INVALID_LIGHTBAR_SETTING;
|
||||||
|
|
||||||
|
SDL_GameControllerSetLED(pController, pParam->r, pParam->g, pParam->b);
|
||||||
return Ok;
|
return Ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT SYSV_ABI int scePadResetLightBar(int32_t handle) {
|
EXPORT SYSV_ABI int scePadResetLightBar(int32_t handle) {
|
||||||
if (handle < 0) return Err::INVALID_HANDLE;
|
if (handle < 0) return Err::INVALID_HANDLE;
|
||||||
|
|
||||||
|
auto pData = getData();
|
||||||
|
auto pController = pData->controller[handle].padPtr;
|
||||||
|
if (SDL_GameControllerHasLED(pController) == false) return Err::INVALID_LIGHTBAR_SETTING;
|
||||||
|
|
||||||
|
SDL_GameControllerSetLED(pController, 0, 0, 0);
|
||||||
return Ok;
|
return Ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT SYSV_ABI int scePadGetControllerInformation(int32_t handle, ScePadControllerInformation* pInfo) {
|
EXPORT SYSV_ABI int scePadGetControllerInformation(int32_t handle, ScePadControllerInformation* pInfo) {
|
||||||
LOG_USE_MODULE(libScePad);
|
LOG_USE_MODULE(libScePad);
|
||||||
LOG_DEBUG(L"");
|
|
||||||
if (handle < 0) return Err::INVALID_HANDLE;
|
if (handle < 0) return Err::INVALID_HANDLE;
|
||||||
auto pData = getData();
|
auto pData = getData();
|
||||||
|
|
||||||
@ -282,10 +346,10 @@ EXPORT SYSV_ABI int scePadGetControllerInformation(int32_t handle, ScePadControl
|
|||||||
pInfo->stickInfo.deadZoneLeft = 2; // todo make config
|
pInfo->stickInfo.deadZoneLeft = 2; // todo make config
|
||||||
pInfo->stickInfo.deadZoneRight = 2; // todo make config
|
pInfo->stickInfo.deadZoneRight = 2; // todo make config
|
||||||
|
|
||||||
auto lockGlfw = accessVideoOut().getGlfwLock();
|
auto lockSDL2 = accessVideoOut().getSDLLock();
|
||||||
pInfo->connectionType = (uint8_t)PadPortType::STANDARD;
|
pInfo->connectionType = (uint8_t)PadPortType::STANDARD;
|
||||||
pInfo->connectedCount = pad.countConnect;
|
pInfo->connectedCount = pad.countConnect;
|
||||||
pInfo->connected = glfwJoystickPresent(handle) == GLFW_TRUE;
|
pInfo->connected = SDL_GameControllerGetAttached(pad.padPtr) == true;
|
||||||
pInfo->deviceClass = ScePadDeviceClass::STANDARD;
|
pInfo->deviceClass = ScePadDeviceClass::STANDARD;
|
||||||
|
|
||||||
LOG_DEBUG(L"handle:%d connected:%d", handle, pInfo->connected);
|
LOG_DEBUG(L"handle:%d connected:%d", handle, pInfo->connected);
|
||||||
@ -294,15 +358,15 @@ EXPORT SYSV_ABI int scePadGetControllerInformation(int32_t handle, ScePadControl
|
|||||||
|
|
||||||
EXPORT SYSV_ABI int scePadDeviceClassParseData(int32_t handle, const ScePadData* pData, ScePadDeviceClassData* pDeviceClassData) {
|
EXPORT SYSV_ABI int scePadDeviceClassParseData(int32_t handle, const ScePadData* pData, ScePadDeviceClassData* pDeviceClassData) {
|
||||||
LOG_USE_MODULE(libScePad);
|
LOG_USE_MODULE(libScePad);
|
||||||
LOG_DEBUG(L"");
|
LOG_DEBUG(L"todo %S", __FUNCTION__);
|
||||||
if (handle < 0) return Err::INVALID_HANDLE;
|
if (handle < 0) return Err::INVALID_HANDLE;
|
||||||
return Ok;
|
return Ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT SYSV_ABI int scePadDeviceClassGetExtendedInformation(int32_t handle, ScePadDeviceClassExtendedInformation* pExtInfo) {
|
EXPORT SYSV_ABI int scePadDeviceClassGetExtendedInformation(int32_t handle, ScePadDeviceClassExtendedInformation* pExtInfo) {
|
||||||
LOG_USE_MODULE(libScePad);
|
LOG_USE_MODULE(libScePad);
|
||||||
LOG_DEBUG(L"");
|
LOG_DEBUG(L"todo %S", __FUNCTION__);
|
||||||
if (handle < 0) return Err::INVALID_HANDLE;
|
if (handle < 0) return Err::INVALID_HANDLE;
|
||||||
return Ok;
|
return Ok;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -160,6 +160,7 @@ struct ScePadColor {
|
|||||||
|
|
||||||
struct ScePadTouchPadInformation {
|
struct ScePadTouchPadInformation {
|
||||||
float pixelDensity;
|
float pixelDensity;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
uint16_t x;
|
uint16_t x;
|
||||||
uint16_t y;
|
uint16_t y;
|
||||||
@ -203,6 +204,7 @@ struct ScePadDeviceClassData {
|
|||||||
uint8_t gear;
|
uint8_t gear;
|
||||||
uint8_t reserved[1];
|
uint8_t reserved[1];
|
||||||
} steeringWheel;
|
} steeringWheel;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
uint8_t toneNumber;
|
uint8_t toneNumber;
|
||||||
uint8_t whammyBar;
|
uint8_t whammyBar;
|
||||||
@ -213,6 +215,7 @@ struct ScePadDeviceClassData {
|
|||||||
uint8_t fretSolo;
|
uint8_t fretSolo;
|
||||||
uint8_t reserved[11];
|
uint8_t reserved[11];
|
||||||
} guitar;
|
} guitar;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
uint8_t snare;
|
uint8_t snare;
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ add_library(${libName} SHARED
|
|||||||
pthread.cpp
|
pthread.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
add_dependencies(${libName} core third_party)
|
add_dependencies(${libName} core third_party boost)
|
||||||
target_link_libraries(${libName} PRIVATE
|
target_link_libraries(${libName} PRIVATE
|
||||||
core.lib
|
core.lib
|
||||||
libboost_thread
|
libboost_thread
|
||||||
|
@ -6,7 +6,7 @@ project(${libName})
|
|||||||
|
|
||||||
add_library(${libName} SHARED entry.cpp)
|
add_library(${libName} SHARED entry.cpp)
|
||||||
|
|
||||||
add_dependencies(${libName} third_party)
|
add_dependencies(${libName} third_party boost)
|
||||||
target_link_libraries(${libName} PRIVATE
|
target_link_libraries(${libName} PRIVATE
|
||||||
libboost_chrono
|
libboost_chrono
|
||||||
)
|
)
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
#include "..\libSceCommonDialog\types.h"
|
#include "..\libSceCommonDialog\types.h"
|
||||||
#include "codes.h"
|
#include "codes.h"
|
||||||
|
|
||||||
|
|
||||||
struct SceSaveDataDialogAnimationParam {
|
struct SceSaveDataDialogAnimationParam {
|
||||||
SceSaveDataDialogAnimation userOK; /// animation setting when user decide OK or ListItem
|
SceSaveDataDialogAnimation userOK; /// animation setting when user decide OK or ListItem
|
||||||
SceSaveDataDialogAnimation userCancel; /// animation setting when user cancel
|
SceSaveDataDialogAnimation userCancel; /// animation setting when user cancel
|
||||||
@ -126,4 +125,4 @@ struct SceSaveDataDialogResult {
|
|||||||
|
|
||||||
void* userData; /// Userdata specified at calling function
|
void* userData; /// Userdata specified at calling function
|
||||||
uint8_t reserved[32]; /// Reserved range (must be filled by zero)
|
uint8_t reserved[32]; /// Reserved range (must be filled by zero)
|
||||||
};
|
};
|
||||||
|
@ -3,38 +3,47 @@
|
|||||||
|
|
||||||
struct SceSystemServiceEvent {
|
struct SceSystemServiceEvent {
|
||||||
SceSystemServiceEventType eventType;
|
SceSystemServiceEventType eventType;
|
||||||
|
|
||||||
union {
|
union {
|
||||||
char param[8192];
|
char param[8192];
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
char source[1024];
|
char source[1024];
|
||||||
|
|
||||||
union {
|
union {
|
||||||
char arg[4096];
|
char arg[4096];
|
||||||
char url[4096];
|
char url[4096];
|
||||||
};
|
};
|
||||||
} urlOpen;
|
} urlOpen;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
uint32_t size;
|
uint32_t size;
|
||||||
uint8_t arg[8188];
|
uint8_t arg[8188];
|
||||||
} launchApp;
|
} launchApp;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
uint32_t size;
|
uint32_t size;
|
||||||
uint8_t arg[2020];
|
uint8_t arg[2020];
|
||||||
} appLaunchLink;
|
} appLaunchLink;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
int32_t userId;
|
int32_t userId;
|
||||||
char eventId[37];
|
char eventId[37];
|
||||||
char bootArgument[7169];
|
char bootArgument[7169];
|
||||||
} joinEvent;
|
} joinEvent;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
int32_t userId;
|
int32_t userId;
|
||||||
uint32_t npServiceLabel;
|
uint32_t npServiceLabel;
|
||||||
uint8_t reserved[8184];
|
uint8_t reserved[8184];
|
||||||
} serviceEntitlementUpdate;
|
} serviceEntitlementUpdate;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
int32_t userId;
|
int32_t userId;
|
||||||
uint32_t npServiceLabel;
|
uint32_t npServiceLabel;
|
||||||
uint8_t reserved[8184];
|
uint8_t reserved[8184];
|
||||||
} unifiedEntitlementUpdate;
|
} unifiedEntitlementUpdate;
|
||||||
|
|
||||||
uint8_t reserved[8192];
|
uint8_t reserved[8192];
|
||||||
} data;
|
} data;
|
||||||
};
|
};
|
||||||
|
@ -15,7 +15,7 @@ add_library(${libName} SHARED
|
|||||||
pthread.cpp
|
pthread.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
add_dependencies(${libName} core third_party)
|
add_dependencies(${libName} core third_party boost)
|
||||||
target_link_libraries(${libName} PRIVATE
|
target_link_libraries(${libName} PRIVATE
|
||||||
core.lib
|
core.lib
|
||||||
libboost_thread
|
libboost_thread
|
||||||
|
@ -6,7 +6,7 @@ project(${libName})
|
|||||||
|
|
||||||
add_library(${libName} SHARED entry.cpp)
|
add_library(${libName} SHARED entry.cpp)
|
||||||
|
|
||||||
add_dependencies(${libName} core third_party)
|
add_dependencies(${libName} core third_party boost)
|
||||||
target_link_libraries(${libName} PRIVATE
|
target_link_libraries(${libName} PRIVATE
|
||||||
core.lib
|
core.lib
|
||||||
libboost_thread
|
libboost_thread
|
||||||
|
16
readme.md
16
readme.md
@ -1,6 +1,6 @@
|
|||||||
# psOff - PlayStation 4 Emulation (Windows)
|
# psOff - PlayStation 4 Emulation (Windows)
|
||||||
|
|
||||||
![Discord](https://img.shields.io/discord/1215784508708749322?style=plastic&logo=discord&logoColor=white&link=https%3A%2F%2Fdiscord.gg%2FJd2AuBN6eW)
|
[<img src="https://img.shields.io/discord/1215784508708749322?color=5865F2&label=ps_off&logo=discord&logoColor=white"/>](https://discord.gg/Jd2AuBN6eW)
|
||||||
|
|
||||||
**In development. Does it run ...? No!**
|
**In development. Does it run ...? No!**
|
||||||
|
|
||||||
@ -13,7 +13,7 @@ Target is to have a standalone framework for shader reconstruction, command buff
|
|||||||
<img src="https://github.com/SysRay/psOff_public/assets/48695846/7e723874-5bb9-4cb7-bb28-5b0001d81f65" width="400" title="fps is capped internally">
|
<img src="https://github.com/SysRay/psOff_public/assets/48695846/7e723874-5bb9-4cb7-bb28-5b0001d81f65" width="400" title="fps is capped internally">
|
||||||
|
|
||||||
|
|
||||||
No, the fps is not fake :)
|
No, the fps is not fake. :)
|
||||||
|
|
||||||
## Description
|
## Description
|
||||||
Yet another compatibility layer! I solely focused on the rendering part and recently started to implement the system functions to run some binaries.
|
Yet another compatibility layer! I solely focused on the rendering part and recently started to implement the system functions to run some binaries.
|
||||||
@ -31,18 +31,18 @@ I don't serve spaghetti only bugs.
|
|||||||
## Getting Started
|
## Getting Started
|
||||||
### Dependencies
|
### Dependencies
|
||||||
+ Vulkan SDK 1.3.268.0, minimum
|
+ Vulkan SDK 1.3.268.0, minimum
|
||||||
+ up to date graphic drivers
|
+ Up to date graphic drivers
|
||||||
|
|
||||||
(May add the Vulkan libs in future Releases, if needed )
|
(May add the Vulkan libs in Future Releases, if needed.)
|
||||||
|
|
||||||
For development:
|
For development:
|
||||||
|
|
||||||
+ Ninja
|
+ Ninja
|
||||||
+ CMake 3.24+
|
+ CMake 3.24+
|
||||||
+ Visual Studio 2019 or newer, it' just for the build environment (uses clang-cl,c++20)
|
+ Visual Studio 2019 or newer, it's just for the build environment (uses clang-cl,c++20)
|
||||||
|
|
||||||
### Installing
|
### Installing
|
||||||
For testing, just download the latest release and install the Vulkan SDK
|
For testing, just download the latest release and install the Vulkan SDK.
|
||||||
|
|
||||||
### Executing program
|
### Executing program
|
||||||
```
|
```
|
||||||
@ -62,7 +62,7 @@ eboot.bin
|
|||||||
|
|
||||||
## Development
|
## Development
|
||||||
|
|
||||||
Use boosts thread, mutex and conditions. The waits have to be alert able in order to receive fake signals from "kernel".
|
Use boosts thread, mutex and conditions. The waits have to be alertable in order to receive fake signals from "kernel".
|
||||||
|
|
||||||
Project uses p7 for tracing -> Baical server.
|
Project uses p7 for tracing -> Baical server.
|
||||||
|
|
||||||
@ -70,4 +70,4 @@ Project uses p7 for tracing -> Baical server.
|
|||||||
* core: kernel, memory etc.
|
* core: kernel, memory etc.
|
||||||
* emulator.exe: (From Releases) contains the runtime and rendering
|
* emulator.exe: (From Releases) contains the runtime and rendering
|
||||||
|
|
||||||
I'm using vscode, '.vscode\tasks.json' contains the config&build tasks.
|
I'm using vscode, '.vscode\tasks.json' contains the config & build tasks.
|
||||||
|
28
third_party/CMakeLists.txt
vendored
28
third_party/CMakeLists.txt
vendored
@ -3,9 +3,9 @@ project(third_party VERSION 0.0.1)
|
|||||||
|
|
||||||
include(ExternalProject)
|
include(ExternalProject)
|
||||||
|
|
||||||
add_subdirectory(portAudio)
|
|
||||||
add_subdirectory(optick)
|
add_subdirectory(optick)
|
||||||
add_subdirectory(p7)
|
add_subdirectory(p7)
|
||||||
|
add_subdirectory(SDL2)
|
||||||
|
|
||||||
install(DIRECTORY "ffmpeg/bin/" DESTINATION "${CMAKE_BINARY_DIR}/bin"
|
install(DIRECTORY "ffmpeg/bin/" DESTINATION "${CMAKE_BINARY_DIR}/bin"
|
||||||
FILES_MATCHING PATTERN "*.dll"
|
FILES_MATCHING PATTERN "*.dll"
|
||||||
@ -17,27 +17,11 @@ set_target_properties(OptickCore
|
|||||||
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/install/lib"
|
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/install/lib"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Boost
|
set_target_properties(SDL2
|
||||||
set(BOOST_INCLUDE_LIBRARIES "program_options;date_time;interprocess;stacktrace;uuid;beast;signals2;thread")
|
PROPERTIES
|
||||||
ExternalProject_Add(boost_thirdParty
|
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/install/lib"
|
||||||
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/boost
|
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/install/lib"
|
||||||
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/boost
|
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/install/bin"
|
||||||
CMAKE_ARGS
|
|
||||||
-DCMAKE_BUILD_TYPE:STRING=Release
|
|
||||||
-DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/install
|
|
||||||
-DCMAKE_CXX_FLAGS_RELEASE=${CMAKE_CXX_FLAGS_RELEASE}
|
|
||||||
-DCMAKE_C_FLAGS_RELEASE=${CMAKE_C_FLAGS_RELEASE}
|
|
||||||
-DBoost_USE_STATIC_LIBS=ON
|
|
||||||
-DBoost_USE_MULTITHREADED=ON
|
|
||||||
-DBUILD_TESTING=OFF
|
|
||||||
-DBOOST_INSTALL_LAYOUT=system
|
|
||||||
CMAKE_CACHE_ARGS -DBOOST_INCLUDE_LIBRARIES:STRING=${BOOST_INCLUDE_LIBRARIES}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
|
option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
|
||||||
option(GLFW_BUILD_EXAMPLES "Build the GLFW example programs" OFF)
|
|
||||||
option(GLFW_BUILD_TESTS "Build the GLFW test programs" OFF)
|
|
||||||
option(GLFW_BUILD_DOCS "Build the GLFW documentation" OFF)
|
|
||||||
option(GLFW_INSTALL "Generate installation target" ON)
|
|
||||||
option(GLFW_VULKAN_STATIC "Assume the Vulkan loader is linked with the application" ON)
|
|
||||||
add_subdirectory(glfw)
|
|
1
third_party/SDL2
vendored
Submodule
1
third_party/SDL2
vendored
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit 31849369506d54aac7fa799c8c2851ded18c87f5
|
1
third_party/glfw
vendored
1
third_party/glfw
vendored
@ -1 +0,0 @@
|
|||||||
Subproject commit dc557ecf38a42b0b93898a7aef69f6dc48bf0e57
|
|
487
third_party/portAudio/CMakeLists.txt
vendored
487
third_party/portAudio/CMakeLists.txt
vendored
@ -1,487 +0,0 @@
|
|||||||
# $Id: $
|
|
||||||
#
|
|
||||||
# For a "How-To" please refer to the Portaudio documentation at:
|
|
||||||
# http://www.portaudio.com/trac/wiki/TutorialDir/Compile/CMake
|
|
||||||
#
|
|
||||||
|
|
||||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
|
|
||||||
|
|
||||||
# Check if the user is building PortAudio stand-alone or as part of a larger
|
|
||||||
# project. If this is part of a larger project (i.e. the CMakeLists.txt has
|
|
||||||
# been imported by some other CMakeLists.txt), we don't want to trump over
|
|
||||||
# the top of that project's global settings.
|
|
||||||
IF(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_LIST_DIR})
|
|
||||||
PROJECT(portaudio)
|
|
||||||
|
|
||||||
# CMAKE_CONFIGURATION_TYPES only exists for multi-config generators (like
|
|
||||||
# Visual Studio or Xcode). For these projects, we won't define
|
|
||||||
# CMAKE_BUILD_TYPE as it does not make sense.
|
|
||||||
IF(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
|
||||||
MESSAGE(STATUS "Setting CMAKE_BUILD_TYPE type to 'Debug' as none was specified.")
|
|
||||||
SET(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build." FORCE)
|
|
||||||
SET_PROPERTY(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release")
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
SET_PROPERTY(GLOBAL PROPERTY USE_FOLDERS ON)
|
|
||||||
|
|
||||||
IF(WIN32 AND MSVC)
|
|
||||||
OPTION(PA_DLL_LINK_WITH_STATIC_RUNTIME "Link with static runtime libraries (minimizes runtime dependencies)" ON)
|
|
||||||
IF(PA_DLL_LINK_WITH_STATIC_RUNTIME)
|
|
||||||
FOREACH(flag_var
|
|
||||||
CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
|
|
||||||
CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO
|
|
||||||
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
|
|
||||||
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
|
|
||||||
IF(${flag_var} MATCHES "/MD")
|
|
||||||
STRING(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
|
|
||||||
ENDIF()
|
|
||||||
ENDFOREACH()
|
|
||||||
ENDIF()
|
|
||||||
ENDIF()
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
SET(PA_VERSION 19)
|
|
||||||
SET(PA_PKGCONFIG_VERSION ${PA_VERSION})
|
|
||||||
SET(PA_SOVERSION "${PA_VERSION}.0")
|
|
||||||
|
|
||||||
# Most of the code from this point onwards is related to populating the
|
|
||||||
# following variables:
|
|
||||||
# PA_PUBLIC_INCLUDES - This contains the list of public PortAudio header
|
|
||||||
# files. These files will be copied into /include paths on Unix'y
|
|
||||||
# systems when "make install" is invoked.
|
|
||||||
# PA_PRIVATE_INCLUDES - This contains the list of header files which
|
|
||||||
# are not part of PortAudio, but are required by the various hostapis.
|
|
||||||
# It is only used by CMake IDE generators (like Visual Studio) to
|
|
||||||
# provide quick-links to useful headers. It has no impact on build
|
|
||||||
# output.
|
|
||||||
# PA_PRIVATE_INCLUDE_PATHS - This contains the list of include paths which
|
|
||||||
# will be passed to the compiler while PortAudio is being built which
|
|
||||||
# are not required by applications using the PortAudio API.
|
|
||||||
# PA_PRIVATE_COMPILE_DEFINITIONS - This contains a list of preprocessor
|
|
||||||
# macro definitions which will be set when compiling PortAudio source
|
|
||||||
# files.
|
|
||||||
# PA_SOURCES - This contains the list of source files which will be built
|
|
||||||
# into the static and shared PortAudio libraries.
|
|
||||||
# PA_NON_UNICODE_SOURCES - This also contains a list of source files which
|
|
||||||
# will be build into the static and shared PortAudio libraries. However,
|
|
||||||
# these sources will not have any unicode compiler definitions added
|
|
||||||
# to them. This list should only contain external source dependencies.
|
|
||||||
# PA_EXTRA_SHARED_SOURCES - Contains a list of extra files which will be
|
|
||||||
# associated only with the shared PortAudio library. This only seems
|
|
||||||
# relevant for Windows shared libraries which require a list of export
|
|
||||||
# symbols.
|
|
||||||
# Where other PA_* variables are set, these are almost always only used to
|
|
||||||
# preserve the historic SOURCE_GROUP behavior (which again only has an impact
|
|
||||||
# on IDE-style generators for visual appearance) or store the output of
|
|
||||||
# find_library() calls.
|
|
||||||
|
|
||||||
SET(PA_COMMON_INCLUDES
|
|
||||||
src/common/pa_allocation.h
|
|
||||||
src/common/pa_converters.h
|
|
||||||
src/common/pa_cpuload.h
|
|
||||||
src/common/pa_debugprint.h
|
|
||||||
src/common/pa_dither.h
|
|
||||||
src/common/pa_endianness.h
|
|
||||||
src/common/pa_hostapi.h
|
|
||||||
src/common/pa_memorybarrier.h
|
|
||||||
src/common/pa_process.h
|
|
||||||
src/common/pa_ringbuffer.h
|
|
||||||
src/common/pa_stream.h
|
|
||||||
src/common/pa_trace.h
|
|
||||||
src/common/pa_types.h
|
|
||||||
src/common/pa_util.h
|
|
||||||
)
|
|
||||||
|
|
||||||
SET(PA_COMMON_SOURCES
|
|
||||||
src/common/pa_allocation.c
|
|
||||||
src/common/pa_converters.c
|
|
||||||
src/common/pa_cpuload.c
|
|
||||||
src/common/pa_debugprint.c
|
|
||||||
src/common/pa_dither.c
|
|
||||||
src/common/pa_front.c
|
|
||||||
src/common/pa_process.c
|
|
||||||
src/common/pa_ringbuffer.c
|
|
||||||
src/common/pa_stream.c
|
|
||||||
src/common/pa_trace.c
|
|
||||||
)
|
|
||||||
|
|
||||||
SOURCE_GROUP("common" FILES ${PA_COMMON_INCLUDES} ${PA_COMMON_SOURCES})
|
|
||||||
|
|
||||||
SET(PA_PUBLIC_INCLUDES include/portaudio.h)
|
|
||||||
|
|
||||||
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake_support)
|
|
||||||
|
|
||||||
SET(PA_SKELETON_SOURCES src/hostapi/skeleton/pa_hostapi_skeleton.c)
|
|
||||||
SOURCE_GROUP("hostapi\\skeleton" ${PA_SKELETON_SOURCES})
|
|
||||||
SET(PA_SOURCES ${PA_COMMON_SOURCES} ${PA_SKELETON_SOURCES})
|
|
||||||
SET(PA_PRIVATE_INCLUDE_PATHS src/common ${CMAKE_CURRENT_BINARY_DIR})
|
|
||||||
|
|
||||||
IF(WIN32)
|
|
||||||
SET(PA_PRIVATE_COMPILE_DEFINITIONS ${PA_PRIVATE_COMPILE_DEFINITIONS} _CRT_SECURE_NO_WARNINGS)
|
|
||||||
|
|
||||||
SET(PA_PLATFORM_SOURCES
|
|
||||||
src/os/win/pa_win_hostapis.c
|
|
||||||
src/os/win/pa_win_util.c
|
|
||||||
src/os/win/pa_win_waveformat.c
|
|
||||||
src/os/win/pa_win_wdmks_utils.c
|
|
||||||
src/os/win/pa_win_coinitialize.c)
|
|
||||||
SET(PA_PLATFORM_INCLUDES
|
|
||||||
src/os/win/pa_win_coinitialize.h
|
|
||||||
src/os/win/pa_win_wdmks_utils.h)
|
|
||||||
|
|
||||||
IF(MSVC)
|
|
||||||
SET(PA_PLATFORM_SOURCES ${PA_PLATFORM_SOURCES} src/os/win/pa_x86_plain_converters.c)
|
|
||||||
SET(PA_PLATFORM_INCLUDES ${PA_PLATFORM_INCLUDES} src/os/win/pa_x86_plain_converters.h)
|
|
||||||
ELSE()
|
|
||||||
SET(PA_PRIVATE_COMPILE_DEFINITIONS ${PA_PRIVATE_COMPILE_DEFINITIONS} _WIN32_WINNT=0x0501 WINVER=0x0501)
|
|
||||||
SET(DEF_EXCLUDE_X86_PLAIN_CONVERTERS ";")
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
SOURCE_GROUP("os\\win" FILES ${PA_PLATFORM_SOURCES} ${PA_PLATFORM_INCLUDES})
|
|
||||||
SET(PA_SOURCES ${PA_SOURCES} ${PA_PLATFORM_SOURCES})
|
|
||||||
SET(PA_PRIVATE_INCLUDES ${PA_PRIVATE_INCLUDES} ${PA_PLATFORM_INCLUDES})
|
|
||||||
SET(PA_PRIVATE_INCLUDE_PATHS ${PA_PRIVATE_INCLUDE_PATHS} src/os/win)
|
|
||||||
|
|
||||||
SET(PA_LIBRARY_DEPENDENCIES ${PA_LIBRARY_DEPENDENCIES} winmm)
|
|
||||||
|
|
||||||
# Try to find ASIO SDK (assumes that portaudio and asiosdk folders are side-by-side, see
|
|
||||||
# http://www.portaudio.com/trac/wiki/TutorialDir/Compile/WindowsASIOMSVC)
|
|
||||||
FIND_PACKAGE(ASIOSDK)
|
|
||||||
IF(ASIOSDK_FOUND)
|
|
||||||
OPTION(PA_USE_ASIO "Enable support for ASIO" ON)
|
|
||||||
ELSE()
|
|
||||||
OPTION(PA_USE_ASIO "Enable support for ASIO" OFF)
|
|
||||||
ENDIF()
|
|
||||||
IF(PA_USE_ASIO)
|
|
||||||
SET(PA_PRIVATE_INCLUDE_PATHS ${PA_PRIVATE_INCLUDE_PATHS} ${ASIOSDK_ROOT_DIR}/common)
|
|
||||||
SET(PA_PRIVATE_INCLUDE_PATHS ${PA_PRIVATE_INCLUDE_PATHS} ${ASIOSDK_ROOT_DIR}/host)
|
|
||||||
SET(PA_PRIVATE_INCLUDE_PATHS ${PA_PRIVATE_INCLUDE_PATHS} ${ASIOSDK_ROOT_DIR}/host/pc)
|
|
||||||
SET(PA_ASIO_SOURCES src/hostapi/asio/pa_asio.cpp src/hostapi/asio/iasiothiscallresolver.cpp)
|
|
||||||
SET(PA_ASIOSDK_SOURCES ${ASIOSDK_ROOT_DIR}/common/asio.cpp ${ASIOSDK_ROOT_DIR}/host/pc/asiolist.cpp ${ASIOSDK_ROOT_DIR}/host/asiodrivers.cpp)
|
|
||||||
SOURCE_GROUP("hostapi\\ASIO" FILES ${PA_ASIO_SOURCES})
|
|
||||||
SOURCE_GROUP("hostapi\\ASIO\\ASIOSDK" FILES ${PA_ASIOSDK_SOURCES})
|
|
||||||
SET(PA_PUBLIC_INCLUDES ${PA_PUBLIC_INCLUDES} include/pa_asio.h)
|
|
||||||
SET(PA_SOURCES ${PA_SOURCES} ${PA_ASIO_SOURCES})
|
|
||||||
SET(PA_NON_UNICODE_SOURCES ${PA_NON_UNICODE_SOURCES} ${PA_ASIOSDK_SOURCES})
|
|
||||||
SET(PA_LIBRARY_DEPENDENCIES ${PA_LIBRARY_DEPENDENCIES} ole32 uuid)
|
|
||||||
ELSE()
|
|
||||||
# Set variables for DEF file expansion
|
|
||||||
SET(DEF_EXCLUDE_ASIO_SYMBOLS ";")
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
OPTION(PA_USE_DS "Enable support for DirectSound" ON)
|
|
||||||
IF(PA_USE_DS)
|
|
||||||
IF(MINGW)
|
|
||||||
MESSAGE(STATUS "DirectSound support will be built with DSound provided by MinGW.")
|
|
||||||
OPTION(PA_USE_DIRECTSOUNDFULLDUPLEXCREATE "Use DirectSound full duplex create" OFF)
|
|
||||||
ELSE(MINGW)
|
|
||||||
OPTION(PA_USE_DIRECTSOUNDFULLDUPLEXCREATE "Use DirectSound full duplex create" ON)
|
|
||||||
ENDIF(MINGW)
|
|
||||||
MARK_AS_ADVANCED(PA_USE_DIRECTSOUNDFULLDUPLEXCREATE)
|
|
||||||
IF(PA_USE_DIRECTSOUNDFULLDUPLEXCREATE)
|
|
||||||
SET(PA_PRIVATE_COMPILE_DEFINITIONS ${PA_PRIVATE_COMPILE_DEFINITIONS} PAWIN_USE_DIRECTSOUNDFULLDUPLEXCREATE)
|
|
||||||
ENDIF()
|
|
||||||
SET(PA_DS_INCLUDES src/hostapi/dsound/pa_win_ds_dynlink.h)
|
|
||||||
SET(PA_DS_SOURCES src/hostapi/dsound/pa_win_ds.c src/hostapi/dsound/pa_win_ds_dynlink.c)
|
|
||||||
SOURCE_GROUP("hostapi\\dsound" FILES ${PA_DS_INCLUDES} ${PA_DS_SOURCES})
|
|
||||||
SET(PA_PUBLIC_INCLUDES ${PA_PUBLIC_INCLUDES} include/pa_win_ds.h include/pa_win_waveformat.h)
|
|
||||||
SET(PA_PRIVATE_INCLUDES ${PA_PRIVATE_INCLUDES} ${PA_DS_INCLUDES})
|
|
||||||
SET(PA_SOURCES ${PA_SOURCES} ${PA_DS_SOURCES})
|
|
||||||
SET(PA_LIBRARY_DEPENDENCIES ${PA_LIBRARY_DEPENDENCIES} dsound)
|
|
||||||
ENDIF(PA_USE_DS)
|
|
||||||
|
|
||||||
OPTION(PA_USE_WMME "Enable support for MME" ON)
|
|
||||||
IF(PA_USE_WMME)
|
|
||||||
SET(PA_WMME_SOURCES src/hostapi/wmme/pa_win_wmme.c)
|
|
||||||
SOURCE_GROUP("hostapi\\wmme" FILES ${PA_WMME_SOURCES})
|
|
||||||
SET(PA_PUBLIC_INCLUDES ${PA_PUBLIC_INCLUDES} include/pa_win_wmme.h include/pa_win_waveformat.h)
|
|
||||||
SET(PA_SOURCES ${PA_SOURCES} ${PA_WMME_SOURCES})
|
|
||||||
SET(PA_LIBRARY_DEPENDENCIES ${PA_LIBRARY_DEPENDENCIES} ole32 uuid)
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
# MinGW versions below 4.93, especially non MinGW-w64 distributions may
|
|
||||||
# break in the wasapi build. If an older MinGW version is required, WASAPI-
|
|
||||||
# support needs to be disabled.
|
|
||||||
OPTION(PA_USE_WASAPI "Enable support for WASAPI" ON)
|
|
||||||
IF(PA_USE_WASAPI)
|
|
||||||
SET(PA_WASAPI_SOURCES src/hostapi/wasapi/pa_win_wasapi.c)
|
|
||||||
SOURCE_GROUP("hostapi\\wasapi" FILES ${PA_WASAPI_SOURCES})
|
|
||||||
SET(PA_PUBLIC_INCLUDES ${PA_PUBLIC_INCLUDES} include/pa_win_wasapi.h include/pa_win_waveformat.h)
|
|
||||||
SET(PA_SOURCES ${PA_SOURCES} ${PA_WASAPI_SOURCES})
|
|
||||||
SET(PA_LIBRARY_DEPENDENCIES ${PA_LIBRARY_DEPENDENCIES} ole32 uuid)
|
|
||||||
ELSE()
|
|
||||||
SET(DEF_EXCLUDE_WASAPI_SYMBOLS ";")
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
OPTION(PA_USE_WDMKS "Enable support for WDMKS" ON)
|
|
||||||
IF(PA_USE_WDMKS)
|
|
||||||
SET(PA_WDMKS_SOURCES src/hostapi/wdmks/pa_win_wdmks.c)
|
|
||||||
SOURCE_GROUP("hostapi\\wdmks" FILES ${PA_WDMKS_SOURCES})
|
|
||||||
SET(PA_PUBLIC_INCLUDES ${PA_PUBLIC_INCLUDES} include/pa_win_wdmks.h)
|
|
||||||
SET(PA_SOURCES ${PA_SOURCES} ${PA_WDMKS_SOURCES})
|
|
||||||
SET(PA_LIBRARY_DEPENDENCIES ${PA_LIBRARY_DEPENDENCIES} setupapi ole32 uuid)
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
OPTION(PA_USE_WDMKS_DEVICE_INFO "Use WDM/KS API for device info" ON)
|
|
||||||
MARK_AS_ADVANCED(PA_USE_WDMKS_DEVICE_INFO)
|
|
||||||
IF(PA_USE_WDMKS_DEVICE_INFO)
|
|
||||||
SET(PA_PRIVATE_COMPILE_DEFINITIONS ${PA_PRIVATE_COMPILE_DEFINITIONS} PAWIN_USE_WDMKS_DEVICE_INFO)
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
SET(GENERATED_MESSAGE "CMake generated file, do NOT edit! Use CMake-GUI to change configuration instead.")
|
|
||||||
CONFIGURE_FILE(cmake_support/template_portaudio.def ${CMAKE_CURRENT_BINARY_DIR}/portaudio_cmake.def @ONLY)
|
|
||||||
CONFIGURE_FILE(cmake_support/options_cmake.h.in ${CMAKE_CURRENT_BINARY_DIR}/options_cmake.h @ONLY)
|
|
||||||
SET(PA_PRIVATE_INCLUDES ${PA_PRIVATE_INCLUDES} ${CMAKE_CURRENT_BINARY_DIR}/options_cmake.h)
|
|
||||||
SET(PA_PRIVATE_COMPILE_DEFINITIONS ${PA_PRIVATE_COMPILE_DEFINITIONS} PORTAUDIO_CMAKE_GENERATED)
|
|
||||||
SOURCE_GROUP("cmake_generated" FILES ${CMAKE_CURRENT_BINARY_DIR}/portaudio_cmake.def ${CMAKE_CURRENT_BINARY_DIR}/options_cmake.h)
|
|
||||||
|
|
||||||
SET(PA_EXTRA_SHARED_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/portaudio_cmake.def)
|
|
||||||
|
|
||||||
ELSE()
|
|
||||||
|
|
||||||
SET(PA_PRIVATE_INCLUDE_PATHS ${PA_PRIVATE_INCLUDE_PATHS} src/os/unix)
|
|
||||||
SET(PA_PLATFORM_SOURCES src/os/unix/pa_unix_hostapis.c src/os/unix/pa_unix_util.c)
|
|
||||||
SOURCE_GROUP("os\\unix" FILES ${PA_PLATFORM_SOURCES})
|
|
||||||
SET(PA_SOURCES ${PA_SOURCES} ${PA_PLATFORM_SOURCES})
|
|
||||||
|
|
||||||
IF(APPLE)
|
|
||||||
|
|
||||||
SET(CMAKE_MACOSX_RPATH 1)
|
|
||||||
OPTION(PA_USE_COREAUDIO "Enable support for CoreAudio" ON)
|
|
||||||
IF(PA_USE_COREAUDIO)
|
|
||||||
SET(PA_COREAUDIO_SOURCES
|
|
||||||
src/hostapi/coreaudio/pa_mac_core.c
|
|
||||||
src/hostapi/coreaudio/pa_mac_core_blocking.c
|
|
||||||
src/hostapi/coreaudio/pa_mac_core_utilities.c)
|
|
||||||
SET(PA_COREAUDIO_INCLUDES
|
|
||||||
src/hostapi/coreaudio/pa_mac_core_blocking.h
|
|
||||||
src/hostapi/coreaudio/pa_mac_core_utilities.h)
|
|
||||||
SOURCE_GROUP("hostapi\\coreaudio" FILES ${PA_COREAUDIO_SOURCES} ${PA_COREAUDIO_INCLUDES})
|
|
||||||
SET(PA_PUBLIC_INCLUDES ${PA_PUBLIC_INCLUDES} include/pa_mac_core.h)
|
|
||||||
SET(PA_PRIVATE_INCLUDES ${PA_PRIVATE_INCLUDES} ${PA_COREAUDIO_INCLUDES})
|
|
||||||
SET(PA_SOURCES ${PA_SOURCES} ${PA_COREAUDIO_SOURCES})
|
|
||||||
|
|
||||||
FIND_LIBRARY(COREAUDIO_LIBRARY CoreAudio REQUIRED)
|
|
||||||
FIND_LIBRARY(AUDIOTOOLBOX_LIBRARY AudioToolbox REQUIRED)
|
|
||||||
FIND_LIBRARY(AUDIOUNIT_LIBRARY AudioUnit REQUIRED)
|
|
||||||
FIND_LIBRARY(COREFOUNDATION_LIBRARY CoreFoundation REQUIRED)
|
|
||||||
FIND_LIBRARY(CORESERVICES_LIBRARY CoreServices REQUIRED)
|
|
||||||
MARK_AS_ADVANCED(COREAUDIO_LIBRARY AUDIOTOOLBOX_LIBRARY AUDIOUNIT_LIBRARY COREFOUNDATION_LIBRARY CORESERVICES_LIBRARY)
|
|
||||||
SET(PA_LIBRARY_DEPENDENCIES ${PA_LIBRARY_DEPENDENCIES} ${COREAUDIO_LIBRARY} ${AUDIOTOOLBOX_LIBRARY} ${AUDIOUNIT_LIBRARY} ${COREFOUNDATION_LIBRARY} ${CORESERVICES_LIBRARY})
|
|
||||||
SET(PA_PRIVATE_COMPILE_DEFINITIONS ${PA_PRIVATE_COMPILE_DEFINITIONS} PA_USE_COREAUDIO)
|
|
||||||
SET(PA_PKGCONFIG_LDFLAGS "${PA_PKGCONFIG_LDFLAGS} -framework CoreAudio -framework AudioToolbox -framework AudioUnit -framework CoreFoundation -framework CoreServices")
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
ELSEIF(UNIX)
|
|
||||||
|
|
||||||
FIND_PACKAGE(Jack)
|
|
||||||
IF(JACK_FOUND)
|
|
||||||
OPTION(PA_USE_JACK "Enable support for Jack" ON)
|
|
||||||
ELSE()
|
|
||||||
OPTION(PA_USE_JACK "Enable support for Jack" OFF)
|
|
||||||
ENDIF()
|
|
||||||
IF(PA_USE_JACK)
|
|
||||||
SET(PA_PRIVATE_INCLUDE_PATHS ${PA_PRIVATE_INCLUDE_PATHS} ${JACK_INCLUDE_DIRS})
|
|
||||||
SET(PA_JACK_SOURCES src/hostapi/jack/pa_jack.c)
|
|
||||||
SOURCE_GROUP("hostapi\\JACK" FILES ${PA_JACK_SOURCES})
|
|
||||||
SET(PA_PUBLIC_INCLUDES ${PA_PUBLIC_INCLUDES} include/pa_jack.h)
|
|
||||||
SET(PA_SOURCES ${PA_SOURCES} ${PA_JACK_SOURCES})
|
|
||||||
SET(PA_PRIVATE_COMPILE_DEFINITIONS ${PA_PRIVATE_COMPILE_DEFINITIONS} PA_USE_JACK)
|
|
||||||
SET(PA_LIBRARY_DEPENDENCIES ${PA_LIBRARY_DEPENDENCIES} ${JACK_LIBRARIES})
|
|
||||||
SET(PA_PKGCONFIG_LDFLAGS "${PA_PKGCONFIG_LDFLAGS} -ljack")
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
FIND_PACKAGE(ALSA)
|
|
||||||
IF(ALSA_FOUND)
|
|
||||||
OPTION(PA_USE_ALSA "Enable support for ALSA" ON)
|
|
||||||
OPTION(PA_ALSA_DYNAMIC "Enable loading ALSA through dlopen" OFF)
|
|
||||||
ELSE()
|
|
||||||
OPTION(PA_USE_ALSA "Enable support for ALSA" OFF)
|
|
||||||
ENDIF()
|
|
||||||
IF(PA_USE_ALSA)
|
|
||||||
SET(PA_PRIVATE_INCLUDE_PATHS ${PA_PRIVATE_INCLUDE_PATHS} ${ALSA_INCLUDE_DIRS})
|
|
||||||
SET(PA_ALSA_SOURCES src/hostapi/alsa/pa_linux_alsa.c)
|
|
||||||
SOURCE_GROUP("hostapi\\ALSA" FILES ${PA_ALSA_SOURCES})
|
|
||||||
SET(PA_PUBLIC_INCLUDES ${PA_PUBLIC_INCLUDES} include/pa_linux_alsa.h)
|
|
||||||
SET(PA_SOURCES ${PA_SOURCES} ${PA_ALSA_SOURCES})
|
|
||||||
SET(PA_PRIVATE_COMPILE_DEFINITIONS ${PA_PRIVATE_COMPILE_DEFINITIONS} PA_USE_ALSA)
|
|
||||||
IF(PA_ALSA_DYNAMIC)
|
|
||||||
SET(PA_PRIVATE_COMPILE_DEFINITIONS ${PA_PRIVATE_COMPILE_DEFINITIONS} PA_ALSA_DYNAMIC)
|
|
||||||
SET(PA_LIBRARY_DEPENDENCIES ${PA_LIBRARY_DEPENDENCIES} ${CMAKE_DL_LIBS})
|
|
||||||
SET(PA_PKGCONFIG_LDFLAGS "${PA_PKGCONFIG_LDFLAGS} -l${CMAKE_DL_LIBS}")
|
|
||||||
ELSE()
|
|
||||||
SET(PA_LIBRARY_DEPENDENCIES ${PA_LIBRARY_DEPENDENCIES} ${ALSA_LIBRARIES})
|
|
||||||
SET(PA_PKGCONFIG_LDFLAGS "${PA_PKGCONFIG_LDFLAGS} -lasound")
|
|
||||||
ENDIF()
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
SET(PA_PKGCONFIG_LDFLAGS "${PA_PKGCONFIG_LDFLAGS} -lm -lpthread")
|
|
||||||
SET(PA_LIBRARY_DEPENDENCIES ${PA_LIBRARY_DEPENDENCIES} m pthread)
|
|
||||||
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
SOURCE_GROUP("include" FILES ${PA_PUBLIC_INCLUDES})
|
|
||||||
|
|
||||||
SET(PA_INCLUDES ${PA_PRIVATE_INCLUDES} ${PA_PUBLIC_INCLUDES})
|
|
||||||
|
|
||||||
IF(WIN32)
|
|
||||||
OPTION(PA_UNICODE_BUILD "Enable Portaudio Unicode build" ON)
|
|
||||||
IF(PA_UNICODE_BUILD)
|
|
||||||
SET_SOURCE_FILES_PROPERTIES(${PA_SOURCES} PROPERTIES COMPILE_DEFINITIONS "UNICODE;_UNICODE")
|
|
||||||
ENDIF()
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
OPTION(PA_ENABLE_DEBUG_OUTPUT "Enable debug output for Portaudio" OFF)
|
|
||||||
IF(PA_ENABLE_DEBUG_OUTPUT)
|
|
||||||
SET(PA_PRIVATE_COMPILE_DEFINITIONS ${PA_PRIVATE_COMPILE_DEFINITIONS} PA_ENABLE_DEBUG_OUTPUT)
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
INCLUDE(TestBigEndian)
|
|
||||||
TEST_BIG_ENDIAN(IS_BIG_ENDIAN)
|
|
||||||
IF(IS_BIG_ENDIAN)
|
|
||||||
SET(PA_PRIVATE_COMPILE_DEFINITIONS ${PA_PRIVATE_COMPILE_DEFINITIONS} PA_BIG_ENDIAN)
|
|
||||||
ELSE()
|
|
||||||
SET(PA_PRIVATE_COMPILE_DEFINITIONS ${PA_PRIVATE_COMPILE_DEFINITIONS} PA_LITTLE_ENDIAN)
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
OPTION(PA_BUILD_STATIC "Build static library" ON)
|
|
||||||
OPTION(PA_BUILD_SHARED "Build shared/dynamic library" ON)
|
|
||||||
|
|
||||||
IF(MSVC)
|
|
||||||
OPTION(PA_LIBNAME_ADD_SUFFIX "Add suffix _static to static library name" ON)
|
|
||||||
ELSE()
|
|
||||||
OPTION(PA_LIBNAME_ADD_SUFFIX "Add suffix _static to static library name" OFF)
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
# MSVC: if PA_LIBNAME_ADD_SUFFIX is not used, and both static and shared libraries are
|
|
||||||
# built, one, of import- and static libraries, will overwrite the other. In
|
|
||||||
# embedded builds this is not an issue as they will only build the configuration
|
|
||||||
# used in the host application.
|
|
||||||
MARK_AS_ADVANCED(PA_LIBNAME_ADD_SUFFIX)
|
|
||||||
IF(MSVC AND PA_BUILD_STATIC AND PA_BUILD_SHARED AND NOT PA_LIBNAME_ADD_SUFFIX)
|
|
||||||
MESSAGE(WARNING "Building both shared and static libraries, and avoiding the suffix _static will lead to a name conflict")
|
|
||||||
SET(PA_LIBNAME_ADD_SUFFIX ON CACHE BOOL "Forcing use of suffix _static to avoid name conflict between static and import library" FORCE)
|
|
||||||
MESSAGE(WARNING "PA_LIBNAME_ADD_SUFFIX was set to ON")
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
SET(PA_TARGETS "")
|
|
||||||
|
|
||||||
IF(PA_BUILD_SHARED)
|
|
||||||
LIST(APPEND PA_TARGETS portaudio)
|
|
||||||
ADD_LIBRARY(portaudio SHARED ${PA_INCLUDES} ${PA_COMMON_INCLUDES} ${PA_SOURCES} ${PA_NON_UNICODE_SOURCES} ${PA_EXTRA_SHARED_SOURCES})
|
|
||||||
SET_PROPERTY(TARGET portaudio APPEND_STRING PROPERTY COMPILE_DEFINITIONS ${PA_PRIVATE_COMPILE_DEFINITIONS})
|
|
||||||
TARGET_INCLUDE_DIRECTORIES(portaudio PRIVATE ${PA_PRIVATE_INCLUDE_PATHS})
|
|
||||||
TARGET_INCLUDE_DIRECTORIES(portaudio PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>" "$<INSTALL_INTERFACE:include>")
|
|
||||||
TARGET_LINK_LIBRARIES(portaudio ${PA_LIBRARY_DEPENDENCIES})
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
IF(PA_BUILD_STATIC)
|
|
||||||
LIST(APPEND PA_TARGETS portaudio_static)
|
|
||||||
ADD_LIBRARY(portaudio_static STATIC ${PA_INCLUDES} ${PA_COMMON_INCLUDES} ${PA_SOURCES} ${PA_NON_UNICODE_SOURCES})
|
|
||||||
SET_PROPERTY(TARGET portaudio_static APPEND_STRING PROPERTY COMPILE_DEFINITIONS ${PA_PRIVATE_COMPILE_DEFINITIONS})
|
|
||||||
TARGET_INCLUDE_DIRECTORIES(portaudio_static PRIVATE ${PA_PRIVATE_INCLUDE_PATHS})
|
|
||||||
TARGET_INCLUDE_DIRECTORIES(portaudio_static PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>" "$<INSTALL_INTERFACE:include>")
|
|
||||||
TARGET_LINK_LIBRARIES(portaudio_static ${PA_LIBRARY_DEPENDENCIES})
|
|
||||||
IF(NOT PA_LIBNAME_ADD_SUFFIX)
|
|
||||||
SET_PROPERTY(TARGET portaudio_static PROPERTY OUTPUT_NAME portaudio)
|
|
||||||
ENDIF()
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
IF(WIN32 AND MSVC)
|
|
||||||
OPTION(PA_CONFIG_LIB_OUTPUT_PATH "Make sure that output paths are kept neat" OFF)
|
|
||||||
IF(CMAKE_CL_64)
|
|
||||||
SET(TARGET_POSTFIX x64)
|
|
||||||
IF(PA_CONFIG_LIB_OUTPUT_PATH)
|
|
||||||
SET(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/bin/x64)
|
|
||||||
ENDIF()
|
|
||||||
ELSE()
|
|
||||||
SET(TARGET_POSTFIX x86)
|
|
||||||
IF(PA_CONFIG_LIB_OUTPUT_PATH)
|
|
||||||
SET(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/bin/Win32)
|
|
||||||
ENDIF()
|
|
||||||
ENDIF()
|
|
||||||
IF(PA_BUILD_SHARED)
|
|
||||||
IF(PA_LIBNAME_ADD_SUFFIX)
|
|
||||||
SET_TARGET_PROPERTIES(portaudio PROPERTIES OUTPUT_NAME portaudio_${TARGET_POSTFIX})
|
|
||||||
ELSE()
|
|
||||||
SET_TARGET_PROPERTIES(portaudio PROPERTIES OUTPUT_NAME portaudio)
|
|
||||||
ENDIF()
|
|
||||||
ENDIF()
|
|
||||||
IF(PA_BUILD_STATIC)
|
|
||||||
IF(PA_LIBNAME_ADD_SUFFIX)
|
|
||||||
SET_TARGET_PROPERTIES(portaudio_static PROPERTIES OUTPUT_NAME portaudio_static_${TARGET_POSTFIX})
|
|
||||||
ELSE()
|
|
||||||
SET_TARGET_PROPERTIES(portaudio_static PROPERTIES OUTPUT_NAME portaudio)
|
|
||||||
ENDIF()
|
|
||||||
ENDIF()
|
|
||||||
ELSE()
|
|
||||||
IF(APPLE AND CMAKE_VERSION VERSION_GREATER 3.4.2)
|
|
||||||
OPTION(PA_OUTPUT_OSX_FRAMEWORK "Generate an OS X framework instead of the simple library" OFF)
|
|
||||||
IF(PA_OUTPUT_OSX_FRAMEWORK)
|
|
||||||
SET_TARGET_PROPERTIES(portaudio PROPERTIES
|
|
||||||
FRAMEWORK TRUE
|
|
||||||
MACOSX_FRAMEWORK_IDENTIFIER com.portaudio
|
|
||||||
FRAMEWORK_VERSION A
|
|
||||||
PUBLIC_HEADER "${PA_PUBLIC_INCLUDES}"
|
|
||||||
VERSION ${PA_SOVERSION}
|
|
||||||
SOVERSION ${PA_SOVERSION})
|
|
||||||
ENDIF()
|
|
||||||
ENDIF()
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
# At least on Windows in embedded builds, portaudio's install target should likely
|
|
||||||
# not be executed, as the library would usually already be installed as part of, and
|
|
||||||
# by means of the host application.
|
|
||||||
# The option below offers the option to avoid executing the portaudio install target
|
|
||||||
# for cases in which the host-application executes install, but no independent install
|
|
||||||
# of portaudio is wished.
|
|
||||||
OPTION(PA_DISABLE_INSTALL "Disable targets install and uninstall (for embedded builds)" OFF)
|
|
||||||
|
|
||||||
IF(NOT PA_OUTPUT_OSX_FRAMEWORK AND NOT PA_DISABLE_INSTALL)
|
|
||||||
INCLUDE(CMakePackageConfigHelpers)
|
|
||||||
|
|
||||||
CONFIGURE_PACKAGE_CONFIG_FILE(cmake_support/portaudioConfig.cmake.in ${CMAKE_BINARY_DIR}/cmake/portaudio/portaudioConfig.cmake
|
|
||||||
INSTALL_DESTINATION "lib/cmake/portaudio"
|
|
||||||
NO_CHECK_REQUIRED_COMPONENTS_MACRO)
|
|
||||||
WRITE_BASIC_PACKAGE_VERSION_FILE(${CMAKE_BINARY_DIR}/cmake/portaudio/portaudioConfigVersion.cmake
|
|
||||||
VERSION ${PA_VERSION}
|
|
||||||
COMPATIBILITY SameMajorVersion)
|
|
||||||
CONFIGURE_FILE(cmake_support/portaudio-2.0.pc.in ${CMAKE_CURRENT_BINARY_DIR}/portaudio-2.0.pc @ONLY)
|
|
||||||
INSTALL(FILES README.md DESTINATION share/doc/portaudio)
|
|
||||||
INSTALL(FILES LICENSE.txt DESTINATION share/doc/portaudio)
|
|
||||||
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/portaudio-2.0.pc DESTINATION lib/pkgconfig)
|
|
||||||
INSTALL(FILES ${PA_PUBLIC_INCLUDES} DESTINATION include)
|
|
||||||
INSTALL(TARGETS ${PA_TARGETS}
|
|
||||||
EXPORT portaudio-targets
|
|
||||||
RUNTIME DESTINATION bin
|
|
||||||
LIBRARY DESTINATION lib
|
|
||||||
ARCHIVE DESTINATION lib)
|
|
||||||
INSTALL(EXPORT portaudio-targets FILE "portaudioTargets.cmake" DESTINATION "lib/cmake/portaudio")
|
|
||||||
EXPORT(TARGETS ${PA_TARGETS} FILE "${PROJECT_BINARY_DIR}/cmake/portaudio/portaudioTargets.cmake")
|
|
||||||
INSTALL(FILES "${CMAKE_BINARY_DIR}/cmake/portaudio/portaudioConfig.cmake"
|
|
||||||
"${CMAKE_BINARY_DIR}/cmake/portaudio/portaudioConfigVersion.cmake"
|
|
||||||
DESTINATION "lib/cmake/portaudio")
|
|
||||||
|
|
||||||
IF (NOT TARGET uninstall)
|
|
||||||
CONFIGURE_FILE(
|
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_support/cmake_uninstall.cmake.in"
|
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
|
|
||||||
IMMEDIATE @ONLY)
|
|
||||||
ADD_CUSTOM_TARGET(uninstall
|
|
||||||
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
|
|
||||||
ENDIF()
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
# Prepared for inclusion of test files
|
|
||||||
OPTION(PA_BUILD_TESTS "Include test projects" OFF)
|
|
||||||
IF(PA_BUILD_TESTS)
|
|
||||||
SUBDIRS(test)
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
# Prepared for inclusion of test files
|
|
||||||
OPTION(PA_BUILD_EXAMPLES "Include example projects" OFF)
|
|
||||||
IF(PA_BUILD_EXAMPLES)
|
|
||||||
SUBDIRS(examples)
|
|
||||||
ENDIF()
|
|
81
third_party/portAudio/LICENSE.txt
vendored
81
third_party/portAudio/LICENSE.txt
vendored
@ -1,81 +0,0 @@
|
|||||||
Portable header file to contain:
|
|
||||||
>>>>>
|
|
||||||
/*
|
|
||||||
* PortAudio Portable Real-Time Audio Library
|
|
||||||
* PortAudio API Header File
|
|
||||||
* Latest version available at: http://www.portaudio.com
|
|
||||||
*
|
|
||||||
* Copyright (c) 1999-2006 Ross Bencina and Phil Burk
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files
|
|
||||||
* (the "Software"), to deal in the Software without restriction,
|
|
||||||
* including without limitation the rights to use, copy, modify, merge,
|
|
||||||
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
||||||
* and to permit persons to whom the Software is furnished to do so,
|
|
||||||
* subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be
|
|
||||||
* included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
||||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
|
|
||||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
|
||||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The text above constitutes the entire PortAudio license; however,
|
|
||||||
* the PortAudio community also makes the following non-binding requests:
|
|
||||||
*
|
|
||||||
* Any person wishing to distribute modifications to the Software is
|
|
||||||
* requested to send the modifications to the original developer so that
|
|
||||||
* they can be incorporated into the canonical version. It is also
|
|
||||||
* requested that these non-binding requests be included along with the
|
|
||||||
* license above.
|
|
||||||
*/
|
|
||||||
<<<<<
|
|
||||||
|
|
||||||
|
|
||||||
Implementation files to contain:
|
|
||||||
>>>>>
|
|
||||||
/*
|
|
||||||
* PortAudio Portable Real-Time Audio Library
|
|
||||||
* Latest version at: http://www.portaudio.com
|
|
||||||
* <platform> Implementation
|
|
||||||
* Copyright (c) 1999-2000 <author(s)>
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files
|
|
||||||
* (the "Software"), to deal in the Software without restriction,
|
|
||||||
* including without limitation the rights to use, copy, modify, merge,
|
|
||||||
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
||||||
* and to permit persons to whom the Software is furnished to do so,
|
|
||||||
* subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be
|
|
||||||
* included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
||||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
|
|
||||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
|
||||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The text above constitutes the entire PortAudio license; however,
|
|
||||||
* the PortAudio community also makes the following non-binding requests:
|
|
||||||
*
|
|
||||||
* Any person wishing to distribute modifications to the Software is
|
|
||||||
* requested to send the modifications to the original developer so that
|
|
||||||
* they can be incorporated into the canonical version. It is also
|
|
||||||
* requested that these non-binding requests be included along with the
|
|
||||||
* license above.
|
|
||||||
*/
|
|
||||||
<<<<<
|
|
62
third_party/portAudio/README.md
vendored
62
third_party/portAudio/README.md
vendored
@ -1,62 +0,0 @@
|
|||||||
# PortAudio - portable audio I/O library
|
|
||||||
|
|
||||||
PortAudio is a portable audio I/O library designed for cross-platform
|
|
||||||
support of audio. It uses either a callback mechanism to request audio
|
|
||||||
processing, or blocking read/write calls to buffer data between the
|
|
||||||
native audio subsystem and the client. Audio can be processed in various
|
|
||||||
formats, including 32 bit floating point, and will be converted to the
|
|
||||||
native format internally.
|
|
||||||
|
|
||||||
## Documentation:
|
|
||||||
|
|
||||||
* Documentation is available at http://www.portaudio.com/docs/
|
|
||||||
* Or at `/doc/html/index.html` after running Doxygen.
|
|
||||||
* Also see `src/common/portaudio.h` for the API spec.
|
|
||||||
* And see the `examples/` and `test/` directories for many examples of usage. (We suggest `examples/paex_saw.c` for an example.)
|
|
||||||
|
|
||||||
For information on compiling programs with PortAudio, please see the
|
|
||||||
tutorial at:
|
|
||||||
|
|
||||||
http://portaudio.com/docs/v19-doxydocs/tutorial_start.html
|
|
||||||
|
|
||||||
We have an active mailing list for user and developer discussions.
|
|
||||||
Please feel free to join. See http://www.portaudio.com for details.
|
|
||||||
|
|
||||||
## Important Files and Folders:
|
|
||||||
|
|
||||||
include/portaudio.h = header file for PortAudio API. Specifies API.
|
|
||||||
src/common/ = platform independent code, host independent
|
|
||||||
code for all implementations.
|
|
||||||
src/os = os specific (but host api neutral) code
|
|
||||||
src/hostapi = implementations for different host apis
|
|
||||||
|
|
||||||
|
|
||||||
### Host API Implementations:
|
|
||||||
|
|
||||||
src/hostapi/alsa = Advanced Linux Sound Architecture (ALSA)
|
|
||||||
src/hostapi/asihpi = AudioScience HPI
|
|
||||||
src/hostapi/asio = ASIO for Windows and Macintosh
|
|
||||||
src/hostapi/coreaudio = Macintosh Core Audio for OS X
|
|
||||||
src/hostapi/dsound = Windows Direct Sound
|
|
||||||
src/hostapi/jack = JACK Audio Connection Kit
|
|
||||||
src/hostapi/oss = Unix Open Sound System (OSS)
|
|
||||||
src/hostapi/wasapi = Windows Vista WASAPI
|
|
||||||
src/hostapi/wdmks = Windows WDM Kernel Streaming
|
|
||||||
src/hostapi/wmme = Windows MultiMedia Extensions (MME)
|
|
||||||
|
|
||||||
|
|
||||||
### Test Programs:
|
|
||||||
|
|
||||||
test/pa_fuzz.c = guitar fuzz box
|
|
||||||
test/pa_devs.c = print a list of available devices
|
|
||||||
test/pa_minlat.c = determine minimum latency for your machine
|
|
||||||
test/paqa_devs.c = self test that opens all devices
|
|
||||||
test/paqa_errs.c = test error detection and reporting
|
|
||||||
test/patest_clip.c = hear a sine wave clipped and unclipped
|
|
||||||
test/patest_dither.c = hear effects of dithering (extremely subtle)
|
|
||||||
test/patest_pink.c = fun with pink noise
|
|
||||||
test/patest_record.c = record and playback some audio
|
|
||||||
test/patest_maxsines.c = how many sine waves can we play? Tests Pa_GetCPULoad().
|
|
||||||
test/patest_sine.c = output a sine wave in a simple PA app
|
|
||||||
test/patest_sync.c = test synchronization of audio and video
|
|
||||||
test/patest_wire.c = pass input to output, wire simulator
|
|
@ -1,41 +0,0 @@
|
|||||||
# $Id: $
|
|
||||||
#
|
|
||||||
# - Try to find the ASIO SDK
|
|
||||||
# Once done this will define
|
|
||||||
#
|
|
||||||
# ASIOSDK_FOUND - system has ASIO SDK
|
|
||||||
# ASIOSDK_ROOT_DIR - path to the ASIO SDK base directory
|
|
||||||
# ASIOSDK_INCLUDE_DIR - the ASIO SDK include directory
|
|
||||||
|
|
||||||
if(WIN32)
|
|
||||||
else(WIN32)
|
|
||||||
message(FATAL_ERROR "FindASIOSDK.cmake: Unsupported platform ${CMAKE_SYSTEM_NAME}" )
|
|
||||||
endif(WIN32)
|
|
||||||
|
|
||||||
file(GLOB results "${CMAKE_CURRENT_SOURCE_DIR}/../as*")
|
|
||||||
foreach(f ${results})
|
|
||||||
if(IS_DIRECTORY ${f})
|
|
||||||
set(ASIOSDK_PATH_HINT ${ASIOSDK_PATH_HINT} ${f})
|
|
||||||
endif()
|
|
||||||
endforeach()
|
|
||||||
|
|
||||||
find_path(ASIOSDK_ROOT_DIR
|
|
||||||
common/asio.h
|
|
||||||
HINTS
|
|
||||||
${ASIOSDK_PATH_HINT}
|
|
||||||
)
|
|
||||||
|
|
||||||
find_path(ASIOSDK_INCLUDE_DIR
|
|
||||||
asio.h
|
|
||||||
PATHS
|
|
||||||
${ASIOSDK_ROOT_DIR}/common
|
|
||||||
)
|
|
||||||
|
|
||||||
# handle the QUIETLY and REQUIRED arguments and set ASIOSDK_FOUND to TRUE if
|
|
||||||
# all listed variables are TRUE
|
|
||||||
INCLUDE(FindPackageHandleStandardArgs)
|
|
||||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(ASIOSDK DEFAULT_MSG ASIOSDK_ROOT_DIR ASIOSDK_INCLUDE_DIR)
|
|
||||||
|
|
||||||
MARK_AS_ADVANCED(
|
|
||||||
ASIOSDK_ROOT_DIR ASIOSDK_INCLUDE_DIR
|
|
||||||
)
|
|
@ -1,41 +0,0 @@
|
|||||||
# - Try to find jack
|
|
||||||
# Once done this will define
|
|
||||||
# JACK_FOUND - System has jack
|
|
||||||
# JACK_INCLUDE_DIRS - The jack include directories
|
|
||||||
# JACK_LIBRARIES - The libraries needed to use jack
|
|
||||||
# JACK_DEFINITIONS - Compiler switches required for using jack
|
|
||||||
|
|
||||||
if (JACK_LIBRARIES AND JACK_INCLUDE_DIRS)
|
|
||||||
|
|
||||||
# in cache already
|
|
||||||
set(JACK_FOUND TRUE)
|
|
||||||
|
|
||||||
else (JACK_LIBRARIES AND JACK_INCLUDE_DIRS)
|
|
||||||
|
|
||||||
set(JACK_DEFINITIONS "")
|
|
||||||
|
|
||||||
# Look for pkg-config and use it (if available) to find package
|
|
||||||
find_package(PkgConfig QUIET)
|
|
||||||
if (PKG_CONFIG_FOUND)
|
|
||||||
pkg_search_module(JACK QUIET jack)
|
|
||||||
endif (PKG_CONFIG_FOUND)
|
|
||||||
|
|
||||||
if (NOT JACK_FOUND)
|
|
||||||
|
|
||||||
find_path(JACK_INCLUDE_DIR jack/jack.h HINTS ${JACK_INCLUDEDIR} ${JACK_INCLUDE_DIRS} PATH_SUFFIXES jack)
|
|
||||||
find_library(JACK_LIBRARY NAMES jack HINTS ${JACK_LIBDIR} ${JACK_LIBRARY_DIRS})
|
|
||||||
|
|
||||||
set(JACK_LIBRARIES ${JACK_LIBRARY})
|
|
||||||
set(JACK_INCLUDE_DIRS ${JACK_INCLUDE_DIR})
|
|
||||||
|
|
||||||
include(FindPackageHandleStandardArgs)
|
|
||||||
|
|
||||||
# Set JACK_FOUND if the library and include paths were found
|
|
||||||
find_package_handle_standard_args(jack DEFAULT_MSG JACK_LIBRARY JACK_INCLUDE_DIR)
|
|
||||||
|
|
||||||
# Don't show include/library paths in cmake GUI
|
|
||||||
mark_as_advanced(JACK_INCLUDE_DIR JACK_LIBRARY)
|
|
||||||
|
|
||||||
endif (NOT JACK_FOUND)
|
|
||||||
|
|
||||||
endif (JACK_LIBRARIES AND JACK_INCLUDE_DIRS)
|
|
@ -1,21 +0,0 @@
|
|||||||
if(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
|
|
||||||
message(FATAL_ERROR "Cannot find install manifest: @CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
|
|
||||||
endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
|
|
||||||
|
|
||||||
file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
|
|
||||||
string(REGEX REPLACE "\n" ";" files "${files}")
|
|
||||||
foreach(file ${files})
|
|
||||||
message(STATUS "Uninstalling $ENV{DESTDIR}${file}")
|
|
||||||
if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
|
|
||||||
exec_program(
|
|
||||||
"@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
|
|
||||||
OUTPUT_VARIABLE rm_out
|
|
||||||
RETURN_VALUE rm_retval
|
|
||||||
)
|
|
||||||
if(NOT "${rm_retval}" STREQUAL 0)
|
|
||||||
message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}")
|
|
||||||
endif(NOT "${rm_retval}" STREQUAL 0)
|
|
||||||
else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
|
|
||||||
message(STATUS "File $ENV{DESTDIR}${file} does not exist.")
|
|
||||||
endif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
|
|
||||||
endforeach(file)
|
|
@ -1,31 +0,0 @@
|
|||||||
/* $Id: $
|
|
||||||
|
|
||||||
!!! @GENERATED_MESSAGE@ !!!
|
|
||||||
|
|
||||||
Header file configured by CMake to convert CMake options/vars to macros. It is done this way because if set via
|
|
||||||
preprocessor options, MSVC f.i. has no way of knowing when an option (or var) changes as there is no dependency chain.
|
|
||||||
|
|
||||||
The generated "options_cmake.h" should be included like so:
|
|
||||||
|
|
||||||
#ifdef PORTAUDIO_CMAKE_GENERATED
|
|
||||||
#include "options_cmake.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
so that non-CMake build environments are left intact.
|
|
||||||
|
|
||||||
Source template: cmake_support/options_cmake.h.in
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
#if defined(PA_USE_ASIO) || defined(PA_USE_DS) || defined(PA_USE_WMME) || defined(PA_USE_WASAPI) || defined(PA_USE_WDMKS)
|
|
||||||
#error "This header needs to be included before pa_hostapi.h!!"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#cmakedefine01 PA_USE_ASIO
|
|
||||||
#cmakedefine01 PA_USE_DS
|
|
||||||
#cmakedefine01 PA_USE_WMME
|
|
||||||
#cmakedefine01 PA_USE_WASAPI
|
|
||||||
#cmakedefine01 PA_USE_WDMKS
|
|
||||||
#else
|
|
||||||
#error "Platform currently not supported by CMake script"
|
|
||||||
#endif
|
|
@ -1,12 +0,0 @@
|
|||||||
prefix=@CMAKE_INSTALL_PREFIX@
|
|
||||||
exec_prefix=${prefix}
|
|
||||||
libdir=${prefix}/lib
|
|
||||||
includedir=${prefix}/include
|
|
||||||
|
|
||||||
Name: PortAudio
|
|
||||||
Description: Portable audio I/O
|
|
||||||
Requires:
|
|
||||||
Version: @PA_PKGCONFIG_VERSION@
|
|
||||||
|
|
||||||
Libs: -L${libdir} -lportaudio @PA_PKGCONFIG_LDFLAGS@
|
|
||||||
Cflags: -I${includedir} @PA_PKGCONFIG_CFLAGS@
|
|
@ -1 +0,0 @@
|
|||||||
include("${CMAKE_CURRENT_LIST_DIR}/portaudioTargets.cmake")
|
|
@ -1,61 +0,0 @@
|
|||||||
; $Id: $
|
|
||||||
;
|
|
||||||
; !!! @GENERATED_MESSAGE@ !!!
|
|
||||||
EXPORTS
|
|
||||||
|
|
||||||
;
|
|
||||||
Pa_GetVersion @1
|
|
||||||
Pa_GetVersionText @2
|
|
||||||
Pa_GetErrorText @3
|
|
||||||
Pa_Initialize @4
|
|
||||||
Pa_Terminate @5
|
|
||||||
Pa_GetHostApiCount @6
|
|
||||||
Pa_GetDefaultHostApi @7
|
|
||||||
Pa_GetHostApiInfo @8
|
|
||||||
Pa_HostApiTypeIdToHostApiIndex @9
|
|
||||||
Pa_HostApiDeviceIndexToDeviceIndex @10
|
|
||||||
Pa_GetLastHostErrorInfo @11
|
|
||||||
Pa_GetDeviceCount @12
|
|
||||||
Pa_GetDefaultInputDevice @13
|
|
||||||
Pa_GetDefaultOutputDevice @14
|
|
||||||
Pa_GetDeviceInfo @15
|
|
||||||
Pa_IsFormatSupported @16
|
|
||||||
Pa_OpenStream @17
|
|
||||||
Pa_OpenDefaultStream @18
|
|
||||||
Pa_CloseStream @19
|
|
||||||
Pa_SetStreamFinishedCallback @20
|
|
||||||
Pa_StartStream @21
|
|
||||||
Pa_StopStream @22
|
|
||||||
Pa_AbortStream @23
|
|
||||||
Pa_IsStreamStopped @24
|
|
||||||
Pa_IsStreamActive @25
|
|
||||||
Pa_GetStreamInfo @26
|
|
||||||
Pa_GetStreamTime @27
|
|
||||||
Pa_GetStreamCpuLoad @28
|
|
||||||
Pa_ReadStream @29
|
|
||||||
Pa_WriteStream @30
|
|
||||||
Pa_GetStreamReadAvailable @31
|
|
||||||
Pa_GetStreamWriteAvailable @32
|
|
||||||
Pa_GetSampleSize @33
|
|
||||||
Pa_Sleep @34
|
|
||||||
@DEF_EXCLUDE_ASIO_SYMBOLS@PaAsio_GetAvailableBufferSizes @50
|
|
||||||
@DEF_EXCLUDE_ASIO_SYMBOLS@PaAsio_ShowControlPanel @51
|
|
||||||
@DEF_EXCLUDE_X86_PLAIN_CONVERTERS@PaUtil_InitializeX86PlainConverters @52
|
|
||||||
@DEF_EXCLUDE_ASIO_SYMBOLS@PaAsio_GetInputChannelName @53
|
|
||||||
@DEF_EXCLUDE_ASIO_SYMBOLS@PaAsio_GetOutputChannelName @54
|
|
||||||
PaUtil_SetDebugPrintFunction @55
|
|
||||||
@DEF_EXCLUDE_WASAPI_SYMBOLS@PaWasapi_GetAudioClient @56
|
|
||||||
@DEF_EXCLUDE_WASAPI_SYMBOLS@PaWasapi_UpdateDeviceList @57
|
|
||||||
@DEF_EXCLUDE_WASAPI_SYMBOLS@PaWasapi_GetDeviceCurrentFormat @58
|
|
||||||
@DEF_EXCLUDE_WASAPI_SYMBOLS@PaWasapi_GetDeviceDefaultFormat @59
|
|
||||||
@DEF_EXCLUDE_WASAPI_SYMBOLS@PaWasapi_GetDeviceMixFormat @60
|
|
||||||
@DEF_EXCLUDE_WASAPI_SYMBOLS@PaWasapi_GetDeviceRole @61
|
|
||||||
@DEF_EXCLUDE_WASAPI_SYMBOLS@PaWasapi_ThreadPriorityBoost @62
|
|
||||||
@DEF_EXCLUDE_WASAPI_SYMBOLS@PaWasapi_ThreadPriorityRevert @63
|
|
||||||
@DEF_EXCLUDE_WASAPI_SYMBOLS@PaWasapi_GetFramesPerHostBuffer @64
|
|
||||||
@DEF_EXCLUDE_WASAPI_SYMBOLS@PaWasapi_GetJackCount @65
|
|
||||||
@DEF_EXCLUDE_WASAPI_SYMBOLS@PaWasapi_GetJackDescription @66
|
|
||||||
@DEF_EXCLUDE_WASAPI_SYMBOLS@PaWasapi_SetStreamStateHandler @68
|
|
||||||
@DEF_EXCLUDE_WASAPI_SYMBOLS@PaWasapiWinrt_SetDefaultDeviceId @67
|
|
||||||
@DEF_EXCLUDE_WASAPI_SYMBOLS@PaWasapiWinrt_PopulateDeviceList @69
|
|
||||||
@DEF_EXCLUDE_WASAPI_SYMBOLS@PaWasapi_GetIMMDevice @70
|
|
150
third_party/portAudio/include/pa_asio.h
vendored
150
third_party/portAudio/include/pa_asio.h
vendored
@ -1,150 +0,0 @@
|
|||||||
#ifndef PA_ASIO_H
|
|
||||||
#define PA_ASIO_H
|
|
||||||
/*
|
|
||||||
* $Id$
|
|
||||||
* PortAudio Portable Real-Time Audio Library
|
|
||||||
* ASIO specific extensions
|
|
||||||
*
|
|
||||||
* Copyright (c) 1999-2000 Ross Bencina and Phil Burk
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files
|
|
||||||
* (the "Software"), to deal in the Software without restriction,
|
|
||||||
* including without limitation the rights to use, copy, modify, merge,
|
|
||||||
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
||||||
* and to permit persons to whom the Software is furnished to do so,
|
|
||||||
* subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be
|
|
||||||
* included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
||||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
|
|
||||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
|
||||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The text above constitutes the entire PortAudio license; however,
|
|
||||||
* the PortAudio community also makes the following non-binding requests:
|
|
||||||
*
|
|
||||||
* Any person wishing to distribute modifications to the Software is
|
|
||||||
* requested to send the modifications to the original developer so that
|
|
||||||
* they can be incorporated into the canonical version. It is also
|
|
||||||
* requested that these non-binding requests be included along with the
|
|
||||||
* license above.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/** @file
|
|
||||||
@ingroup public_header
|
|
||||||
@brief ASIO-specific PortAudio API extension header file.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "portaudio.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#endif /* __cplusplus */
|
|
||||||
|
|
||||||
|
|
||||||
/** Retrieve legal native buffer sizes for the specified device, in sample frames.
|
|
||||||
|
|
||||||
@param device The global index of the device about which the query is being made.
|
|
||||||
@param minBufferSizeFrames A pointer to the location which will receive the minimum buffer size value.
|
|
||||||
@param maxBufferSizeFrames A pointer to the location which will receive the maximum buffer size value.
|
|
||||||
@param preferredBufferSizeFrames A pointer to the location which will receive the preferred buffer size value.
|
|
||||||
@param granularity A pointer to the location which will receive the "granularity". This value determines
|
|
||||||
the step size used to compute the legal values between minBufferSizeFrames and maxBufferSizeFrames.
|
|
||||||
If granularity is -1 then available buffer size values are powers of two.
|
|
||||||
|
|
||||||
@see ASIOGetBufferSize in the ASIO SDK.
|
|
||||||
|
|
||||||
@note: this function used to be called PaAsio_GetAvailableLatencyValues. There is a
|
|
||||||
#define that maps PaAsio_GetAvailableLatencyValues to this function for backwards compatibility.
|
|
||||||
*/
|
|
||||||
PaError PaAsio_GetAvailableBufferSizes( PaDeviceIndex device,
|
|
||||||
long *minBufferSizeFrames, long *maxBufferSizeFrames, long *preferredBufferSizeFrames, long *granularity );
|
|
||||||
|
|
||||||
|
|
||||||
/** Backwards compatibility alias for PaAsio_GetAvailableBufferSizes
|
|
||||||
|
|
||||||
@see PaAsio_GetAvailableBufferSizes
|
|
||||||
*/
|
|
||||||
#define PaAsio_GetAvailableLatencyValues PaAsio_GetAvailableBufferSizes
|
|
||||||
|
|
||||||
|
|
||||||
/** Display the ASIO control panel for the specified device.
|
|
||||||
|
|
||||||
@param device The global index of the device whose control panel is to be displayed.
|
|
||||||
@param systemSpecific On Windows, the calling application's main window handle,
|
|
||||||
on Macintosh this value should be zero.
|
|
||||||
*/
|
|
||||||
PaError PaAsio_ShowControlPanel( PaDeviceIndex device, void* systemSpecific );
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** Retrieve a pointer to a string containing the name of the specified
|
|
||||||
input channel. The string is valid until Pa_Terminate is called.
|
|
||||||
|
|
||||||
The string will be no longer than 32 characters including the null terminator.
|
|
||||||
*/
|
|
||||||
PaError PaAsio_GetInputChannelName( PaDeviceIndex device, int channelIndex,
|
|
||||||
const char** channelName );
|
|
||||||
|
|
||||||
|
|
||||||
/** Retrieve a pointer to a string containing the name of the specified
|
|
||||||
input channel. The string is valid until Pa_Terminate is called.
|
|
||||||
|
|
||||||
The string will be no longer than 32 characters including the null terminator.
|
|
||||||
*/
|
|
||||||
PaError PaAsio_GetOutputChannelName( PaDeviceIndex device, int channelIndex,
|
|
||||||
const char** channelName );
|
|
||||||
|
|
||||||
|
|
||||||
/** Set the sample rate of an open paASIO stream.
|
|
||||||
|
|
||||||
@param stream The stream to operate on.
|
|
||||||
@param sampleRate The new sample rate.
|
|
||||||
|
|
||||||
Note that this function may fail if the stream is already running and the
|
|
||||||
ASIO driver does not support switching the sample rate of a running stream.
|
|
||||||
|
|
||||||
Returns paIncompatibleStreamHostApi if stream is not a paASIO stream.
|
|
||||||
*/
|
|
||||||
PaError PaAsio_SetStreamSampleRate( PaStream* stream, double sampleRate );
|
|
||||||
|
|
||||||
|
|
||||||
#define paAsioUseChannelSelectors (0x01)
|
|
||||||
|
|
||||||
typedef struct PaAsioStreamInfo{
|
|
||||||
unsigned long size; /**< sizeof(PaAsioStreamInfo) */
|
|
||||||
PaHostApiTypeId hostApiType; /**< paASIO */
|
|
||||||
unsigned long version; /**< 1 */
|
|
||||||
|
|
||||||
unsigned long flags;
|
|
||||||
|
|
||||||
/* Support for opening only specific channels of an ASIO device.
|
|
||||||
If the paAsioUseChannelSelectors flag is set, channelSelectors is a
|
|
||||||
pointer to an array of integers specifying the device channels to use.
|
|
||||||
When used, the length of the channelSelectors array must match the
|
|
||||||
corresponding channelCount parameter to Pa_OpenStream() otherwise a
|
|
||||||
crash may result.
|
|
||||||
The values in the selectors array must specify channels within the
|
|
||||||
range of supported channels for the device or paInvalidChannelCount will
|
|
||||||
result.
|
|
||||||
*/
|
|
||||||
int *channelSelectors;
|
|
||||||
}PaAsioStreamInfo;
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif /* __cplusplus */
|
|
||||||
|
|
||||||
#endif /* PA_ASIO_H */
|
|
77
third_party/portAudio/include/pa_jack.h
vendored
77
third_party/portAudio/include/pa_jack.h
vendored
@ -1,77 +0,0 @@
|
|||||||
#ifndef PA_JACK_H
|
|
||||||
#define PA_JACK_H
|
|
||||||
|
|
||||||
/*
|
|
||||||
* $Id:
|
|
||||||
* PortAudio Portable Real-Time Audio Library
|
|
||||||
* JACK-specific extensions
|
|
||||||
*
|
|
||||||
* Copyright (c) 1999-2000 Ross Bencina and Phil Burk
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files
|
|
||||||
* (the "Software"), to deal in the Software without restriction,
|
|
||||||
* including without limitation the rights to use, copy, modify, merge,
|
|
||||||
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
||||||
* and to permit persons to whom the Software is furnished to do so,
|
|
||||||
* subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be
|
|
||||||
* included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
||||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
|
|
||||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
|
||||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The text above constitutes the entire PortAudio license; however,
|
|
||||||
* the PortAudio community also makes the following non-binding requests:
|
|
||||||
*
|
|
||||||
* Any person wishing to distribute modifications to the Software is
|
|
||||||
* requested to send the modifications to the original developer so that
|
|
||||||
* they can be incorporated into the canonical version. It is also
|
|
||||||
* requested that these non-binding requests be included along with the
|
|
||||||
* license above.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @file
|
|
||||||
* @ingroup public_header
|
|
||||||
* @brief JACK-specific PortAudio API extension header file.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "portaudio.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/** Set the JACK client name.
|
|
||||||
*
|
|
||||||
* During Pa_Initialize, When PA JACK connects as a client of the JACK server, it requests a certain
|
|
||||||
* name, which is for instance prepended to port names. By default this name is "PortAudio". The
|
|
||||||
* JACK server may append a suffix to the client name, in order to avoid clashes among clients that
|
|
||||||
* try to connect with the same name (e.g., different PA JACK clients).
|
|
||||||
*
|
|
||||||
* This function must be called before Pa_Initialize, otherwise it won't have any effect. Note that
|
|
||||||
* the string is not copied, but instead referenced directly, so it must not be freed for as long as
|
|
||||||
* PA might need it.
|
|
||||||
* @sa PaJack_GetClientName
|
|
||||||
*/
|
|
||||||
PaError PaJack_SetClientName( const char* name );
|
|
||||||
|
|
||||||
/** Get the JACK client name used by PA JACK.
|
|
||||||
*
|
|
||||||
* The caller is responsible for freeing the returned pointer.
|
|
||||||
*/
|
|
||||||
PaError PaJack_GetClientName(const char** clientName);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
107
third_party/portAudio/include/pa_linux_alsa.h
vendored
107
third_party/portAudio/include/pa_linux_alsa.h
vendored
@ -1,107 +0,0 @@
|
|||||||
#ifndef PA_LINUX_ALSA_H
|
|
||||||
#define PA_LINUX_ALSA_H
|
|
||||||
|
|
||||||
/*
|
|
||||||
* $Id$
|
|
||||||
* PortAudio Portable Real-Time Audio Library
|
|
||||||
* ALSA-specific extensions
|
|
||||||
*
|
|
||||||
* Copyright (c) 1999-2000 Ross Bencina and Phil Burk
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files
|
|
||||||
* (the "Software"), to deal in the Software without restriction,
|
|
||||||
* including without limitation the rights to use, copy, modify, merge,
|
|
||||||
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
||||||
* and to permit persons to whom the Software is furnished to do so,
|
|
||||||
* subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be
|
|
||||||
* included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
||||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
|
|
||||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
|
||||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The text above constitutes the entire PortAudio license; however,
|
|
||||||
* the PortAudio community also makes the following non-binding requests:
|
|
||||||
*
|
|
||||||
* Any person wishing to distribute modifications to the Software is
|
|
||||||
* requested to send the modifications to the original developer so that
|
|
||||||
* they can be incorporated into the canonical version. It is also
|
|
||||||
* requested that these non-binding requests be included along with the
|
|
||||||
* license above.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @file
|
|
||||||
* @ingroup public_header
|
|
||||||
* @brief ALSA-specific PortAudio API extension header file.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "portaudio.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef struct PaAlsaStreamInfo
|
|
||||||
{
|
|
||||||
unsigned long size;
|
|
||||||
PaHostApiTypeId hostApiType;
|
|
||||||
unsigned long version;
|
|
||||||
|
|
||||||
const char *deviceString;
|
|
||||||
}
|
|
||||||
PaAlsaStreamInfo;
|
|
||||||
|
|
||||||
/** Initialize host API specific structure, call this before setting relevant attributes. */
|
|
||||||
void PaAlsa_InitializeStreamInfo( PaAlsaStreamInfo *info );
|
|
||||||
|
|
||||||
/** Instruct whether to enable real-time priority when starting the audio thread.
|
|
||||||
*
|
|
||||||
* If this is turned on by the stream is started, the audio callback thread will be created
|
|
||||||
* with the FIFO scheduling policy, which is suitable for realtime operation.
|
|
||||||
**/
|
|
||||||
void PaAlsa_EnableRealtimeScheduling( PaStream *s, int enable );
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
void PaAlsa_EnableWatchdog( PaStream *s, int enable );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/** Get the ALSA-lib card index of this stream's input device. */
|
|
||||||
PaError PaAlsa_GetStreamInputCard( PaStream *s, int *card );
|
|
||||||
|
|
||||||
/** Get the ALSA-lib card index of this stream's output device. */
|
|
||||||
PaError PaAlsa_GetStreamOutputCard( PaStream *s, int *card );
|
|
||||||
|
|
||||||
/** Set the number of periods (buffer fragments) to configure devices with.
|
|
||||||
*
|
|
||||||
* By default the number of periods is 4, this is the lowest number of periods that works well on
|
|
||||||
* the author's soundcard.
|
|
||||||
* @param numPeriods The number of periods.
|
|
||||||
*/
|
|
||||||
PaError PaAlsa_SetNumPeriods( int numPeriods );
|
|
||||||
|
|
||||||
/** Set the maximum number of times to retry opening busy device (sleeping for a
|
|
||||||
* short interval inbetween).
|
|
||||||
*/
|
|
||||||
PaError PaAlsa_SetRetriesBusy( int retries );
|
|
||||||
|
|
||||||
/** Set the path and name of ALSA library file if PortAudio is configured to load it dynamically (see
|
|
||||||
* PA_ALSA_DYNAMIC). This setting will overwrite the default name set by PA_ALSA_PATHNAME define.
|
|
||||||
* @param pathName Full path with filename. Only filename can be used, but dlopen() will lookup default
|
|
||||||
* searchable directories (/usr/lib;/usr/local/lib) then.
|
|
||||||
*/
|
|
||||||
void PaAlsa_SetLibraryPathName( const char *pathName );
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
191
third_party/portAudio/include/pa_mac_core.h
vendored
191
third_party/portAudio/include/pa_mac_core.h
vendored
@ -1,191 +0,0 @@
|
|||||||
#ifndef PA_MAC_CORE_H
|
|
||||||
#define PA_MAC_CORE_H
|
|
||||||
/*
|
|
||||||
* PortAudio Portable Real-Time Audio Library
|
|
||||||
* Macintosh Core Audio specific extensions
|
|
||||||
* portaudio.h should be included before this file.
|
|
||||||
*
|
|
||||||
* Copyright (c) 2005-2006 Bjorn Roche
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files
|
|
||||||
* (the "Software"), to deal in the Software without restriction,
|
|
||||||
* including without limitation the rights to use, copy, modify, merge,
|
|
||||||
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
||||||
* and to permit persons to whom the Software is furnished to do so,
|
|
||||||
* subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be
|
|
||||||
* included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
||||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
|
|
||||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
|
||||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The text above constitutes the entire PortAudio license; however,
|
|
||||||
* the PortAudio community also makes the following non-binding requests:
|
|
||||||
*
|
|
||||||
* Any person wishing to distribute modifications to the Software is
|
|
||||||
* requested to send the modifications to the original developer so that
|
|
||||||
* they can be incorporated into the canonical version. It is also
|
|
||||||
* requested that these non-binding requests be included along with the
|
|
||||||
* license above.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @file
|
|
||||||
* @ingroup public_header
|
|
||||||
* @brief CoreAudio-specific PortAudio API extension header file.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "portaudio.h"
|
|
||||||
|
|
||||||
#include <AudioUnit/AudioUnit.h>
|
|
||||||
#include <AudioToolbox/AudioToolbox.h>
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A pointer to a paMacCoreStreamInfo may be passed as
|
|
||||||
* the hostApiSpecificStreamInfo in the PaStreamParameters struct
|
|
||||||
* when opening a stream or querying the format. Use NULL, for the
|
|
||||||
* defaults. Note that for duplex streams, flags for input and output
|
|
||||||
* should be the same or behaviour is undefined.
|
|
||||||
*/
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
unsigned long size; /**size of whole structure including this header */
|
|
||||||
PaHostApiTypeId hostApiType; /**host API for which this data is intended */
|
|
||||||
unsigned long version; /**structure version */
|
|
||||||
unsigned long flags; /** flags to modify behaviour */
|
|
||||||
SInt32 const * channelMap; /** Channel map for HAL channel mapping , if not needed, use NULL;*/
|
|
||||||
unsigned long channelMapSize; /** Channel map size for HAL channel mapping , if not needed, use 0;*/
|
|
||||||
} PaMacCoreStreamInfo;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Functions
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/** Use this function to initialize a paMacCoreStreamInfo struct
|
|
||||||
* using the requested flags. Note that channel mapping is turned
|
|
||||||
* off after a call to this function.
|
|
||||||
* @param data The datastructure to initialize
|
|
||||||
* @param flags The flags to initialize the datastructure with.
|
|
||||||
*/
|
|
||||||
void PaMacCore_SetupStreamInfo( PaMacCoreStreamInfo *data, unsigned long flags );
|
|
||||||
|
|
||||||
/** call this after pa_SetupMacCoreStreamInfo to use channel mapping as described in notes.txt.
|
|
||||||
* @param data The stream info structure to assign a channel mapping to
|
|
||||||
* @param channelMap The channel map array, as described in notes.txt. This array pointer will be used directly (ie the underlying data will not be copied), so the caller should not free the array until after the stream has been opened.
|
|
||||||
* @param channelMapSize The size of the channel map array.
|
|
||||||
*/
|
|
||||||
void PaMacCore_SetupChannelMap( PaMacCoreStreamInfo *data, const SInt32 * const channelMap, unsigned long channelMapSize );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieve the AudioDeviceID of the input device assigned to an open stream
|
|
||||||
*
|
|
||||||
* @param s The stream to query.
|
|
||||||
*
|
|
||||||
* @return A valid AudioDeviceID, or NULL if an error occurred.
|
|
||||||
*/
|
|
||||||
AudioDeviceID PaMacCore_GetStreamInputDevice( PaStream* s );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieve the AudioDeviceID of the output device assigned to an open stream
|
|
||||||
*
|
|
||||||
* @param s The stream to query.
|
|
||||||
*
|
|
||||||
* @return A valid AudioDeviceID, or NULL if an error occurred.
|
|
||||||
*/
|
|
||||||
AudioDeviceID PaMacCore_GetStreamOutputDevice( PaStream* s );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a statically allocated string with the device's name
|
|
||||||
* for the given channel. NULL will be returned on failure.
|
|
||||||
*
|
|
||||||
* This function's implementation is not complete!
|
|
||||||
*
|
|
||||||
* @param device The PortAudio device index.
|
|
||||||
* @param channel The channel number who's name is requested.
|
|
||||||
* @return a statically allocated string with the name of the device.
|
|
||||||
* Because this string is statically allocated, it must be
|
|
||||||
* copied if it is to be saved and used by the user after
|
|
||||||
* another call to this function.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
const char *PaMacCore_GetChannelName( int device, int channelIndex, bool input );
|
|
||||||
|
|
||||||
|
|
||||||
/** Retrieve the range of legal native buffer sizes for the specified device, in sample frames.
|
|
||||||
|
|
||||||
@param device The global index of the PortAudio device about which the query is being made.
|
|
||||||
@param minBufferSizeFrames A pointer to the location which will receive the minimum buffer size value.
|
|
||||||
@param maxBufferSizeFrames A pointer to the location which will receive the maximum buffer size value.
|
|
||||||
|
|
||||||
@see kAudioDevicePropertyBufferFrameSizeRange in the CoreAudio SDK.
|
|
||||||
*/
|
|
||||||
PaError PaMacCore_GetBufferSizeRange( PaDeviceIndex device,
|
|
||||||
long *minBufferSizeFrames, long *maxBufferSizeFrames );
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Flags
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The following flags alter the behaviour of PA on the mac platform.
|
|
||||||
* they can be ORed together. These should work both for opening and
|
|
||||||
* checking a device.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** Allows PortAudio to change things like the device's frame size,
|
|
||||||
* which allows for much lower latency, but might disrupt the device
|
|
||||||
* if other programs are using it, even when you are just Querying
|
|
||||||
* the device. */
|
|
||||||
#define paMacCoreChangeDeviceParameters (0x01)
|
|
||||||
|
|
||||||
/** In combination with the above flag,
|
|
||||||
* causes the stream opening to fail, unless the exact sample rates
|
|
||||||
* are supported by the device. */
|
|
||||||
#define paMacCoreFailIfConversionRequired (0x02)
|
|
||||||
|
|
||||||
/** These flags set the SR conversion quality, if required. The weird ordering
|
|
||||||
* allows Maximum Quality to be the default.*/
|
|
||||||
#define paMacCoreConversionQualityMin (0x0100)
|
|
||||||
#define paMacCoreConversionQualityMedium (0x0200)
|
|
||||||
#define paMacCoreConversionQualityLow (0x0300)
|
|
||||||
#define paMacCoreConversionQualityHigh (0x0400)
|
|
||||||
#define paMacCoreConversionQualityMax (0x0000)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Here are some "preset" combinations of flags (above) to get to some
|
|
||||||
* common configurations. THIS IS OVERKILL, but if more flags are added
|
|
||||||
* it won't be.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**This is the default setting: do as much sample rate conversion as possible
|
|
||||||
* and as little mucking with the device as possible. */
|
|
||||||
#define paMacCorePlayNice (0x00)
|
|
||||||
/**This setting is tuned for pro audio apps. It allows SR conversion on input
|
|
||||||
and output, but it tries to set the appropriate SR on the device.*/
|
|
||||||
#define paMacCorePro (0x01)
|
|
||||||
/**This is a setting to minimize CPU usage and still play nice.*/
|
|
||||||
#define paMacCoreMinimizeCPUButPlayNice (0x0100)
|
|
||||||
/**This is a setting to minimize CPU usage, even if that means interrupting the device. */
|
|
||||||
#define paMacCoreMinimizeCPU (0x0101)
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif /** __cplusplus */
|
|
||||||
|
|
||||||
#endif /** PA_MAC_CORE_H */
|
|
95
third_party/portAudio/include/pa_win_ds.h
vendored
95
third_party/portAudio/include/pa_win_ds.h
vendored
@ -1,95 +0,0 @@
|
|||||||
#ifndef PA_WIN_DS_H
|
|
||||||
#define PA_WIN_DS_H
|
|
||||||
/*
|
|
||||||
* $Id: $
|
|
||||||
* PortAudio Portable Real-Time Audio Library
|
|
||||||
* DirectSound specific extensions
|
|
||||||
*
|
|
||||||
* Copyright (c) 1999-2007 Ross Bencina and Phil Burk
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files
|
|
||||||
* (the "Software"), to deal in the Software without restriction,
|
|
||||||
* including without limitation the rights to use, copy, modify, merge,
|
|
||||||
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
||||||
* and to permit persons to whom the Software is furnished to do so,
|
|
||||||
* subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be
|
|
||||||
* included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
||||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
|
|
||||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
|
||||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The text above constitutes the entire PortAudio license; however,
|
|
||||||
* the PortAudio community also makes the following non-binding requests:
|
|
||||||
*
|
|
||||||
* Any person wishing to distribute modifications to the Software is
|
|
||||||
* requested to send the modifications to the original developer so that
|
|
||||||
* they can be incorporated into the canonical version. It is also
|
|
||||||
* requested that these non-binding requests be included along with the
|
|
||||||
* license above.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @file
|
|
||||||
@ingroup public_header
|
|
||||||
@brief DirectSound-specific PortAudio API extension header file.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "portaudio.h"
|
|
||||||
#include "pa_win_waveformat.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#endif /* __cplusplus */
|
|
||||||
|
|
||||||
|
|
||||||
#define paWinDirectSoundUseLowLevelLatencyParameters (0x01)
|
|
||||||
#define paWinDirectSoundUseChannelMask (0x04)
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct PaWinDirectSoundStreamInfo{
|
|
||||||
unsigned long size; /**< sizeof(PaWinDirectSoundStreamInfo) */
|
|
||||||
PaHostApiTypeId hostApiType; /**< paDirectSound */
|
|
||||||
unsigned long version; /**< 2 */
|
|
||||||
|
|
||||||
unsigned long flags; /**< enable other features of this struct */
|
|
||||||
|
|
||||||
/**
|
|
||||||
low-level latency setting support
|
|
||||||
Sets the size of the DirectSound host buffer.
|
|
||||||
When flags contains the paWinDirectSoundUseLowLevelLatencyParameters
|
|
||||||
this size will be used instead of interpreting the generic latency
|
|
||||||
parameters to Pa_OpenStream(). If the flag is not set this value is ignored.
|
|
||||||
|
|
||||||
If the stream is a full duplex stream the implementation requires that
|
|
||||||
the values of framesPerBuffer for input and output match (if both are specified).
|
|
||||||
*/
|
|
||||||
unsigned long framesPerBuffer;
|
|
||||||
|
|
||||||
/**
|
|
||||||
support for WAVEFORMATEXTENSIBLE channel masks. If flags contains
|
|
||||||
paWinDirectSoundUseChannelMask this allows you to specify which speakers
|
|
||||||
to address in a multichannel stream. Constants for channelMask
|
|
||||||
are specified in pa_win_waveformat.h
|
|
||||||
|
|
||||||
*/
|
|
||||||
PaWinWaveFormatChannelMask channelMask;
|
|
||||||
|
|
||||||
}PaWinDirectSoundStreamInfo;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif /* __cplusplus */
|
|
||||||
|
|
||||||
#endif /* PA_WIN_DS_H */
|
|
729
third_party/portAudio/include/pa_win_wasapi.h
vendored
729
third_party/portAudio/include/pa_win_wasapi.h
vendored
@ -1,729 +0,0 @@
|
|||||||
#ifndef PA_WIN_WASAPI_H
|
|
||||||
#define PA_WIN_WASAPI_H
|
|
||||||
/*
|
|
||||||
* $Id: $
|
|
||||||
* PortAudio Portable Real-Time Audio Library
|
|
||||||
* WASAPI specific extensions
|
|
||||||
*
|
|
||||||
* Copyright (c) 1999-2018 Ross Bencina and Phil Burk
|
|
||||||
* Copyright (c) 2006-2010 David Viens
|
|
||||||
* Copyright (c) 2010-2018 Dmitry Kostjuchenko
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files
|
|
||||||
* (the "Software"), to deal in the Software without restriction,
|
|
||||||
* including without limitation the rights to use, copy, modify, merge,
|
|
||||||
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
||||||
* and to permit persons to whom the Software is furnished to do so,
|
|
||||||
* subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be
|
|
||||||
* included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
||||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
|
|
||||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
|
||||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The text above constitutes the entire PortAudio license; however,
|
|
||||||
* the PortAudio community also makes the following non-binding requests:
|
|
||||||
*
|
|
||||||
* Any person wishing to distribute modifications to the Software is
|
|
||||||
* requested to send the modifications to the original developer so that
|
|
||||||
* they can be incorporated into the canonical version. It is also
|
|
||||||
* requested that these non-binding requests be included along with the
|
|
||||||
* license above.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @file
|
|
||||||
@ingroup public_header
|
|
||||||
@brief WASAPI-specific PortAudio API extension header file.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "portaudio.h"
|
|
||||||
#include "pa_win_waveformat.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#endif /* __cplusplus */
|
|
||||||
|
|
||||||
|
|
||||||
/* Stream setup flags. */
|
|
||||||
typedef enum PaWasapiFlags
|
|
||||||
{
|
|
||||||
/* put WASAPI into exclusive mode */
|
|
||||||
paWinWasapiExclusive = (1 << 0),
|
|
||||||
|
|
||||||
/* allow to skip internal PA processing completely */
|
|
||||||
paWinWasapiRedirectHostProcessor = (1 << 1),
|
|
||||||
|
|
||||||
/* assign custom channel mask */
|
|
||||||
paWinWasapiUseChannelMask = (1 << 2),
|
|
||||||
|
|
||||||
/* select non-Event driven method of data read/write
|
|
||||||
Note: WASAPI Event driven core is capable of 2ms latency!!!, but Polling
|
|
||||||
method can only provide 15-20ms latency. */
|
|
||||||
paWinWasapiPolling = (1 << 3),
|
|
||||||
|
|
||||||
/* force custom thread priority setting, must be used if PaWasapiStreamInfo::threadPriority
|
|
||||||
is set to a custom value */
|
|
||||||
paWinWasapiThreadPriority = (1 << 4),
|
|
||||||
|
|
||||||
/* force explicit sample format and do not allow PA to select suitable working format, API will
|
|
||||||
fail if provided sample format is not supported by audio hardware in Exclusive mode
|
|
||||||
or system mixer in Shared mode */
|
|
||||||
paWinWasapiExplicitSampleFormat = (1 << 5),
|
|
||||||
|
|
||||||
/* allow API to insert system-level channel matrix mixer and sample rate converter to allow
|
|
||||||
playback formats that do not match the current configured system settings.
|
|
||||||
this is in particular required for streams not matching the system mixer sample rate.
|
|
||||||
only applies in Shared mode. */
|
|
||||||
paWinWasapiAutoConvert = (1 << 6)
|
|
||||||
}
|
|
||||||
PaWasapiFlags;
|
|
||||||
#define paWinWasapiExclusive (paWinWasapiExclusive)
|
|
||||||
#define paWinWasapiRedirectHostProcessor (paWinWasapiRedirectHostProcessor)
|
|
||||||
#define paWinWasapiUseChannelMask (paWinWasapiUseChannelMask)
|
|
||||||
#define paWinWasapiPolling (paWinWasapiPolling)
|
|
||||||
#define paWinWasapiThreadPriority (paWinWasapiThreadPriority)
|
|
||||||
#define paWinWasapiExplicitSampleFormat (paWinWasapiExplicitSampleFormat)
|
|
||||||
#define paWinWasapiAutoConvert (paWinWasapiAutoConvert)
|
|
||||||
|
|
||||||
|
|
||||||
/* Stream state.
|
|
||||||
|
|
||||||
@note Multiple states can be united into a bitmask.
|
|
||||||
@see PaWasapiStreamStateCallback, PaWasapi_SetStreamStateHandler
|
|
||||||
*/
|
|
||||||
typedef enum PaWasapiStreamState
|
|
||||||
{
|
|
||||||
/* state change was caused by the error:
|
|
||||||
|
|
||||||
Example:
|
|
||||||
1) If thread execution stopped due to AUDCLNT_E_RESOURCES_INVALIDATED then state
|
|
||||||
value will contain paWasapiStreamStateError|paWasapiStreamStateThreadStop.
|
|
||||||
*/
|
|
||||||
paWasapiStreamStateError = (1 << 0),
|
|
||||||
|
|
||||||
/* processing thread is preparing to start execution */
|
|
||||||
paWasapiStreamStateThreadPrepare = (1 << 1),
|
|
||||||
|
|
||||||
/* processing thread started execution (enters its loop) */
|
|
||||||
paWasapiStreamStateThreadStart = (1 << 2),
|
|
||||||
|
|
||||||
/* processing thread stopped execution */
|
|
||||||
paWasapiStreamStateThreadStop = (1 << 3)
|
|
||||||
}
|
|
||||||
PaWasapiStreamState;
|
|
||||||
#define paWasapiStreamStateError (paWasapiStreamStateError)
|
|
||||||
#define paWasapiStreamStateThreadPrepare (paWasapiStreamStateThreadPrepare)
|
|
||||||
#define paWasapiStreamStateThreadStart (paWasapiStreamStateThreadStart)
|
|
||||||
#define paWasapiStreamStateThreadStop (paWasapiStreamStateThreadStop)
|
|
||||||
|
|
||||||
|
|
||||||
/* Host processor.
|
|
||||||
|
|
||||||
Allows to skip internal PA processing completely. paWinWasapiRedirectHostProcessor flag
|
|
||||||
must be set to the PaWasapiStreamInfo::flags member in order to have host processor
|
|
||||||
redirected to this callback.
|
|
||||||
|
|
||||||
Use with caution! inputFrames and outputFrames depend solely on final device setup.
|
|
||||||
To query max values of inputFrames/outputFrames use PaWasapi_GetFramesPerHostBuffer.
|
|
||||||
*/
|
|
||||||
typedef void (*PaWasapiHostProcessorCallback) (void *inputBuffer, long inputFrames,
|
|
||||||
void *outputBuffer, long outputFrames, void *userData);
|
|
||||||
|
|
||||||
|
|
||||||
/* Stream state handler.
|
|
||||||
|
|
||||||
@param pStream Pointer to PaStream object.
|
|
||||||
@param stateFlags State flags, a collection of values from PaWasapiStreamState enum.
|
|
||||||
@param errorId Error id provided by system API (HRESULT).
|
|
||||||
@param userData Pointer to user data.
|
|
||||||
|
|
||||||
@see PaWasapiStreamState
|
|
||||||
*/
|
|
||||||
typedef void (*PaWasapiStreamStateCallback) (PaStream *pStream, unsigned int stateFlags,
|
|
||||||
unsigned int errorId, void *pUserData);
|
|
||||||
|
|
||||||
|
|
||||||
/* Device role. */
|
|
||||||
typedef enum PaWasapiDeviceRole
|
|
||||||
{
|
|
||||||
eRoleRemoteNetworkDevice = 0,
|
|
||||||
eRoleSpeakers,
|
|
||||||
eRoleLineLevel,
|
|
||||||
eRoleHeadphones,
|
|
||||||
eRoleMicrophone,
|
|
||||||
eRoleHeadset,
|
|
||||||
eRoleHandset,
|
|
||||||
eRoleUnknownDigitalPassthrough,
|
|
||||||
eRoleSPDIF,
|
|
||||||
eRoleHDMI,
|
|
||||||
eRoleUnknownFormFactor
|
|
||||||
}
|
|
||||||
PaWasapiDeviceRole;
|
|
||||||
|
|
||||||
|
|
||||||
/* Jack connection type. */
|
|
||||||
typedef enum PaWasapiJackConnectionType
|
|
||||||
{
|
|
||||||
eJackConnTypeUnknown,
|
|
||||||
eJackConnType3Point5mm,
|
|
||||||
eJackConnTypeQuarter,
|
|
||||||
eJackConnTypeAtapiInternal,
|
|
||||||
eJackConnTypeRCA,
|
|
||||||
eJackConnTypeOptical,
|
|
||||||
eJackConnTypeOtherDigital,
|
|
||||||
eJackConnTypeOtherAnalog,
|
|
||||||
eJackConnTypeMultichannelAnalogDIN,
|
|
||||||
eJackConnTypeXlrProfessional,
|
|
||||||
eJackConnTypeRJ11Modem,
|
|
||||||
eJackConnTypeCombination
|
|
||||||
}
|
|
||||||
PaWasapiJackConnectionType;
|
|
||||||
|
|
||||||
|
|
||||||
/* Jack geometric location. */
|
|
||||||
typedef enum PaWasapiJackGeoLocation
|
|
||||||
{
|
|
||||||
eJackGeoLocUnk = 0,
|
|
||||||
eJackGeoLocRear = 0x1, /* matches EPcxGeoLocation::eGeoLocRear */
|
|
||||||
eJackGeoLocFront,
|
|
||||||
eJackGeoLocLeft,
|
|
||||||
eJackGeoLocRight,
|
|
||||||
eJackGeoLocTop,
|
|
||||||
eJackGeoLocBottom,
|
|
||||||
eJackGeoLocRearPanel,
|
|
||||||
eJackGeoLocRiser,
|
|
||||||
eJackGeoLocInsideMobileLid,
|
|
||||||
eJackGeoLocDrivebay,
|
|
||||||
eJackGeoLocHDMI,
|
|
||||||
eJackGeoLocOutsideMobileLid,
|
|
||||||
eJackGeoLocATAPI,
|
|
||||||
eJackGeoLocReserved5,
|
|
||||||
eJackGeoLocReserved6,
|
|
||||||
}
|
|
||||||
PaWasapiJackGeoLocation;
|
|
||||||
|
|
||||||
|
|
||||||
/* Jack general location. */
|
|
||||||
typedef enum PaWasapiJackGenLocation
|
|
||||||
{
|
|
||||||
eJackGenLocPrimaryBox = 0,
|
|
||||||
eJackGenLocInternal,
|
|
||||||
eJackGenLocSeparate,
|
|
||||||
eJackGenLocOther
|
|
||||||
}
|
|
||||||
PaWasapiJackGenLocation;
|
|
||||||
|
|
||||||
|
|
||||||
/* Jack's type of port. */
|
|
||||||
typedef enum PaWasapiJackPortConnection
|
|
||||||
{
|
|
||||||
eJackPortConnJack = 0,
|
|
||||||
eJackPortConnIntegratedDevice,
|
|
||||||
eJackPortConnBothIntegratedAndJack,
|
|
||||||
eJackPortConnUnknown
|
|
||||||
}
|
|
||||||
PaWasapiJackPortConnection;
|
|
||||||
|
|
||||||
|
|
||||||
/* Thread priority. */
|
|
||||||
typedef enum PaWasapiThreadPriority
|
|
||||||
{
|
|
||||||
eThreadPriorityNone = 0,
|
|
||||||
eThreadPriorityAudio, //!< Default for Shared mode.
|
|
||||||
eThreadPriorityCapture,
|
|
||||||
eThreadPriorityDistribution,
|
|
||||||
eThreadPriorityGames,
|
|
||||||
eThreadPriorityPlayback,
|
|
||||||
eThreadPriorityProAudio, //!< Default for Exclusive mode.
|
|
||||||
eThreadPriorityWindowManager
|
|
||||||
}
|
|
||||||
PaWasapiThreadPriority;
|
|
||||||
|
|
||||||
|
|
||||||
/* Stream descriptor. */
|
|
||||||
typedef struct PaWasapiJackDescription
|
|
||||||
{
|
|
||||||
unsigned long channelMapping;
|
|
||||||
unsigned long color; /* derived from macro: #define RGB(r,g,b) ((COLORREF)(((BYTE)(r)|((WORD)((BYTE)(g))<<8))|(((DWORD)(BYTE)(b))<<16))) */
|
|
||||||
PaWasapiJackConnectionType connectionType;
|
|
||||||
PaWasapiJackGeoLocation geoLocation;
|
|
||||||
PaWasapiJackGenLocation genLocation;
|
|
||||||
PaWasapiJackPortConnection portConnection;
|
|
||||||
unsigned int isConnected;
|
|
||||||
}
|
|
||||||
PaWasapiJackDescription;
|
|
||||||
|
|
||||||
|
|
||||||
/** Stream category.
|
|
||||||
Note:
|
|
||||||
- values are equal to WASAPI AUDIO_STREAM_CATEGORY enum
|
|
||||||
- supported since Windows 8.0, noop on earlier versions
|
|
||||||
- values 1,2 are deprecated on Windows 10 and not included into enumeration
|
|
||||||
|
|
||||||
@version Available as of 19.6.0
|
|
||||||
*/
|
|
||||||
typedef enum PaWasapiStreamCategory
|
|
||||||
{
|
|
||||||
eAudioCategoryOther = 0,
|
|
||||||
eAudioCategoryCommunications = 3,
|
|
||||||
eAudioCategoryAlerts = 4,
|
|
||||||
eAudioCategorySoundEffects = 5,
|
|
||||||
eAudioCategoryGameEffects = 6,
|
|
||||||
eAudioCategoryGameMedia = 7,
|
|
||||||
eAudioCategoryGameChat = 8,
|
|
||||||
eAudioCategorySpeech = 9,
|
|
||||||
eAudioCategoryMovie = 10,
|
|
||||||
eAudioCategoryMedia = 11
|
|
||||||
}
|
|
||||||
PaWasapiStreamCategory;
|
|
||||||
|
|
||||||
|
|
||||||
/** Stream option.
|
|
||||||
Note:
|
|
||||||
- values are equal to WASAPI AUDCLNT_STREAMOPTIONS enum
|
|
||||||
- supported since Windows 8.1, noop on earlier versions
|
|
||||||
|
|
||||||
@version Available as of 19.6.0
|
|
||||||
*/
|
|
||||||
typedef enum PaWasapiStreamOption
|
|
||||||
{
|
|
||||||
eStreamOptionNone = 0, //!< default
|
|
||||||
eStreamOptionRaw = 1, //!< bypass WASAPI Audio Engine DSP effects, supported since Windows 8.1
|
|
||||||
eStreamOptionMatchFormat = 2 //!< force WASAPI Audio Engine into a stream format, supported since Windows 10
|
|
||||||
}
|
|
||||||
PaWasapiStreamOption;
|
|
||||||
|
|
||||||
|
|
||||||
/* Stream descriptor. */
|
|
||||||
typedef struct PaWasapiStreamInfo
|
|
||||||
{
|
|
||||||
unsigned long size; /**< sizeof(PaWasapiStreamInfo) */
|
|
||||||
PaHostApiTypeId hostApiType; /**< paWASAPI */
|
|
||||||
unsigned long version; /**< 1 */
|
|
||||||
|
|
||||||
unsigned long flags; /**< collection of PaWasapiFlags */
|
|
||||||
|
|
||||||
/** Support for WAVEFORMATEXTENSIBLE channel masks. If flags contains
|
|
||||||
paWinWasapiUseChannelMask this allows you to specify which speakers
|
|
||||||
to address in a multichannel stream. Constants for channelMask
|
|
||||||
are specified in pa_win_waveformat.h. Will be used only if
|
|
||||||
paWinWasapiUseChannelMask flag is specified.
|
|
||||||
*/
|
|
||||||
PaWinWaveFormatChannelMask channelMask;
|
|
||||||
|
|
||||||
/** Delivers raw data to callback obtained from GetBuffer() methods skipping
|
|
||||||
internal PortAudio processing inventory completely. userData parameter will
|
|
||||||
be the same that was passed to Pa_OpenStream method. Will be used only if
|
|
||||||
paWinWasapiRedirectHostProcessor flag is specified.
|
|
||||||
*/
|
|
||||||
PaWasapiHostProcessorCallback hostProcessorOutput;
|
|
||||||
PaWasapiHostProcessorCallback hostProcessorInput;
|
|
||||||
|
|
||||||
/** Specifies thread priority explicitly. Will be used only if paWinWasapiThreadPriority flag
|
|
||||||
is specified.
|
|
||||||
|
|
||||||
Please note, if Input/Output streams are opened simultaneously (Full-Duplex mode)
|
|
||||||
you shall specify same value for threadPriority or othervise one of the values will be used
|
|
||||||
to setup thread priority.
|
|
||||||
*/
|
|
||||||
PaWasapiThreadPriority threadPriority;
|
|
||||||
|
|
||||||
/** Stream category.
|
|
||||||
@see PaWasapiStreamCategory
|
|
||||||
@version Available as of 19.6.0
|
|
||||||
*/
|
|
||||||
PaWasapiStreamCategory streamCategory;
|
|
||||||
|
|
||||||
/** Stream option.
|
|
||||||
@see PaWasapiStreamOption
|
|
||||||
@version Available as of 19.6.0
|
|
||||||
*/
|
|
||||||
PaWasapiStreamOption streamOption;
|
|
||||||
}
|
|
||||||
PaWasapiStreamInfo;
|
|
||||||
|
|
||||||
|
|
||||||
/** Returns pointer to WASAPI's IAudioClient object of the stream.
|
|
||||||
|
|
||||||
@param pStream Pointer to PaStream object.
|
|
||||||
@param pAudioClient Pointer to pointer of IAudioClient.
|
|
||||||
@param bOutput TRUE (1) for output stream, FALSE (0) for input stream.
|
|
||||||
|
|
||||||
@return Error code indicating success or failure.
|
|
||||||
*/
|
|
||||||
PaError PaWasapi_GetAudioClient( PaStream *pStream, void **pAudioClient, int bOutput );
|
|
||||||
|
|
||||||
|
|
||||||
/** Update device list.
|
|
||||||
|
|
||||||
This function is available if PA_WASAPI_MAX_CONST_DEVICE_COUNT is defined during compile time
|
|
||||||
with maximum constant WASAPI device count (recommended value - 32).
|
|
||||||
If PA_WASAPI_MAX_CONST_DEVICE_COUNT is set to 0 (or not defined) during compile time the implementation
|
|
||||||
will not define PaWasapi_UpdateDeviceList() and thus updating device list can only be possible by calling
|
|
||||||
Pa_Terminate() and then Pa_Initialize().
|
|
||||||
|
|
||||||
@return Error code indicating success or failure.
|
|
||||||
*/
|
|
||||||
PaError PaWasapi_UpdateDeviceList();
|
|
||||||
|
|
||||||
|
|
||||||
/** Get current audio format of the device assigned to the opened stream.
|
|
||||||
|
|
||||||
Format is represented by PaWinWaveFormat or WAVEFORMATEXTENSIBLE structure.
|
|
||||||
Use this function to reconfirm format if PA's processor is overridden and
|
|
||||||
paWinWasapiRedirectHostProcessor flag is specified.
|
|
||||||
|
|
||||||
@param pStream Pointer to PaStream object.
|
|
||||||
@param pFormat Pointer to PaWinWaveFormat or WAVEFORMATEXTENSIBLE structure.
|
|
||||||
@param formatSize Size of PaWinWaveFormat or WAVEFORMATEXTENSIBLE structure in bytes.
|
|
||||||
@param bOutput TRUE (1) for output stream, FALSE (0) for input stream.
|
|
||||||
|
|
||||||
@return Non-negative value indicating the number of bytes copied into format descriptor
|
|
||||||
or, a PaErrorCode (which is always negative) if PortAudio is not initialized
|
|
||||||
or an error is encountered.
|
|
||||||
*/
|
|
||||||
int PaWasapi_GetDeviceCurrentFormat( PaStream *pStream, void *pFormat, unsigned int formatSize, int bOutput );
|
|
||||||
|
|
||||||
|
|
||||||
/** Get default audio format for the device in Shared Mode.
|
|
||||||
|
|
||||||
Format is represented by PaWinWaveFormat or WAVEFORMATEXTENSIBLE structure and obtained
|
|
||||||
by getting the device property with a PKEY_AudioEngine_DeviceFormat key.
|
|
||||||
|
|
||||||
@param pFormat Pointer to PaWinWaveFormat or WAVEFORMATEXTENSIBLE structure.
|
|
||||||
@param formatSize Size of PaWinWaveFormat or WAVEFORMATEXTENSIBLE structure in bytes.
|
|
||||||
@param device Device index.
|
|
||||||
|
|
||||||
@return Non-negative value indicating the number of bytes copied into format descriptor
|
|
||||||
or, a PaErrorCode (which is always negative) if PortAudio is not initialized
|
|
||||||
or an error is encountered.
|
|
||||||
*/
|
|
||||||
int PaWasapi_GetDeviceDefaultFormat( void *pFormat, unsigned int formatSize, PaDeviceIndex device );
|
|
||||||
|
|
||||||
|
|
||||||
/** Get mix audio format for the device in Shared Mode.
|
|
||||||
|
|
||||||
Format is represented by PaWinWaveFormat or WAVEFORMATEXTENSIBLE structureand obtained by
|
|
||||||
IAudioClient::GetMixFormat.
|
|
||||||
|
|
||||||
@param pFormat Pointer to PaWinWaveFormat or WAVEFORMATEXTENSIBLE structure.
|
|
||||||
@param formatSize Size of PaWinWaveFormat or WAVEFORMATEXTENSIBLE structure in bytes.
|
|
||||||
@param device Device index.
|
|
||||||
|
|
||||||
@return Non-negative value indicating the number of bytes copied into format descriptor
|
|
||||||
or, a PaErrorCode (which is always negative) if PortAudio is not initialized
|
|
||||||
or an error is encountered.
|
|
||||||
*/
|
|
||||||
int PaWasapi_GetDeviceMixFormat( void *pFormat, unsigned int formatSize, PaDeviceIndex device );
|
|
||||||
|
|
||||||
|
|
||||||
/** Get device role (PaWasapiDeviceRole enum).
|
|
||||||
|
|
||||||
@param device Device index.
|
|
||||||
|
|
||||||
@return Non-negative value indicating device role or, a PaErrorCode (which is always negative)
|
|
||||||
if PortAudio is not initialized or an error is encountered.
|
|
||||||
*/
|
|
||||||
int/*PaWasapiDeviceRole*/ PaWasapi_GetDeviceRole( PaDeviceIndex device );
|
|
||||||
|
|
||||||
|
|
||||||
/** Get device IMMDevice pointer
|
|
||||||
|
|
||||||
@param device Device index.
|
|
||||||
@param pAudioClient Pointer to pointer of IMMDevice.
|
|
||||||
|
|
||||||
@return Error code indicating success or failure.
|
|
||||||
*/
|
|
||||||
PaError PaWasapi_GetIMMDevice( PaDeviceIndex device, void **pIMMDevice );
|
|
||||||
|
|
||||||
|
|
||||||
/** Boost thread priority of calling thread (MMCSS).
|
|
||||||
|
|
||||||
Use it for Blocking Interface only inside the thread which makes calls to Pa_WriteStream/Pa_ReadStream.
|
|
||||||
|
|
||||||
@param pTask Handle to pointer to priority task. Must be used with PaWasapi_RevertThreadPriority
|
|
||||||
method to revert thread priority to initial state.
|
|
||||||
|
|
||||||
@param priorityClass Id of thread priority of PaWasapiThreadPriority type. Specifying
|
|
||||||
eThreadPriorityNone does nothing.
|
|
||||||
|
|
||||||
@return Error code indicating success or failure.
|
|
||||||
@see PaWasapi_RevertThreadPriority
|
|
||||||
*/
|
|
||||||
PaError PaWasapi_ThreadPriorityBoost( void **pTask, PaWasapiThreadPriority priorityClass );
|
|
||||||
|
|
||||||
|
|
||||||
/** Boost thread priority of calling thread (MMCSS).
|
|
||||||
|
|
||||||
Use it for Blocking Interface only inside the thread which makes calls to Pa_WriteStream/Pa_ReadStream.
|
|
||||||
|
|
||||||
@param pTask Task handle obtained by PaWasapi_BoostThreadPriority method.
|
|
||||||
|
|
||||||
@return Error code indicating success or failure.
|
|
||||||
@see PaWasapi_BoostThreadPriority
|
|
||||||
*/
|
|
||||||
PaError PaWasapi_ThreadPriorityRevert( void *pTask );
|
|
||||||
|
|
||||||
|
|
||||||
/** Get number of frames per host buffer.
|
|
||||||
|
|
||||||
It is max value of frames of WASAPI buffer which can be locked for operations.
|
|
||||||
Use this method as helper to find out max values of inputFrames/outputFrames
|
|
||||||
of PaWasapiHostProcessorCallback.
|
|
||||||
|
|
||||||
@param pStream Pointer to PaStream object.
|
|
||||||
@param pInput Pointer to variable to receive number of input frames. Can be NULL.
|
|
||||||
@param pOutput Pointer to variable to receive number of output frames. Can be NULL.
|
|
||||||
|
|
||||||
@return Error code indicating success or failure.
|
|
||||||
@see PaWasapiHostProcessorCallback
|
|
||||||
*/
|
|
||||||
PaError PaWasapi_GetFramesPerHostBuffer( PaStream *pStream, unsigned int *pInput, unsigned int *pOutput );
|
|
||||||
|
|
||||||
|
|
||||||
/** Get number of jacks associated with a WASAPI device.
|
|
||||||
|
|
||||||
Use this method to determine if there are any jacks associated with the provided WASAPI device.
|
|
||||||
Not all audio devices will support this capability. This is valid for both input and output devices.
|
|
||||||
|
|
||||||
@note Not available on UWP platform.
|
|
||||||
|
|
||||||
@param device Device index.
|
|
||||||
@param pJackCount Pointer to variable to receive number of jacks.
|
|
||||||
|
|
||||||
@return Error code indicating success or failure.
|
|
||||||
@see PaWasapi_GetJackDescription
|
|
||||||
*/
|
|
||||||
PaError PaWasapi_GetJackCount( PaDeviceIndex device, int *pJackCount );
|
|
||||||
|
|
||||||
|
|
||||||
/** Get the jack description associated with a WASAPI device and jack number.
|
|
||||||
|
|
||||||
Before this function is called, use PaWasapi_GetJackCount to determine the
|
|
||||||
number of jacks associated with device. If jcount is greater than zero, then
|
|
||||||
each jack from 0 to jcount can be queried with this function to get the jack
|
|
||||||
description.
|
|
||||||
|
|
||||||
@note Not available on UWP platform.
|
|
||||||
|
|
||||||
@param device Device index.
|
|
||||||
@param jackIndex Jack index.
|
|
||||||
@param pJackDescription Pointer to PaWasapiJackDescription.
|
|
||||||
|
|
||||||
@return Error code indicating success or failure.
|
|
||||||
@see PaWasapi_GetJackCount
|
|
||||||
*/
|
|
||||||
PaError PaWasapi_GetJackDescription( PaDeviceIndex device, int jackIndex, PaWasapiJackDescription *pJackDescription );
|
|
||||||
|
|
||||||
|
|
||||||
/** Set stream state handler.
|
|
||||||
|
|
||||||
@param pStream Pointer to PaStream object.
|
|
||||||
@param fnStateHandler Pointer to state handling function.
|
|
||||||
@param pUserData Pointer to user data.
|
|
||||||
|
|
||||||
@return Error code indicating success or failure.
|
|
||||||
*/
|
|
||||||
PaError PaWasapi_SetStreamStateHandler( PaStream *pStream, PaWasapiStreamStateCallback fnStateHandler, void *pUserData );
|
|
||||||
|
|
||||||
|
|
||||||
/** Set default device Id.
|
|
||||||
|
|
||||||
By default implementation will use the DEVINTERFACE_AUDIO_RENDER and
|
|
||||||
DEVINTERFACE_AUDIO_CAPTURE Ids if device Id is not provided explicitly. These default Ids
|
|
||||||
will not allow to use Exclusive mode on UWP/WinRT platform and thus you must provide
|
|
||||||
device Id explicitly via this API before calling the Pa_OpenStream().
|
|
||||||
|
|
||||||
Device Ids on UWP platform are obtainable via:
|
|
||||||
Windows::Media::Devices::MediaDevice::GetDefaultAudioRenderId() or
|
|
||||||
Windows::Media::Devices::MediaDevice::GetDefaultAudioCaptureId() API.
|
|
||||||
|
|
||||||
After the call completes, memory referenced by pointers can be freed, as implementation keeps its own copy.
|
|
||||||
|
|
||||||
Call this function before calling Pa_IsFormatSupported() when Exclusive mode is requested.
|
|
||||||
|
|
||||||
See an example in the IMPORTANT notes.
|
|
||||||
|
|
||||||
@note UWP/WinRT platform only.
|
|
||||||
|
|
||||||
@param pId Device Id, pointer to the 16-bit Unicode string (WCHAR). If NULL then device Id
|
|
||||||
will be reset to the default, e.g. DEVINTERFACE_AUDIO_RENDER or DEVINTERFACE_AUDIO_CAPTURE.
|
|
||||||
@param bOutput TRUE (1) for output (render), FALSE (0) for input (capture).
|
|
||||||
|
|
||||||
@return Error code indicating success or failure. Will return paIncompatibleStreamHostApi if library is not compiled
|
|
||||||
for UWP/WinRT platform. If Id is longer than PA_WASAPI_DEVICE_ID_LEN characters paBufferTooBig will
|
|
||||||
be returned.
|
|
||||||
*/
|
|
||||||
PaError PaWasapiWinrt_SetDefaultDeviceId( const unsigned short *pId, int bOutput );
|
|
||||||
|
|
||||||
|
|
||||||
/** Populate the device list.
|
|
||||||
|
|
||||||
By default the implementation will rely on DEVINTERFACE_AUDIO_RENDER and DEVINTERFACE_AUDIO_CAPTURE as
|
|
||||||
default devices. If device Id is provided by PaWasapiWinrt_SetDefaultDeviceId() then those
|
|
||||||
device Ids will be used as default and only devices for the device list.
|
|
||||||
|
|
||||||
By populating the device list you can provide an additional available audio devices of the system to PA
|
|
||||||
which are obtainable by:
|
|
||||||
Windows::Devices::Enumeration::DeviceInformation::FindAllAsync(selector) where selector is obtainable by
|
|
||||||
Windows::Media::Devices::MediaDevice::GetAudioRenderSelector() or
|
|
||||||
Windows::Media::Devices::MediaDevice::GetAudioCaptureSelector() API.
|
|
||||||
|
|
||||||
After the call completes, memory referenced by pointers can be freed, as implementation keeps its own copy.
|
|
||||||
|
|
||||||
You must call PaWasapi_UpdateDeviceList() to update the internal device list of the implementation after
|
|
||||||
calling this function.
|
|
||||||
|
|
||||||
See an example in the IMPORTANT notes.
|
|
||||||
|
|
||||||
@note UWP/WinRT platform only.
|
|
||||||
|
|
||||||
@param pId Array of device Ids, pointer to the array of pointers of 16-bit Unicode string (WCHAR). If NULL
|
|
||||||
and count is also 0 then device Ids will be reset to the default. Required.
|
|
||||||
@param pName Array of device Names, pointer to the array of pointers of 16-bit Unicode string (WCHAR). Optional.
|
|
||||||
@param pRole Array of device Roles, see PaWasapiDeviceRole and PaWasapi_GetDeviceRole() for more details. Optional.
|
|
||||||
@param count Number of devices, the number of array elements (pId, pName, pRole). Maximum count of devices
|
|
||||||
is limited by PA_WASAPI_DEVICE_MAX_COUNT.
|
|
||||||
@param bOutput TRUE (1) for output (render), FALSE (0) for input (capture).
|
|
||||||
|
|
||||||
@return Error code indicating success or failure. Will return paIncompatibleStreamHostApi if library is not compiled
|
|
||||||
for UWP/WinRT platform. If Id is longer than PA_WASAPI_DEVICE_ID_LEN characters paBufferTooBig will
|
|
||||||
be returned. If Name is longer than PA_WASAPI_DEVICE_NAME_LEN characters paBufferTooBig will
|
|
||||||
be returned.
|
|
||||||
*/
|
|
||||||
PaError PaWasapiWinrt_PopulateDeviceList( const unsigned short **pId, const unsigned short **pName,
|
|
||||||
const PaWasapiDeviceRole *pRole, unsigned int count, int bOutput );
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
IMPORTANT:
|
|
||||||
|
|
||||||
WASAPI is implemented for Callback and Blocking interfaces. It supports Shared and Exclusive
|
|
||||||
share modes.
|
|
||||||
|
|
||||||
Exclusive Mode:
|
|
||||||
|
|
||||||
Exclusive mode allows to deliver audio data directly to hardware bypassing
|
|
||||||
software mixing.
|
|
||||||
Exclusive mode is specified by 'paWinWasapiExclusive' flag.
|
|
||||||
|
|
||||||
Callback Interface:
|
|
||||||
|
|
||||||
Provides best audio quality with low latency. Callback interface is implemented in
|
|
||||||
two versions:
|
|
||||||
|
|
||||||
1) Event-Driven:
|
|
||||||
This is the most powerful WASAPI implementation which provides glitch-free
|
|
||||||
audio at around 3ms latency in Exclusive mode. Lowest possible latency for this mode is
|
|
||||||
3 ms for HD Audio class audio chips. For the Shared mode latency can not be
|
|
||||||
lower than 20 ms.
|
|
||||||
|
|
||||||
2) Poll-Driven:
|
|
||||||
Polling is another 2-nd method to operate with WASAPI. It is less efficient than Event-Driven
|
|
||||||
and provides latency at around 10-13ms. Polling must be used to overcome a system bug
|
|
||||||
under Windows Vista x64 when application is WOW64(32-bit) and Event-Driven method simply
|
|
||||||
times out (event handle is never signalled on buffer completion). Please note, such WOW64 bug
|
|
||||||
does not exist in Vista x86 or Windows 7.
|
|
||||||
Polling can be setup by specifying 'paWinWasapiPolling' flag. Our WASAPI implementation detects
|
|
||||||
WOW64 bug and sets 'paWinWasapiPolling' automatically.
|
|
||||||
|
|
||||||
Thread priority:
|
|
||||||
|
|
||||||
Normally thread priority is set automatically and does not require modification. Although
|
|
||||||
if user wants some tweaking thread priority can be modified by setting 'paWinWasapiThreadPriority'
|
|
||||||
flag and specifying 'PaWasapiStreamInfo::threadPriority' with value from PaWasapiThreadPriority
|
|
||||||
enum.
|
|
||||||
|
|
||||||
Blocking Interface:
|
|
||||||
|
|
||||||
Blocking interface is implemented but due to above described Poll-Driven method can not
|
|
||||||
deliver lowest possible latency. Specifying too low latency in Shared mode will result in
|
|
||||||
distorted audio although Exclusive mode adds stability.
|
|
||||||
|
|
||||||
8.24 format:
|
|
||||||
|
|
||||||
If paCustomFormat is specified as sample format then the implementation will understand it
|
|
||||||
as valid 24-bits inside 32-bit container (e.g. wBitsPerSample = 32, Samples.wValidBitsPerSample = 24).
|
|
||||||
|
|
||||||
By using paCustomFormat there will be small optimization when samples are be copied
|
|
||||||
with Copy_24_To_24 by PA processor instead of conversion from packed 3-byte (24-bit) data
|
|
||||||
with Int24_To_Int32.
|
|
||||||
|
|
||||||
Pa_IsFormatSupported:
|
|
||||||
|
|
||||||
To check format with correct Share Mode (Exclusive/Shared) you must supply PaWasapiStreamInfo
|
|
||||||
with flags paWinWasapiExclusive set through member of PaStreamParameters::hostApiSpecificStreamInfo
|
|
||||||
structure.
|
|
||||||
|
|
||||||
If paWinWasapiExplicitSampleFormat flag is provided then implementation will not try to select
|
|
||||||
suitable close format and will return an error instead of paFormatIsSupported. By specifying
|
|
||||||
paWinWasapiExplicitSampleFormat flag it is possible to find out what sample formats are
|
|
||||||
supported by Exclusive or Shared modes.
|
|
||||||
|
|
||||||
Pa_OpenStream:
|
|
||||||
|
|
||||||
To set desired Share Mode (Exclusive/Shared) you must supply
|
|
||||||
PaWasapiStreamInfo with flags paWinWasapiExclusive set through member of
|
|
||||||
PaStreamParameters::hostApiSpecificStreamInfo structure.
|
|
||||||
|
|
||||||
Coding style for parameters and structure members of the public API:
|
|
||||||
|
|
||||||
1) bXXX - boolean, [1 (TRUE), 0 (FALSE)]
|
|
||||||
2) pXXX - pointer
|
|
||||||
3) fnXXX - pointer to function
|
|
||||||
4) structure members are never prefixed with a type distinguisher
|
|
||||||
|
|
||||||
|
|
||||||
UWP/WinRT:
|
|
||||||
|
|
||||||
This platform has number of limitations which do not allow to enumerate audio devices without
|
|
||||||
an additional external help. Enumeration is possible though from C++/CX, check the related API
|
|
||||||
Windows::Devices::Enumeration::DeviceInformation::FindAllAsync().
|
|
||||||
|
|
||||||
The main limitation is an absence of the device enumeration from inside the PA's implementation.
|
|
||||||
This problem can be solved by using the following functions:
|
|
||||||
|
|
||||||
PaWasapiWinrt_SetDefaultDeviceId() - to set default input/output device,
|
|
||||||
PaWasapiWinrt_PopulateDeviceList() - to populate device list with devices.
|
|
||||||
|
|
||||||
Here is an example of populating the device list which can also be updated dynamically depending on
|
|
||||||
whether device was removed from or added to the system:
|
|
||||||
|
|
||||||
----------------
|
|
||||||
|
|
||||||
std::vector<const UINT16 *> ids, names;
|
|
||||||
std::vector<PaWasapiDeviceRole> role;
|
|
||||||
|
|
||||||
ids.resize(count);
|
|
||||||
names.resize(count);
|
|
||||||
role.resize(count);
|
|
||||||
|
|
||||||
for (UINT32 i = 0; i < count; ++i)
|
|
||||||
{
|
|
||||||
ids[i] = (const UINT16 *)device_ids[i].c_str();
|
|
||||||
names[i] = (const UINT16 *)device_names[i].c_str();
|
|
||||||
role[i] = eRoleUnknownFormFactor;
|
|
||||||
}
|
|
||||||
|
|
||||||
PaWasapiWinrt_SetDefaultDeviceId((const UINT16 *)default_device_id.c_str(), !capture);
|
|
||||||
PaWasapiWinrt_PopulateDeviceList(ids.data(), names.data(), role.data(), count, !capture);
|
|
||||||
PaWasapi_UpdateDeviceList();
|
|
||||||
|
|
||||||
----------------
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif /* __cplusplus */
|
|
||||||
|
|
||||||
#endif /* PA_WIN_WASAPI_H */
|
|
199
third_party/portAudio/include/pa_win_waveformat.h
vendored
199
third_party/portAudio/include/pa_win_waveformat.h
vendored
@ -1,199 +0,0 @@
|
|||||||
#ifndef PA_WIN_WAVEFORMAT_H
|
|
||||||
#define PA_WIN_WAVEFORMAT_H
|
|
||||||
|
|
||||||
/*
|
|
||||||
* PortAudio Portable Real-Time Audio Library
|
|
||||||
* Windows WAVEFORMAT* data structure utilities
|
|
||||||
* portaudio.h should be included before this file.
|
|
||||||
*
|
|
||||||
* Copyright (c) 2007 Ross Bencina
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files
|
|
||||||
* (the "Software"), to deal in the Software without restriction,
|
|
||||||
* including without limitation the rights to use, copy, modify, merge,
|
|
||||||
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
||||||
* and to permit persons to whom the Software is furnished to do so,
|
|
||||||
* subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be
|
|
||||||
* included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
||||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
|
|
||||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
|
||||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The text above constitutes the entire PortAudio license; however,
|
|
||||||
* the PortAudio community also makes the following non-binding requests:
|
|
||||||
*
|
|
||||||
* Any person wishing to distribute modifications to the Software is
|
|
||||||
* requested to send the modifications to the original developer so that
|
|
||||||
* they can be incorporated into the canonical version. It is also
|
|
||||||
* requested that these non-binding requests be included along with the
|
|
||||||
* license above.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @file
|
|
||||||
@ingroup public_header
|
|
||||||
@brief Windows specific PortAudio API extension and utilities header file.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
The following #defines for speaker channel masks are the same
|
|
||||||
as those in ksmedia.h, except with PAWIN_ prepended, KSAUDIO_ removed
|
|
||||||
in some cases, and casts to PaWinWaveFormatChannelMask added.
|
|
||||||
*/
|
|
||||||
|
|
||||||
typedef unsigned long PaWinWaveFormatChannelMask;
|
|
||||||
|
|
||||||
/* Speaker Positions: */
|
|
||||||
#define PAWIN_SPEAKER_FRONT_LEFT ((PaWinWaveFormatChannelMask)0x1)
|
|
||||||
#define PAWIN_SPEAKER_FRONT_RIGHT ((PaWinWaveFormatChannelMask)0x2)
|
|
||||||
#define PAWIN_SPEAKER_FRONT_CENTER ((PaWinWaveFormatChannelMask)0x4)
|
|
||||||
#define PAWIN_SPEAKER_LOW_FREQUENCY ((PaWinWaveFormatChannelMask)0x8)
|
|
||||||
#define PAWIN_SPEAKER_BACK_LEFT ((PaWinWaveFormatChannelMask)0x10)
|
|
||||||
#define PAWIN_SPEAKER_BACK_RIGHT ((PaWinWaveFormatChannelMask)0x20)
|
|
||||||
#define PAWIN_SPEAKER_FRONT_LEFT_OF_CENTER ((PaWinWaveFormatChannelMask)0x40)
|
|
||||||
#define PAWIN_SPEAKER_FRONT_RIGHT_OF_CENTER ((PaWinWaveFormatChannelMask)0x80)
|
|
||||||
#define PAWIN_SPEAKER_BACK_CENTER ((PaWinWaveFormatChannelMask)0x100)
|
|
||||||
#define PAWIN_SPEAKER_SIDE_LEFT ((PaWinWaveFormatChannelMask)0x200)
|
|
||||||
#define PAWIN_SPEAKER_SIDE_RIGHT ((PaWinWaveFormatChannelMask)0x400)
|
|
||||||
#define PAWIN_SPEAKER_TOP_CENTER ((PaWinWaveFormatChannelMask)0x800)
|
|
||||||
#define PAWIN_SPEAKER_TOP_FRONT_LEFT ((PaWinWaveFormatChannelMask)0x1000)
|
|
||||||
#define PAWIN_SPEAKER_TOP_FRONT_CENTER ((PaWinWaveFormatChannelMask)0x2000)
|
|
||||||
#define PAWIN_SPEAKER_TOP_FRONT_RIGHT ((PaWinWaveFormatChannelMask)0x4000)
|
|
||||||
#define PAWIN_SPEAKER_TOP_BACK_LEFT ((PaWinWaveFormatChannelMask)0x8000)
|
|
||||||
#define PAWIN_SPEAKER_TOP_BACK_CENTER ((PaWinWaveFormatChannelMask)0x10000)
|
|
||||||
#define PAWIN_SPEAKER_TOP_BACK_RIGHT ((PaWinWaveFormatChannelMask)0x20000)
|
|
||||||
|
|
||||||
/* Bit mask locations reserved for future use */
|
|
||||||
#define PAWIN_SPEAKER_RESERVED ((PaWinWaveFormatChannelMask)0x7FFC0000)
|
|
||||||
|
|
||||||
/* Used to specify that any possible permutation of speaker configurations */
|
|
||||||
#define PAWIN_SPEAKER_ALL ((PaWinWaveFormatChannelMask)0x80000000)
|
|
||||||
|
|
||||||
/* DirectSound Speaker Config */
|
|
||||||
#define PAWIN_SPEAKER_DIRECTOUT 0
|
|
||||||
#define PAWIN_SPEAKER_MONO (PAWIN_SPEAKER_FRONT_CENTER)
|
|
||||||
#define PAWIN_SPEAKER_STEREO (PAWIN_SPEAKER_FRONT_LEFT | PAWIN_SPEAKER_FRONT_RIGHT)
|
|
||||||
#define PAWIN_SPEAKER_QUAD (PAWIN_SPEAKER_FRONT_LEFT | PAWIN_SPEAKER_FRONT_RIGHT | \
|
|
||||||
PAWIN_SPEAKER_BACK_LEFT | PAWIN_SPEAKER_BACK_RIGHT)
|
|
||||||
#define PAWIN_SPEAKER_SURROUND (PAWIN_SPEAKER_FRONT_LEFT | PAWIN_SPEAKER_FRONT_RIGHT | \
|
|
||||||
PAWIN_SPEAKER_FRONT_CENTER | PAWIN_SPEAKER_BACK_CENTER)
|
|
||||||
#define PAWIN_SPEAKER_5POINT1 (PAWIN_SPEAKER_FRONT_LEFT | PAWIN_SPEAKER_FRONT_RIGHT | \
|
|
||||||
PAWIN_SPEAKER_FRONT_CENTER | PAWIN_SPEAKER_LOW_FREQUENCY | \
|
|
||||||
PAWIN_SPEAKER_BACK_LEFT | PAWIN_SPEAKER_BACK_RIGHT)
|
|
||||||
#define PAWIN_SPEAKER_7POINT1 (PAWIN_SPEAKER_FRONT_LEFT | PAWIN_SPEAKER_FRONT_RIGHT | \
|
|
||||||
PAWIN_SPEAKER_FRONT_CENTER | PAWIN_SPEAKER_LOW_FREQUENCY | \
|
|
||||||
PAWIN_SPEAKER_BACK_LEFT | PAWIN_SPEAKER_BACK_RIGHT | \
|
|
||||||
PAWIN_SPEAKER_FRONT_LEFT_OF_CENTER | PAWIN_SPEAKER_FRONT_RIGHT_OF_CENTER)
|
|
||||||
#define PAWIN_SPEAKER_5POINT1_SURROUND (PAWIN_SPEAKER_FRONT_LEFT | PAWIN_SPEAKER_FRONT_RIGHT | \
|
|
||||||
PAWIN_SPEAKER_FRONT_CENTER | PAWIN_SPEAKER_LOW_FREQUENCY | \
|
|
||||||
PAWIN_SPEAKER_SIDE_LEFT | PAWIN_SPEAKER_SIDE_RIGHT)
|
|
||||||
#define PAWIN_SPEAKER_7POINT1_SURROUND (PAWIN_SPEAKER_FRONT_LEFT | PAWIN_SPEAKER_FRONT_RIGHT | \
|
|
||||||
PAWIN_SPEAKER_FRONT_CENTER | PAWIN_SPEAKER_LOW_FREQUENCY | \
|
|
||||||
PAWIN_SPEAKER_BACK_LEFT | PAWIN_SPEAKER_BACK_RIGHT | \
|
|
||||||
PAWIN_SPEAKER_SIDE_LEFT | PAWIN_SPEAKER_SIDE_RIGHT)
|
|
||||||
/*
|
|
||||||
According to the Microsoft documentation:
|
|
||||||
The following are obsolete 5.1 and 7.1 settings (they lack side speakers). Note this means
|
|
||||||
that the default 5.1 and 7.1 settings (KSAUDIO_SPEAKER_5POINT1 and KSAUDIO_SPEAKER_7POINT1 are
|
|
||||||
similarly obsolete but are unchanged for compatibility reasons).
|
|
||||||
*/
|
|
||||||
#define PAWIN_SPEAKER_5POINT1_BACK PAWIN_SPEAKER_5POINT1
|
|
||||||
#define PAWIN_SPEAKER_7POINT1_WIDE PAWIN_SPEAKER_7POINT1
|
|
||||||
|
|
||||||
/* DVD Speaker Positions */
|
|
||||||
#define PAWIN_SPEAKER_GROUND_FRONT_LEFT PAWIN_SPEAKER_FRONT_LEFT
|
|
||||||
#define PAWIN_SPEAKER_GROUND_FRONT_CENTER PAWIN_SPEAKER_FRONT_CENTER
|
|
||||||
#define PAWIN_SPEAKER_GROUND_FRONT_RIGHT PAWIN_SPEAKER_FRONT_RIGHT
|
|
||||||
#define PAWIN_SPEAKER_GROUND_REAR_LEFT PAWIN_SPEAKER_BACK_LEFT
|
|
||||||
#define PAWIN_SPEAKER_GROUND_REAR_RIGHT PAWIN_SPEAKER_BACK_RIGHT
|
|
||||||
#define PAWIN_SPEAKER_TOP_MIDDLE PAWIN_SPEAKER_TOP_CENTER
|
|
||||||
#define PAWIN_SPEAKER_SUPER_WOOFER PAWIN_SPEAKER_LOW_FREQUENCY
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
PaWinWaveFormat is defined here to provide compatibility with
|
|
||||||
compilation environments which don't have headers defining
|
|
||||||
WAVEFORMATEXTENSIBLE (e.g. older versions of MSVC, Borland C++ etc.
|
|
||||||
|
|
||||||
The fields for WAVEFORMATEX and WAVEFORMATEXTENSIBLE are declared as an
|
|
||||||
unsigned char array here to avoid clients who include this file having
|
|
||||||
a dependency on windows.h and mmsystem.h, and also to to avoid having
|
|
||||||
to write separate packing pragmas for each compiler.
|
|
||||||
*/
|
|
||||||
#define PAWIN_SIZEOF_WAVEFORMATEX 18
|
|
||||||
#define PAWIN_SIZEOF_WAVEFORMATEXTENSIBLE (PAWIN_SIZEOF_WAVEFORMATEX + 22)
|
|
||||||
|
|
||||||
typedef struct{
|
|
||||||
unsigned char fields[ PAWIN_SIZEOF_WAVEFORMATEXTENSIBLE ];
|
|
||||||
unsigned long extraLongForAlignment; /* ensure that compiler aligns struct to DWORD */
|
|
||||||
} PaWinWaveFormat;
|
|
||||||
|
|
||||||
/*
|
|
||||||
WAVEFORMATEXTENSIBLE fields:
|
|
||||||
|
|
||||||
union {
|
|
||||||
WORD wValidBitsPerSample;
|
|
||||||
WORD wSamplesPerBlock;
|
|
||||||
WORD wReserved;
|
|
||||||
} Samples;
|
|
||||||
DWORD dwChannelMask;
|
|
||||||
GUID SubFormat;
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define PAWIN_INDEXOF_WVALIDBITSPERSAMPLE (PAWIN_SIZEOF_WAVEFORMATEX+0)
|
|
||||||
#define PAWIN_INDEXOF_DWCHANNELMASK (PAWIN_SIZEOF_WAVEFORMATEX+2)
|
|
||||||
#define PAWIN_INDEXOF_SUBFORMAT (PAWIN_SIZEOF_WAVEFORMATEX+6)
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
Valid values to pass for the waveFormatTag PaWin_InitializeWaveFormatEx and
|
|
||||||
PaWin_InitializeWaveFormatExtensible functions below. These must match
|
|
||||||
the standard Windows WAVE_FORMAT_* values.
|
|
||||||
*/
|
|
||||||
#define PAWIN_WAVE_FORMAT_PCM (1)
|
|
||||||
#define PAWIN_WAVE_FORMAT_IEEE_FLOAT (3)
|
|
||||||
#define PAWIN_WAVE_FORMAT_DOLBY_AC3_SPDIF (0x0092)
|
|
||||||
#define PAWIN_WAVE_FORMAT_WMA_SPDIF (0x0164)
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
returns PAWIN_WAVE_FORMAT_PCM or PAWIN_WAVE_FORMAT_IEEE_FLOAT
|
|
||||||
depending on the sampleFormat parameter.
|
|
||||||
*/
|
|
||||||
int PaWin_SampleFormatToLinearWaveFormatTag( PaSampleFormat sampleFormat );
|
|
||||||
|
|
||||||
/*
|
|
||||||
Use the following two functions to initialize the waveformat structure.
|
|
||||||
*/
|
|
||||||
|
|
||||||
void PaWin_InitializeWaveFormatEx( PaWinWaveFormat *waveFormat,
|
|
||||||
int numChannels, PaSampleFormat sampleFormat, int waveFormatTag, double sampleRate );
|
|
||||||
|
|
||||||
|
|
||||||
void PaWin_InitializeWaveFormatExtensible( PaWinWaveFormat *waveFormat,
|
|
||||||
int numChannels, PaSampleFormat sampleFormat, int waveFormatTag, double sampleRate,
|
|
||||||
PaWinWaveFormatChannelMask channelMask );
|
|
||||||
|
|
||||||
|
|
||||||
/* Map a channel count to a speaker channel mask */
|
|
||||||
PaWinWaveFormatChannelMask PaWin_DefaultChannelMask( int numChannels );
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif /* __cplusplus */
|
|
||||||
|
|
||||||
#endif /* PA_WIN_WAVEFORMAT_H */
|
|
137
third_party/portAudio/include/pa_win_wdmks.h
vendored
137
third_party/portAudio/include/pa_win_wdmks.h
vendored
@ -1,137 +0,0 @@
|
|||||||
#ifndef PA_WIN_WDMKS_H
|
|
||||||
#define PA_WIN_WDMKS_H
|
|
||||||
/*
|
|
||||||
* $Id$
|
|
||||||
* PortAudio Portable Real-Time Audio Library
|
|
||||||
* WDM/KS specific extensions
|
|
||||||
*
|
|
||||||
* Copyright (c) 1999-2007 Ross Bencina and Phil Burk
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files
|
|
||||||
* (the "Software"), to deal in the Software without restriction,
|
|
||||||
* including without limitation the rights to use, copy, modify, merge,
|
|
||||||
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
||||||
* and to permit persons to whom the Software is furnished to do so,
|
|
||||||
* subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be
|
|
||||||
* included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
||||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
|
|
||||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
|
||||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The text above constitutes the entire PortAudio license; however,
|
|
||||||
* the PortAudio community also makes the following non-binding requests:
|
|
||||||
*
|
|
||||||
* Any person wishing to distribute modifications to the Software is
|
|
||||||
* requested to send the modifications to the original developer so that
|
|
||||||
* they can be incorporated into the canonical version. It is also
|
|
||||||
* requested that these non-binding requests be included along with the
|
|
||||||
* license above.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @file
|
|
||||||
@ingroup public_header
|
|
||||||
@brief WDM Kernel Streaming-specific PortAudio API extension header file.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include "portaudio.h"
|
|
||||||
|
|
||||||
#include <windows.h>
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#endif /* __cplusplus */
|
|
||||||
|
|
||||||
/** Flags to indicate valid fields in PaWinWDMKSInfo.
|
|
||||||
@see PaWinWDMKSInfo
|
|
||||||
@version Available as of 19.5.0.
|
|
||||||
*/
|
|
||||||
typedef enum PaWinWDMKSFlags
|
|
||||||
{
|
|
||||||
/** Makes WDMKS use the supplied latency figures instead of relying on the frame size reported
|
|
||||||
by the WaveCyclic device. Use at own risk!
|
|
||||||
*/
|
|
||||||
paWinWDMKSOverrideFramesize = (1 << 0),
|
|
||||||
|
|
||||||
/** Makes WDMKS (output stream) use the given channelMask instead of the default.
|
|
||||||
@version Available as of 19.5.0.
|
|
||||||
*/
|
|
||||||
paWinWDMKSUseGivenChannelMask = (1 << 1),
|
|
||||||
|
|
||||||
} PaWinWDMKSFlags;
|
|
||||||
|
|
||||||
typedef struct PaWinWDMKSInfo{
|
|
||||||
unsigned long size; /**< sizeof(PaWinWDMKSInfo) */
|
|
||||||
PaHostApiTypeId hostApiType; /**< paWDMKS */
|
|
||||||
unsigned long version; /**< 1 */
|
|
||||||
|
|
||||||
/** Flags indicate which fields are valid.
|
|
||||||
@see PaWinWDMKSFlags
|
|
||||||
@version Available as of 19.5.0.
|
|
||||||
*/
|
|
||||||
unsigned long flags;
|
|
||||||
|
|
||||||
/** The number of packets to use for WaveCyclic devices, range is [2, 8]. Set to zero for default value of 2. */
|
|
||||||
unsigned noOfPackets;
|
|
||||||
|
|
||||||
/** If paWinWDMKSUseGivenChannelMask bit is set in flags, use this as channelMask instead of default.
|
|
||||||
@see PaWinWDMKSFlags
|
|
||||||
@version Available as of 19.5.0.
|
|
||||||
*/
|
|
||||||
unsigned channelMask;
|
|
||||||
} PaWinWDMKSInfo;
|
|
||||||
|
|
||||||
typedef enum PaWDMKSType
|
|
||||||
{
|
|
||||||
Type_kNotUsed,
|
|
||||||
Type_kWaveCyclic,
|
|
||||||
Type_kWaveRT,
|
|
||||||
Type_kCnt,
|
|
||||||
} PaWDMKSType;
|
|
||||||
|
|
||||||
typedef enum PaWDMKSSubType
|
|
||||||
{
|
|
||||||
SubType_kUnknown,
|
|
||||||
SubType_kNotification,
|
|
||||||
SubType_kPolled,
|
|
||||||
SubType_kCnt,
|
|
||||||
} PaWDMKSSubType;
|
|
||||||
|
|
||||||
typedef struct PaWinWDMKSDeviceInfo {
|
|
||||||
wchar_t filterPath[MAX_PATH]; /**< KS filter path in Unicode! */
|
|
||||||
wchar_t topologyPath[MAX_PATH]; /**< Topology filter path in Unicode! */
|
|
||||||
PaWDMKSType streamingType;
|
|
||||||
GUID deviceProductGuid; /**< The product GUID of the device (if supported) */
|
|
||||||
} PaWinWDMKSDeviceInfo;
|
|
||||||
|
|
||||||
typedef struct PaWDMKSDirectionSpecificStreamInfo
|
|
||||||
{
|
|
||||||
PaDeviceIndex device;
|
|
||||||
unsigned channels; /**< No of channels the device is opened with */
|
|
||||||
unsigned framesPerHostBuffer; /**< No of frames of the device buffer */
|
|
||||||
int endpointPinId; /**< Endpoint pin ID (on topology filter if topologyName is not empty) */
|
|
||||||
int muxNodeId; /**< Only valid for input */
|
|
||||||
PaWDMKSSubType streamingSubType; /**< Not known until device is opened for streaming */
|
|
||||||
} PaWDMKSDirectionSpecificStreamInfo;
|
|
||||||
|
|
||||||
typedef struct PaWDMKSSpecificStreamInfo {
|
|
||||||
PaWDMKSDirectionSpecificStreamInfo input;
|
|
||||||
PaWDMKSDirectionSpecificStreamInfo output;
|
|
||||||
} PaWDMKSSpecificStreamInfo;
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif /* __cplusplus */
|
|
||||||
|
|
||||||
#endif /* PA_WIN_DS_H */
|
|
185
third_party/portAudio/include/pa_win_wmme.h
vendored
185
third_party/portAudio/include/pa_win_wmme.h
vendored
@ -1,185 +0,0 @@
|
|||||||
#ifndef PA_WIN_WMME_H
|
|
||||||
#define PA_WIN_WMME_H
|
|
||||||
/*
|
|
||||||
* $Id$
|
|
||||||
* PortAudio Portable Real-Time Audio Library
|
|
||||||
* MME specific extensions
|
|
||||||
*
|
|
||||||
* Copyright (c) 1999-2000 Ross Bencina and Phil Burk
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files
|
|
||||||
* (the "Software"), to deal in the Software without restriction,
|
|
||||||
* including without limitation the rights to use, copy, modify, merge,
|
|
||||||
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
||||||
* and to permit persons to whom the Software is furnished to do so,
|
|
||||||
* subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be
|
|
||||||
* included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
||||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
|
|
||||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
|
||||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The text above constitutes the entire PortAudio license; however,
|
|
||||||
* the PortAudio community also makes the following non-binding requests:
|
|
||||||
*
|
|
||||||
* Any person wishing to distribute modifications to the Software is
|
|
||||||
* requested to send the modifications to the original developer so that
|
|
||||||
* they can be incorporated into the canonical version. It is also
|
|
||||||
* requested that these non-binding requests be included along with the
|
|
||||||
* license above.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @file
|
|
||||||
@ingroup public_header
|
|
||||||
@brief WMME-specific PortAudio API extension header file.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "portaudio.h"
|
|
||||||
#include "pa_win_waveformat.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#endif /* __cplusplus */
|
|
||||||
|
|
||||||
|
|
||||||
/* The following are flags which can be set in
|
|
||||||
PaWinMmeStreamInfo's flags field.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define paWinMmeUseLowLevelLatencyParameters (0x01)
|
|
||||||
#define paWinMmeUseMultipleDevices (0x02) /* use mme specific multiple device feature */
|
|
||||||
#define paWinMmeUseChannelMask (0x04)
|
|
||||||
|
|
||||||
/* By default, the mme implementation drops the processing thread's priority
|
|
||||||
to THREAD_PRIORITY_NORMAL and sleeps the thread if the CPU load exceeds 100%
|
|
||||||
This flag disables any priority throttling. The processing thread will always
|
|
||||||
run at THREAD_PRIORITY_TIME_CRITICAL.
|
|
||||||
*/
|
|
||||||
#define paWinMmeDontThrottleOverloadedProcessingThread (0x08)
|
|
||||||
|
|
||||||
/* Flags for non-PCM spdif passthrough.
|
|
||||||
*/
|
|
||||||
#define paWinMmeWaveFormatDolbyAc3Spdif (0x10)
|
|
||||||
#define paWinMmeWaveFormatWmaSpdif (0x20)
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct PaWinMmeDeviceAndChannelCount{
|
|
||||||
PaDeviceIndex device;
|
|
||||||
int channelCount;
|
|
||||||
}PaWinMmeDeviceAndChannelCount;
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct PaWinMmeStreamInfo{
|
|
||||||
unsigned long size; /**< sizeof(PaWinMmeStreamInfo) */
|
|
||||||
PaHostApiTypeId hostApiType; /**< paMME */
|
|
||||||
unsigned long version; /**< 1 */
|
|
||||||
|
|
||||||
unsigned long flags;
|
|
||||||
|
|
||||||
/* low-level latency setting support
|
|
||||||
These settings control the number and size of host buffers in order
|
|
||||||
to set latency. They will be used instead of the generic parameters
|
|
||||||
to Pa_OpenStream() if flags contains the PaWinMmeUseLowLevelLatencyParameters
|
|
||||||
flag.
|
|
||||||
|
|
||||||
If PaWinMmeStreamInfo structures with PaWinMmeUseLowLevelLatencyParameters
|
|
||||||
are supplied for both input and output in a full duplex stream, then the
|
|
||||||
input and output framesPerBuffer must be the same, or the larger of the
|
|
||||||
two must be a multiple of the smaller, otherwise a
|
|
||||||
paIncompatibleHostApiSpecificStreamInfo error will be returned from
|
|
||||||
Pa_OpenStream().
|
|
||||||
*/
|
|
||||||
unsigned long framesPerBuffer;
|
|
||||||
unsigned long bufferCount; /* formerly numBuffers */
|
|
||||||
|
|
||||||
/* multiple devices per direction support
|
|
||||||
If flags contains the PaWinMmeUseMultipleDevices flag,
|
|
||||||
this functionality will be used, otherwise the device parameter to
|
|
||||||
Pa_OpenStream() will be used instead.
|
|
||||||
If devices are specified here, the corresponding device parameter
|
|
||||||
to Pa_OpenStream() should be set to paUseHostApiSpecificDeviceSpecification,
|
|
||||||
otherwise an paInvalidDevice error will result.
|
|
||||||
The total number of channels across all specified devices
|
|
||||||
must agree with the corresponding channelCount parameter to
|
|
||||||
Pa_OpenStream() otherwise a paInvalidChannelCount error will result.
|
|
||||||
*/
|
|
||||||
PaWinMmeDeviceAndChannelCount *devices;
|
|
||||||
unsigned long deviceCount;
|
|
||||||
|
|
||||||
/*
|
|
||||||
support for WAVEFORMATEXTENSIBLE channel masks. If flags contains
|
|
||||||
paWinMmeUseChannelMask this allows you to specify which speakers
|
|
||||||
to address in a multichannel stream. Constants for channelMask
|
|
||||||
are specified in pa_win_waveformat.h
|
|
||||||
|
|
||||||
*/
|
|
||||||
PaWinWaveFormatChannelMask channelMask;
|
|
||||||
|
|
||||||
}PaWinMmeStreamInfo;
|
|
||||||
|
|
||||||
|
|
||||||
/** Retrieve the number of wave in handles used by a PortAudio WinMME stream.
|
|
||||||
Returns zero if the stream is output only.
|
|
||||||
|
|
||||||
@return A non-negative value indicating the number of wave in handles
|
|
||||||
or, a PaErrorCode (which are always negative) if PortAudio is not initialized
|
|
||||||
or an error is encountered.
|
|
||||||
|
|
||||||
@see PaWinMME_GetStreamInputHandle
|
|
||||||
*/
|
|
||||||
int PaWinMME_GetStreamInputHandleCount( PaStream* stream );
|
|
||||||
|
|
||||||
|
|
||||||
/** Retrieve a wave in handle used by a PortAudio WinMME stream.
|
|
||||||
|
|
||||||
@param stream The stream to query.
|
|
||||||
@param handleIndex The zero based index of the wave in handle to retrieve. This
|
|
||||||
should be in the range [0, PaWinMME_GetStreamInputHandleCount(stream)-1].
|
|
||||||
|
|
||||||
@return A valid wave in handle, or NULL if an error occurred.
|
|
||||||
|
|
||||||
@see PaWinMME_GetStreamInputHandle
|
|
||||||
*/
|
|
||||||
HWAVEIN PaWinMME_GetStreamInputHandle( PaStream* stream, int handleIndex );
|
|
||||||
|
|
||||||
|
|
||||||
/** Retrieve the number of wave out handles used by a PortAudio WinMME stream.
|
|
||||||
Returns zero if the stream is input only.
|
|
||||||
|
|
||||||
@return A non-negative value indicating the number of wave out handles
|
|
||||||
or, a PaErrorCode (which are always negative) if PortAudio is not initialized
|
|
||||||
or an error is encountered.
|
|
||||||
|
|
||||||
@see PaWinMME_GetStreamOutputHandle
|
|
||||||
*/
|
|
||||||
int PaWinMME_GetStreamOutputHandleCount( PaStream* stream );
|
|
||||||
|
|
||||||
|
|
||||||
/** Retrieve a wave out handle used by a PortAudio WinMME stream.
|
|
||||||
|
|
||||||
@param stream The stream to query.
|
|
||||||
@param handleIndex The zero based index of the wave out handle to retrieve.
|
|
||||||
This should be in the range [0, PaWinMME_GetStreamOutputHandleCount(stream)-1].
|
|
||||||
|
|
||||||
@return A valid wave out handle, or NULL if an error occurred.
|
|
||||||
|
|
||||||
@see PaWinMME_GetStreamOutputHandleCount
|
|
||||||
*/
|
|
||||||
HWAVEOUT PaWinMME_GetStreamOutputHandle( PaStream* stream, int handleIndex );
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif /* __cplusplus */
|
|
||||||
|
|
||||||
#endif /* PA_WIN_WMME_H */
|
|
1228
third_party/portAudio/include/portaudio.h
vendored
1228
third_party/portAudio/include/portaudio.h
vendored
File diff suppressed because it is too large
Load Diff
220
third_party/portAudio/src/SConscript
vendored
220
third_party/portAudio/src/SConscript
vendored
@ -1,220 +0,0 @@
|
|||||||
import os.path, copy, sys
|
|
||||||
|
|
||||||
def checkSymbol(conf, header, library=None, symbol=None, autoAdd=True, critical=False, pkgName=None):
|
|
||||||
""" Check for symbol in library, optionally look only for header.
|
|
||||||
@param conf: Configure instance.
|
|
||||||
@param header: The header file where the symbol is declared.
|
|
||||||
@param library: The library in which the symbol exists, if None it is taken to be the standard C library.
|
|
||||||
@param symbol: The symbol to look for, if None only the header will be looked up.
|
|
||||||
@param autoAdd: Automatically link with this library if check is positive.
|
|
||||||
@param critical: Raise on error?
|
|
||||||
@param pkgName: Optional name of pkg-config entry for library, to determine build parameters.
|
|
||||||
@return: True/False
|
|
||||||
"""
|
|
||||||
origEnv = conf.env.Copy() # Copy unmodified environment so we can restore it upon error
|
|
||||||
env = conf.env
|
|
||||||
if library is None:
|
|
||||||
library = "c" # Standard library
|
|
||||||
autoAdd = False
|
|
||||||
|
|
||||||
if pkgName is not None:
|
|
||||||
origLibs = copy.copy(env.get("LIBS", None))
|
|
||||||
|
|
||||||
try: env.ParseConfig("pkg-config --silence-errors %s --cflags --libs" % pkgName)
|
|
||||||
except: pass
|
|
||||||
else:
|
|
||||||
# I see no other way of checking that the parsing succeeded, if it did add no more linking parameters
|
|
||||||
if env.get("LIBS", None) != origLibs:
|
|
||||||
autoAdd = False
|
|
||||||
|
|
||||||
try:
|
|
||||||
if not conf.CheckCHeader(header, include_quotes="<>"):
|
|
||||||
raise ConfigurationError("missing header %s" % header)
|
|
||||||
if symbol is not None and not conf.CheckLib(library, symbol, language="C", autoadd=autoAdd):
|
|
||||||
raise ConfigurationError("missing symbol %s in library %s" % (symbol, library))
|
|
||||||
except ConfigurationError:
|
|
||||||
conf.env = origEnv
|
|
||||||
if not critical:
|
|
||||||
return False
|
|
||||||
raise
|
|
||||||
|
|
||||||
return True
|
|
||||||
|
|
||||||
import SCons.Errors
|
|
||||||
|
|
||||||
# Import common variables
|
|
||||||
|
|
||||||
# Could use '#' to refer to top-level SConstruct directory, but looks like env.SConsignFile doesn't interpret this at least :(
|
|
||||||
sconsDir = os.path.abspath(os.path.join("build", "scons"))
|
|
||||||
|
|
||||||
try:
|
|
||||||
Import("Platform", "Posix", "ConfigurationError", "ApiVer")
|
|
||||||
except SCons.Errors.UserError:
|
|
||||||
# The common objects must be exported first
|
|
||||||
SConscript(os.path.join(sconsDir, "SConscript_common"))
|
|
||||||
Import("Platform", "Posix", "ConfigurationError", "ApiVer")
|
|
||||||
|
|
||||||
Import("env")
|
|
||||||
|
|
||||||
# This will be manipulated
|
|
||||||
env = env.Copy()
|
|
||||||
|
|
||||||
# We operate with a set of needed libraries and optional libraries, the latter stemming from host API implementations.
|
|
||||||
# For libraries of both types we record a set of values that is used to look for the library in question, during
|
|
||||||
# configuration. If the corresponding library for a host API implementation isn't found, the implementation is left out.
|
|
||||||
neededLibs = []
|
|
||||||
optionalImpls = {}
|
|
||||||
if Platform in Posix:
|
|
||||||
env.Append(CPPPATH=os.path.join("os", "unix"))
|
|
||||||
neededLibs += [("pthread", "pthread.h", "pthread_create"), ("m", "math.h", "sin")]
|
|
||||||
if env["useALSA"]:
|
|
||||||
optionalImpls["ALSA"] = ("asound", "alsa/asoundlib.h", "snd_pcm_open")
|
|
||||||
if env["useJACK"]:
|
|
||||||
optionalImpls["JACK"] = ("jack", "jack/jack.h", "jack_client_new")
|
|
||||||
if env["useOSS"]:
|
|
||||||
# TODO: It looks like the prefix for soundcard.h depends on the platform
|
|
||||||
optionalImpls["OSS"] = ("oss", "sys/soundcard.h", None)
|
|
||||||
if Platform == 'netbsd':
|
|
||||||
optionalImpls["OSS"] = ("ossaudio", "sys/soundcard.h", "_oss_ioctl")
|
|
||||||
if env["useASIHPI"]:
|
|
||||||
optionalImpls["ASIHPI"] = ("hpi", "asihpi/hpi.h", "HPI_SubSysCreate")
|
|
||||||
if env["useCOREAUDIO"]:
|
|
||||||
optionalImpls["COREAUDIO"] = ("CoreAudio", "CoreAudio/CoreAudio.h", None)
|
|
||||||
else:
|
|
||||||
raise ConfigurationError("unknown platform %s" % Platform)
|
|
||||||
|
|
||||||
if Platform == "darwin":
|
|
||||||
env.Append(LINKFLAGS="-framework CoreFoundation -framework CoreServices -framework CoreAudio -framework AudioToolBox -framework AudioUnit")
|
|
||||||
elif Platform == "cygwin":
|
|
||||||
env.Append(LIBS=["winmm"])
|
|
||||||
elif Platform == "irix":
|
|
||||||
neededLibs += [("audio", "dmedia/audio.h", "alOpenPort"), ("dmedia", "dmedia/dmedia.h", "dmGetUST")]
|
|
||||||
env.Append(CPPDEFINES=["PA_USE_SGI"])
|
|
||||||
|
|
||||||
def CheckCTypeSize(context, tp):
|
|
||||||
""" Check size of C type.
|
|
||||||
@param context: A configuration context.
|
|
||||||
@param tp: The type to check.
|
|
||||||
@return: Size of type, in bytes.
|
|
||||||
"""
|
|
||||||
context.Message("Checking the size of C type %s..." % tp)
|
|
||||||
ret = context.TryRun("""
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
int main() {
|
|
||||||
printf("%%d", sizeof(%s));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
""" % tp, ".c")
|
|
||||||
if not ret[0]:
|
|
||||||
context.Result(" Couldn't obtain size of type %s!" % tp)
|
|
||||||
return None
|
|
||||||
|
|
||||||
assert ret[1]
|
|
||||||
sz = int(ret[1])
|
|
||||||
context.Result("%d" % sz)
|
|
||||||
return sz
|
|
||||||
|
|
||||||
"""
|
|
||||||
if sys.byteorder == "little":
|
|
||||||
env.Append(CPPDEFINES=["PA_LITTLE_ENDIAN"])
|
|
||||||
elif sys.byteorder == "big":
|
|
||||||
env.Append(CPPDEFINES=["PA_BIG_ENDIAN"])
|
|
||||||
else:
|
|
||||||
raise ConfigurationError("unknown byte order: %s" % sys.byteorder)
|
|
||||||
"""
|
|
||||||
if env["enableDebugOutput"]:
|
|
||||||
env.Append(CPPDEFINES=["PA_ENABLE_DEBUG_OUTPUT"])
|
|
||||||
|
|
||||||
# Start configuration
|
|
||||||
|
|
||||||
# Use an absolute path for conf_dir, otherwise it gets created both relative to current directory and build directory
|
|
||||||
conf = env.Configure(log_file=os.path.join(sconsDir, "sconf.log"), custom_tests={"CheckCTypeSize": CheckCTypeSize},
|
|
||||||
conf_dir=os.path.join(sconsDir, ".sconf_temp"))
|
|
||||||
conf.env.Append(CPPDEFINES=["SIZEOF_SHORT=%d" % conf.CheckCTypeSize("short")])
|
|
||||||
conf.env.Append(CPPDEFINES=["SIZEOF_INT=%d" % conf.CheckCTypeSize("int")])
|
|
||||||
conf.env.Append(CPPDEFINES=["SIZEOF_LONG=%d" % conf.CheckCTypeSize("long")])
|
|
||||||
if checkSymbol(conf, "time.h", "rt", "clock_gettime"):
|
|
||||||
conf.env.Append(CPPDEFINES=["HAVE_CLOCK_GETTIME"])
|
|
||||||
if checkSymbol(conf, "time.h", symbol="nanosleep"):
|
|
||||||
conf.env.Append(CPPDEFINES=["HAVE_NANOSLEEP"])
|
|
||||||
if conf.CheckCHeader("sys/soundcard.h"):
|
|
||||||
conf.env.Append(CPPDEFINES=["HAVE_SYS_SOUNDCARD_H"])
|
|
||||||
if conf.CheckCHeader("linux/soundcard.h"):
|
|
||||||
conf.env.Append(CPPDEFINES=["HAVE_LINUX_SOUNDCARD_H"])
|
|
||||||
if conf.CheckCHeader("machine/soundcard.h"):
|
|
||||||
conf.env.Append(CPPDEFINES=["HAVE_MACHINE_SOUNDCARD_H"])
|
|
||||||
|
|
||||||
# Look for needed libraries and link with them
|
|
||||||
for lib, hdr, sym in neededLibs:
|
|
||||||
checkSymbol(conf, hdr, lib, sym, critical=True)
|
|
||||||
# Look for host API libraries, if a library isn't found disable corresponding host API implementation.
|
|
||||||
for name, val in optionalImpls.items():
|
|
||||||
lib, hdr, sym = val
|
|
||||||
if checkSymbol(conf, hdr, lib, sym, critical=False, pkgName=name.lower()):
|
|
||||||
conf.env.Append(CPPDEFINES=["PA_USE_%s=1" % name.upper()])
|
|
||||||
else:
|
|
||||||
del optionalImpls[name]
|
|
||||||
|
|
||||||
# Configuration finished
|
|
||||||
env = conf.Finish()
|
|
||||||
|
|
||||||
# PA infrastructure
|
|
||||||
CommonSources = [os.path.join("common", f) for f in "pa_allocation.c pa_converters.c pa_cpuload.c pa_dither.c pa_front.c \
|
|
||||||
pa_process.c pa_stream.c pa_trace.c pa_debugprint.c pa_ringbuffer.c".split()]
|
|
||||||
CommonSources.append(os.path.join("hostapi", "skeleton", "pa_hostapi_skeleton.c"))
|
|
||||||
|
|
||||||
# Host APIs implementations
|
|
||||||
ImplSources = []
|
|
||||||
if Platform in Posix:
|
|
||||||
ImplSources += [os.path.join("os", "unix", f) for f in "pa_unix_hostapis.c pa_unix_util.c".split()]
|
|
||||||
|
|
||||||
if "ALSA" in optionalImpls:
|
|
||||||
ImplSources.append(os.path.join("hostapi", "alsa", "pa_linux_alsa.c"))
|
|
||||||
if "JACK" in optionalImpls:
|
|
||||||
ImplSources.append(os.path.join("hostapi", "jack", "pa_jack.c"))
|
|
||||||
if "OSS" in optionalImpls:
|
|
||||||
ImplSources.append(os.path.join("hostapi", "oss", "pa_unix_oss.c"))
|
|
||||||
if "ASIHPI" in optionalImpls:
|
|
||||||
ImplSources.append(os.path.join("hostapi", "asihpi", "pa_linux_asihpi.c"))
|
|
||||||
if "COREAUDIO" in optionalImpls:
|
|
||||||
ImplSources.append([os.path.join("hostapi", "coreaudio", f) for f in """
|
|
||||||
pa_mac_core.c pa_mac_core_blocking.c pa_mac_core_utilities.c
|
|
||||||
""".split()])
|
|
||||||
|
|
||||||
|
|
||||||
sources = CommonSources + ImplSources
|
|
||||||
|
|
||||||
sharedLibEnv = env.Copy()
|
|
||||||
if Platform in Posix:
|
|
||||||
# Add soname to library, this is so a reference is made to the versioned library in programs linking against libportaudio.so
|
|
||||||
if Platform != 'darwin':
|
|
||||||
sharedLibEnv.AppendUnique(SHLINKFLAGS="-Wl,-soname=libportaudio.so.%d" % int(ApiVer.split(".")[0]))
|
|
||||||
sharedLib = sharedLibEnv.SharedLibrary(target="portaudio", source=sources)
|
|
||||||
|
|
||||||
staticLib = env.StaticLibrary(target="portaudio", source=sources)
|
|
||||||
|
|
||||||
if Platform in Posix:
|
|
||||||
prefix = env["prefix"]
|
|
||||||
includeDir = os.path.join(prefix, "include")
|
|
||||||
libDir = os.path.join(prefix, "lib")
|
|
||||||
|
|
||||||
testNames = ["patest_sine", "paqa_devs", "paqa_errs", "patest1", "patest_buffer", "patest_callbackstop", "patest_clip", \
|
|
||||||
"patest_dither", "patest_hang", "patest_in_overflow", "patest_latency", "patest_leftright", "patest_longsine", \
|
|
||||||
"patest_many", "patest_maxsines", "patest_multi_sine", "patest_out_underflow", "patest_pink", "patest_prime", \
|
|
||||||
"patest_read_record", "patest_record", "patest_ringmix", "patest_saw", "patest_sine8", "patest_sine", \
|
|
||||||
"patest_sine_time", "patest_start_stop", "patest_stop", "patest_sync", "patest_toomanysines", \
|
|
||||||
"patest_underflow", "patest_wire", "patest_write_sine", "pa_devs", "pa_fuzz", "pa_minlat", \
|
|
||||||
"patest_sine_channelmaps",]
|
|
||||||
|
|
||||||
# The test directory ("bin") should be in the top-level PA directory
|
|
||||||
tests = [env.Program(target=os.path.join("#", "bin", name), source=[os.path.join("#", "test", name + ".c"),
|
|
||||||
staticLib]) for name in testNames]
|
|
||||||
|
|
||||||
# Detect host APIs
|
|
||||||
hostApis = []
|
|
||||||
for cppdef in env["CPPDEFINES"]:
|
|
||||||
if cppdef.startswith("PA_USE_"):
|
|
||||||
hostApis.append(cppdef[7:-2])
|
|
||||||
|
|
||||||
Return("sources", "sharedLib", "staticLib", "tests", "env", "hostApis")
|
|
242
third_party/portAudio/src/common/pa_allocation.c
vendored
242
third_party/portAudio/src/common/pa_allocation.c
vendored
@ -1,242 +0,0 @@
|
|||||||
/*
|
|
||||||
* $Id$
|
|
||||||
* Portable Audio I/O Library allocation group implementation
|
|
||||||
* memory allocation group for tracking allocation groups
|
|
||||||
*
|
|
||||||
* Based on the Open Source API proposed by Ross Bencina
|
|
||||||
* Copyright (c) 1999-2002 Ross Bencina, Phil Burk
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files
|
|
||||||
* (the "Software"), to deal in the Software without restriction,
|
|
||||||
* including without limitation the rights to use, copy, modify, merge,
|
|
||||||
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
||||||
* and to permit persons to whom the Software is furnished to do so,
|
|
||||||
* subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be
|
|
||||||
* included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
||||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
|
|
||||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
|
||||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The text above constitutes the entire PortAudio license; however,
|
|
||||||
* the PortAudio community also makes the following non-binding requests:
|
|
||||||
*
|
|
||||||
* Any person wishing to distribute modifications to the Software is
|
|
||||||
* requested to send the modifications to the original developer so that
|
|
||||||
* they can be incorporated into the canonical version. It is also
|
|
||||||
* requested that these non-binding requests be included along with the
|
|
||||||
* license above.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @file
|
|
||||||
@ingroup common_src
|
|
||||||
|
|
||||||
@brief Allocation Group implementation.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include "pa_allocation.h"
|
|
||||||
#include "pa_util.h"
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
Maintain 3 singly linked lists...
|
|
||||||
linkBlocks: the buffers used to allocate the links
|
|
||||||
spareLinks: links available for use in the allocations list
|
|
||||||
allocations: the buffers currently allocated using PaUtil_ContextAllocateMemory()
|
|
||||||
|
|
||||||
Link block size is doubled every time new links are allocated.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#define PA_INITIAL_LINK_COUNT_ 16
|
|
||||||
|
|
||||||
struct PaUtilAllocationGroupLink
|
|
||||||
{
|
|
||||||
struct PaUtilAllocationGroupLink *next;
|
|
||||||
void *buffer;
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
Allocate a block of links. The first link will have it's buffer member
|
|
||||||
pointing to the block, and it's next member set to <nextBlock>. The remaining
|
|
||||||
links will have NULL buffer members, and each link will point to
|
|
||||||
the next link except the last, which will point to <nextSpare>
|
|
||||||
*/
|
|
||||||
static struct PaUtilAllocationGroupLink *AllocateLinks( long count,
|
|
||||||
struct PaUtilAllocationGroupLink *nextBlock,
|
|
||||||
struct PaUtilAllocationGroupLink *nextSpare )
|
|
||||||
{
|
|
||||||
struct PaUtilAllocationGroupLink *result;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
result = (struct PaUtilAllocationGroupLink *)PaUtil_AllocateMemory(
|
|
||||||
sizeof(struct PaUtilAllocationGroupLink) * count );
|
|
||||||
if( result )
|
|
||||||
{
|
|
||||||
/* the block link */
|
|
||||||
result[0].buffer = result;
|
|
||||||
result[0].next = nextBlock;
|
|
||||||
|
|
||||||
/* the spare links */
|
|
||||||
for( i=1; i<count; ++i )
|
|
||||||
{
|
|
||||||
result[i].buffer = 0;
|
|
||||||
result[i].next = &result[i+1];
|
|
||||||
}
|
|
||||||
result[count-1].next = nextSpare;
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
PaUtilAllocationGroup* PaUtil_CreateAllocationGroup( void )
|
|
||||||
{
|
|
||||||
PaUtilAllocationGroup* result = 0;
|
|
||||||
struct PaUtilAllocationGroupLink *links;
|
|
||||||
|
|
||||||
|
|
||||||
links = AllocateLinks( PA_INITIAL_LINK_COUNT_, 0, 0 );
|
|
||||||
if( links != 0 )
|
|
||||||
{
|
|
||||||
result = (PaUtilAllocationGroup*)PaUtil_AllocateMemory( sizeof(PaUtilAllocationGroup) );
|
|
||||||
if( result )
|
|
||||||
{
|
|
||||||
result->linkCount = PA_INITIAL_LINK_COUNT_;
|
|
||||||
result->linkBlocks = &links[0];
|
|
||||||
result->spareLinks = &links[1];
|
|
||||||
result->allocations = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
PaUtil_FreeMemory( links );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void PaUtil_DestroyAllocationGroup( PaUtilAllocationGroup* group )
|
|
||||||
{
|
|
||||||
struct PaUtilAllocationGroupLink *current = group->linkBlocks;
|
|
||||||
struct PaUtilAllocationGroupLink *next;
|
|
||||||
|
|
||||||
while( current )
|
|
||||||
{
|
|
||||||
next = current->next;
|
|
||||||
PaUtil_FreeMemory( current->buffer );
|
|
||||||
current = next;
|
|
||||||
}
|
|
||||||
|
|
||||||
PaUtil_FreeMemory( group );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void* PaUtil_GroupAllocateMemory( PaUtilAllocationGroup* group, long size )
|
|
||||||
{
|
|
||||||
struct PaUtilAllocationGroupLink *links, *link;
|
|
||||||
void *result = 0;
|
|
||||||
|
|
||||||
/* allocate more links if necessary */
|
|
||||||
if( !group->spareLinks )
|
|
||||||
{
|
|
||||||
/* double the link count on each block allocation */
|
|
||||||
links = AllocateLinks( group->linkCount, group->linkBlocks, group->spareLinks );
|
|
||||||
if( links )
|
|
||||||
{
|
|
||||||
group->linkCount += group->linkCount;
|
|
||||||
group->linkBlocks = &links[0];
|
|
||||||
group->spareLinks = &links[1];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if( group->spareLinks )
|
|
||||||
{
|
|
||||||
result = PaUtil_AllocateMemory( size );
|
|
||||||
if( result )
|
|
||||||
{
|
|
||||||
link = group->spareLinks;
|
|
||||||
group->spareLinks = link->next;
|
|
||||||
|
|
||||||
link->buffer = result;
|
|
||||||
link->next = group->allocations;
|
|
||||||
|
|
||||||
group->allocations = link;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void PaUtil_GroupFreeMemory( PaUtilAllocationGroup* group, void *buffer )
|
|
||||||
{
|
|
||||||
struct PaUtilAllocationGroupLink *current = group->allocations;
|
|
||||||
struct PaUtilAllocationGroupLink *previous = 0;
|
|
||||||
|
|
||||||
if( buffer == 0 )
|
|
||||||
return;
|
|
||||||
|
|
||||||
/* find the right link and remove it */
|
|
||||||
while( current )
|
|
||||||
{
|
|
||||||
if( current->buffer == buffer )
|
|
||||||
{
|
|
||||||
if( previous )
|
|
||||||
{
|
|
||||||
previous->next = current->next;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
group->allocations = current->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
current->buffer = 0;
|
|
||||||
current->next = group->spareLinks;
|
|
||||||
group->spareLinks = current;
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
previous = current;
|
|
||||||
current = current->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
PaUtil_FreeMemory( buffer ); /* free the memory whether we found it in the list or not */
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void PaUtil_FreeAllAllocations( PaUtilAllocationGroup* group )
|
|
||||||
{
|
|
||||||
struct PaUtilAllocationGroupLink *current = group->allocations;
|
|
||||||
struct PaUtilAllocationGroupLink *previous = 0;
|
|
||||||
|
|
||||||
/* free all buffers in the allocations list */
|
|
||||||
while( current )
|
|
||||||
{
|
|
||||||
PaUtil_FreeMemory( current->buffer );
|
|
||||||
current->buffer = 0;
|
|
||||||
|
|
||||||
previous = current;
|
|
||||||
current = current->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* link the former allocations list onto the front of the spareLinks list */
|
|
||||||
if( previous )
|
|
||||||
{
|
|
||||||
previous->next = group->spareLinks;
|
|
||||||
group->spareLinks = group->allocations;
|
|
||||||
group->allocations = 0;
|
|
||||||
}
|
|
||||||
}
|
|
104
third_party/portAudio/src/common/pa_allocation.h
vendored
104
third_party/portAudio/src/common/pa_allocation.h
vendored
@ -1,104 +0,0 @@
|
|||||||
#ifndef PA_ALLOCATION_H
|
|
||||||
#define PA_ALLOCATION_H
|
|
||||||
/*
|
|
||||||
* $Id$
|
|
||||||
* Portable Audio I/O Library allocation context header
|
|
||||||
* memory allocation context for tracking allocation groups
|
|
||||||
*
|
|
||||||
* Based on the Open Source API proposed by Ross Bencina
|
|
||||||
* Copyright (c) 1999-2008 Ross Bencina, Phil Burk
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files
|
|
||||||
* (the "Software"), to deal in the Software without restriction,
|
|
||||||
* including without limitation the rights to use, copy, modify, merge,
|
|
||||||
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
||||||
* and to permit persons to whom the Software is furnished to do so,
|
|
||||||
* subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be
|
|
||||||
* included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
||||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
|
|
||||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
|
||||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The text above constitutes the entire PortAudio license; however,
|
|
||||||
* the PortAudio community also makes the following non-binding requests:
|
|
||||||
*
|
|
||||||
* Any person wishing to distribute modifications to the Software is
|
|
||||||
* requested to send the modifications to the original developer so that
|
|
||||||
* they can be incorporated into the canonical version. It is also
|
|
||||||
* requested that these non-binding requests be included along with the
|
|
||||||
* license above.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @file
|
|
||||||
@ingroup common_src
|
|
||||||
|
|
||||||
@brief Allocation Group prototypes. An Allocation Group makes it easy to
|
|
||||||
allocate multiple blocks of memory and free them all at once.
|
|
||||||
|
|
||||||
An allocation group is useful for keeping track of multiple blocks
|
|
||||||
of memory which are allocated at the same time (such as during initialization)
|
|
||||||
and need to be deallocated at the same time. The allocation group maintains
|
|
||||||
a list of allocated blocks, and can free all allocations at once. This
|
|
||||||
can be useful for cleaning up after a partially initialized object fails.
|
|
||||||
|
|
||||||
The allocation group implementation is built on top of the lower
|
|
||||||
level allocation functions defined in pa_util.h
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#endif /* __cplusplus */
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
long linkCount;
|
|
||||||
struct PaUtilAllocationGroupLink *linkBlocks;
|
|
||||||
struct PaUtilAllocationGroupLink *spareLinks;
|
|
||||||
struct PaUtilAllocationGroupLink *allocations;
|
|
||||||
}PaUtilAllocationGroup;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** Create an allocation group.
|
|
||||||
*/
|
|
||||||
PaUtilAllocationGroup* PaUtil_CreateAllocationGroup( void );
|
|
||||||
|
|
||||||
/** Destroy an allocation group, but not the memory allocated through the group.
|
|
||||||
*/
|
|
||||||
void PaUtil_DestroyAllocationGroup( PaUtilAllocationGroup* group );
|
|
||||||
|
|
||||||
/** Allocate a block of memory though an allocation group.
|
|
||||||
*/
|
|
||||||
void* PaUtil_GroupAllocateMemory( PaUtilAllocationGroup* group, long size );
|
|
||||||
|
|
||||||
/** Free a block of memory that was previously allocated though an allocation
|
|
||||||
group. Calling this function is a relatively time consuming operation.
|
|
||||||
Under normal circumstances clients should call PaUtil_FreeAllAllocations to
|
|
||||||
free all allocated blocks simultaneously.
|
|
||||||
@see PaUtil_FreeAllAllocations
|
|
||||||
*/
|
|
||||||
void PaUtil_GroupFreeMemory( PaUtilAllocationGroup* group, void *buffer );
|
|
||||||
|
|
||||||
/** Free all blocks of memory which have been allocated through the allocation
|
|
||||||
group. This function doesn't destroy the group itself.
|
|
||||||
*/
|
|
||||||
void PaUtil_FreeAllAllocations( PaUtilAllocationGroup* group );
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif /* __cplusplus */
|
|
||||||
#endif /* PA_ALLOCATION_H */
|
|
1983
third_party/portAudio/src/common/pa_converters.c
vendored
1983
third_party/portAudio/src/common/pa_converters.c
vendored
File diff suppressed because it is too large
Load Diff
263
third_party/portAudio/src/common/pa_converters.h
vendored
263
third_party/portAudio/src/common/pa_converters.h
vendored
@ -1,263 +0,0 @@
|
|||||||
#ifndef PA_CONVERTERS_H
|
|
||||||
#define PA_CONVERTERS_H
|
|
||||||
/*
|
|
||||||
* $Id$
|
|
||||||
* Portable Audio I/O Library sample conversion mechanism
|
|
||||||
*
|
|
||||||
* Based on the Open Source API proposed by Ross Bencina
|
|
||||||
* Copyright (c) 1999-2002 Phil Burk, Ross Bencina
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files
|
|
||||||
* (the "Software"), to deal in the Software without restriction,
|
|
||||||
* including without limitation the rights to use, copy, modify, merge,
|
|
||||||
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
||||||
* and to permit persons to whom the Software is furnished to do so,
|
|
||||||
* subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be
|
|
||||||
* included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
||||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
|
|
||||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
|
||||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The text above constitutes the entire PortAudio license; however,
|
|
||||||
* the PortAudio community also makes the following non-binding requests:
|
|
||||||
*
|
|
||||||
* Any person wishing to distribute modifications to the Software is
|
|
||||||
* requested to send the modifications to the original developer so that
|
|
||||||
* they can be incorporated into the canonical version. It is also
|
|
||||||
* requested that these non-binding requests be included along with the
|
|
||||||
* license above.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @file
|
|
||||||
@ingroup common_src
|
|
||||||
|
|
||||||
@brief Conversion functions used to convert buffers of samples from one
|
|
||||||
format to another.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include "portaudio.h" /* for PaSampleFormat */
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#endif /* __cplusplus */
|
|
||||||
|
|
||||||
|
|
||||||
struct PaUtilTriangularDitherGenerator;
|
|
||||||
|
|
||||||
|
|
||||||
/** Choose an available sample format which is most appropriate for
|
|
||||||
representing the requested format. If the requested format is not available
|
|
||||||
higher quality formats are considered before lower quality formats.
|
|
||||||
@param availableFormats A variable containing the logical OR of all available
|
|
||||||
formats.
|
|
||||||
@param format The desired format.
|
|
||||||
@return The most appropriate available format for representing the requested
|
|
||||||
format.
|
|
||||||
*/
|
|
||||||
PaSampleFormat PaUtil_SelectClosestAvailableFormat(
|
|
||||||
PaSampleFormat availableFormats, PaSampleFormat format );
|
|
||||||
|
|
||||||
|
|
||||||
/* high level conversions functions for use by implementations */
|
|
||||||
|
|
||||||
|
|
||||||
/** The generic sample converter prototype. Sample converters convert count
|
|
||||||
samples from sourceBuffer to destinationBuffer. The actual type of the data
|
|
||||||
pointed to by these parameters varys for different converter functions.
|
|
||||||
@param destinationBuffer A pointer to the first sample of the destination.
|
|
||||||
@param destinationStride An offset between successive destination samples
|
|
||||||
expressed in samples (not bytes.) It may be negative.
|
|
||||||
@param sourceBuffer A pointer to the first sample of the source.
|
|
||||||
@param sourceStride An offset between successive source samples
|
|
||||||
expressed in samples (not bytes.) It may be negative.
|
|
||||||
@param count The number of samples to convert.
|
|
||||||
@param ditherState State information used to calculate dither. Converters
|
|
||||||
that do not perform dithering will ignore this parameter, in which case
|
|
||||||
NULL or invalid dither state may be passed.
|
|
||||||
*/
|
|
||||||
typedef void PaUtilConverter(
|
|
||||||
void *destinationBuffer, signed int destinationStride,
|
|
||||||
void *sourceBuffer, signed int sourceStride,
|
|
||||||
unsigned int count, struct PaUtilTriangularDitherGenerator *ditherGenerator );
|
|
||||||
|
|
||||||
|
|
||||||
/** Find a sample converter function for the given source and destinations
|
|
||||||
formats and flags (clip and dither.)
|
|
||||||
@return
|
|
||||||
A pointer to a PaUtilConverter which will perform the requested
|
|
||||||
conversion, or NULL if the given format conversion is not supported.
|
|
||||||
For conversions where clipping or dithering is not necessary, the
|
|
||||||
clip and dither flags are ignored and a non-clipping or dithering
|
|
||||||
version is returned.
|
|
||||||
If the source and destination formats are the same, a function which
|
|
||||||
copies data of the appropriate size will be returned.
|
|
||||||
*/
|
|
||||||
PaUtilConverter* PaUtil_SelectConverter( PaSampleFormat sourceFormat,
|
|
||||||
PaSampleFormat destinationFormat, PaStreamFlags flags );
|
|
||||||
|
|
||||||
|
|
||||||
/** The generic buffer zeroer prototype. Buffer zeroers copy count zeros to
|
|
||||||
destinationBuffer. The actual type of the data pointed to varys for
|
|
||||||
different zeroer functions.
|
|
||||||
@param destinationBuffer A pointer to the first sample of the destination.
|
|
||||||
@param destinationStride An offset between successive destination samples
|
|
||||||
expressed in samples (not bytes.) It may be negative.
|
|
||||||
@param count The number of samples to zero.
|
|
||||||
*/
|
|
||||||
typedef void PaUtilZeroer(
|
|
||||||
void *destinationBuffer, signed int destinationStride, unsigned int count );
|
|
||||||
|
|
||||||
|
|
||||||
/** Find a buffer zeroer function for the given destination format.
|
|
||||||
@return
|
|
||||||
A pointer to a PaUtilZeroer which will perform the requested
|
|
||||||
zeroing.
|
|
||||||
*/
|
|
||||||
PaUtilZeroer* PaUtil_SelectZeroer( PaSampleFormat destinationFormat );
|
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------*/
|
|
||||||
/* low level functions and data structures which may be used for
|
|
||||||
substituting conversion functions */
|
|
||||||
|
|
||||||
|
|
||||||
/** The type used to store all sample conversion functions.
|
|
||||||
@see paConverters;
|
|
||||||
*/
|
|
||||||
typedef struct{
|
|
||||||
PaUtilConverter *Float32_To_Int32;
|
|
||||||
PaUtilConverter *Float32_To_Int32_Dither;
|
|
||||||
PaUtilConverter *Float32_To_Int32_Clip;
|
|
||||||
PaUtilConverter *Float32_To_Int32_DitherClip;
|
|
||||||
|
|
||||||
PaUtilConverter *Float32_To_Int24;
|
|
||||||
PaUtilConverter *Float32_To_Int24_Dither;
|
|
||||||
PaUtilConverter *Float32_To_Int24_Clip;
|
|
||||||
PaUtilConverter *Float32_To_Int24_DitherClip;
|
|
||||||
|
|
||||||
PaUtilConverter *Float32_To_Int16;
|
|
||||||
PaUtilConverter *Float32_To_Int16_Dither;
|
|
||||||
PaUtilConverter *Float32_To_Int16_Clip;
|
|
||||||
PaUtilConverter *Float32_To_Int16_DitherClip;
|
|
||||||
|
|
||||||
PaUtilConverter *Float32_To_Int8;
|
|
||||||
PaUtilConverter *Float32_To_Int8_Dither;
|
|
||||||
PaUtilConverter *Float32_To_Int8_Clip;
|
|
||||||
PaUtilConverter *Float32_To_Int8_DitherClip;
|
|
||||||
|
|
||||||
PaUtilConverter *Float32_To_UInt8;
|
|
||||||
PaUtilConverter *Float32_To_UInt8_Dither;
|
|
||||||
PaUtilConverter *Float32_To_UInt8_Clip;
|
|
||||||
PaUtilConverter *Float32_To_UInt8_DitherClip;
|
|
||||||
|
|
||||||
PaUtilConverter *Int32_To_Float32;
|
|
||||||
PaUtilConverter *Int32_To_Int24;
|
|
||||||
PaUtilConverter *Int32_To_Int24_Dither;
|
|
||||||
PaUtilConverter *Int32_To_Int16;
|
|
||||||
PaUtilConverter *Int32_To_Int16_Dither;
|
|
||||||
PaUtilConverter *Int32_To_Int8;
|
|
||||||
PaUtilConverter *Int32_To_Int8_Dither;
|
|
||||||
PaUtilConverter *Int32_To_UInt8;
|
|
||||||
PaUtilConverter *Int32_To_UInt8_Dither;
|
|
||||||
|
|
||||||
PaUtilConverter *Int24_To_Float32;
|
|
||||||
PaUtilConverter *Int24_To_Int32;
|
|
||||||
PaUtilConverter *Int24_To_Int16;
|
|
||||||
PaUtilConverter *Int24_To_Int16_Dither;
|
|
||||||
PaUtilConverter *Int24_To_Int8;
|
|
||||||
PaUtilConverter *Int24_To_Int8_Dither;
|
|
||||||
PaUtilConverter *Int24_To_UInt8;
|
|
||||||
PaUtilConverter *Int24_To_UInt8_Dither;
|
|
||||||
|
|
||||||
PaUtilConverter *Int16_To_Float32;
|
|
||||||
PaUtilConverter *Int16_To_Int32;
|
|
||||||
PaUtilConverter *Int16_To_Int24;
|
|
||||||
PaUtilConverter *Int16_To_Int8;
|
|
||||||
PaUtilConverter *Int16_To_Int8_Dither;
|
|
||||||
PaUtilConverter *Int16_To_UInt8;
|
|
||||||
PaUtilConverter *Int16_To_UInt8_Dither;
|
|
||||||
|
|
||||||
PaUtilConverter *Int8_To_Float32;
|
|
||||||
PaUtilConverter *Int8_To_Int32;
|
|
||||||
PaUtilConverter *Int8_To_Int24;
|
|
||||||
PaUtilConverter *Int8_To_Int16;
|
|
||||||
PaUtilConverter *Int8_To_UInt8;
|
|
||||||
|
|
||||||
PaUtilConverter *UInt8_To_Float32;
|
|
||||||
PaUtilConverter *UInt8_To_Int32;
|
|
||||||
PaUtilConverter *UInt8_To_Int24;
|
|
||||||
PaUtilConverter *UInt8_To_Int16;
|
|
||||||
PaUtilConverter *UInt8_To_Int8;
|
|
||||||
|
|
||||||
PaUtilConverter *Copy_8_To_8; /* copy without any conversion */
|
|
||||||
PaUtilConverter *Copy_16_To_16; /* copy without any conversion */
|
|
||||||
PaUtilConverter *Copy_24_To_24; /* copy without any conversion */
|
|
||||||
PaUtilConverter *Copy_32_To_32; /* copy without any conversion */
|
|
||||||
} PaUtilConverterTable;
|
|
||||||
|
|
||||||
|
|
||||||
/** A table of pointers to all required converter functions.
|
|
||||||
PaUtil_SelectConverter() uses this table to lookup the appropriate
|
|
||||||
conversion functions. The fields of this structure are initialized
|
|
||||||
with default conversion functions. Fields may be NULL, indicating that
|
|
||||||
no conversion function is available. User code may substitute optimised
|
|
||||||
conversion functions by assigning different function pointers to
|
|
||||||
these fields.
|
|
||||||
|
|
||||||
@note
|
|
||||||
If the PA_NO_STANDARD_CONVERTERS preprocessor variable is defined,
|
|
||||||
PortAudio's standard converters will not be compiled, and all fields
|
|
||||||
of this structure will be initialized to NULL. In such cases, users
|
|
||||||
should supply their own conversion functions if the require PortAudio
|
|
||||||
to open a stream that requires sample conversion.
|
|
||||||
|
|
||||||
@see PaUtilConverterTable, PaUtilConverter, PaUtil_SelectConverter
|
|
||||||
*/
|
|
||||||
extern PaUtilConverterTable paConverters;
|
|
||||||
|
|
||||||
|
|
||||||
/** The type used to store all buffer zeroing functions.
|
|
||||||
@see paZeroers;
|
|
||||||
*/
|
|
||||||
typedef struct{
|
|
||||||
PaUtilZeroer *ZeroU8; /* unsigned 8 bit, zero == 128 */
|
|
||||||
PaUtilZeroer *Zero8;
|
|
||||||
PaUtilZeroer *Zero16;
|
|
||||||
PaUtilZeroer *Zero24;
|
|
||||||
PaUtilZeroer *Zero32;
|
|
||||||
} PaUtilZeroerTable;
|
|
||||||
|
|
||||||
|
|
||||||
/** A table of pointers to all required zeroer functions.
|
|
||||||
PaUtil_SelectZeroer() uses this table to lookup the appropriate
|
|
||||||
conversion functions. The fields of this structure are initialized
|
|
||||||
with default conversion functions. User code may substitute optimised
|
|
||||||
conversion functions by assigning different function pointers to
|
|
||||||
these fields.
|
|
||||||
|
|
||||||
@note
|
|
||||||
If the PA_NO_STANDARD_ZEROERS preprocessor variable is defined,
|
|
||||||
PortAudio's standard zeroers will not be compiled, and all fields
|
|
||||||
of this structure will be initialized to NULL. In such cases, users
|
|
||||||
should supply their own zeroing functions for the sample sizes which
|
|
||||||
they intend to use.
|
|
||||||
|
|
||||||
@see PaUtilZeroerTable, PaUtilZeroer, PaUtil_SelectZeroer
|
|
||||||
*/
|
|
||||||
extern PaUtilZeroerTable paZeroers;
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif /* __cplusplus */
|
|
||||||
#endif /* PA_CONVERTERS_H */
|
|
105
third_party/portAudio/src/common/pa_cpuload.c
vendored
105
third_party/portAudio/src/common/pa_cpuload.c
vendored
@ -1,105 +0,0 @@
|
|||||||
/*
|
|
||||||
* $Id$
|
|
||||||
* Portable Audio I/O Library CPU Load measurement functions
|
|
||||||
* Portable CPU load measurement facility.
|
|
||||||
*
|
|
||||||
* Based on the Open Source API proposed by Ross Bencina
|
|
||||||
* Copyright (c) 2002 Ross Bencina
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files
|
|
||||||
* (the "Software"), to deal in the Software without restriction,
|
|
||||||
* including without limitation the rights to use, copy, modify, merge,
|
|
||||||
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
||||||
* and to permit persons to whom the Software is furnished to do so,
|
|
||||||
* subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be
|
|
||||||
* included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
||||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
|
|
||||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
|
||||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The text above constitutes the entire PortAudio license; however,
|
|
||||||
* the PortAudio community also makes the following non-binding requests:
|
|
||||||
*
|
|
||||||
* Any person wishing to distribute modifications to the Software is
|
|
||||||
* requested to send the modifications to the original developer so that
|
|
||||||
* they can be incorporated into the canonical version. It is also
|
|
||||||
* requested that these non-binding requests be included along with the
|
|
||||||
* license above.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @file
|
|
||||||
@ingroup common_src
|
|
||||||
|
|
||||||
@brief Functions to assist in measuring the CPU utilization of a callback
|
|
||||||
stream. Used to implement the Pa_GetStreamCpuLoad() function.
|
|
||||||
|
|
||||||
@todo Dynamically calculate the coefficients used to smooth the CPU Load
|
|
||||||
Measurements over time to provide a uniform characterisation of CPU Load
|
|
||||||
independent of rate at which PaUtil_BeginCpuLoadMeasurement /
|
|
||||||
PaUtil_EndCpuLoadMeasurement are called. see http://www.portaudio.com/trac/ticket/113
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include "pa_cpuload.h"
|
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
#include "pa_util.h" /* for PaUtil_GetTime() */
|
|
||||||
|
|
||||||
|
|
||||||
void PaUtil_InitializeCpuLoadMeasurer( PaUtilCpuLoadMeasurer* measurer, double sampleRate )
|
|
||||||
{
|
|
||||||
assert( sampleRate > 0 );
|
|
||||||
|
|
||||||
measurer->samplingPeriod = 1. / sampleRate;
|
|
||||||
measurer->averageLoad = 0.;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PaUtil_ResetCpuLoadMeasurer( PaUtilCpuLoadMeasurer* measurer )
|
|
||||||
{
|
|
||||||
measurer->averageLoad = 0.;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PaUtil_BeginCpuLoadMeasurement( PaUtilCpuLoadMeasurer* measurer )
|
|
||||||
{
|
|
||||||
measurer->measurementStartTime = PaUtil_GetTime();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void PaUtil_EndCpuLoadMeasurement( PaUtilCpuLoadMeasurer* measurer, unsigned long framesProcessed )
|
|
||||||
{
|
|
||||||
double measurementEndTime, secondsFor100Percent, measuredLoad;
|
|
||||||
|
|
||||||
if( framesProcessed > 0 ){
|
|
||||||
measurementEndTime = PaUtil_GetTime();
|
|
||||||
|
|
||||||
assert( framesProcessed > 0 );
|
|
||||||
secondsFor100Percent = framesProcessed * measurer->samplingPeriod;
|
|
||||||
|
|
||||||
measuredLoad = (measurementEndTime - measurer->measurementStartTime) / secondsFor100Percent;
|
|
||||||
|
|
||||||
/* Low pass filter the calculated CPU load to reduce jitter using a simple IIR low pass filter. */
|
|
||||||
/** FIXME @todo these coefficients shouldn't be hardwired see: http://www.portaudio.com/trac/ticket/113 */
|
|
||||||
#define LOWPASS_COEFFICIENT_0 (0.9)
|
|
||||||
#define LOWPASS_COEFFICIENT_1 (0.99999 - LOWPASS_COEFFICIENT_0)
|
|
||||||
|
|
||||||
measurer->averageLoad = (LOWPASS_COEFFICIENT_0 * measurer->averageLoad) +
|
|
||||||
(LOWPASS_COEFFICIENT_1 * measuredLoad);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
double PaUtil_GetCpuLoad( PaUtilCpuLoadMeasurer* measurer )
|
|
||||||
{
|
|
||||||
return measurer->averageLoad;
|
|
||||||
}
|
|
72
third_party/portAudio/src/common/pa_cpuload.h
vendored
72
third_party/portAudio/src/common/pa_cpuload.h
vendored
@ -1,72 +0,0 @@
|
|||||||
#ifndef PA_CPULOAD_H
|
|
||||||
#define PA_CPULOAD_H
|
|
||||||
/*
|
|
||||||
* $Id$
|
|
||||||
* Portable Audio I/O Library CPU Load measurement functions
|
|
||||||
* Portable CPU load measurement facility.
|
|
||||||
*
|
|
||||||
* Based on the Open Source API proposed by Ross Bencina
|
|
||||||
* Copyright (c) 2002 Ross Bencina
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files
|
|
||||||
* (the "Software"), to deal in the Software without restriction,
|
|
||||||
* including without limitation the rights to use, copy, modify, merge,
|
|
||||||
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
||||||
* and to permit persons to whom the Software is furnished to do so,
|
|
||||||
* subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be
|
|
||||||
* included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
||||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
|
|
||||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
|
||||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The text above constitutes the entire PortAudio license; however,
|
|
||||||
* the PortAudio community also makes the following non-binding requests:
|
|
||||||
*
|
|
||||||
* Any person wishing to distribute modifications to the Software is
|
|
||||||
* requested to send the modifications to the original developer so that
|
|
||||||
* they can be incorporated into the canonical version. It is also
|
|
||||||
* requested that these non-binding requests be included along with the
|
|
||||||
* license above.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @file
|
|
||||||
@ingroup common_src
|
|
||||||
|
|
||||||
@brief Functions to assist in measuring the CPU utilization of a callback
|
|
||||||
stream. Used to implement the Pa_GetStreamCpuLoad() function.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#endif /* __cplusplus */
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
double samplingPeriod;
|
|
||||||
double measurementStartTime;
|
|
||||||
double averageLoad;
|
|
||||||
} PaUtilCpuLoadMeasurer; /**< @todo need better name than measurer */
|
|
||||||
|
|
||||||
void PaUtil_InitializeCpuLoadMeasurer( PaUtilCpuLoadMeasurer* measurer, double sampleRate );
|
|
||||||
void PaUtil_BeginCpuLoadMeasurement( PaUtilCpuLoadMeasurer* measurer );
|
|
||||||
void PaUtil_EndCpuLoadMeasurement( PaUtilCpuLoadMeasurer* measurer, unsigned long framesProcessed );
|
|
||||||
void PaUtil_ResetCpuLoadMeasurer( PaUtilCpuLoadMeasurer* measurer );
|
|
||||||
double PaUtil_GetCpuLoad( PaUtilCpuLoadMeasurer* measurer );
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif /* __cplusplus */
|
|
||||||
#endif /* PA_CPULOAD_H */
|
|
123
third_party/portAudio/src/common/pa_debugprint.c
vendored
123
third_party/portAudio/src/common/pa_debugprint.c
vendored
@ -1,123 +0,0 @@
|
|||||||
/*
|
|
||||||
* $Id: pa_log.c $
|
|
||||||
* Portable Audio I/O Library Multi-Host API front end
|
|
||||||
* Validate function parameters and manage multiple host APIs.
|
|
||||||
*
|
|
||||||
* Based on the Open Source API proposed by Ross Bencina
|
|
||||||
* Copyright (c) 1999-2006 Ross Bencina, Phil Burk
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files
|
|
||||||
* (the "Software"), to deal in the Software without restriction,
|
|
||||||
* including without limitation the rights to use, copy, modify, merge,
|
|
||||||
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
||||||
* and to permit persons to whom the Software is furnished to do so,
|
|
||||||
* subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be
|
|
||||||
* included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
||||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
|
|
||||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
|
||||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The text above constitutes the entire PortAudio license; however,
|
|
||||||
* the PortAudio community also makes the following non-binding requests:
|
|
||||||
*
|
|
||||||
* Any person wishing to distribute modifications to the Software is
|
|
||||||
* requested to send the modifications to the original developer so that
|
|
||||||
* they can be incorporated into the canonical version. It is also
|
|
||||||
* requested that these non-binding requests be included along with the
|
|
||||||
* license above.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @file
|
|
||||||
@ingroup common_src
|
|
||||||
|
|
||||||
@brief Implements log function.
|
|
||||||
|
|
||||||
PaUtil_SetLogPrintFunction can be user called to replace the provided
|
|
||||||
DefaultLogPrint function, which writes to stderr.
|
|
||||||
One can NOT pass var_args across compiler/dll boundaries as it is not
|
|
||||||
"byte code/abi portable". So the technique used here is to allocate a local
|
|
||||||
a static array, write in it, then callback the user with a pointer to its
|
|
||||||
start.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdarg.h>
|
|
||||||
|
|
||||||
#include "pa_debugprint.h"
|
|
||||||
|
|
||||||
// for OutputDebugStringA
|
|
||||||
#if defined(_MSC_VER) && defined(PA_ENABLE_MSVC_DEBUG_OUTPUT)
|
|
||||||
#define WIN32_LEAN_AND_MEAN // exclude rare headers
|
|
||||||
#include "windows.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// User callback
|
|
||||||
static PaUtilLogCallback userCB = NULL;
|
|
||||||
|
|
||||||
// Sets user callback
|
|
||||||
void PaUtil_SetDebugPrintFunction(PaUtilLogCallback cb)
|
|
||||||
{
|
|
||||||
userCB = cb;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
If your platform doesn't have vsnprintf, you are stuck with a
|
|
||||||
VERY dangerous alternative, vsprintf (with no n)
|
|
||||||
*/
|
|
||||||
#if _MSC_VER
|
|
||||||
/* Some Windows Mobile SDKs don't define vsnprintf but all define _vsnprintf (hopefully).
|
|
||||||
According to MSDN "vsnprintf is identical to _vsnprintf". So we use _vsnprintf with MSC.
|
|
||||||
*/
|
|
||||||
#define VSNPRINTF _vsnprintf
|
|
||||||
#else
|
|
||||||
#define VSNPRINTF vsnprintf
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define PA_LOG_BUF_SIZE 2048
|
|
||||||
|
|
||||||
void PaUtil_DebugPrint( const char *format, ... )
|
|
||||||
{
|
|
||||||
// Optional logging into Output console of Visual Studio
|
|
||||||
#if defined(_MSC_VER) && defined(PA_ENABLE_MSVC_DEBUG_OUTPUT)
|
|
||||||
{
|
|
||||||
char buf[PA_LOG_BUF_SIZE];
|
|
||||||
va_list ap;
|
|
||||||
va_start(ap, format);
|
|
||||||
VSNPRINTF(buf, sizeof(buf), format, ap);
|
|
||||||
buf[sizeof(buf)-1] = 0;
|
|
||||||
OutputDebugStringA(buf);
|
|
||||||
va_end(ap);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Output to User-Callback
|
|
||||||
if (userCB != NULL)
|
|
||||||
{
|
|
||||||
char strdump[PA_LOG_BUF_SIZE];
|
|
||||||
va_list ap;
|
|
||||||
va_start(ap, format);
|
|
||||||
VSNPRINTF(strdump, sizeof(strdump), format, ap);
|
|
||||||
strdump[sizeof(strdump)-1] = 0;
|
|
||||||
userCB(strdump);
|
|
||||||
va_end(ap);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
// Standard output to stderr
|
|
||||||
{
|
|
||||||
va_list ap;
|
|
||||||
va_start(ap, format);
|
|
||||||
vfprintf(stderr, format, ap);
|
|
||||||
va_end(ap);
|
|
||||||
fflush(stderr);
|
|
||||||
}
|
|
||||||
}
|
|
149
third_party/portAudio/src/common/pa_debugprint.h
vendored
149
third_party/portAudio/src/common/pa_debugprint.h
vendored
@ -1,149 +0,0 @@
|
|||||||
#ifndef PA_LOG_H
|
|
||||||
#define PA_LOG_H
|
|
||||||
/*
|
|
||||||
* Log file redirector function
|
|
||||||
* Copyright (c) 1999-2006 Ross Bencina, Phil Burk
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files
|
|
||||||
* (the "Software"), to deal in the Software without restriction,
|
|
||||||
* including without limitation the rights to use, copy, modify, merge,
|
|
||||||
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
||||||
* and to permit persons to whom the Software is furnished to do so,
|
|
||||||
* subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be
|
|
||||||
* included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
||||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
|
|
||||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
|
||||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The text above constitutes the entire PortAudio license; however,
|
|
||||||
* the PortAudio community also makes the following non-binding requests:
|
|
||||||
*
|
|
||||||
* Any person wishing to distribute modifications to the Software is
|
|
||||||
* requested to send the modifications to the original developer so that
|
|
||||||
* they can be incorporated into the canonical version. It is also
|
|
||||||
* requested that these non-binding requests be included along with the
|
|
||||||
* license above.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @file
|
|
||||||
@ingroup common_src
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#endif /* __cplusplus */
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void PaUtil_DebugPrint( const char *format, ... );
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
The basic format for log messages is described below. If you need to
|
|
||||||
add any log messages, please follow this format.
|
|
||||||
|
|
||||||
Function entry (void function):
|
|
||||||
|
|
||||||
"FunctionName called.\n"
|
|
||||||
|
|
||||||
Function entry (non void function):
|
|
||||||
|
|
||||||
"FunctionName called:\n"
|
|
||||||
"\tParam1Type param1: param1Value\n"
|
|
||||||
"\tParam2Type param2: param2Value\n" (etc...)
|
|
||||||
|
|
||||||
|
|
||||||
Function exit (no return value):
|
|
||||||
|
|
||||||
"FunctionName returned.\n"
|
|
||||||
|
|
||||||
Function exit (simple return value):
|
|
||||||
|
|
||||||
"FunctionName returned:\n"
|
|
||||||
"\tReturnType: returnValue\n"
|
|
||||||
|
|
||||||
If the return type is an error code, the error text is displayed in ()
|
|
||||||
|
|
||||||
If the return type is not an error code, but has taken a special value
|
|
||||||
because an error occurred, then the reason for the error is shown in []
|
|
||||||
|
|
||||||
If the return type is a struct ptr, the struct is dumped.
|
|
||||||
|
|
||||||
See the code below for examples
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** PA_DEBUG() provides a simple debug message printing facility. The macro
|
|
||||||
passes it's argument to a printf-like function called PaUtil_DebugPrint()
|
|
||||||
which prints to stderr and always flushes the stream after printing.
|
|
||||||
Because preprocessor macros cannot directly accept variable length argument
|
|
||||||
lists, calls to the macro must include an additional set of parenthesis, eg:
|
|
||||||
PA_DEBUG(("errorno: %d", 1001 ));
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef PA_ENABLE_DEBUG_OUTPUT
|
|
||||||
#define PA_DEBUG(x) PaUtil_DebugPrint x ;
|
|
||||||
#else
|
|
||||||
#define PA_DEBUG(x)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef PA_LOG_API_CALLS
|
|
||||||
#define PA_LOGAPI(x) PaUtil_DebugPrint x
|
|
||||||
|
|
||||||
#define PA_LOGAPI_ENTER(functionName) PaUtil_DebugPrint( functionName " called.\n" )
|
|
||||||
|
|
||||||
#define PA_LOGAPI_ENTER_PARAMS(functionName) PaUtil_DebugPrint( functionName " called:\n" )
|
|
||||||
|
|
||||||
#define PA_LOGAPI_EXIT(functionName) PaUtil_DebugPrint( functionName " returned.\n" )
|
|
||||||
|
|
||||||
#define PA_LOGAPI_EXIT_PAERROR( functionName, result ) \
|
|
||||||
PaUtil_DebugPrint( functionName " returned:\n" ); \
|
|
||||||
PaUtil_DebugPrint("\tPaError: %d ( %s )\n", result, Pa_GetErrorText( result ) )
|
|
||||||
|
|
||||||
#define PA_LOGAPI_EXIT_T( functionName, resultFormatString, result ) \
|
|
||||||
PaUtil_DebugPrint( functionName " returned:\n" ); \
|
|
||||||
PaUtil_DebugPrint("\t" resultFormatString "\n", result )
|
|
||||||
|
|
||||||
#define PA_LOGAPI_EXIT_PAERROR_OR_T_RESULT( functionName, positiveResultFormatString, result ) \
|
|
||||||
PaUtil_DebugPrint( functionName " returned:\n" ); \
|
|
||||||
if( result > 0 ) \
|
|
||||||
PaUtil_DebugPrint("\t" positiveResultFormatString "\n", result ); \
|
|
||||||
else \
|
|
||||||
PaUtil_DebugPrint("\tPaError: %d ( %s )\n", result, Pa_GetErrorText( result ) )
|
|
||||||
#else
|
|
||||||
#define PA_LOGAPI(x)
|
|
||||||
#define PA_LOGAPI_ENTER(functionName)
|
|
||||||
#define PA_LOGAPI_ENTER_PARAMS(functionName)
|
|
||||||
#define PA_LOGAPI_EXIT(functionName)
|
|
||||||
#define PA_LOGAPI_EXIT_PAERROR( functionName, result )
|
|
||||||
#define PA_LOGAPI_EXIT_T( functionName, resultFormatString, result )
|
|
||||||
#define PA_LOGAPI_EXIT_PAERROR_OR_T_RESULT( functionName, positiveResultFormatString, result )
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
typedef void (*PaUtilLogCallback ) (const char *log);
|
|
||||||
|
|
||||||
/**
|
|
||||||
Install user provided log function
|
|
||||||
*/
|
|
||||||
void PaUtil_SetDebugPrintFunction(PaUtilLogCallback cb);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif /* __cplusplus */
|
|
||||||
#endif /* PA_LOG_H */
|
|
218
third_party/portAudio/src/common/pa_dither.c
vendored
218
third_party/portAudio/src/common/pa_dither.c
vendored
@ -1,218 +0,0 @@
|
|||||||
/*
|
|
||||||
* $Id$
|
|
||||||
* Portable Audio I/O Library triangular dither generator
|
|
||||||
*
|
|
||||||
* Based on the Open Source API proposed by Ross Bencina
|
|
||||||
* Copyright (c) 1999-2002 Phil Burk, Ross Bencina
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files
|
|
||||||
* (the "Software"), to deal in the Software without restriction,
|
|
||||||
* including without limitation the rights to use, copy, modify, merge,
|
|
||||||
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
||||||
* and to permit persons to whom the Software is furnished to do so,
|
|
||||||
* subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be
|
|
||||||
* included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
||||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
|
|
||||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
|
||||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The text above constitutes the entire PortAudio license; however,
|
|
||||||
* the PortAudio community also makes the following non-binding requests:
|
|
||||||
*
|
|
||||||
* Any person wishing to distribute modifications to the Software is
|
|
||||||
* requested to send the modifications to the original developer so that
|
|
||||||
* they can be incorporated into the canonical version. It is also
|
|
||||||
* requested that these non-binding requests be included along with the
|
|
||||||
* license above.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @file
|
|
||||||
@ingroup common_src
|
|
||||||
|
|
||||||
@brief Functions for generating dither noise
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "pa_types.h"
|
|
||||||
#include "pa_dither.h"
|
|
||||||
|
|
||||||
|
|
||||||
/* Note that the linear congruential algorithm requires 32 bit integers
|
|
||||||
* because it uses arithmetic overflow. So use PaUint32 instead of
|
|
||||||
* unsigned long so it will work on 64 bit systems.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define PA_DITHER_BITS_ (15)
|
|
||||||
|
|
||||||
|
|
||||||
void PaUtil_InitializeTriangularDitherState( PaUtilTriangularDitherGenerator *state )
|
|
||||||
{
|
|
||||||
state->previous = 0;
|
|
||||||
state->randSeed1 = 22222;
|
|
||||||
state->randSeed2 = 5555555;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
PaInt32 PaUtil_Generate16BitTriangularDither( PaUtilTriangularDitherGenerator *state )
|
|
||||||
{
|
|
||||||
PaInt32 current, highPass;
|
|
||||||
|
|
||||||
/* Generate two random numbers. */
|
|
||||||
state->randSeed1 = (state->randSeed1 * 196314165) + 907633515;
|
|
||||||
state->randSeed2 = (state->randSeed2 * 196314165) + 907633515;
|
|
||||||
|
|
||||||
/* Generate triangular distribution about 0.
|
|
||||||
* Shift before adding to prevent overflow which would skew the distribution.
|
|
||||||
* Also shift an extra bit for the high pass filter.
|
|
||||||
*/
|
|
||||||
#define DITHER_SHIFT_ ((sizeof(PaInt32)*8 - PA_DITHER_BITS_) + 1)
|
|
||||||
|
|
||||||
current = (((PaInt32)state->randSeed1)>>DITHER_SHIFT_) +
|
|
||||||
(((PaInt32)state->randSeed2)>>DITHER_SHIFT_);
|
|
||||||
|
|
||||||
/* High pass filter to reduce audibility. */
|
|
||||||
highPass = current - state->previous;
|
|
||||||
state->previous = current;
|
|
||||||
return highPass;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Multiply by PA_FLOAT_DITHER_SCALE_ to get a float between -2.0 and +1.99999 */
|
|
||||||
#define PA_FLOAT_DITHER_SCALE_ (1.0f / ((1<<PA_DITHER_BITS_)-1))
|
|
||||||
static const float const_float_dither_scale_ = PA_FLOAT_DITHER_SCALE_;
|
|
||||||
|
|
||||||
float PaUtil_GenerateFloatTriangularDither( PaUtilTriangularDitherGenerator *state )
|
|
||||||
{
|
|
||||||
PaInt32 current, highPass;
|
|
||||||
|
|
||||||
/* Generate two random numbers. */
|
|
||||||
state->randSeed1 = (state->randSeed1 * 196314165) + 907633515;
|
|
||||||
state->randSeed2 = (state->randSeed2 * 196314165) + 907633515;
|
|
||||||
|
|
||||||
/* Generate triangular distribution about 0.
|
|
||||||
* Shift before adding to prevent overflow which would skew the distribution.
|
|
||||||
* Also shift an extra bit for the high pass filter.
|
|
||||||
*/
|
|
||||||
current = (((PaInt32)state->randSeed1)>>DITHER_SHIFT_) +
|
|
||||||
(((PaInt32)state->randSeed2)>>DITHER_SHIFT_);
|
|
||||||
|
|
||||||
/* High pass filter to reduce audibility. */
|
|
||||||
highPass = current - state->previous;
|
|
||||||
state->previous = current;
|
|
||||||
return ((float)highPass) * const_float_dither_scale_;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
The following alternate dither algorithms (from musicdsp.org) could be
|
|
||||||
considered
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*Noise shaped dither (March 2000)
|
|
||||||
-------------------
|
|
||||||
|
|
||||||
This is a simple implementation of highpass triangular-PDF dither with
|
|
||||||
2nd-order noise shaping, for use when truncating floating point audio
|
|
||||||
data to fixed point.
|
|
||||||
|
|
||||||
The noise shaping lowers the noise floor by 11dB below 5kHz (@ 44100Hz
|
|
||||||
sample rate) compared to triangular-PDF dither. The code below assumes
|
|
||||||
input data is in the range +1 to -1 and doesn't check for overloads!
|
|
||||||
|
|
||||||
To save time when generating dither for multiple channels you can do
|
|
||||||
things like this: r3=(r1 & 0x7F)<<8; instead of calling rand() again.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int r1, r2; //rectangular-PDF random numbers
|
|
||||||
float s1, s2; //error feedback buffers
|
|
||||||
float s = 0.5f; //set to 0.0f for no noise shaping
|
|
||||||
float w = pow(2.0,bits-1); //word length (usually bits=16)
|
|
||||||
float wi= 1.0f/w;
|
|
||||||
float d = wi / RAND_MAX; //dither amplitude (2 lsb)
|
|
||||||
float o = wi * 0.5f; //remove dc offset
|
|
||||||
float in, tmp;
|
|
||||||
int out;
|
|
||||||
|
|
||||||
|
|
||||||
//for each sample...
|
|
||||||
|
|
||||||
r2=r1; //can make HP-TRI dither by
|
|
||||||
r1=rand(); //subtracting previous rand()
|
|
||||||
|
|
||||||
in += s * (s1 + s1 - s2); //error feedback
|
|
||||||
tmp = in + o + d * (float)(r1 - r2); //dc offset and dither
|
|
||||||
|
|
||||||
out = (int)(w * tmp); //truncate downwards
|
|
||||||
if(tmp<0.0f) out--; //this is faster than floor()
|
|
||||||
|
|
||||||
s2 = s1;
|
|
||||||
s1 = in - wi * (float)out; //error
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--
|
|
||||||
paul.kellett@maxim.abel.co.uk
|
|
||||||
http://www.maxim.abel.co.uk
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
16-to-8-bit first-order dither
|
|
||||||
|
|
||||||
Type : First order error feedforward dithering code
|
|
||||||
References : Posted by Jon Watte
|
|
||||||
|
|
||||||
Notes :
|
|
||||||
This is about as simple a dithering algorithm as you can implement, but it's
|
|
||||||
likely to sound better than just truncating to N bits.
|
|
||||||
|
|
||||||
Note that you might not want to carry forward the full difference for infinity.
|
|
||||||
It's probably likely that the worst performance hit comes from the saturation
|
|
||||||
conditionals, which can be avoided with appropriate instructions on many DSPs
|
|
||||||
and integer SIMD type instructions, or CMOV.
|
|
||||||
|
|
||||||
Last, if sound quality is paramount (such as when going from > 16 bits to 16
|
|
||||||
bits) you probably want to use a higher-order dither function found elsewhere
|
|
||||||
on this site.
|
|
||||||
|
|
||||||
|
|
||||||
Code :
|
|
||||||
// This code will down-convert and dither a 16-bit signed short
|
|
||||||
// mono signal into an 8-bit unsigned char signal, using a first
|
|
||||||
// order forward-feeding error term dither.
|
|
||||||
|
|
||||||
#define uchar unsigned char
|
|
||||||
|
|
||||||
void dither_one_channel_16_to_8( short * input, uchar * output, int count, int * memory )
|
|
||||||
{
|
|
||||||
int m = *memory;
|
|
||||||
while( count-- > 0 ) {
|
|
||||||
int i = *input++;
|
|
||||||
i += m;
|
|
||||||
int j = i + 32768 - 128;
|
|
||||||
uchar o;
|
|
||||||
if( j < 0 ) {
|
|
||||||
o = 0;
|
|
||||||
}
|
|
||||||
else if( j > 65535 ) {
|
|
||||||
o = 255;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
o = (uchar)((j>>8)&0xff);
|
|
||||||
}
|
|
||||||
m = ((j-32768+128)-i);
|
|
||||||
*output++ = o;
|
|
||||||
}
|
|
||||||
*memory = m;
|
|
||||||
}
|
|
||||||
*/
|
|
106
third_party/portAudio/src/common/pa_dither.h
vendored
106
third_party/portAudio/src/common/pa_dither.h
vendored
@ -1,106 +0,0 @@
|
|||||||
#ifndef PA_DITHER_H
|
|
||||||
#define PA_DITHER_H
|
|
||||||
/*
|
|
||||||
* $Id$
|
|
||||||
* Portable Audio I/O Library triangular dither generator
|
|
||||||
*
|
|
||||||
* Based on the Open Source API proposed by Ross Bencina
|
|
||||||
* Copyright (c) 1999-2002 Phil Burk, Ross Bencina
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files
|
|
||||||
* (the "Software"), to deal in the Software without restriction,
|
|
||||||
* including without limitation the rights to use, copy, modify, merge,
|
|
||||||
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
||||||
* and to permit persons to whom the Software is furnished to do so,
|
|
||||||
* subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be
|
|
||||||
* included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
||||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
|
|
||||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
|
||||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The text above constitutes the entire PortAudio license; however,
|
|
||||||
* the PortAudio community also makes the following non-binding requests:
|
|
||||||
*
|
|
||||||
* Any person wishing to distribute modifications to the Software is
|
|
||||||
* requested to send the modifications to the original developer so that
|
|
||||||
* they can be incorporated into the canonical version. It is also
|
|
||||||
* requested that these non-binding requests be included along with the
|
|
||||||
* license above.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @file
|
|
||||||
@ingroup common_src
|
|
||||||
|
|
||||||
@brief Functions for generating dither noise
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "pa_types.h"
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#endif /* __cplusplus */
|
|
||||||
|
|
||||||
/* Note that the linear congruential algorithm requires 32 bit integers
|
|
||||||
* because it uses arithmetic overflow. So use PaUint32 instead of
|
|
||||||
* unsigned long so it will work on 64 bit systems.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @brief State needed to generate a dither signal */
|
|
||||||
typedef struct PaUtilTriangularDitherGenerator{
|
|
||||||
PaUint32 previous;
|
|
||||||
PaUint32 randSeed1;
|
|
||||||
PaUint32 randSeed2;
|
|
||||||
} PaUtilTriangularDitherGenerator;
|
|
||||||
|
|
||||||
|
|
||||||
/** @brief Initialize dither state */
|
|
||||||
void PaUtil_InitializeTriangularDitherState( PaUtilTriangularDitherGenerator *ditherState );
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
@brief Calculate 2 LSB dither signal with a triangular distribution.
|
|
||||||
Ranged for adding to a 1 bit right-shifted 32 bit integer
|
|
||||||
prior to >>15. eg:
|
|
||||||
<pre>
|
|
||||||
signed long in = *
|
|
||||||
signed long dither = PaUtil_Generate16BitTriangularDither( ditherState );
|
|
||||||
signed short out = (signed short)(((in>>1) + dither) >> 15);
|
|
||||||
</pre>
|
|
||||||
@return
|
|
||||||
A signed 32-bit integer with a range of +32767 to -32768
|
|
||||||
*/
|
|
||||||
PaInt32 PaUtil_Generate16BitTriangularDither( PaUtilTriangularDitherGenerator *ditherState );
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
@brief Calculate 2 LSB dither signal with a triangular distribution.
|
|
||||||
Ranged for adding to a pre-scaled float.
|
|
||||||
<pre>
|
|
||||||
float in = *
|
|
||||||
float dither = PaUtil_GenerateFloatTriangularDither( ditherState );
|
|
||||||
// use smaller scaler to prevent overflow when we add the dither
|
|
||||||
signed short out = (signed short)(in*(32766.0f) + dither );
|
|
||||||
</pre>
|
|
||||||
@return
|
|
||||||
A float with a range of -2.0 to +1.99999.
|
|
||||||
*/
|
|
||||||
float PaUtil_GenerateFloatTriangularDither( PaUtilTriangularDitherGenerator *ditherState );
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif /* __cplusplus */
|
|
||||||
#endif /* PA_DITHER_H */
|
|
145
third_party/portAudio/src/common/pa_endianness.h
vendored
145
third_party/portAudio/src/common/pa_endianness.h
vendored
@ -1,145 +0,0 @@
|
|||||||
#ifndef PA_ENDIANNESS_H
|
|
||||||
#define PA_ENDIANNESS_H
|
|
||||||
/*
|
|
||||||
* $Id$
|
|
||||||
* Portable Audio I/O Library current platform endianness macros
|
|
||||||
*
|
|
||||||
* Based on the Open Source API proposed by Ross Bencina
|
|
||||||
* Copyright (c) 1999-2002 Phil Burk, Ross Bencina
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files
|
|
||||||
* (the "Software"), to deal in the Software without restriction,
|
|
||||||
* including without limitation the rights to use, copy, modify, merge,
|
|
||||||
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
||||||
* and to permit persons to whom the Software is furnished to do so,
|
|
||||||
* subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be
|
|
||||||
* included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
||||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
|
|
||||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
|
||||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The text above constitutes the entire PortAudio license; however,
|
|
||||||
* the PortAudio community also makes the following non-binding requests:
|
|
||||||
*
|
|
||||||
* Any person wishing to distribute modifications to the Software is
|
|
||||||
* requested to send the modifications to the original developer so that
|
|
||||||
* they can be incorporated into the canonical version. It is also
|
|
||||||
* requested that these non-binding requests be included along with the
|
|
||||||
* license above.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @file
|
|
||||||
@ingroup common_src
|
|
||||||
|
|
||||||
@brief Configure endianness symbols for the target processor.
|
|
||||||
|
|
||||||
Arrange for either the PA_LITTLE_ENDIAN or PA_BIG_ENDIAN preprocessor symbols
|
|
||||||
to be defined. The one that is defined reflects the endianness of the target
|
|
||||||
platform and may be used to implement conditional compilation of byte-order
|
|
||||||
dependent code.
|
|
||||||
|
|
||||||
If either PA_LITTLE_ENDIAN or PA_BIG_ENDIAN is defined already, then no attempt
|
|
||||||
is made to override that setting. This may be useful if you have a better way
|
|
||||||
of determining the platform's endianness. The autoconf mechanism uses this for
|
|
||||||
example.
|
|
||||||
|
|
||||||
A PA_VALIDATE_ENDIANNESS macro is provided to compare the compile time
|
|
||||||
and runtime endianness and raise an assertion if they don't match.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#endif /* __cplusplus */
|
|
||||||
|
|
||||||
/* If this is an apple, we need to do detect endianness this way */
|
|
||||||
#if defined(__APPLE__)
|
|
||||||
/* we need to do some endian detection that is sensitive to hardware arch */
|
|
||||||
#if defined(__LITTLE_ENDIAN__)
|
|
||||||
#if !defined( PA_LITTLE_ENDIAN )
|
|
||||||
#define PA_LITTLE_ENDIAN
|
|
||||||
#endif
|
|
||||||
#if defined( PA_BIG_ENDIAN )
|
|
||||||
#undef PA_BIG_ENDIAN
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
#if !defined( PA_BIG_ENDIAN )
|
|
||||||
#define PA_BIG_ENDIAN
|
|
||||||
#endif
|
|
||||||
#if defined( PA_LITTLE_ENDIAN )
|
|
||||||
#undef PA_LITTLE_ENDIAN
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
/* this is not an apple, so first check the existing defines, and, failing that,
|
|
||||||
detect well-known architectures. */
|
|
||||||
|
|
||||||
#if defined(PA_LITTLE_ENDIAN) || defined(PA_BIG_ENDIAN)
|
|
||||||
/* endianness define has been set externally, such as by autoconf */
|
|
||||||
|
|
||||||
#if defined(PA_LITTLE_ENDIAN) && defined(PA_BIG_ENDIAN)
|
|
||||||
#error both PA_LITTLE_ENDIAN and PA_BIG_ENDIAN have been defined externally to pa_endianness.h - only one endianness at a time please
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#else
|
|
||||||
/* endianness define has not been set externally */
|
|
||||||
|
|
||||||
/* set PA_LITTLE_ENDIAN or PA_BIG_ENDIAN by testing well known platform specific defines */
|
|
||||||
|
|
||||||
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__) || defined(LITTLE_ENDIAN) || defined(__i386) || defined(_M_IX86) || defined(__x86_64__)
|
|
||||||
#define PA_LITTLE_ENDIAN /* win32, assume intel byte order */
|
|
||||||
#else
|
|
||||||
#define PA_BIG_ENDIAN
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined(PA_LITTLE_ENDIAN) && !defined(PA_BIG_ENDIAN)
|
|
||||||
/*
|
|
||||||
If the following error is raised, you either need to modify the code above
|
|
||||||
to automatically determine the endianness from other symbols defined on your
|
|
||||||
platform, or define either PA_LITTLE_ENDIAN or PA_BIG_ENDIAN externally.
|
|
||||||
*/
|
|
||||||
#error pa_endianness.h was unable to automatically determine the endianness of the target platform
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/* PA_VALIDATE_ENDIANNESS compares the compile time and runtime endianness,
|
|
||||||
and raises an assertion if they don't match. <assert.h> must be included in
|
|
||||||
the context in which this macro is used.
|
|
||||||
*/
|
|
||||||
#if defined(NDEBUG)
|
|
||||||
#define PA_VALIDATE_ENDIANNESS
|
|
||||||
#else
|
|
||||||
#if defined(PA_LITTLE_ENDIAN)
|
|
||||||
#define PA_VALIDATE_ENDIANNESS \
|
|
||||||
{ \
|
|
||||||
const long nativeOne = 1; \
|
|
||||||
assert( "PortAudio: compile time and runtime endianness don't match" && (((char *)&nativeOne)[0]) == 1 ); \
|
|
||||||
}
|
|
||||||
#elif defined(PA_BIG_ENDIAN)
|
|
||||||
#define PA_VALIDATE_ENDIANNESS \
|
|
||||||
{ \
|
|
||||||
const long nativeOne = 1; \
|
|
||||||
assert( "PortAudio: compile time and runtime endianness don't match" && (((char *)&nativeOne)[0]) == 0 ); \
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif /* __cplusplus */
|
|
||||||
#endif /* PA_ENDIANNESS_H */
|
|
1810
third_party/portAudio/src/common/pa_front.c
vendored
1810
third_party/portAudio/src/common/pa_front.c
vendored
File diff suppressed because it is too large
Load Diff
@ -1 +0,0 @@
|
|||||||
#define PA_GIT_REVISION 147dd722548358763a8b649b3e4b41dfffbcfbb6
|
|
362
third_party/portAudio/src/common/pa_hostapi.h
vendored
362
third_party/portAudio/src/common/pa_hostapi.h
vendored
@ -1,362 +0,0 @@
|
|||||||
#ifndef PA_HOSTAPI_H
|
|
||||||
#define PA_HOSTAPI_H
|
|
||||||
/*
|
|
||||||
* $Id$
|
|
||||||
* Portable Audio I/O Library
|
|
||||||
* host api representation
|
|
||||||
*
|
|
||||||
* Based on the Open Source API proposed by Ross Bencina
|
|
||||||
* Copyright (c) 1999-2008 Ross Bencina, Phil Burk
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files
|
|
||||||
* (the "Software"), to deal in the Software without restriction,
|
|
||||||
* including without limitation the rights to use, copy, modify, merge,
|
|
||||||
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
||||||
* and to permit persons to whom the Software is furnished to do so,
|
|
||||||
* subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be
|
|
||||||
* included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
||||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
|
|
||||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
|
||||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The text above constitutes the entire PortAudio license; however,
|
|
||||||
* the PortAudio community also makes the following non-binding requests:
|
|
||||||
*
|
|
||||||
* Any person wishing to distribute modifications to the Software is
|
|
||||||
* requested to send the modifications to the original developer so that
|
|
||||||
* they can be incorporated into the canonical version. It is also
|
|
||||||
* requested that these non-binding requests be included along with the
|
|
||||||
* license above.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @file
|
|
||||||
@ingroup common_src
|
|
||||||
|
|
||||||
@brief Interfaces and representation structures used by pa_front.c
|
|
||||||
to manage and communicate with host API implementations.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "portaudio.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
The PA_NO_* host API macros are now deprecated in favor of PA_USE_* macros.
|
|
||||||
PA_USE_* indicates whether a particular host API will be initialized by PortAudio.
|
|
||||||
An undefined or 0 value indicates that the host API will not be used. A value of 1
|
|
||||||
indicates that the host API will be used. PA_USE_* macros should be left undefined
|
|
||||||
or defined to either 0 or 1.
|
|
||||||
|
|
||||||
The code below ensures that PA_USE_* macros are always defined and have value
|
|
||||||
0 or 1. Undefined symbols are defaulted to 0. Symbols that are neither 0 nor 1
|
|
||||||
are defaulted to 1.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef PA_USE_SKELETON
|
|
||||||
#define PA_USE_SKELETON 0
|
|
||||||
#elif (PA_USE_SKELETON != 0) && (PA_USE_SKELETON != 1)
|
|
||||||
#undef PA_USE_SKELETON
|
|
||||||
#define PA_USE_SKELETON 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(PA_NO_ASIO) || defined(PA_NO_DS) || defined(PA_NO_WMME) || defined(PA_NO_WASAPI) || defined(PA_NO_WDMKS)
|
|
||||||
#error "Portaudio: PA_NO_<APINAME> is no longer supported, please remove definition and use PA_USE_<APINAME> instead"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef PA_USE_ASIO
|
|
||||||
#define PA_USE_ASIO 0
|
|
||||||
#elif (PA_USE_ASIO != 0) && (PA_USE_ASIO != 1)
|
|
||||||
#undef PA_USE_ASIO
|
|
||||||
#define PA_USE_ASIO 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef PA_USE_DS
|
|
||||||
#define PA_USE_DS 0
|
|
||||||
#elif (PA_USE_DS != 0) && (PA_USE_DS != 1)
|
|
||||||
#undef PA_USE_DS
|
|
||||||
#define PA_USE_DS 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef PA_USE_WMME
|
|
||||||
#define PA_USE_WMME 0
|
|
||||||
#elif (PA_USE_WMME != 0) && (PA_USE_WMME != 1)
|
|
||||||
#undef PA_USE_WMME
|
|
||||||
#define PA_USE_WMME 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef PA_USE_WASAPI
|
|
||||||
#define PA_USE_WASAPI 0
|
|
||||||
#elif (PA_USE_WASAPI != 0) && (PA_USE_WASAPI != 1)
|
|
||||||
#undef PA_USE_WASAPI
|
|
||||||
#define PA_USE_WASAPI 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef PA_USE_WDMKS
|
|
||||||
#define PA_USE_WDMKS 0
|
|
||||||
#elif (PA_USE_WDMKS != 0) && (PA_USE_WDMKS != 1)
|
|
||||||
#undef PA_USE_WDMKS
|
|
||||||
#define PA_USE_WDMKS 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Set default values for Unix based APIs. */
|
|
||||||
#if defined(PA_NO_OSS) || defined(PA_NO_ALSA) || defined(PA_NO_JACK) || defined(PA_NO_COREAUDIO) || defined(PA_NO_SGI) || defined(PA_NO_ASIHPI)
|
|
||||||
#error "Portaudio: PA_NO_<APINAME> is no longer supported, please remove definition and use PA_USE_<APINAME> instead"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef PA_USE_OSS
|
|
||||||
#define PA_USE_OSS 0
|
|
||||||
#elif (PA_USE_OSS != 0) && (PA_USE_OSS != 1)
|
|
||||||
#undef PA_USE_OSS
|
|
||||||
#define PA_USE_OSS 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef PA_USE_ALSA
|
|
||||||
#define PA_USE_ALSA 0
|
|
||||||
#elif (PA_USE_ALSA != 0) && (PA_USE_ALSA != 1)
|
|
||||||
#undef PA_USE_ALSA
|
|
||||||
#define PA_USE_ALSA 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef PA_USE_JACK
|
|
||||||
#define PA_USE_JACK 0
|
|
||||||
#elif (PA_USE_JACK != 0) && (PA_USE_JACK != 1)
|
|
||||||
#undef PA_USE_JACK
|
|
||||||
#define PA_USE_JACK 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef PA_USE_SGI
|
|
||||||
#define PA_USE_SGI 0
|
|
||||||
#elif (PA_USE_SGI != 0) && (PA_USE_SGI != 1)
|
|
||||||
#undef PA_USE_SGI
|
|
||||||
#define PA_USE_SGI 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef PA_USE_COREAUDIO
|
|
||||||
#define PA_USE_COREAUDIO 0
|
|
||||||
#elif (PA_USE_COREAUDIO != 0) && (PA_USE_COREAUDIO != 1)
|
|
||||||
#undef PA_USE_COREAUDIO
|
|
||||||
#define PA_USE_COREAUDIO 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef PA_USE_ASIHPI
|
|
||||||
#define PA_USE_ASIHPI 0
|
|
||||||
#elif (PA_USE_ASIHPI != 0) && (PA_USE_ASIHPI != 1)
|
|
||||||
#undef PA_USE_ASIHPI
|
|
||||||
#define PA_USE_ASIHPI 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#endif /* __cplusplus */
|
|
||||||
|
|
||||||
|
|
||||||
/** **FOR THE USE OF pa_front.c ONLY**
|
|
||||||
Do NOT use fields in this structure, they my change at any time.
|
|
||||||
Use functions defined in pa_util.h if you think you need functionality
|
|
||||||
which can be derived from here.
|
|
||||||
*/
|
|
||||||
typedef struct PaUtilPrivatePaFrontHostApiInfo {
|
|
||||||
|
|
||||||
|
|
||||||
unsigned long baseDeviceIndex;
|
|
||||||
}PaUtilPrivatePaFrontHostApiInfo;
|
|
||||||
|
|
||||||
|
|
||||||
/** The common header for all data structures whose pointers are passed through
|
|
||||||
the hostApiSpecificStreamInfo field of the PaStreamParameters structure.
|
|
||||||
Note that in order to keep the public PortAudio interface clean, this structure
|
|
||||||
is not used explicitly when declaring hostApiSpecificStreamInfo data structures.
|
|
||||||
However, some code in pa_front depends on the first 3 members being equivalent
|
|
||||||
with this structure.
|
|
||||||
@see PaStreamParameters
|
|
||||||
*/
|
|
||||||
typedef struct PaUtilHostApiSpecificStreamInfoHeader
|
|
||||||
{
|
|
||||||
unsigned long size; /**< size of whole structure including this header */
|
|
||||||
PaHostApiTypeId hostApiType; /**< host API for which this data is intended */
|
|
||||||
unsigned long version; /**< structure version */
|
|
||||||
} PaUtilHostApiSpecificStreamInfoHeader;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** A structure representing the interface to a host API. Contains both
|
|
||||||
concrete data and pointers to functions which implement the interface.
|
|
||||||
*/
|
|
||||||
typedef struct PaUtilHostApiRepresentation {
|
|
||||||
PaUtilPrivatePaFrontHostApiInfo privatePaFrontInfo;
|
|
||||||
|
|
||||||
/** The host api implementation should populate the info field. In the
|
|
||||||
case of info.defaultInputDevice and info.defaultOutputDevice the
|
|
||||||
values stored should be 0 based indices within the host api's own
|
|
||||||
device index range (0 to deviceCount). These values will be converted
|
|
||||||
to global device indices by pa_front after PaUtilHostApiInitializer()
|
|
||||||
returns.
|
|
||||||
*/
|
|
||||||
PaHostApiInfo info;
|
|
||||||
|
|
||||||
PaDeviceInfo** deviceInfos;
|
|
||||||
|
|
||||||
/**
|
|
||||||
(*Terminate)() is guaranteed to be called with a valid <hostApi>
|
|
||||||
parameter, which was previously returned from the same implementation's
|
|
||||||
initializer.
|
|
||||||
*/
|
|
||||||
void (*Terminate)( struct PaUtilHostApiRepresentation *hostApi );
|
|
||||||
|
|
||||||
/**
|
|
||||||
The inputParameters and outputParameters pointers should not be saved
|
|
||||||
as they will not remain valid after OpenStream is called.
|
|
||||||
|
|
||||||
|
|
||||||
The following guarantees are made about parameters to (*OpenStream)():
|
|
||||||
|
|
||||||
[NOTE: the following list up to *END PA FRONT VALIDATIONS* should be
|
|
||||||
kept in sync with the one for ValidateOpenStreamParameters and
|
|
||||||
Pa_OpenStream in pa_front.c]
|
|
||||||
|
|
||||||
PaHostApiRepresentation *hostApi
|
|
||||||
- is valid for this implementation
|
|
||||||
|
|
||||||
PaStream** stream
|
|
||||||
- is non-null
|
|
||||||
|
|
||||||
- at least one of inputParameters & outputParmeters is valid (not NULL)
|
|
||||||
|
|
||||||
- if inputParameters & outputParmeters are both valid, that
|
|
||||||
inputParameters->device & outputParmeters->device both use the same host api
|
|
||||||
|
|
||||||
PaDeviceIndex inputParameters->device
|
|
||||||
- is within range (0 to Pa_CountDevices-1) Or:
|
|
||||||
- is paUseHostApiSpecificDeviceSpecification and
|
|
||||||
inputParameters->hostApiSpecificStreamInfo is non-NULL and refers
|
|
||||||
to a valid host api
|
|
||||||
|
|
||||||
int inputParameters->numChannels
|
|
||||||
- if inputParameters->device is not paUseHostApiSpecificDeviceSpecification, numInputChannels is > 0
|
|
||||||
- upper bound is NOT validated against device capabilities
|
|
||||||
|
|
||||||
PaSampleFormat inputParameters->sampleFormat
|
|
||||||
- is one of the sample formats defined in portaudio.h
|
|
||||||
|
|
||||||
void *inputParameters->hostApiSpecificStreamInfo
|
|
||||||
- if supplied its hostApi field matches the input device's host Api
|
|
||||||
|
|
||||||
PaDeviceIndex outputParmeters->device
|
|
||||||
- is within range (0 to Pa_CountDevices-1)
|
|
||||||
|
|
||||||
int outputParmeters->numChannels
|
|
||||||
- if inputDevice is valid, numInputChannels is > 0
|
|
||||||
- upper bound is NOT validated against device capabilities
|
|
||||||
|
|
||||||
PaSampleFormat outputParmeters->sampleFormat
|
|
||||||
- is one of the sample formats defined in portaudio.h
|
|
||||||
|
|
||||||
void *outputParmeters->hostApiSpecificStreamInfo
|
|
||||||
- if supplied its hostApi field matches the output device's host Api
|
|
||||||
|
|
||||||
double sampleRate
|
|
||||||
- is not an 'absurd' rate (less than 1000. or greater than 384000.)
|
|
||||||
- sampleRate is NOT validated against device capabilities
|
|
||||||
|
|
||||||
PaStreamFlags streamFlags
|
|
||||||
- unused platform neutral flags are zero
|
|
||||||
- paNeverDropInput is only used for full-duplex callback streams
|
|
||||||
with variable buffer size (paFramesPerBufferUnspecified)
|
|
||||||
|
|
||||||
[*END PA FRONT VALIDATIONS*]
|
|
||||||
|
|
||||||
|
|
||||||
The following validations MUST be performed by (*OpenStream)():
|
|
||||||
|
|
||||||
- check that input device can support numInputChannels
|
|
||||||
|
|
||||||
- check that input device can support inputSampleFormat, or that
|
|
||||||
we have the capability to convert from outputSampleFormat to
|
|
||||||
a native format
|
|
||||||
|
|
||||||
- if inputStreamInfo is supplied, validate its contents,
|
|
||||||
or return an error if no inputStreamInfo is expected
|
|
||||||
|
|
||||||
- check that output device can support numOutputChannels
|
|
||||||
|
|
||||||
- check that output device can support outputSampleFormat, or that
|
|
||||||
we have the capability to convert from outputSampleFormat to
|
|
||||||
a native format
|
|
||||||
|
|
||||||
- if outputStreamInfo is supplied, validate its contents,
|
|
||||||
or return an error if no outputStreamInfo is expected
|
|
||||||
|
|
||||||
- if a full duplex stream is requested, check that the combination
|
|
||||||
of input and output parameters is supported
|
|
||||||
|
|
||||||
- check that the device supports sampleRate
|
|
||||||
|
|
||||||
- alter sampleRate to a close allowable rate if necessary
|
|
||||||
|
|
||||||
- validate inputLatency and outputLatency
|
|
||||||
|
|
||||||
- validate any platform specific flags, if flags are supplied they
|
|
||||||
must be valid.
|
|
||||||
*/
|
|
||||||
PaError (*OpenStream)( struct PaUtilHostApiRepresentation *hostApi,
|
|
||||||
PaStream** stream,
|
|
||||||
const PaStreamParameters *inputParameters,
|
|
||||||
const PaStreamParameters *outputParameters,
|
|
||||||
double sampleRate,
|
|
||||||
unsigned long framesPerCallback,
|
|
||||||
PaStreamFlags streamFlags,
|
|
||||||
PaStreamCallback *streamCallback,
|
|
||||||
void *userData );
|
|
||||||
|
|
||||||
|
|
||||||
PaError (*IsFormatSupported)( struct PaUtilHostApiRepresentation *hostApi,
|
|
||||||
const PaStreamParameters *inputParameters,
|
|
||||||
const PaStreamParameters *outputParameters,
|
|
||||||
double sampleRate );
|
|
||||||
} PaUtilHostApiRepresentation;
|
|
||||||
|
|
||||||
|
|
||||||
/** Prototype for the initialization function which must be implemented by every
|
|
||||||
host API.
|
|
||||||
|
|
||||||
This function should only return an error other than paNoError if it encounters
|
|
||||||
an unexpected and fatal error (memory allocation error for example). In general,
|
|
||||||
there may be conditions under which it returns a NULL interface pointer and also
|
|
||||||
returns paNoError. For example, if the ASIO implementation detects that ASIO is
|
|
||||||
not installed, it should return a NULL interface, and paNoError.
|
|
||||||
|
|
||||||
@see paHostApiInitializers
|
|
||||||
*/
|
|
||||||
typedef PaError PaUtilHostApiInitializer( PaUtilHostApiRepresentation**, PaHostApiIndex );
|
|
||||||
|
|
||||||
|
|
||||||
/** paHostApiInitializers is a NULL-terminated array of host API initialization
|
|
||||||
functions. These functions are called by pa_front.c to initialize the host APIs
|
|
||||||
when the client calls Pa_Initialize().
|
|
||||||
|
|
||||||
The initialization functions are invoked in order.
|
|
||||||
|
|
||||||
The first successfully initialized host API that has a default input *or* output
|
|
||||||
device is used as the default PortAudio host API. This is based on the logic that
|
|
||||||
there is only one default host API, and it must contain the default input and output
|
|
||||||
devices (if defined).
|
|
||||||
|
|
||||||
There is a platform specific file that defines paHostApiInitializers for that
|
|
||||||
platform, pa_win/pa_win_hostapis.c contains the Win32 definitions for example.
|
|
||||||
*/
|
|
||||||
extern PaUtilHostApiInitializer *paHostApiInitializers[];
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif /* __cplusplus */
|
|
||||||
#endif /* PA_HOSTAPI_H */
|
|
128
third_party/portAudio/src/common/pa_memorybarrier.h
vendored
128
third_party/portAudio/src/common/pa_memorybarrier.h
vendored
@ -1,128 +0,0 @@
|
|||||||
/*
|
|
||||||
* $Id: pa_memorybarrier.h 1240 2007-07-17 13:05:07Z bjornroche $
|
|
||||||
* Portable Audio I/O Library
|
|
||||||
* Memory barrier utilities
|
|
||||||
*
|
|
||||||
* Author: Bjorn Roche, XO Audio, LLC
|
|
||||||
*
|
|
||||||
* This program uses the PortAudio Portable Audio Library.
|
|
||||||
* For more information see: http://www.portaudio.com
|
|
||||||
* Copyright (c) 1999-2000 Ross Bencina and Phil Burk
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files
|
|
||||||
* (the "Software"), to deal in the Software without restriction,
|
|
||||||
* including without limitation the rights to use, copy, modify, merge,
|
|
||||||
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
||||||
* and to permit persons to whom the Software is furnished to do so,
|
|
||||||
* subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be
|
|
||||||
* included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
||||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
|
|
||||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
|
||||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The text above constitutes the entire PortAudio license; however,
|
|
||||||
* the PortAudio community also makes the following non-binding requests:
|
|
||||||
*
|
|
||||||
* Any person wishing to distribute modifications to the Software is
|
|
||||||
* requested to send the modifications to the original developer so that
|
|
||||||
* they can be incorporated into the canonical version. It is also
|
|
||||||
* requested that these non-binding requests be included along with the
|
|
||||||
* license above.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
@file pa_memorybarrier.h
|
|
||||||
@ingroup common_src
|
|
||||||
*/
|
|
||||||
|
|
||||||
/****************
|
|
||||||
* Some memory barrier primitives based on the system.
|
|
||||||
* right now only OS X, FreeBSD, and Linux are supported. In addition to providing
|
|
||||||
* memory barriers, these functions should ensure that data cached in registers
|
|
||||||
* is written out to cache where it can be snooped by other CPUs. (ie, the volatile
|
|
||||||
* keyword should not be required)
|
|
||||||
*
|
|
||||||
* the primitives that must be defined are:
|
|
||||||
*
|
|
||||||
* PaUtil_FullMemoryBarrier()
|
|
||||||
* PaUtil_ReadMemoryBarrier()
|
|
||||||
* PaUtil_WriteMemoryBarrier()
|
|
||||||
*
|
|
||||||
****************/
|
|
||||||
|
|
||||||
#if defined(__APPLE__)
|
|
||||||
# include <libkern/OSAtomic.h>
|
|
||||||
/* Here are the memory barrier functions. Mac OS X only provides
|
|
||||||
full memory barriers, so the three types of barriers are the same,
|
|
||||||
however, these barriers are superior to compiler-based ones. */
|
|
||||||
# define PaUtil_FullMemoryBarrier() OSMemoryBarrier()
|
|
||||||
# define PaUtil_ReadMemoryBarrier() OSMemoryBarrier()
|
|
||||||
# define PaUtil_WriteMemoryBarrier() OSMemoryBarrier()
|
|
||||||
#elif defined(__GNUC__)
|
|
||||||
/* GCC >= 4.1 has built-in intrinsics. We'll use those */
|
|
||||||
# if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)
|
|
||||||
# define PaUtil_FullMemoryBarrier() __sync_synchronize()
|
|
||||||
# define PaUtil_ReadMemoryBarrier() __sync_synchronize()
|
|
||||||
# define PaUtil_WriteMemoryBarrier() __sync_synchronize()
|
|
||||||
/* as a fallback, GCC understands volatile asm and "memory" to mean it
|
|
||||||
* should not reorder memory read/writes */
|
|
||||||
/* Note that it is not clear that any compiler actually defines __PPC__,
|
|
||||||
* it can probably removed safely. */
|
|
||||||
# elif defined( __ppc__ ) || defined( __powerpc__) || defined( __PPC__ )
|
|
||||||
# define PaUtil_FullMemoryBarrier() asm volatile("sync":::"memory")
|
|
||||||
# define PaUtil_ReadMemoryBarrier() asm volatile("sync":::"memory")
|
|
||||||
# define PaUtil_WriteMemoryBarrier() asm volatile("sync":::"memory")
|
|
||||||
# elif defined( __i386__ ) || defined( __i486__ ) || defined( __i586__ ) || \
|
|
||||||
defined( __i686__ ) || defined( __x86_64__ )
|
|
||||||
# define PaUtil_FullMemoryBarrier() asm volatile("mfence":::"memory")
|
|
||||||
# define PaUtil_ReadMemoryBarrier() asm volatile("lfence":::"memory")
|
|
||||||
# define PaUtil_WriteMemoryBarrier() asm volatile("sfence":::"memory")
|
|
||||||
# else
|
|
||||||
# ifdef ALLOW_SMP_DANGERS
|
|
||||||
# warning Memory barriers not defined on this system or system unknown
|
|
||||||
# warning For SMP safety, you should fix this.
|
|
||||||
# define PaUtil_FullMemoryBarrier()
|
|
||||||
# define PaUtil_ReadMemoryBarrier()
|
|
||||||
# define PaUtil_WriteMemoryBarrier()
|
|
||||||
# else
|
|
||||||
# error Memory barriers are not defined on this system. You can still compile by defining ALLOW_SMP_DANGERS, but SMP safety will not be guaranteed.
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
#elif (_MSC_VER >= 1400) && !defined(_WIN32_WCE)
|
|
||||||
# include <intrin.h>
|
|
||||||
# pragma intrinsic(_ReadWriteBarrier)
|
|
||||||
# pragma intrinsic(_ReadBarrier)
|
|
||||||
# pragma intrinsic(_WriteBarrier)
|
|
||||||
/* note that MSVC intrinsics _ReadWriteBarrier(), _ReadBarrier(), _WriteBarrier() are just compiler barriers *not* memory barriers */
|
|
||||||
# define PaUtil_FullMemoryBarrier() _ReadWriteBarrier()
|
|
||||||
# define PaUtil_ReadMemoryBarrier() _ReadBarrier()
|
|
||||||
# define PaUtil_WriteMemoryBarrier() _WriteBarrier()
|
|
||||||
#elif defined(_WIN32_WCE)
|
|
||||||
# define PaUtil_FullMemoryBarrier()
|
|
||||||
# define PaUtil_ReadMemoryBarrier()
|
|
||||||
# define PaUtil_WriteMemoryBarrier()
|
|
||||||
#elif defined(_MSC_VER) || defined(__BORLANDC__)
|
|
||||||
# define PaUtil_FullMemoryBarrier() _asm { lock add [esp], 0 }
|
|
||||||
# define PaUtil_ReadMemoryBarrier() _asm { lock add [esp], 0 }
|
|
||||||
# define PaUtil_WriteMemoryBarrier() _asm { lock add [esp], 0 }
|
|
||||||
#else
|
|
||||||
# ifdef ALLOW_SMP_DANGERS
|
|
||||||
# warning Memory barriers not defined on this system or system unknown
|
|
||||||
# warning For SMP safety, you should fix this.
|
|
||||||
# define PaUtil_FullMemoryBarrier()
|
|
||||||
# define PaUtil_ReadMemoryBarrier()
|
|
||||||
# define PaUtil_WriteMemoryBarrier()
|
|
||||||
# else
|
|
||||||
# error Memory barriers are not defined on this system. You can still compile by defining ALLOW_SMP_DANGERS, but SMP safety will not be guaranteed.
|
|
||||||
# endif
|
|
||||||
#endif
|
|
1831
third_party/portAudio/src/common/pa_process.c
vendored
1831
third_party/portAudio/src/common/pa_process.c
vendored
File diff suppressed because it is too large
Load Diff
754
third_party/portAudio/src/common/pa_process.h
vendored
754
third_party/portAudio/src/common/pa_process.h
vendored
@ -1,754 +0,0 @@
|
|||||||
#ifndef PA_PROCESS_H
|
|
||||||
#define PA_PROCESS_H
|
|
||||||
/*
|
|
||||||
* $Id$
|
|
||||||
* Portable Audio I/O Library callback buffer processing adapters
|
|
||||||
*
|
|
||||||
* Based on the Open Source API proposed by Ross Bencina
|
|
||||||
* Copyright (c) 1999-2002 Phil Burk, Ross Bencina
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files
|
|
||||||
* (the "Software"), to deal in the Software without restriction,
|
|
||||||
* including without limitation the rights to use, copy, modify, merge,
|
|
||||||
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
||||||
* and to permit persons to whom the Software is furnished to do so,
|
|
||||||
* subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be
|
|
||||||
* included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
||||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
|
|
||||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
|
||||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The text above constitutes the entire PortAudio license; however,
|
|
||||||
* the PortAudio community also makes the following non-binding requests:
|
|
||||||
*
|
|
||||||
* Any person wishing to distribute modifications to the Software is
|
|
||||||
* requested to send the modifications to the original developer so that
|
|
||||||
* they can be incorporated into the canonical version. It is also
|
|
||||||
* requested that these non-binding requests be included along with the
|
|
||||||
* license above.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @file
|
|
||||||
@ingroup common_src
|
|
||||||
|
|
||||||
@brief Buffer Processor prototypes. A Buffer Processor performs buffer length
|
|
||||||
adaption, coordinates sample format conversion, and interleaves/deinterleaves
|
|
||||||
channels.
|
|
||||||
|
|
||||||
<h3>Overview</h3>
|
|
||||||
|
|
||||||
The "Buffer Processor" (PaUtilBufferProcessor) manages conversion of audio
|
|
||||||
data from host buffers to user buffers and back again. Where required, the
|
|
||||||
buffer processor takes care of converting between host and user sample formats,
|
|
||||||
interleaving and deinterleaving multichannel buffers, and adapting between host
|
|
||||||
and user buffers with different lengths. The buffer processor may be used with
|
|
||||||
full and half duplex streams, for both callback streams and blocking read/write
|
|
||||||
streams.
|
|
||||||
|
|
||||||
One of the important capabilities provided by the buffer processor is
|
|
||||||
the ability to adapt between user and host buffer sizes of different lengths
|
|
||||||
with minimum latency. Although this task is relatively easy to perform when
|
|
||||||
the host buffer size is an integer multiple of the user buffer size, the
|
|
||||||
problem is more complicated when this is not the case - especially for
|
|
||||||
full-duplex callback streams. Where necessary the adaption is implemented by
|
|
||||||
internally buffering some input and/or output data. The buffer adation
|
|
||||||
algorithm used by the buffer processor was originally implemented by
|
|
||||||
Stephan Letz for the ASIO version of PortAudio, and is described in his
|
|
||||||
Callback_adaption_.pdf which is included in the distribution.
|
|
||||||
|
|
||||||
The buffer processor performs sample conversion using the functions provided
|
|
||||||
by pa_converters.c.
|
|
||||||
|
|
||||||
The following sections provide an overview of how to use the buffer processor.
|
|
||||||
Interested readers are advised to consult the host API implementations for
|
|
||||||
examples of buffer processor usage.
|
|
||||||
|
|
||||||
|
|
||||||
<h4>Initialization, resetting and termination</h4>
|
|
||||||
|
|
||||||
When a stream is opened, the buffer processor should be initialized using
|
|
||||||
PaUtil_InitializeBufferProcessor. This function initializes internal state
|
|
||||||
and allocates temporary buffers as necessary according to the supplied
|
|
||||||
configuration parameters. Some of the parameters correspond to those requested
|
|
||||||
by the user in their call to Pa_OpenStream(), others reflect the requirements
|
|
||||||
of the host API implementation - they indicate host buffer sizes, formats,
|
|
||||||
and the type of buffering which the Host API uses. The buffer processor should
|
|
||||||
be initialized for callback streams and blocking read/write streams.
|
|
||||||
|
|
||||||
Call PaUtil_ResetBufferProcessor to clear any sample data which is present
|
|
||||||
in the buffer processor before starting to use it (for example when
|
|
||||||
Pa_StartStream is called).
|
|
||||||
|
|
||||||
When the buffer processor is no longer used call
|
|
||||||
PaUtil_TerminateBufferProcessor.
|
|
||||||
|
|
||||||
|
|
||||||
<h4>Using the buffer processor for a callback stream</h4>
|
|
||||||
|
|
||||||
The buffer processor's role in a callback stream is to take host input buffers
|
|
||||||
process them with the stream callback, and fill host output buffers. For a
|
|
||||||
full duplex stream, the buffer processor handles input and output simultaneously
|
|
||||||
due to the requirements of the minimum-latency buffer adation algorithm.
|
|
||||||
|
|
||||||
When a host buffer becomes available, the implementation should call
|
|
||||||
the buffer processor to process the buffer. The buffer processor calls the
|
|
||||||
stream callback to consume and/or produce audio data as necessary. The buffer
|
|
||||||
processor will convert sample formats, interleave/deinterleave channels,
|
|
||||||
and slice or chunk the data to the appropriate buffer lengths according to
|
|
||||||
the requirements of the stream callback and the host API.
|
|
||||||
|
|
||||||
To process a host buffer (or a pair of host buffers for a full-duplex stream)
|
|
||||||
use the following calling sequence:
|
|
||||||
|
|
||||||
-# Call PaUtil_BeginBufferProcessing
|
|
||||||
-# For a stream which takes input:
|
|
||||||
- Call PaUtil_SetInputFrameCount with the number of frames in the host input
|
|
||||||
buffer.
|
|
||||||
- Call one of the following functions one or more times to tell the
|
|
||||||
buffer processor about the host input buffer(s): PaUtil_SetInputChannel,
|
|
||||||
PaUtil_SetInterleavedInputChannels, PaUtil_SetNonInterleavedInputChannel.
|
|
||||||
Which function you call will depend on whether the host buffer(s) are
|
|
||||||
interleaved or not.
|
|
||||||
- If the available host data is split across two buffers (for example a
|
|
||||||
data range at the end of a circular buffer and another range at the
|
|
||||||
beginning of the circular buffer), also call
|
|
||||||
PaUtil_Set2ndInputFrameCount, PaUtil_Set2ndInputChannel,
|
|
||||||
PaUtil_Set2ndInterleavedInputChannels,
|
|
||||||
PaUtil_Set2ndNonInterleavedInputChannel as necessary to tell the buffer
|
|
||||||
processor about the second buffer.
|
|
||||||
-# For a stream which generates output:
|
|
||||||
- Call PaUtil_SetOutputFrameCount with the number of frames in the host
|
|
||||||
output buffer.
|
|
||||||
- Call one of the following functions one or more times to tell the
|
|
||||||
buffer processor about the host output buffer(s): PaUtil_SetOutputChannel,
|
|
||||||
PaUtil_SetInterleavedOutputChannels, PaUtil_SetNonInterleavedOutputChannel.
|
|
||||||
Which function you call will depend on whether the host buffer(s) are
|
|
||||||
interleaved or not.
|
|
||||||
- If the available host output buffer space is split across two buffers
|
|
||||||
(for example a data range at the end of a circular buffer and another
|
|
||||||
range at the beginning of the circular buffer), call
|
|
||||||
PaUtil_Set2ndOutputFrameCount, PaUtil_Set2ndOutputChannel,
|
|
||||||
PaUtil_Set2ndInterleavedOutputChannels,
|
|
||||||
PaUtil_Set2ndNonInterleavedOutputChannel as necessary to tell the buffer
|
|
||||||
processor about the second buffer.
|
|
||||||
-# Call PaUtil_EndBufferProcessing, this function performs the actual data
|
|
||||||
conversion and processing.
|
|
||||||
|
|
||||||
|
|
||||||
<h4>Using the buffer processor for a blocking read/write stream</h4>
|
|
||||||
|
|
||||||
Blocking read/write streams use the buffer processor to convert and copy user
|
|
||||||
output data to a host buffer, and to convert and copy host input data to
|
|
||||||
the user's buffer. The buffer processor does not perform any buffer adaption.
|
|
||||||
When using the buffer processor in a blocking read/write stream the input and
|
|
||||||
output conversion are performed separately by the PaUtil_CopyInput and
|
|
||||||
PaUtil_CopyOutput functions.
|
|
||||||
|
|
||||||
To copy data from a host input buffer to the buffer(s) which the user supplies
|
|
||||||
to Pa_ReadStream, use the following calling sequence.
|
|
||||||
|
|
||||||
- Repeat the following three steps until the user buffer(s) have been filled
|
|
||||||
with samples from the host input buffers:
|
|
||||||
-# Call PaUtil_SetInputFrameCount with the number of frames in the host
|
|
||||||
input buffer.
|
|
||||||
-# Call one of the following functions one or more times to tell the
|
|
||||||
buffer processor about the host input buffer(s): PaUtil_SetInputChannel,
|
|
||||||
PaUtil_SetInterleavedInputChannels, PaUtil_SetNonInterleavedInputChannel.
|
|
||||||
Which function you call will depend on whether the host buffer(s) are
|
|
||||||
interleaved or not.
|
|
||||||
-# Call PaUtil_CopyInput with the user buffer pointer (or a copy of the
|
|
||||||
array of buffer pointers for a non-interleaved stream) passed to
|
|
||||||
Pa_ReadStream, along with the number of frames in the user buffer(s).
|
|
||||||
Be careful to pass a <i>copy</i> of the user buffer pointers to
|
|
||||||
PaUtil_CopyInput because PaUtil_CopyInput advances the pointers to
|
|
||||||
the start of the next region to copy.
|
|
||||||
- PaUtil_CopyInput will not copy more data than is available in the
|
|
||||||
host buffer(s), so the above steps need to be repeated until the user
|
|
||||||
buffer(s) are full.
|
|
||||||
|
|
||||||
|
|
||||||
To copy data to the host output buffer from the user buffers(s) supplied
|
|
||||||
to Pa_WriteStream use the following calling sequence.
|
|
||||||
|
|
||||||
- Repeat the following three steps until all frames from the user buffer(s)
|
|
||||||
have been copied to the host API:
|
|
||||||
-# Call PaUtil_SetOutputFrameCount with the number of frames in the host
|
|
||||||
output buffer.
|
|
||||||
-# Call one of the following functions one or more times to tell the
|
|
||||||
buffer processor about the host output buffer(s): PaUtil_SetOutputChannel,
|
|
||||||
PaUtil_SetInterleavedOutputChannels, PaUtil_SetNonInterleavedOutputChannel.
|
|
||||||
Which function you call will depend on whether the host buffer(s) are
|
|
||||||
interleaved or not.
|
|
||||||
-# Call PaUtil_CopyOutput with the user buffer pointer (or a copy of the
|
|
||||||
array of buffer pointers for a non-interleaved stream) passed to
|
|
||||||
Pa_WriteStream, along with the number of frames in the user buffer(s).
|
|
||||||
Be careful to pass a <i>copy</i> of the user buffer pointers to
|
|
||||||
PaUtil_CopyOutput because PaUtil_CopyOutput advances the pointers to
|
|
||||||
the start of the next region to copy.
|
|
||||||
- PaUtil_CopyOutput will not copy more data than fits in the host buffer(s),
|
|
||||||
so the above steps need to be repeated until all user data is copied.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include "portaudio.h"
|
|
||||||
#include "pa_converters.h"
|
|
||||||
#include "pa_dither.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#endif /* __cplusplus */
|
|
||||||
|
|
||||||
|
|
||||||
/** @brief Mode flag passed to PaUtil_InitializeBufferProcessor indicating the type
|
|
||||||
of buffering that the host API uses.
|
|
||||||
|
|
||||||
The mode used depends on whether the host API or the implementation manages
|
|
||||||
the buffers, and how these buffers are used (scatter gather, circular buffer).
|
|
||||||
*/
|
|
||||||
typedef enum {
|
|
||||||
/** The host buffer size is a fixed known size. */
|
|
||||||
paUtilFixedHostBufferSize,
|
|
||||||
|
|
||||||
/** The host buffer size may vary, but has a known maximum size. */
|
|
||||||
paUtilBoundedHostBufferSize,
|
|
||||||
|
|
||||||
/** Nothing is known about the host buffer size. */
|
|
||||||
paUtilUnknownHostBufferSize,
|
|
||||||
|
|
||||||
/** The host buffer size varies, and the client does not require the buffer
|
|
||||||
processor to consume all of the input and fill all of the output buffer. This
|
|
||||||
is useful when the implementation has access to the host API's circular buffer
|
|
||||||
and only needs to consume/fill some of it, not necessarily all of it, with each
|
|
||||||
call to the buffer processor. This is the only mode where
|
|
||||||
PaUtil_EndBufferProcessing() may not consume the whole buffer.
|
|
||||||
*/
|
|
||||||
paUtilVariableHostBufferSizePartialUsageAllowed
|
|
||||||
}PaUtilHostBufferSizeMode;
|
|
||||||
|
|
||||||
|
|
||||||
/** @brief An auxiliary data structure used internally by the buffer processor
|
|
||||||
to represent host input and output buffers. */
|
|
||||||
typedef struct PaUtilChannelDescriptor{
|
|
||||||
void *data;
|
|
||||||
unsigned int stride; /**< stride in samples, not bytes */
|
|
||||||
}PaUtilChannelDescriptor;
|
|
||||||
|
|
||||||
|
|
||||||
/** @brief The main buffer processor data structure.
|
|
||||||
|
|
||||||
Allocate one of these, initialize it with PaUtil_InitializeBufferProcessor
|
|
||||||
and terminate it with PaUtil_TerminateBufferProcessor.
|
|
||||||
*/
|
|
||||||
typedef struct {
|
|
||||||
unsigned long framesPerUserBuffer;
|
|
||||||
unsigned long framesPerHostBuffer;
|
|
||||||
|
|
||||||
PaUtilHostBufferSizeMode hostBufferSizeMode;
|
|
||||||
int useNonAdaptingProcess;
|
|
||||||
int userOutputSampleFormatIsEqualToHost;
|
|
||||||
int userInputSampleFormatIsEqualToHost;
|
|
||||||
unsigned long framesPerTempBuffer;
|
|
||||||
|
|
||||||
unsigned int inputChannelCount;
|
|
||||||
unsigned int bytesPerHostInputSample;
|
|
||||||
unsigned int bytesPerUserInputSample;
|
|
||||||
int userInputIsInterleaved;
|
|
||||||
PaUtilConverter *inputConverter;
|
|
||||||
PaUtilZeroer *inputZeroer;
|
|
||||||
|
|
||||||
unsigned int outputChannelCount;
|
|
||||||
unsigned int bytesPerHostOutputSample;
|
|
||||||
unsigned int bytesPerUserOutputSample;
|
|
||||||
int userOutputIsInterleaved;
|
|
||||||
PaUtilConverter *outputConverter;
|
|
||||||
PaUtilZeroer *outputZeroer;
|
|
||||||
|
|
||||||
unsigned long initialFramesInTempInputBuffer;
|
|
||||||
unsigned long initialFramesInTempOutputBuffer;
|
|
||||||
|
|
||||||
void *tempInputBuffer; /**< used for slips, block adaption, and conversion. */
|
|
||||||
void **tempInputBufferPtrs; /**< storage for non-interleaved buffer pointers, NULL for interleaved user input */
|
|
||||||
unsigned long framesInTempInputBuffer; /**< frames remaining in input buffer from previous adaption iteration */
|
|
||||||
|
|
||||||
void *tempOutputBuffer; /**< used for slips, block adaption, and conversion. */
|
|
||||||
void **tempOutputBufferPtrs; /**< storage for non-interleaved buffer pointers, NULL for interleaved user output */
|
|
||||||
unsigned long framesInTempOutputBuffer; /**< frames remaining in input buffer from previous adaption iteration */
|
|
||||||
|
|
||||||
PaStreamCallbackTimeInfo *timeInfo;
|
|
||||||
|
|
||||||
PaStreamCallbackFlags callbackStatusFlags;
|
|
||||||
|
|
||||||
int hostInputIsInterleaved;
|
|
||||||
unsigned long hostInputFrameCount[2];
|
|
||||||
PaUtilChannelDescriptor *hostInputChannels[2]; /**< pointers to arrays of channel descriptors.
|
|
||||||
pointers are NULL for half-duplex output processing.
|
|
||||||
hostInputChannels[i].data is NULL when the caller
|
|
||||||
calls PaUtil_SetNoInput()
|
|
||||||
*/
|
|
||||||
int hostOutputIsInterleaved;
|
|
||||||
unsigned long hostOutputFrameCount[2];
|
|
||||||
PaUtilChannelDescriptor *hostOutputChannels[2]; /**< pointers to arrays of channel descriptors.
|
|
||||||
pointers are NULL for half-duplex input processing.
|
|
||||||
hostOutputChannels[i].data is NULL when the caller
|
|
||||||
calls PaUtil_SetNoOutput()
|
|
||||||
*/
|
|
||||||
|
|
||||||
PaUtilTriangularDitherGenerator ditherGenerator;
|
|
||||||
|
|
||||||
double samplePeriod;
|
|
||||||
|
|
||||||
PaStreamCallback *streamCallback;
|
|
||||||
void *userData;
|
|
||||||
} PaUtilBufferProcessor;
|
|
||||||
|
|
||||||
|
|
||||||
/** @name Initialization, termination, resetting and info */
|
|
||||||
/*@{*/
|
|
||||||
|
|
||||||
/** Initialize a buffer processor's representation stored in a
|
|
||||||
PaUtilBufferProcessor structure. Be sure to call
|
|
||||||
PaUtil_TerminateBufferProcessor after finishing with a buffer processor.
|
|
||||||
|
|
||||||
@param bufferProcessor The buffer processor structure to initialize.
|
|
||||||
|
|
||||||
@param inputChannelCount The number of input channels as passed to
|
|
||||||
Pa_OpenStream or 0 for an output-only stream.
|
|
||||||
|
|
||||||
@param userInputSampleFormat Format of user input samples, as passed to
|
|
||||||
Pa_OpenStream. This parameter is ignored for ouput-only streams.
|
|
||||||
|
|
||||||
@param hostInputSampleFormat Format of host input samples. This parameter is
|
|
||||||
ignored for output-only streams. See note about host buffer interleave below.
|
|
||||||
|
|
||||||
@param outputChannelCount The number of output channels as passed to
|
|
||||||
Pa_OpenStream or 0 for an input-only stream.
|
|
||||||
|
|
||||||
@param userOutputSampleFormat Format of user output samples, as passed to
|
|
||||||
Pa_OpenStream. This parameter is ignored for input-only streams.
|
|
||||||
|
|
||||||
@param hostOutputSampleFormat Format of host output samples. This parameter is
|
|
||||||
ignored for input-only streams. See note about host buffer interleave below.
|
|
||||||
|
|
||||||
@param sampleRate Sample rate of the stream. The more accurate this is the
|
|
||||||
better - it is used for updating time stamps when adapting buffers.
|
|
||||||
|
|
||||||
@param streamFlags Stream flags as passed to Pa_OpenStream, this parameter is
|
|
||||||
used for selecting special sample conversion options such as clipping and
|
|
||||||
dithering.
|
|
||||||
|
|
||||||
@param framesPerUserBuffer Number of frames per user buffer, as requested
|
|
||||||
by the framesPerBuffer parameter to Pa_OpenStream. This parameter may be
|
|
||||||
zero to indicate that the user will accept any (and varying) buffer sizes.
|
|
||||||
|
|
||||||
@param framesPerHostBuffer Specifies the number of frames per host buffer
|
|
||||||
for the fixed buffer size mode, and the maximum number of frames
|
|
||||||
per host buffer for the bounded host buffer size mode. It is ignored for
|
|
||||||
the other modes.
|
|
||||||
|
|
||||||
@param hostBufferSizeMode A mode flag indicating the size variability of
|
|
||||||
host buffers that will be passed to the buffer processor. See
|
|
||||||
PaUtilHostBufferSizeMode for further details.
|
|
||||||
|
|
||||||
@param streamCallback The user stream callback passed to Pa_OpenStream.
|
|
||||||
|
|
||||||
@param userData The user data field passed to Pa_OpenStream.
|
|
||||||
|
|
||||||
@note The interleave flag is ignored for host buffer formats. Host
|
|
||||||
interleave is determined by the use of different SetInput and SetOutput
|
|
||||||
functions.
|
|
||||||
|
|
||||||
@return An error code indicating whether the initialization was successful.
|
|
||||||
If the error code is not PaNoError, the buffer processor was not initialized
|
|
||||||
and should not be used.
|
|
||||||
|
|
||||||
@see Pa_OpenStream, PaUtilHostBufferSizeMode, PaUtil_TerminateBufferProcessor
|
|
||||||
*/
|
|
||||||
PaError PaUtil_InitializeBufferProcessor( PaUtilBufferProcessor* bufferProcessor,
|
|
||||||
int inputChannelCount, PaSampleFormat userInputSampleFormat,
|
|
||||||
PaSampleFormat hostInputSampleFormat,
|
|
||||||
int outputChannelCount, PaSampleFormat userOutputSampleFormat,
|
|
||||||
PaSampleFormat hostOutputSampleFormat,
|
|
||||||
double sampleRate,
|
|
||||||
PaStreamFlags streamFlags,
|
|
||||||
unsigned long framesPerUserBuffer, /* 0 indicates don't care */
|
|
||||||
unsigned long framesPerHostBuffer,
|
|
||||||
PaUtilHostBufferSizeMode hostBufferSizeMode,
|
|
||||||
PaStreamCallback *streamCallback, void *userData );
|
|
||||||
|
|
||||||
|
|
||||||
/** Terminate a buffer processor's representation. Deallocates any temporary
|
|
||||||
buffers allocated by PaUtil_InitializeBufferProcessor.
|
|
||||||
|
|
||||||
@param bufferProcessor The buffer processor structure to terminate.
|
|
||||||
|
|
||||||
@see PaUtil_InitializeBufferProcessor.
|
|
||||||
*/
|
|
||||||
void PaUtil_TerminateBufferProcessor( PaUtilBufferProcessor* bufferProcessor );
|
|
||||||
|
|
||||||
|
|
||||||
/** Clear any internally buffered data. If you call
|
|
||||||
PaUtil_InitializeBufferProcessor in your OpenStream routine, make sure you
|
|
||||||
call PaUtil_ResetBufferProcessor in your StartStream call.
|
|
||||||
|
|
||||||
@param bufferProcessor The buffer processor to reset.
|
|
||||||
*/
|
|
||||||
void PaUtil_ResetBufferProcessor( PaUtilBufferProcessor* bufferProcessor );
|
|
||||||
|
|
||||||
|
|
||||||
/** Retrieve the input latency of a buffer processor, in frames.
|
|
||||||
|
|
||||||
@param bufferProcessor The buffer processor examine.
|
|
||||||
|
|
||||||
@return The input latency introduced by the buffer processor, in frames.
|
|
||||||
|
|
||||||
@see PaUtil_GetBufferProcessorOutputLatencyFrames
|
|
||||||
*/
|
|
||||||
unsigned long PaUtil_GetBufferProcessorInputLatencyFrames( PaUtilBufferProcessor* bufferProcessor );
|
|
||||||
|
|
||||||
/** Retrieve the output latency of a buffer processor, in frames.
|
|
||||||
|
|
||||||
@param bufferProcessor The buffer processor examine.
|
|
||||||
|
|
||||||
@return The output latency introduced by the buffer processor, in frames.
|
|
||||||
|
|
||||||
@see PaUtil_GetBufferProcessorInputLatencyFrames
|
|
||||||
*/
|
|
||||||
unsigned long PaUtil_GetBufferProcessorOutputLatencyFrames( PaUtilBufferProcessor* bufferProcessor );
|
|
||||||
|
|
||||||
/*@}*/
|
|
||||||
|
|
||||||
|
|
||||||
/** @name Host buffer pointer configuration
|
|
||||||
|
|
||||||
Functions to set host input and output buffers, used by both callback streams
|
|
||||||
and blocking read/write streams.
|
|
||||||
*/
|
|
||||||
/*@{*/
|
|
||||||
|
|
||||||
|
|
||||||
/** Set the number of frames in the input host buffer(s) specified by the
|
|
||||||
PaUtil_Set*InputChannel functions.
|
|
||||||
|
|
||||||
@param bufferProcessor The buffer processor.
|
|
||||||
|
|
||||||
@param frameCount The number of host input frames. A 0 frameCount indicates to
|
|
||||||
use the framesPerHostBuffer value passed to PaUtil_InitializeBufferProcessor.
|
|
||||||
|
|
||||||
@see PaUtil_SetNoInput, PaUtil_SetInputChannel,
|
|
||||||
PaUtil_SetInterleavedInputChannels, PaUtil_SetNonInterleavedInputChannel
|
|
||||||
*/
|
|
||||||
void PaUtil_SetInputFrameCount( PaUtilBufferProcessor* bufferProcessor,
|
|
||||||
unsigned long frameCount );
|
|
||||||
|
|
||||||
|
|
||||||
/** Indicate that no input is available. This function should be used when
|
|
||||||
priming the output of a full-duplex stream opened with the
|
|
||||||
paPrimeOutputBuffersUsingStreamCallback flag. Note that it is not necessary
|
|
||||||
to call this or any other PaUtil_Set*Input* functions for ouput-only streams.
|
|
||||||
|
|
||||||
@param bufferProcessor The buffer processor.
|
|
||||||
*/
|
|
||||||
void PaUtil_SetNoInput( PaUtilBufferProcessor* bufferProcessor );
|
|
||||||
|
|
||||||
|
|
||||||
/** Provide the buffer processor with a pointer to a host input channel.
|
|
||||||
|
|
||||||
@param bufferProcessor The buffer processor.
|
|
||||||
@param channel The channel number.
|
|
||||||
@param data The buffer.
|
|
||||||
@param stride The stride from one sample to the next, in samples. For
|
|
||||||
interleaved host buffers, the stride will usually be the same as the number of
|
|
||||||
channels in the buffer.
|
|
||||||
*/
|
|
||||||
void PaUtil_SetInputChannel( PaUtilBufferProcessor* bufferProcessor,
|
|
||||||
unsigned int channel, void *data, unsigned int stride );
|
|
||||||
|
|
||||||
|
|
||||||
/** Provide the buffer processor with a pointer to an number of interleaved
|
|
||||||
host input channels.
|
|
||||||
|
|
||||||
@param bufferProcessor The buffer processor.
|
|
||||||
@param firstChannel The first channel number.
|
|
||||||
@param data The buffer.
|
|
||||||
@param channelCount The number of interleaved channels in the buffer. If
|
|
||||||
channelCount is zero, the number of channels specified to
|
|
||||||
PaUtil_InitializeBufferProcessor will be used.
|
|
||||||
*/
|
|
||||||
void PaUtil_SetInterleavedInputChannels( PaUtilBufferProcessor* bufferProcessor,
|
|
||||||
unsigned int firstChannel, void *data, unsigned int channelCount );
|
|
||||||
|
|
||||||
|
|
||||||
/** Provide the buffer processor with a pointer to one non-interleaved host
|
|
||||||
output channel.
|
|
||||||
|
|
||||||
@param bufferProcessor The buffer processor.
|
|
||||||
@param channel The channel number.
|
|
||||||
@param data The buffer.
|
|
||||||
*/
|
|
||||||
void PaUtil_SetNonInterleavedInputChannel( PaUtilBufferProcessor* bufferProcessor,
|
|
||||||
unsigned int channel, void *data );
|
|
||||||
|
|
||||||
|
|
||||||
/** Use for the second buffer half when the input buffer is split in two halves.
|
|
||||||
@see PaUtil_SetInputFrameCount
|
|
||||||
*/
|
|
||||||
void PaUtil_Set2ndInputFrameCount( PaUtilBufferProcessor* bufferProcessor,
|
|
||||||
unsigned long frameCount );
|
|
||||||
|
|
||||||
/** Use for the second buffer half when the input buffer is split in two halves.
|
|
||||||
@see PaUtil_SetInputChannel
|
|
||||||
*/
|
|
||||||
void PaUtil_Set2ndInputChannel( PaUtilBufferProcessor* bufferProcessor,
|
|
||||||
unsigned int channel, void *data, unsigned int stride );
|
|
||||||
|
|
||||||
/** Use for the second buffer half when the input buffer is split in two halves.
|
|
||||||
@see PaUtil_SetInterleavedInputChannels
|
|
||||||
*/
|
|
||||||
void PaUtil_Set2ndInterleavedInputChannels( PaUtilBufferProcessor* bufferProcessor,
|
|
||||||
unsigned int firstChannel, void *data, unsigned int channelCount );
|
|
||||||
|
|
||||||
/** Use for the second buffer half when the input buffer is split in two halves.
|
|
||||||
@see PaUtil_SetNonInterleavedInputChannel
|
|
||||||
*/
|
|
||||||
void PaUtil_Set2ndNonInterleavedInputChannel( PaUtilBufferProcessor* bufferProcessor,
|
|
||||||
unsigned int channel, void *data );
|
|
||||||
|
|
||||||
|
|
||||||
/** Set the number of frames in the output host buffer(s) specified by the
|
|
||||||
PaUtil_Set*OutputChannel functions.
|
|
||||||
|
|
||||||
@param bufferProcessor The buffer processor.
|
|
||||||
|
|
||||||
@param frameCount The number of host output frames. A 0 frameCount indicates to
|
|
||||||
use the framesPerHostBuffer value passed to PaUtil_InitializeBufferProcessor.
|
|
||||||
|
|
||||||
@see PaUtil_SetOutputChannel, PaUtil_SetInterleavedOutputChannels,
|
|
||||||
PaUtil_SetNonInterleavedOutputChannel
|
|
||||||
*/
|
|
||||||
void PaUtil_SetOutputFrameCount( PaUtilBufferProcessor* bufferProcessor,
|
|
||||||
unsigned long frameCount );
|
|
||||||
|
|
||||||
|
|
||||||
/** Indicate that the output will be discarded. This function should be used
|
|
||||||
when implementing the paNeverDropInput mode for full duplex streams.
|
|
||||||
|
|
||||||
@param bufferProcessor The buffer processor.
|
|
||||||
*/
|
|
||||||
void PaUtil_SetNoOutput( PaUtilBufferProcessor* bufferProcessor );
|
|
||||||
|
|
||||||
|
|
||||||
/** Provide the buffer processor with a pointer to a host output channel.
|
|
||||||
|
|
||||||
@param bufferProcessor The buffer processor.
|
|
||||||
@param channel The channel number.
|
|
||||||
@param data The buffer.
|
|
||||||
@param stride The stride from one sample to the next, in samples. For
|
|
||||||
interleaved host buffers, the stride will usually be the same as the number of
|
|
||||||
channels in the buffer.
|
|
||||||
*/
|
|
||||||
void PaUtil_SetOutputChannel( PaUtilBufferProcessor* bufferProcessor,
|
|
||||||
unsigned int channel, void *data, unsigned int stride );
|
|
||||||
|
|
||||||
|
|
||||||
/** Provide the buffer processor with a pointer to a number of interleaved
|
|
||||||
host output channels.
|
|
||||||
|
|
||||||
@param bufferProcessor The buffer processor.
|
|
||||||
@param firstChannel The first channel number.
|
|
||||||
@param data The buffer.
|
|
||||||
@param channelCount The number of interleaved channels in the buffer. If
|
|
||||||
channelCount is zero, the number of channels specified to
|
|
||||||
PaUtil_InitializeBufferProcessor will be used.
|
|
||||||
*/
|
|
||||||
void PaUtil_SetInterleavedOutputChannels( PaUtilBufferProcessor* bufferProcessor,
|
|
||||||
unsigned int firstChannel, void *data, unsigned int channelCount );
|
|
||||||
|
|
||||||
|
|
||||||
/** Provide the buffer processor with a pointer to one non-interleaved host
|
|
||||||
output channel.
|
|
||||||
|
|
||||||
@param bufferProcessor The buffer processor.
|
|
||||||
@param channel The channel number.
|
|
||||||
@param data The buffer.
|
|
||||||
*/
|
|
||||||
void PaUtil_SetNonInterleavedOutputChannel( PaUtilBufferProcessor* bufferProcessor,
|
|
||||||
unsigned int channel, void *data );
|
|
||||||
|
|
||||||
|
|
||||||
/** Use for the second buffer half when the output buffer is split in two halves.
|
|
||||||
@see PaUtil_SetOutputFrameCount
|
|
||||||
*/
|
|
||||||
void PaUtil_Set2ndOutputFrameCount( PaUtilBufferProcessor* bufferProcessor,
|
|
||||||
unsigned long frameCount );
|
|
||||||
|
|
||||||
/** Use for the second buffer half when the output buffer is split in two halves.
|
|
||||||
@see PaUtil_SetOutputChannel
|
|
||||||
*/
|
|
||||||
void PaUtil_Set2ndOutputChannel( PaUtilBufferProcessor* bufferProcessor,
|
|
||||||
unsigned int channel, void *data, unsigned int stride );
|
|
||||||
|
|
||||||
/** Use for the second buffer half when the output buffer is split in two halves.
|
|
||||||
@see PaUtil_SetInterleavedOutputChannels
|
|
||||||
*/
|
|
||||||
void PaUtil_Set2ndInterleavedOutputChannels( PaUtilBufferProcessor* bufferProcessor,
|
|
||||||
unsigned int firstChannel, void *data, unsigned int channelCount );
|
|
||||||
|
|
||||||
/** Use for the second buffer half when the output buffer is split in two halves.
|
|
||||||
@see PaUtil_SetNonInterleavedOutputChannel
|
|
||||||
*/
|
|
||||||
void PaUtil_Set2ndNonInterleavedOutputChannel( PaUtilBufferProcessor* bufferProcessor,
|
|
||||||
unsigned int channel, void *data );
|
|
||||||
|
|
||||||
/*@}*/
|
|
||||||
|
|
||||||
|
|
||||||
/** @name Buffer processing functions for callback streams
|
|
||||||
*/
|
|
||||||
/*@{*/
|
|
||||||
|
|
||||||
/** Commence processing a host buffer (or a pair of host buffers in the
|
|
||||||
full-duplex case) for a callback stream.
|
|
||||||
|
|
||||||
@param bufferProcessor The buffer processor.
|
|
||||||
|
|
||||||
@param timeInfo Timing information for the first sample of the host
|
|
||||||
buffer(s). This information may be adjusted when buffer adaption is being
|
|
||||||
performed.
|
|
||||||
|
|
||||||
@param callbackStatusFlags Flags indicating whether underruns and overruns
|
|
||||||
have occurred since the last time the buffer processor was called.
|
|
||||||
*/
|
|
||||||
void PaUtil_BeginBufferProcessing( PaUtilBufferProcessor* bufferProcessor,
|
|
||||||
PaStreamCallbackTimeInfo* timeInfo, PaStreamCallbackFlags callbackStatusFlags );
|
|
||||||
|
|
||||||
|
|
||||||
/** Finish processing a host buffer (or a pair of host buffers in the
|
|
||||||
full-duplex case) for a callback stream.
|
|
||||||
|
|
||||||
@param bufferProcessor The buffer processor.
|
|
||||||
|
|
||||||
@param callbackResult On input, indicates a previous callback result, and on
|
|
||||||
exit, the result of the user stream callback, if it is called.
|
|
||||||
On entry callbackResult should contain one of { paContinue, paComplete, or
|
|
||||||
paAbort}. If paComplete is passed, the stream callback will not be called
|
|
||||||
but any audio that was generated by previous stream callbacks will be copied
|
|
||||||
to the output buffer(s). You can check whether the buffer processor's internal
|
|
||||||
buffer is empty by calling PaUtil_IsBufferProcessorOutputEmpty.
|
|
||||||
|
|
||||||
If the stream callback is called its result is stored in *callbackResult. If
|
|
||||||
the stream callback returns paComplete or paAbort, all output buffers will be
|
|
||||||
full of valid data - some of which may be zeros to account for data that
|
|
||||||
wasn't generated by the terminating callback.
|
|
||||||
|
|
||||||
@return The number of frames processed. This usually corresponds to the
|
|
||||||
number of frames specified by the PaUtil_Set*FrameCount functions, except in
|
|
||||||
the paUtilVariableHostBufferSizePartialUsageAllowed buffer size mode when a
|
|
||||||
smaller value may be returned.
|
|
||||||
*/
|
|
||||||
unsigned long PaUtil_EndBufferProcessing( PaUtilBufferProcessor* bufferProcessor,
|
|
||||||
int *callbackResult );
|
|
||||||
|
|
||||||
|
|
||||||
/** Determine whether any callback generated output remains in the buffer
|
|
||||||
processor's internal buffers. This method may be used to determine when to
|
|
||||||
continue calling PaUtil_EndBufferProcessing() after the callback has returned
|
|
||||||
a callbackResult of paComplete.
|
|
||||||
|
|
||||||
@param bufferProcessor The buffer processor.
|
|
||||||
|
|
||||||
@return Returns non-zero when callback generated output remains in the internal
|
|
||||||
buffer and zero (0) when there internal buffer contains no callback generated
|
|
||||||
data.
|
|
||||||
*/
|
|
||||||
int PaUtil_IsBufferProcessorOutputEmpty( PaUtilBufferProcessor* bufferProcessor );
|
|
||||||
|
|
||||||
/*@}*/
|
|
||||||
|
|
||||||
|
|
||||||
/** @name Buffer processing functions for blocking read/write streams
|
|
||||||
*/
|
|
||||||
/*@{*/
|
|
||||||
|
|
||||||
/** Copy samples from host input channels set up by the PaUtil_Set*InputChannels
|
|
||||||
functions to a user supplied buffer. This function is intended for use with
|
|
||||||
blocking read/write streams. Copies the minimum of the number of
|
|
||||||
user frames (specified by the frameCount parameter) and the number of available
|
|
||||||
host frames (specified in a previous call to SetInputFrameCount()).
|
|
||||||
|
|
||||||
@param bufferProcessor The buffer processor.
|
|
||||||
|
|
||||||
@param buffer A pointer to the user buffer pointer, or a pointer to a pointer
|
|
||||||
to an array of user buffer pointers for a non-interleaved stream. It is
|
|
||||||
important that this parameter points to a copy of the user buffer pointers,
|
|
||||||
not to the actual user buffer pointers, because this function updates the
|
|
||||||
pointers before returning.
|
|
||||||
|
|
||||||
@param frameCount The number of frames of data in the buffer(s) pointed to by
|
|
||||||
the buffer parameter.
|
|
||||||
|
|
||||||
@return The number of frames copied. The buffer pointer(s) pointed to by the
|
|
||||||
buffer parameter are advanced to point to the frame(s) following the last one
|
|
||||||
filled.
|
|
||||||
*/
|
|
||||||
unsigned long PaUtil_CopyInput( PaUtilBufferProcessor* bufferProcessor,
|
|
||||||
void **buffer, unsigned long frameCount );
|
|
||||||
|
|
||||||
|
|
||||||
/* Copy samples from a user supplied buffer to host output channels set up by
|
|
||||||
the PaUtil_Set*OutputChannels functions. This function is intended for use with
|
|
||||||
blocking read/write streams. Copies the minimum of the number of
|
|
||||||
user frames (specified by the frameCount parameter) and the number of
|
|
||||||
host frames (specified in a previous call to SetOutputFrameCount()).
|
|
||||||
|
|
||||||
@param bufferProcessor The buffer processor.
|
|
||||||
|
|
||||||
@param buffer A pointer to the user buffer pointer, or a pointer to a pointer
|
|
||||||
to an array of user buffer pointers for a non-interleaved stream. It is
|
|
||||||
important that this parameter points to a copy of the user buffer pointers,
|
|
||||||
not to the actual user buffer pointers, because this function updates the
|
|
||||||
pointers before returning.
|
|
||||||
|
|
||||||
@param frameCount The number of frames of data in the buffer(s) pointed to by
|
|
||||||
the buffer parameter.
|
|
||||||
|
|
||||||
@return The number of frames copied. The buffer pointer(s) pointed to by the
|
|
||||||
buffer parameter are advanced to point to the frame(s) following the last one
|
|
||||||
copied.
|
|
||||||
*/
|
|
||||||
unsigned long PaUtil_CopyOutput( PaUtilBufferProcessor* bufferProcessor,
|
|
||||||
const void ** buffer, unsigned long frameCount );
|
|
||||||
|
|
||||||
|
|
||||||
/* Zero samples in host output channels set up by the PaUtil_Set*OutputChannels
|
|
||||||
functions. This function is useful for flushing streams.
|
|
||||||
Zeros the minimum of frameCount and the number of host frames specified in a
|
|
||||||
previous call to SetOutputFrameCount().
|
|
||||||
|
|
||||||
@param bufferProcessor The buffer processor.
|
|
||||||
|
|
||||||
@param frameCount The maximum number of frames to zero.
|
|
||||||
|
|
||||||
@return The number of frames zeroed.
|
|
||||||
*/
|
|
||||||
unsigned long PaUtil_ZeroOutput( PaUtilBufferProcessor* bufferProcessor,
|
|
||||||
unsigned long frameCount );
|
|
||||||
|
|
||||||
|
|
||||||
/*@}*/
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif /* __cplusplus */
|
|
||||||
#endif /* PA_PROCESS_H */
|
|
237
third_party/portAudio/src/common/pa_ringbuffer.c
vendored
237
third_party/portAudio/src/common/pa_ringbuffer.c
vendored
@ -1,237 +0,0 @@
|
|||||||
/*
|
|
||||||
* $Id$
|
|
||||||
* Portable Audio I/O Library
|
|
||||||
* Ring Buffer utility.
|
|
||||||
*
|
|
||||||
* Author: Phil Burk, http://www.softsynth.com
|
|
||||||
* modified for SMP safety on Mac OS X by Bjorn Roche
|
|
||||||
* modified for SMP safety on Linux by Leland Lucius
|
|
||||||
* also, allowed for const where possible
|
|
||||||
* modified for multiple-byte-sized data elements by Sven Fischer
|
|
||||||
*
|
|
||||||
* Note that this is safe only for a single-thread reader and a
|
|
||||||
* single-thread writer.
|
|
||||||
*
|
|
||||||
* This program uses the PortAudio Portable Audio Library.
|
|
||||||
* For more information see: http://www.portaudio.com
|
|
||||||
* Copyright (c) 1999-2000 Ross Bencina and Phil Burk
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files
|
|
||||||
* (the "Software"), to deal in the Software without restriction,
|
|
||||||
* including without limitation the rights to use, copy, modify, merge,
|
|
||||||
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
||||||
* and to permit persons to whom the Software is furnished to do so,
|
|
||||||
* subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be
|
|
||||||
* included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
||||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
|
|
||||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
|
||||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The text above constitutes the entire PortAudio license; however,
|
|
||||||
* the PortAudio community also makes the following non-binding requests:
|
|
||||||
*
|
|
||||||
* Any person wishing to distribute modifications to the Software is
|
|
||||||
* requested to send the modifications to the original developer so that
|
|
||||||
* they can be incorporated into the canonical version. It is also
|
|
||||||
* requested that these non-binding requests be included along with the
|
|
||||||
* license above.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
@file
|
|
||||||
@ingroup common_src
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <math.h>
|
|
||||||
#include "pa_ringbuffer.h"
|
|
||||||
#include <string.h>
|
|
||||||
#include "pa_memorybarrier.h"
|
|
||||||
|
|
||||||
/***************************************************************************
|
|
||||||
* Initialize FIFO.
|
|
||||||
* elementCount must be power of 2, returns -1 if not.
|
|
||||||
*/
|
|
||||||
ring_buffer_size_t PaUtil_InitializeRingBuffer( PaUtilRingBuffer *rbuf, ring_buffer_size_t elementSizeBytes, ring_buffer_size_t elementCount, void *dataPtr )
|
|
||||||
{
|
|
||||||
if( ((elementCount-1) & elementCount) != 0) return -1; /* Not Power of two. */
|
|
||||||
rbuf->bufferSize = elementCount;
|
|
||||||
rbuf->buffer = (char *)dataPtr;
|
|
||||||
PaUtil_FlushRingBuffer( rbuf );
|
|
||||||
rbuf->bigMask = (elementCount*2)-1;
|
|
||||||
rbuf->smallMask = (elementCount)-1;
|
|
||||||
rbuf->elementSizeBytes = elementSizeBytes;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***************************************************************************
|
|
||||||
** Return number of elements available for reading. */
|
|
||||||
ring_buffer_size_t PaUtil_GetRingBufferReadAvailable( const PaUtilRingBuffer *rbuf )
|
|
||||||
{
|
|
||||||
return ( (rbuf->writeIndex - rbuf->readIndex) & rbuf->bigMask );
|
|
||||||
}
|
|
||||||
/***************************************************************************
|
|
||||||
** Return number of elements available for writing. */
|
|
||||||
ring_buffer_size_t PaUtil_GetRingBufferWriteAvailable( const PaUtilRingBuffer *rbuf )
|
|
||||||
{
|
|
||||||
return ( rbuf->bufferSize - PaUtil_GetRingBufferReadAvailable(rbuf));
|
|
||||||
}
|
|
||||||
|
|
||||||
/***************************************************************************
|
|
||||||
** Clear buffer. Should only be called when buffer is NOT being read or written. */
|
|
||||||
void PaUtil_FlushRingBuffer( PaUtilRingBuffer *rbuf )
|
|
||||||
{
|
|
||||||
rbuf->writeIndex = rbuf->readIndex = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***************************************************************************
|
|
||||||
** Get address of region(s) to which we can write data.
|
|
||||||
** If the region is contiguous, size2 will be zero.
|
|
||||||
** If non-contiguous, size2 will be the size of second region.
|
|
||||||
** Returns room available to be written or elementCount, whichever is smaller.
|
|
||||||
*/
|
|
||||||
ring_buffer_size_t PaUtil_GetRingBufferWriteRegions( PaUtilRingBuffer *rbuf, ring_buffer_size_t elementCount,
|
|
||||||
void **dataPtr1, ring_buffer_size_t *sizePtr1,
|
|
||||||
void **dataPtr2, ring_buffer_size_t *sizePtr2 )
|
|
||||||
{
|
|
||||||
ring_buffer_size_t index;
|
|
||||||
ring_buffer_size_t available = PaUtil_GetRingBufferWriteAvailable( rbuf );
|
|
||||||
if( elementCount > available ) elementCount = available;
|
|
||||||
/* Check to see if write is not contiguous. */
|
|
||||||
index = rbuf->writeIndex & rbuf->smallMask;
|
|
||||||
if( (index + elementCount) > rbuf->bufferSize )
|
|
||||||
{
|
|
||||||
/* Write data in two blocks that wrap the buffer. */
|
|
||||||
ring_buffer_size_t firstHalf = rbuf->bufferSize - index;
|
|
||||||
*dataPtr1 = &rbuf->buffer[index*rbuf->elementSizeBytes];
|
|
||||||
*sizePtr1 = firstHalf;
|
|
||||||
*dataPtr2 = &rbuf->buffer[0];
|
|
||||||
*sizePtr2 = elementCount - firstHalf;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
*dataPtr1 = &rbuf->buffer[index*rbuf->elementSizeBytes];
|
|
||||||
*sizePtr1 = elementCount;
|
|
||||||
*dataPtr2 = NULL;
|
|
||||||
*sizePtr2 = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( available )
|
|
||||||
PaUtil_FullMemoryBarrier(); /* (write-after-read) => full barrier */
|
|
||||||
|
|
||||||
return elementCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************************
|
|
||||||
*/
|
|
||||||
ring_buffer_size_t PaUtil_AdvanceRingBufferWriteIndex( PaUtilRingBuffer *rbuf, ring_buffer_size_t elementCount )
|
|
||||||
{
|
|
||||||
/* ensure that previous writes are seen before we update the write index
|
|
||||||
(write after write)
|
|
||||||
*/
|
|
||||||
PaUtil_WriteMemoryBarrier();
|
|
||||||
return rbuf->writeIndex = (rbuf->writeIndex + elementCount) & rbuf->bigMask;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***************************************************************************
|
|
||||||
** Get address of region(s) from which we can read data.
|
|
||||||
** If the region is contiguous, size2 will be zero.
|
|
||||||
** If non-contiguous, size2 will be the size of second region.
|
|
||||||
** Returns room available to be read or elementCount, whichever is smaller.
|
|
||||||
*/
|
|
||||||
ring_buffer_size_t PaUtil_GetRingBufferReadRegions( PaUtilRingBuffer *rbuf, ring_buffer_size_t elementCount,
|
|
||||||
void **dataPtr1, ring_buffer_size_t *sizePtr1,
|
|
||||||
void **dataPtr2, ring_buffer_size_t *sizePtr2 )
|
|
||||||
{
|
|
||||||
ring_buffer_size_t index;
|
|
||||||
ring_buffer_size_t available = PaUtil_GetRingBufferReadAvailable( rbuf ); /* doesn't use memory barrier */
|
|
||||||
if( elementCount > available ) elementCount = available;
|
|
||||||
/* Check to see if read is not contiguous. */
|
|
||||||
index = rbuf->readIndex & rbuf->smallMask;
|
|
||||||
if( (index + elementCount) > rbuf->bufferSize )
|
|
||||||
{
|
|
||||||
/* Write data in two blocks that wrap the buffer. */
|
|
||||||
ring_buffer_size_t firstHalf = rbuf->bufferSize - index;
|
|
||||||
*dataPtr1 = &rbuf->buffer[index*rbuf->elementSizeBytes];
|
|
||||||
*sizePtr1 = firstHalf;
|
|
||||||
*dataPtr2 = &rbuf->buffer[0];
|
|
||||||
*sizePtr2 = elementCount - firstHalf;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
*dataPtr1 = &rbuf->buffer[index*rbuf->elementSizeBytes];
|
|
||||||
*sizePtr1 = elementCount;
|
|
||||||
*dataPtr2 = NULL;
|
|
||||||
*sizePtr2 = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( available )
|
|
||||||
PaUtil_ReadMemoryBarrier(); /* (read-after-read) => read barrier */
|
|
||||||
|
|
||||||
return elementCount;
|
|
||||||
}
|
|
||||||
/***************************************************************************
|
|
||||||
*/
|
|
||||||
ring_buffer_size_t PaUtil_AdvanceRingBufferReadIndex( PaUtilRingBuffer *rbuf, ring_buffer_size_t elementCount )
|
|
||||||
{
|
|
||||||
/* ensure that previous reads (copies out of the ring buffer) are always completed before updating (writing) the read index.
|
|
||||||
(write-after-read) => full barrier
|
|
||||||
*/
|
|
||||||
PaUtil_FullMemoryBarrier();
|
|
||||||
return rbuf->readIndex = (rbuf->readIndex + elementCount) & rbuf->bigMask;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***************************************************************************
|
|
||||||
** Return elements written. */
|
|
||||||
ring_buffer_size_t PaUtil_WriteRingBuffer( PaUtilRingBuffer *rbuf, const void *data, ring_buffer_size_t elementCount )
|
|
||||||
{
|
|
||||||
ring_buffer_size_t size1, size2, numWritten;
|
|
||||||
void *data1, *data2;
|
|
||||||
numWritten = PaUtil_GetRingBufferWriteRegions( rbuf, elementCount, &data1, &size1, &data2, &size2 );
|
|
||||||
if( size2 > 0 )
|
|
||||||
{
|
|
||||||
|
|
||||||
memcpy( data1, data, size1*rbuf->elementSizeBytes );
|
|
||||||
data = ((char *)data) + size1*rbuf->elementSizeBytes;
|
|
||||||
memcpy( data2, data, size2*rbuf->elementSizeBytes );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
memcpy( data1, data, size1*rbuf->elementSizeBytes );
|
|
||||||
}
|
|
||||||
PaUtil_AdvanceRingBufferWriteIndex( rbuf, numWritten );
|
|
||||||
return numWritten;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***************************************************************************
|
|
||||||
** Return elements read. */
|
|
||||||
ring_buffer_size_t PaUtil_ReadRingBuffer( PaUtilRingBuffer *rbuf, void *data, ring_buffer_size_t elementCount )
|
|
||||||
{
|
|
||||||
ring_buffer_size_t size1, size2, numRead;
|
|
||||||
void *data1, *data2;
|
|
||||||
numRead = PaUtil_GetRingBufferReadRegions( rbuf, elementCount, &data1, &size1, &data2, &size2 );
|
|
||||||
if( size2 > 0 )
|
|
||||||
{
|
|
||||||
memcpy( data, data1, size1*rbuf->elementSizeBytes );
|
|
||||||
data = ((char *)data) + size1*rbuf->elementSizeBytes;
|
|
||||||
memcpy( data, data2, size2*rbuf->elementSizeBytes );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
memcpy( data, data1, size1*rbuf->elementSizeBytes );
|
|
||||||
}
|
|
||||||
PaUtil_AdvanceRingBufferReadIndex( rbuf, numRead );
|
|
||||||
return numRead;
|
|
||||||
}
|
|
236
third_party/portAudio/src/common/pa_ringbuffer.h
vendored
236
third_party/portAudio/src/common/pa_ringbuffer.h
vendored
@ -1,236 +0,0 @@
|
|||||||
#ifndef PA_RINGBUFFER_H
|
|
||||||
#define PA_RINGBUFFER_H
|
|
||||||
/*
|
|
||||||
* $Id$
|
|
||||||
* Portable Audio I/O Library
|
|
||||||
* Ring Buffer utility.
|
|
||||||
*
|
|
||||||
* Author: Phil Burk, http://www.softsynth.com
|
|
||||||
* modified for SMP safety on OS X by Bjorn Roche.
|
|
||||||
* also allowed for const where possible.
|
|
||||||
* modified for multiple-byte-sized data elements by Sven Fischer
|
|
||||||
*
|
|
||||||
* Note that this is safe only for a single-thread reader
|
|
||||||
* and a single-thread writer.
|
|
||||||
*
|
|
||||||
* This program is distributed with the PortAudio Portable Audio Library.
|
|
||||||
* For more information see: http://www.portaudio.com
|
|
||||||
* Copyright (c) 1999-2000 Ross Bencina and Phil Burk
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files
|
|
||||||
* (the "Software"), to deal in the Software without restriction,
|
|
||||||
* including without limitation the rights to use, copy, modify, merge,
|
|
||||||
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
||||||
* and to permit persons to whom the Software is furnished to do so,
|
|
||||||
* subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be
|
|
||||||
* included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
||||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
|
|
||||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
|
||||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The text above constitutes the entire PortAudio license; however,
|
|
||||||
* the PortAudio community also makes the following non-binding requests:
|
|
||||||
*
|
|
||||||
* Any person wishing to distribute modifications to the Software is
|
|
||||||
* requested to send the modifications to the original developer so that
|
|
||||||
* they can be incorporated into the canonical version. It is also
|
|
||||||
* requested that these non-binding requests be included along with the
|
|
||||||
* license above.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @file
|
|
||||||
@ingroup common_src
|
|
||||||
@brief Single-reader single-writer lock-free ring buffer
|
|
||||||
|
|
||||||
PaUtilRingBuffer is a ring buffer used to transport samples between
|
|
||||||
different execution contexts (threads, OS callbacks, interrupt handlers)
|
|
||||||
without requiring the use of any locks. This only works when there is
|
|
||||||
a single reader and a single writer (ie. one thread or callback writes
|
|
||||||
to the ring buffer, another thread or callback reads from it).
|
|
||||||
|
|
||||||
The PaUtilRingBuffer structure manages a ring buffer containing N
|
|
||||||
elements, where N must be a power of two. An element may be any size
|
|
||||||
(specified in bytes).
|
|
||||||
|
|
||||||
The memory area used to store the buffer elements must be allocated by
|
|
||||||
the client prior to calling PaUtil_InitializeRingBuffer() and must outlive
|
|
||||||
the use of the ring buffer.
|
|
||||||
|
|
||||||
@note The ring buffer functions are not normally exposed in the PortAudio libraries.
|
|
||||||
If you want to call them then you will need to add pa_ringbuffer.c to your application source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if defined(__APPLE__)
|
|
||||||
#include <sys/types.h>
|
|
||||||
typedef int32_t ring_buffer_size_t;
|
|
||||||
#elif defined( __GNUC__ )
|
|
||||||
typedef long ring_buffer_size_t;
|
|
||||||
#elif (_MSC_VER >= 1400)
|
|
||||||
typedef long ring_buffer_size_t;
|
|
||||||
#elif defined(_MSC_VER) || defined(__BORLANDC__)
|
|
||||||
typedef long ring_buffer_size_t;
|
|
||||||
#else
|
|
||||||
typedef long ring_buffer_size_t;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#endif /* __cplusplus */
|
|
||||||
|
|
||||||
typedef struct PaUtilRingBuffer
|
|
||||||
{
|
|
||||||
ring_buffer_size_t bufferSize; /**< Number of elements in FIFO. Power of 2. Set by PaUtil_InitRingBuffer. */
|
|
||||||
volatile ring_buffer_size_t writeIndex; /**< Index of next writable element. Set by PaUtil_AdvanceRingBufferWriteIndex. */
|
|
||||||
volatile ring_buffer_size_t readIndex; /**< Index of next readable element. Set by PaUtil_AdvanceRingBufferReadIndex. */
|
|
||||||
ring_buffer_size_t bigMask; /**< Used for wrapping indices with extra bit to distinguish full/empty. */
|
|
||||||
ring_buffer_size_t smallMask; /**< Used for fitting indices to buffer. */
|
|
||||||
ring_buffer_size_t elementSizeBytes; /**< Number of bytes per element. */
|
|
||||||
char *buffer; /**< Pointer to the buffer containing the actual data. */
|
|
||||||
}PaUtilRingBuffer;
|
|
||||||
|
|
||||||
/** Initialize Ring Buffer to empty state ready to have elements written to it.
|
|
||||||
|
|
||||||
@param rbuf The ring buffer.
|
|
||||||
|
|
||||||
@param elementSizeBytes The size of a single data element in bytes.
|
|
||||||
|
|
||||||
@param elementCount The number of elements in the buffer (must be a power of 2).
|
|
||||||
|
|
||||||
@param dataPtr A pointer to a previously allocated area where the data
|
|
||||||
will be maintained. It must be elementCount*elementSizeBytes long.
|
|
||||||
|
|
||||||
@return -1 if elementCount is not a power of 2, otherwise 0.
|
|
||||||
*/
|
|
||||||
ring_buffer_size_t PaUtil_InitializeRingBuffer( PaUtilRingBuffer *rbuf, ring_buffer_size_t elementSizeBytes, ring_buffer_size_t elementCount, void *dataPtr );
|
|
||||||
|
|
||||||
/** Reset buffer to empty. Should only be called when buffer is NOT being read or written.
|
|
||||||
|
|
||||||
@param rbuf The ring buffer.
|
|
||||||
*/
|
|
||||||
void PaUtil_FlushRingBuffer( PaUtilRingBuffer *rbuf );
|
|
||||||
|
|
||||||
/** Retrieve the number of elements available in the ring buffer for writing.
|
|
||||||
|
|
||||||
@param rbuf The ring buffer.
|
|
||||||
|
|
||||||
@return The number of elements available for writing.
|
|
||||||
*/
|
|
||||||
ring_buffer_size_t PaUtil_GetRingBufferWriteAvailable( const PaUtilRingBuffer *rbuf );
|
|
||||||
|
|
||||||
/** Retrieve the number of elements available in the ring buffer for reading.
|
|
||||||
|
|
||||||
@param rbuf The ring buffer.
|
|
||||||
|
|
||||||
@return The number of elements available for reading.
|
|
||||||
*/
|
|
||||||
ring_buffer_size_t PaUtil_GetRingBufferReadAvailable( const PaUtilRingBuffer *rbuf );
|
|
||||||
|
|
||||||
/** Write data to the ring buffer.
|
|
||||||
|
|
||||||
@param rbuf The ring buffer.
|
|
||||||
|
|
||||||
@param data The address of new data to write to the buffer.
|
|
||||||
|
|
||||||
@param elementCount The number of elements to be written.
|
|
||||||
|
|
||||||
@return The number of elements written.
|
|
||||||
*/
|
|
||||||
ring_buffer_size_t PaUtil_WriteRingBuffer( PaUtilRingBuffer *rbuf, const void *data, ring_buffer_size_t elementCount );
|
|
||||||
|
|
||||||
/** Read data from the ring buffer.
|
|
||||||
|
|
||||||
@param rbuf The ring buffer.
|
|
||||||
|
|
||||||
@param data The address where the data should be stored.
|
|
||||||
|
|
||||||
@param elementCount The number of elements to be read.
|
|
||||||
|
|
||||||
@return The number of elements read.
|
|
||||||
*/
|
|
||||||
ring_buffer_size_t PaUtil_ReadRingBuffer( PaUtilRingBuffer *rbuf, void *data, ring_buffer_size_t elementCount );
|
|
||||||
|
|
||||||
/** Get address of region(s) to which we can write data.
|
|
||||||
|
|
||||||
@param rbuf The ring buffer.
|
|
||||||
|
|
||||||
@param elementCount The number of elements desired.
|
|
||||||
|
|
||||||
@param dataPtr1 The address where the first (or only) region pointer will be
|
|
||||||
stored.
|
|
||||||
|
|
||||||
@param sizePtr1 The address where the first (or only) region length will be
|
|
||||||
stored.
|
|
||||||
|
|
||||||
@param dataPtr2 The address where the second region pointer will be stored if
|
|
||||||
the first region is too small to satisfy elementCount.
|
|
||||||
|
|
||||||
@param sizePtr2 The address where the second region length will be stored if
|
|
||||||
the first region is too small to satisfy elementCount.
|
|
||||||
|
|
||||||
@return The room available to be written or elementCount, whichever is smaller.
|
|
||||||
*/
|
|
||||||
ring_buffer_size_t PaUtil_GetRingBufferWriteRegions( PaUtilRingBuffer *rbuf, ring_buffer_size_t elementCount,
|
|
||||||
void **dataPtr1, ring_buffer_size_t *sizePtr1,
|
|
||||||
void **dataPtr2, ring_buffer_size_t *sizePtr2 );
|
|
||||||
|
|
||||||
/** Advance the write index to the next location to be written.
|
|
||||||
|
|
||||||
@param rbuf The ring buffer.
|
|
||||||
|
|
||||||
@param elementCount The number of elements to advance.
|
|
||||||
|
|
||||||
@return The new position.
|
|
||||||
*/
|
|
||||||
ring_buffer_size_t PaUtil_AdvanceRingBufferWriteIndex( PaUtilRingBuffer *rbuf, ring_buffer_size_t elementCount );
|
|
||||||
|
|
||||||
/** Get address of region(s) from which we can read data.
|
|
||||||
|
|
||||||
@param rbuf The ring buffer.
|
|
||||||
|
|
||||||
@param elementCount The number of elements desired.
|
|
||||||
|
|
||||||
@param dataPtr1 The address where the first (or only) region pointer will be
|
|
||||||
stored.
|
|
||||||
|
|
||||||
@param sizePtr1 The address where the first (or only) region length will be
|
|
||||||
stored.
|
|
||||||
|
|
||||||
@param dataPtr2 The address where the second region pointer will be stored if
|
|
||||||
the first region is too small to satisfy elementCount.
|
|
||||||
|
|
||||||
@param sizePtr2 The address where the second region length will be stored if
|
|
||||||
the first region is too small to satisfy elementCount.
|
|
||||||
|
|
||||||
@return The number of elements available for reading.
|
|
||||||
*/
|
|
||||||
ring_buffer_size_t PaUtil_GetRingBufferReadRegions( PaUtilRingBuffer *rbuf, ring_buffer_size_t elementCount,
|
|
||||||
void **dataPtr1, ring_buffer_size_t *sizePtr1,
|
|
||||||
void **dataPtr2, ring_buffer_size_t *sizePtr2 );
|
|
||||||
|
|
||||||
/** Advance the read index to the next location to be read.
|
|
||||||
|
|
||||||
@param rbuf The ring buffer.
|
|
||||||
|
|
||||||
@param elementCount The number of elements to advance.
|
|
||||||
|
|
||||||
@return The new position.
|
|
||||||
*/
|
|
||||||
ring_buffer_size_t PaUtil_AdvanceRingBufferReadIndex( PaUtilRingBuffer *rbuf, ring_buffer_size_t elementCount );
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif /* __cplusplus */
|
|
||||||
#endif /* PA_RINGBUFFER_H */
|
|
150
third_party/portAudio/src/common/pa_stream.c
vendored
150
third_party/portAudio/src/common/pa_stream.c
vendored
@ -1,150 +0,0 @@
|
|||||||
/*
|
|
||||||
* $Id$
|
|
||||||
* Portable Audio I/O Library
|
|
||||||
* stream interface
|
|
||||||
*
|
|
||||||
* Based on the Open Source API proposed by Ross Bencina
|
|
||||||
* Copyright (c) 2008 Ross Bencina
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files
|
|
||||||
* (the "Software"), to deal in the Software without restriction,
|
|
||||||
* including without limitation the rights to use, copy, modify, merge,
|
|
||||||
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
||||||
* and to permit persons to whom the Software is furnished to do so,
|
|
||||||
* subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be
|
|
||||||
* included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
||||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
|
|
||||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
|
||||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The text above constitutes the entire PortAudio license; however,
|
|
||||||
* the PortAudio community also makes the following non-binding requests:
|
|
||||||
*
|
|
||||||
* Any person wishing to distribute modifications to the Software is
|
|
||||||
* requested to send the modifications to the original developer so that
|
|
||||||
* they can be incorporated into the canonical version. It is also
|
|
||||||
* requested that these non-binding requests be included along with the
|
|
||||||
* license above.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @file
|
|
||||||
@ingroup common_src
|
|
||||||
|
|
||||||
@brief Stream interfaces, representation structures and helper functions
|
|
||||||
used to interface between pa_front.c host API implementations.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include "pa_stream.h"
|
|
||||||
|
|
||||||
|
|
||||||
void PaUtil_InitializeStreamInterface( PaUtilStreamInterface *streamInterface,
|
|
||||||
PaError (*Close)( PaStream* ),
|
|
||||||
PaError (*Start)( PaStream* ),
|
|
||||||
PaError (*Stop)( PaStream* ),
|
|
||||||
PaError (*Abort)( PaStream* ),
|
|
||||||
PaError (*IsStopped)( PaStream* ),
|
|
||||||
PaError (*IsActive)( PaStream* ),
|
|
||||||
PaTime (*GetTime)( PaStream* ),
|
|
||||||
double (*GetCpuLoad)( PaStream* ),
|
|
||||||
PaError (*Read)( PaStream*, void *, unsigned long ),
|
|
||||||
PaError (*Write)( PaStream*, const void *, unsigned long ),
|
|
||||||
signed long (*GetReadAvailable)( PaStream* ),
|
|
||||||
signed long (*GetWriteAvailable)( PaStream* ) )
|
|
||||||
{
|
|
||||||
streamInterface->Close = Close;
|
|
||||||
streamInterface->Start = Start;
|
|
||||||
streamInterface->Stop = Stop;
|
|
||||||
streamInterface->Abort = Abort;
|
|
||||||
streamInterface->IsStopped = IsStopped;
|
|
||||||
streamInterface->IsActive = IsActive;
|
|
||||||
streamInterface->GetTime = GetTime;
|
|
||||||
streamInterface->GetCpuLoad = GetCpuLoad;
|
|
||||||
streamInterface->Read = Read;
|
|
||||||
streamInterface->Write = Write;
|
|
||||||
streamInterface->GetReadAvailable = GetReadAvailable;
|
|
||||||
streamInterface->GetWriteAvailable = GetWriteAvailable;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void PaUtil_InitializeStreamRepresentation( PaUtilStreamRepresentation *streamRepresentation,
|
|
||||||
PaUtilStreamInterface *streamInterface,
|
|
||||||
PaStreamCallback *streamCallback,
|
|
||||||
void *userData )
|
|
||||||
{
|
|
||||||
streamRepresentation->magic = PA_STREAM_MAGIC;
|
|
||||||
streamRepresentation->nextOpenStream = 0;
|
|
||||||
streamRepresentation->streamInterface = streamInterface;
|
|
||||||
streamRepresentation->streamCallback = streamCallback;
|
|
||||||
streamRepresentation->streamFinishedCallback = 0;
|
|
||||||
|
|
||||||
streamRepresentation->userData = userData;
|
|
||||||
|
|
||||||
streamRepresentation->streamInfo.inputLatency = 0.;
|
|
||||||
streamRepresentation->streamInfo.outputLatency = 0.;
|
|
||||||
streamRepresentation->streamInfo.sampleRate = 0.;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void PaUtil_TerminateStreamRepresentation( PaUtilStreamRepresentation *streamRepresentation )
|
|
||||||
{
|
|
||||||
streamRepresentation->magic = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
PaError PaUtil_DummyRead( PaStream* stream,
|
|
||||||
void *buffer,
|
|
||||||
unsigned long frames )
|
|
||||||
{
|
|
||||||
(void)stream; /* unused parameter */
|
|
||||||
(void)buffer; /* unused parameter */
|
|
||||||
(void)frames; /* unused parameter */
|
|
||||||
|
|
||||||
return paCanNotReadFromACallbackStream;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
PaError PaUtil_DummyWrite( PaStream* stream,
|
|
||||||
const void *buffer,
|
|
||||||
unsigned long frames )
|
|
||||||
{
|
|
||||||
(void)stream; /* unused parameter */
|
|
||||||
(void)buffer; /* unused parameter */
|
|
||||||
(void)frames; /* unused parameter */
|
|
||||||
|
|
||||||
return paCanNotWriteToACallbackStream;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
signed long PaUtil_DummyGetReadAvailable( PaStream* stream )
|
|
||||||
{
|
|
||||||
(void)stream; /* unused parameter */
|
|
||||||
|
|
||||||
return paCanNotReadFromACallbackStream;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
signed long PaUtil_DummyGetWriteAvailable( PaStream* stream )
|
|
||||||
{
|
|
||||||
(void)stream; /* unused parameter */
|
|
||||||
|
|
||||||
return paCanNotWriteToACallbackStream;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
double PaUtil_DummyGetCpuLoad( PaStream* stream )
|
|
||||||
{
|
|
||||||
(void)stream; /* unused parameter */
|
|
||||||
|
|
||||||
return 0.0;
|
|
||||||
}
|
|
205
third_party/portAudio/src/common/pa_stream.h
vendored
205
third_party/portAudio/src/common/pa_stream.h
vendored
@ -1,205 +0,0 @@
|
|||||||
#ifndef PA_STREAM_H
|
|
||||||
#define PA_STREAM_H
|
|
||||||
/*
|
|
||||||
* $Id$
|
|
||||||
* Portable Audio I/O Library
|
|
||||||
* stream interface
|
|
||||||
*
|
|
||||||
* Based on the Open Source API proposed by Ross Bencina
|
|
||||||
* Copyright (c) 1999-2008 Ross Bencina, Phil Burk
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files
|
|
||||||
* (the "Software"), to deal in the Software without restriction,
|
|
||||||
* including without limitation the rights to use, copy, modify, merge,
|
|
||||||
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
||||||
* and to permit persons to whom the Software is furnished to do so,
|
|
||||||
* subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be
|
|
||||||
* included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
||||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
|
|
||||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
|
||||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The text above constitutes the entire PortAudio license; however,
|
|
||||||
* the PortAudio community also makes the following non-binding requests:
|
|
||||||
*
|
|
||||||
* Any person wishing to distribute modifications to the Software is
|
|
||||||
* requested to send the modifications to the original developer so that
|
|
||||||
* they can be incorporated into the canonical version. It is also
|
|
||||||
* requested that these non-binding requests be included along with the
|
|
||||||
* license above.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @file
|
|
||||||
@ingroup common_src
|
|
||||||
|
|
||||||
@brief Stream interfaces, representation structures and helper functions
|
|
||||||
used to interface between pa_front.c host API implementations.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include "portaudio.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#endif /* __cplusplus */
|
|
||||||
|
|
||||||
|
|
||||||
#define PA_STREAM_MAGIC (0x18273645)
|
|
||||||
|
|
||||||
|
|
||||||
/** A structure representing an (abstract) interface to a host API. Contains
|
|
||||||
pointers to functions which implement the interface.
|
|
||||||
|
|
||||||
All PaStreamInterface functions are guaranteed to be called with a non-null,
|
|
||||||
valid stream parameter.
|
|
||||||
*/
|
|
||||||
typedef struct {
|
|
||||||
PaError (*Close)( PaStream* stream );
|
|
||||||
PaError (*Start)( PaStream *stream );
|
|
||||||
PaError (*Stop)( PaStream *stream );
|
|
||||||
PaError (*Abort)( PaStream *stream );
|
|
||||||
PaError (*IsStopped)( PaStream *stream );
|
|
||||||
PaError (*IsActive)( PaStream *stream );
|
|
||||||
PaTime (*GetTime)( PaStream *stream );
|
|
||||||
double (*GetCpuLoad)( PaStream* stream );
|
|
||||||
PaError (*Read)( PaStream* stream, void *buffer, unsigned long frames );
|
|
||||||
PaError (*Write)( PaStream* stream, const void *buffer, unsigned long frames );
|
|
||||||
signed long (*GetReadAvailable)( PaStream* stream );
|
|
||||||
signed long (*GetWriteAvailable)( PaStream* stream );
|
|
||||||
} PaUtilStreamInterface;
|
|
||||||
|
|
||||||
|
|
||||||
/** Initialize the fields of a PaUtilStreamInterface structure.
|
|
||||||
*/
|
|
||||||
void PaUtil_InitializeStreamInterface( PaUtilStreamInterface *streamInterface,
|
|
||||||
PaError (*Close)( PaStream* ),
|
|
||||||
PaError (*Start)( PaStream* ),
|
|
||||||
PaError (*Stop)( PaStream* ),
|
|
||||||
PaError (*Abort)( PaStream* ),
|
|
||||||
PaError (*IsStopped)( PaStream* ),
|
|
||||||
PaError (*IsActive)( PaStream* ),
|
|
||||||
PaTime (*GetTime)( PaStream* ),
|
|
||||||
double (*GetCpuLoad)( PaStream* ),
|
|
||||||
PaError (*Read)( PaStream* stream, void *buffer, unsigned long frames ),
|
|
||||||
PaError (*Write)( PaStream* stream, const void *buffer, unsigned long frames ),
|
|
||||||
signed long (*GetReadAvailable)( PaStream* stream ),
|
|
||||||
signed long (*GetWriteAvailable)( PaStream* stream ) );
|
|
||||||
|
|
||||||
|
|
||||||
/** Dummy Read function for use in interfaces to a callback based streams.
|
|
||||||
Pass to the Read parameter of PaUtil_InitializeStreamInterface.
|
|
||||||
@return An error code indicating that the function has no effect
|
|
||||||
because the stream is a callback stream.
|
|
||||||
*/
|
|
||||||
PaError PaUtil_DummyRead( PaStream* stream,
|
|
||||||
void *buffer,
|
|
||||||
unsigned long frames );
|
|
||||||
|
|
||||||
|
|
||||||
/** Dummy Write function for use in an interfaces to callback based streams.
|
|
||||||
Pass to the Write parameter of PaUtil_InitializeStreamInterface.
|
|
||||||
@return An error code indicating that the function has no effect
|
|
||||||
because the stream is a callback stream.
|
|
||||||
*/
|
|
||||||
PaError PaUtil_DummyWrite( PaStream* stream,
|
|
||||||
const void *buffer,
|
|
||||||
unsigned long frames );
|
|
||||||
|
|
||||||
|
|
||||||
/** Dummy GetReadAvailable function for use in interfaces to callback based
|
|
||||||
streams. Pass to the GetReadAvailable parameter of PaUtil_InitializeStreamInterface.
|
|
||||||
@return An error code indicating that the function has no effect
|
|
||||||
because the stream is a callback stream.
|
|
||||||
*/
|
|
||||||
signed long PaUtil_DummyGetReadAvailable( PaStream* stream );
|
|
||||||
|
|
||||||
|
|
||||||
/** Dummy GetWriteAvailable function for use in interfaces to callback based
|
|
||||||
streams. Pass to the GetWriteAvailable parameter of PaUtil_InitializeStreamInterface.
|
|
||||||
@return An error code indicating that the function has no effect
|
|
||||||
because the stream is a callback stream.
|
|
||||||
*/
|
|
||||||
signed long PaUtil_DummyGetWriteAvailable( PaStream* stream );
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** Dummy GetCpuLoad function for use in an interface to a read/write stream.
|
|
||||||
Pass to the GetCpuLoad parameter of PaUtil_InitializeStreamInterface.
|
|
||||||
@return Returns 0.
|
|
||||||
*/
|
|
||||||
double PaUtil_DummyGetCpuLoad( PaStream* stream );
|
|
||||||
|
|
||||||
|
|
||||||
/** Non host specific data for a stream. This data is used by pa_front to
|
|
||||||
forward to the appropriate functions in the streamInterface structure.
|
|
||||||
*/
|
|
||||||
typedef struct PaUtilStreamRepresentation {
|
|
||||||
unsigned long magic; /**< set to PA_STREAM_MAGIC */
|
|
||||||
struct PaUtilStreamRepresentation *nextOpenStream; /**< field used by multi-api code */
|
|
||||||
PaUtilStreamInterface *streamInterface;
|
|
||||||
PaStreamCallback *streamCallback;
|
|
||||||
PaStreamFinishedCallback *streamFinishedCallback;
|
|
||||||
void *userData;
|
|
||||||
PaStreamInfo streamInfo;
|
|
||||||
} PaUtilStreamRepresentation;
|
|
||||||
|
|
||||||
|
|
||||||
/** Initialize a PaUtilStreamRepresentation structure.
|
|
||||||
|
|
||||||
@see PaUtil_InitializeStreamRepresentation
|
|
||||||
*/
|
|
||||||
void PaUtil_InitializeStreamRepresentation(
|
|
||||||
PaUtilStreamRepresentation *streamRepresentation,
|
|
||||||
PaUtilStreamInterface *streamInterface,
|
|
||||||
PaStreamCallback *streamCallback,
|
|
||||||
void *userData );
|
|
||||||
|
|
||||||
|
|
||||||
/** Clean up a PaUtilStreamRepresentation structure previously initialized
|
|
||||||
by a call to PaUtil_InitializeStreamRepresentation.
|
|
||||||
|
|
||||||
@see PaUtil_InitializeStreamRepresentation
|
|
||||||
*/
|
|
||||||
void PaUtil_TerminateStreamRepresentation( PaUtilStreamRepresentation *streamRepresentation );
|
|
||||||
|
|
||||||
|
|
||||||
/** Check that the stream pointer is valid.
|
|
||||||
|
|
||||||
@return Returns paNoError if the stream pointer appears to be OK, otherwise
|
|
||||||
returns an error indicating the cause of failure.
|
|
||||||
*/
|
|
||||||
PaError PaUtil_ValidateStreamPointer( PaStream *stream );
|
|
||||||
|
|
||||||
|
|
||||||
/** Cast an opaque stream pointer into a pointer to a PaUtilStreamRepresentation.
|
|
||||||
|
|
||||||
@see PaUtilStreamRepresentation
|
|
||||||
*/
|
|
||||||
#define PA_STREAM_REP( stream )\
|
|
||||||
((PaUtilStreamRepresentation*) (stream) )
|
|
||||||
|
|
||||||
|
|
||||||
/** Cast an opaque stream pointer into a pointer to a PaUtilStreamInterface.
|
|
||||||
|
|
||||||
@see PaUtilStreamRepresentation, PaUtilStreamInterface
|
|
||||||
*/
|
|
||||||
#define PA_STREAM_INTERFACE( stream )\
|
|
||||||
PA_STREAM_REP( (stream) )->streamInterface
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif /* __cplusplus */
|
|
||||||
#endif /* PA_STREAM_H */
|
|
238
third_party/portAudio/src/common/pa_trace.c
vendored
238
third_party/portAudio/src/common/pa_trace.c
vendored
@ -1,238 +0,0 @@
|
|||||||
/*
|
|
||||||
* $Id$
|
|
||||||
* Portable Audio I/O Library Trace Facility
|
|
||||||
* Store trace information in real-time for later printing.
|
|
||||||
*
|
|
||||||
* Based on the Open Source API proposed by Ross Bencina
|
|
||||||
* Copyright (c) 1999-2000 Phil Burk
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files
|
|
||||||
* (the "Software"), to deal in the Software without restriction,
|
|
||||||
* including without limitation the rights to use, copy, modify, merge,
|
|
||||||
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
||||||
* and to permit persons to whom the Software is furnished to do so,
|
|
||||||
* subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be
|
|
||||||
* included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
||||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
|
|
||||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
|
||||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The text above constitutes the entire PortAudio license; however,
|
|
||||||
* the PortAudio community also makes the following non-binding requests:
|
|
||||||
*
|
|
||||||
* Any person wishing to distribute modifications to the Software is
|
|
||||||
* requested to send the modifications to the original developer so that
|
|
||||||
* they can be incorporated into the canonical version. It is also
|
|
||||||
* requested that these non-binding requests be included along with the
|
|
||||||
* license above.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @file
|
|
||||||
@ingroup common_src
|
|
||||||
|
|
||||||
@brief Real-time safe event trace logging facility for debugging.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdarg.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <assert.h>
|
|
||||||
#include "pa_trace.h"
|
|
||||||
#include "pa_util.h"
|
|
||||||
#include "pa_debugprint.h"
|
|
||||||
|
|
||||||
#if PA_TRACE_REALTIME_EVENTS
|
|
||||||
|
|
||||||
static char const *traceTextArray[PA_MAX_TRACE_RECORDS];
|
|
||||||
static int traceIntArray[PA_MAX_TRACE_RECORDS];
|
|
||||||
static int traceIndex = 0;
|
|
||||||
static int traceBlock = 0;
|
|
||||||
|
|
||||||
/*********************************************************************/
|
|
||||||
void PaUtil_ResetTraceMessages()
|
|
||||||
{
|
|
||||||
traceIndex = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*********************************************************************/
|
|
||||||
void PaUtil_DumpTraceMessages()
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
int messageCount = (traceIndex < PA_MAX_TRACE_RECORDS) ? traceIndex : PA_MAX_TRACE_RECORDS;
|
|
||||||
|
|
||||||
printf("DumpTraceMessages: traceIndex = %d\n", traceIndex );
|
|
||||||
for( i=0; i<messageCount; i++ )
|
|
||||||
{
|
|
||||||
printf("%3d: %s = 0x%08X\n",
|
|
||||||
i, traceTextArray[i], traceIntArray[i] );
|
|
||||||
}
|
|
||||||
PaUtil_ResetTraceMessages();
|
|
||||||
fflush(stdout);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*********************************************************************/
|
|
||||||
void PaUtil_AddTraceMessage( const char *msg, int data )
|
|
||||||
{
|
|
||||||
if( (traceIndex == PA_MAX_TRACE_RECORDS) && (traceBlock == 0) )
|
|
||||||
{
|
|
||||||
traceBlock = 1;
|
|
||||||
/* PaUtil_DumpTraceMessages(); */
|
|
||||||
}
|
|
||||||
else if( traceIndex < PA_MAX_TRACE_RECORDS )
|
|
||||||
{
|
|
||||||
traceTextArray[traceIndex] = msg;
|
|
||||||
traceIntArray[traceIndex] = data;
|
|
||||||
traceIndex++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/************************************************************************/
|
|
||||||
/* High performance log alternative */
|
|
||||||
/************************************************************************/
|
|
||||||
|
|
||||||
typedef unsigned long long PaUint64;
|
|
||||||
|
|
||||||
typedef struct __PaHighPerformanceLog
|
|
||||||
{
|
|
||||||
unsigned magik;
|
|
||||||
int writePtr;
|
|
||||||
int readPtr;
|
|
||||||
int size;
|
|
||||||
double refTime;
|
|
||||||
char* data;
|
|
||||||
} PaHighPerformanceLog;
|
|
||||||
|
|
||||||
static const unsigned kMagik = 0xcafebabe;
|
|
||||||
|
|
||||||
#define USEC_PER_SEC (1000000ULL)
|
|
||||||
|
|
||||||
int PaUtil_InitializeHighSpeedLog( LogHandle* phLog, unsigned maxSizeInBytes )
|
|
||||||
{
|
|
||||||
PaHighPerformanceLog* pLog = (PaHighPerformanceLog*)PaUtil_AllocateMemory(sizeof(PaHighPerformanceLog));
|
|
||||||
if (pLog == 0)
|
|
||||||
{
|
|
||||||
return paInsufficientMemory;
|
|
||||||
}
|
|
||||||
assert(phLog != 0);
|
|
||||||
*phLog = pLog;
|
|
||||||
|
|
||||||
pLog->data = (char*)PaUtil_AllocateMemory(maxSizeInBytes);
|
|
||||||
if (pLog->data == 0)
|
|
||||||
{
|
|
||||||
PaUtil_FreeMemory(pLog);
|
|
||||||
return paInsufficientMemory;
|
|
||||||
}
|
|
||||||
pLog->magik = kMagik;
|
|
||||||
pLog->size = maxSizeInBytes;
|
|
||||||
pLog->refTime = PaUtil_GetTime();
|
|
||||||
return paNoError;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PaUtil_ResetHighSpeedLogTimeRef( LogHandle hLog )
|
|
||||||
{
|
|
||||||
PaHighPerformanceLog* pLog = (PaHighPerformanceLog*)hLog;
|
|
||||||
assert(pLog->magik == kMagik);
|
|
||||||
pLog->refTime = PaUtil_GetTime();
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef struct __PaLogEntryHeader
|
|
||||||
{
|
|
||||||
int size;
|
|
||||||
double timeStamp;
|
|
||||||
} PaLogEntryHeader;
|
|
||||||
|
|
||||||
#ifdef __APPLE__
|
|
||||||
#define _vsnprintf vsnprintf
|
|
||||||
#define min(a,b) ((a)<(b)?(a):(b))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
int PaUtil_AddHighSpeedLogMessage( LogHandle hLog, const char* fmt, ... )
|
|
||||||
{
|
|
||||||
va_list l;
|
|
||||||
int n = 0;
|
|
||||||
PaHighPerformanceLog* pLog = (PaHighPerformanceLog*)hLog;
|
|
||||||
if (pLog != 0)
|
|
||||||
{
|
|
||||||
PaLogEntryHeader* pHeader;
|
|
||||||
char* p;
|
|
||||||
int maxN;
|
|
||||||
assert(pLog->magik == kMagik);
|
|
||||||
pHeader = (PaLogEntryHeader*)( pLog->data + pLog->writePtr );
|
|
||||||
p = (char*)( pHeader + 1 );
|
|
||||||
maxN = pLog->size - pLog->writePtr - 2 * sizeof(PaLogEntryHeader);
|
|
||||||
|
|
||||||
pHeader->timeStamp = PaUtil_GetTime() - pLog->refTime;
|
|
||||||
if (maxN > 0)
|
|
||||||
{
|
|
||||||
if (maxN > 32)
|
|
||||||
{
|
|
||||||
va_start(l, fmt);
|
|
||||||
n = _vsnprintf(p, min(1024, maxN), fmt, l);
|
|
||||||
va_end(l);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
n = sprintf(p, "End of log...");
|
|
||||||
}
|
|
||||||
n = ((n + sizeof(unsigned)) & ~(sizeof(unsigned)-1)) + sizeof(PaLogEntryHeader);
|
|
||||||
pHeader->size = n;
|
|
||||||
#if 0
|
|
||||||
PaUtil_DebugPrint("%05u.%03u: %s\n", pHeader->timeStamp/1000, pHeader->timeStamp%1000, p);
|
|
||||||
#endif
|
|
||||||
pLog->writePtr += n;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return n;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PaUtil_DumpHighSpeedLog( LogHandle hLog, const char* fileName )
|
|
||||||
{
|
|
||||||
FILE* f = (fileName != NULL) ? fopen(fileName, "w") : stdout;
|
|
||||||
unsigned localWritePtr;
|
|
||||||
PaHighPerformanceLog* pLog = (PaHighPerformanceLog*)hLog;
|
|
||||||
assert(pLog->magik == kMagik);
|
|
||||||
localWritePtr = pLog->writePtr;
|
|
||||||
while (pLog->readPtr != localWritePtr)
|
|
||||||
{
|
|
||||||
const PaLogEntryHeader* pHeader = (const PaLogEntryHeader*)( pLog->data + pLog->readPtr );
|
|
||||||
const char* p = (const char*)( pHeader + 1 );
|
|
||||||
const PaUint64 ts = (const PaUint64)( pHeader->timeStamp * USEC_PER_SEC );
|
|
||||||
assert(pHeader->size < (1024+sizeof(unsigned)+sizeof(PaLogEntryHeader)));
|
|
||||||
fprintf(f, "%05u.%03u: %s\n", (unsigned)(ts/1000), (unsigned)(ts%1000), p);
|
|
||||||
pLog->readPtr += pHeader->size;
|
|
||||||
}
|
|
||||||
if (f != stdout)
|
|
||||||
{
|
|
||||||
fclose(f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void PaUtil_DiscardHighSpeedLog( LogHandle hLog )
|
|
||||||
{
|
|
||||||
PaHighPerformanceLog* pLog = (PaHighPerformanceLog*)hLog;
|
|
||||||
assert(pLog->magik == kMagik);
|
|
||||||
PaUtil_FreeMemory(pLog->data);
|
|
||||||
PaUtil_FreeMemory(pLog);
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
/* This stub was added so that this file will generate a symbol.
|
|
||||||
* Otherwise linker/archiver programs will complain.
|
|
||||||
*/
|
|
||||||
int PaUtil_TraceStubToSatisfyLinker(void)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif /* TRACE_REALTIME_EVENTS */
|
|
117
third_party/portAudio/src/common/pa_trace.h
vendored
117
third_party/portAudio/src/common/pa_trace.h
vendored
@ -1,117 +0,0 @@
|
|||||||
#ifndef PA_TRACE_H
|
|
||||||
#define PA_TRACE_H
|
|
||||||
/*
|
|
||||||
* $Id$
|
|
||||||
* Portable Audio I/O Library Trace Facility
|
|
||||||
* Store trace information in real-time for later printing.
|
|
||||||
*
|
|
||||||
* Based on the Open Source API proposed by Ross Bencina
|
|
||||||
* Copyright (c) 1999-2000 Phil Burk
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files
|
|
||||||
* (the "Software"), to deal in the Software without restriction,
|
|
||||||
* including without limitation the rights to use, copy, modify, merge,
|
|
||||||
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
||||||
* and to permit persons to whom the Software is furnished to do so,
|
|
||||||
* subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be
|
|
||||||
* included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
||||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
|
|
||||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
|
||||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The text above constitutes the entire PortAudio license; however,
|
|
||||||
* the PortAudio community also makes the following non-binding requests:
|
|
||||||
*
|
|
||||||
* Any person wishing to distribute modifications to the Software is
|
|
||||||
* requested to send the modifications to the original developer so that
|
|
||||||
* they can be incorporated into the canonical version. It is also
|
|
||||||
* requested that these non-binding requests be included along with the
|
|
||||||
* license above.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @file
|
|
||||||
@ingroup common_src
|
|
||||||
|
|
||||||
@brief Real-time safe event trace logging facility for debugging.
|
|
||||||
|
|
||||||
Allows data to be logged to a fixed size trace buffer in a real-time
|
|
||||||
execution context (such as at interrupt time). Each log entry consists
|
|
||||||
of a message comprising a string pointer and an int. The trace buffer
|
|
||||||
may be dumped to stdout later.
|
|
||||||
|
|
||||||
This facility is only active if PA_TRACE_REALTIME_EVENTS is set to 1,
|
|
||||||
otherwise the trace functions expand to no-ops.
|
|
||||||
|
|
||||||
@fn PaUtil_ResetTraceMessages
|
|
||||||
@brief Clear the trace buffer.
|
|
||||||
|
|
||||||
@fn PaUtil_AddTraceMessage
|
|
||||||
@brief Add a message to the trace buffer. A message consists of string and an int.
|
|
||||||
@param msg The string pointer must remain valid until PaUtil_DumpTraceMessages
|
|
||||||
is called. As a result, usually only string literals should be passed as
|
|
||||||
the msg parameter.
|
|
||||||
|
|
||||||
@fn PaUtil_DumpTraceMessages
|
|
||||||
@brief Print all messages in the trace buffer to stdout and clear the trace buffer.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef PA_TRACE_REALTIME_EVENTS
|
|
||||||
#define PA_TRACE_REALTIME_EVENTS (0) /**< Set to 1 to enable logging using the trace functions defined below */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef PA_MAX_TRACE_RECORDS
|
|
||||||
#define PA_MAX_TRACE_RECORDS (2048) /**< Maximum number of records stored in trace buffer */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#endif /* __cplusplus */
|
|
||||||
|
|
||||||
|
|
||||||
#if PA_TRACE_REALTIME_EVENTS
|
|
||||||
|
|
||||||
void PaUtil_ResetTraceMessages();
|
|
||||||
void PaUtil_AddTraceMessage( const char *msg, int data );
|
|
||||||
void PaUtil_DumpTraceMessages();
|
|
||||||
|
|
||||||
/* Alternative interface */
|
|
||||||
|
|
||||||
typedef void* LogHandle;
|
|
||||||
|
|
||||||
int PaUtil_InitializeHighSpeedLog(LogHandle* phLog, unsigned maxSizeInBytes);
|
|
||||||
void PaUtil_ResetHighSpeedLogTimeRef(LogHandle hLog);
|
|
||||||
int PaUtil_AddHighSpeedLogMessage(LogHandle hLog, const char* fmt, ...);
|
|
||||||
void PaUtil_DumpHighSpeedLog(LogHandle hLog, const char* fileName);
|
|
||||||
void PaUtil_DiscardHighSpeedLog(LogHandle hLog);
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
#define PaUtil_ResetTraceMessages() /* noop */
|
|
||||||
#define PaUtil_AddTraceMessage(msg,data) /* noop */
|
|
||||||
#define PaUtil_DumpTraceMessages() /* noop */
|
|
||||||
|
|
||||||
#define PaUtil_InitializeHighSpeedLog(phLog, maxSizeInBytes) (0)
|
|
||||||
#define PaUtil_ResetHighSpeedLogTimeRef(hLog)
|
|
||||||
#define PaUtil_AddHighSpeedLogMessage(...) (0)
|
|
||||||
#define PaUtil_DumpHighSpeedLog(hLog, fileName)
|
|
||||||
#define PaUtil_DiscardHighSpeedLog(hLog)
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif /* __cplusplus */
|
|
||||||
|
|
||||||
#endif /* PA_TRACE_H */
|
|
107
third_party/portAudio/src/common/pa_types.h
vendored
107
third_party/portAudio/src/common/pa_types.h
vendored
@ -1,107 +0,0 @@
|
|||||||
#ifndef PA_TYPES_H
|
|
||||||
#define PA_TYPES_H
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Portable Audio I/O Library
|
|
||||||
* integer type definitions
|
|
||||||
*
|
|
||||||
* Based on the Open Source API proposed by Ross Bencina
|
|
||||||
* Copyright (c) 1999-2006 Ross Bencina, Phil Burk
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files
|
|
||||||
* (the "Software"), to deal in the Software without restriction,
|
|
||||||
* including without limitation the rights to use, copy, modify, merge,
|
|
||||||
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
||||||
* and to permit persons to whom the Software is furnished to do so,
|
|
||||||
* subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be
|
|
||||||
* included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
||||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
|
|
||||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
|
||||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The text above constitutes the entire PortAudio license; however,
|
|
||||||
* the PortAudio community also makes the following non-binding requests:
|
|
||||||
*
|
|
||||||
* Any person wishing to distribute modifications to the Software is
|
|
||||||
* requested to send the modifications to the original developer so that
|
|
||||||
* they can be incorporated into the canonical version. It is also
|
|
||||||
* requested that these non-binding requests be included along with the
|
|
||||||
* license above.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @file
|
|
||||||
@ingroup common_src
|
|
||||||
|
|
||||||
@brief Definition of 16 and 32 bit integer types (PaInt16, PaInt32 etc)
|
|
||||||
|
|
||||||
SIZEOF_SHORT, SIZEOF_INT and SIZEOF_LONG are set by the configure script
|
|
||||||
when it is used. Otherwise we default to the common 32 bit values, if your
|
|
||||||
platform doesn't use configure, and doesn't use the default values below
|
|
||||||
you will need to explicitly define these symbols in your make file.
|
|
||||||
|
|
||||||
A PA_VALIDATE_SIZES macro is provided to assert that the values set in this
|
|
||||||
file are correct.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef SIZEOF_SHORT
|
|
||||||
#define SIZEOF_SHORT 2
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef SIZEOF_INT
|
|
||||||
#define SIZEOF_INT 4
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef SIZEOF_LONG
|
|
||||||
#define SIZEOF_LONG 4
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#if SIZEOF_SHORT == 2
|
|
||||||
typedef signed short PaInt16;
|
|
||||||
typedef unsigned short PaUint16;
|
|
||||||
#elif SIZEOF_INT == 2
|
|
||||||
typedef signed int PaInt16;
|
|
||||||
typedef unsigned int PaUint16;
|
|
||||||
#else
|
|
||||||
#error pa_types.h was unable to determine which type to use for 16bit integers on the target platform
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if SIZEOF_SHORT == 4
|
|
||||||
typedef signed short PaInt32;
|
|
||||||
typedef unsigned short PaUint32;
|
|
||||||
#elif SIZEOF_INT == 4
|
|
||||||
typedef signed int PaInt32;
|
|
||||||
typedef unsigned int PaUint32;
|
|
||||||
#elif SIZEOF_LONG == 4
|
|
||||||
typedef signed long PaInt32;
|
|
||||||
typedef unsigned long PaUint32;
|
|
||||||
#else
|
|
||||||
#error pa_types.h was unable to determine which type to use for 32bit integers on the target platform
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/* PA_VALIDATE_TYPE_SIZES compares the size of the integer types at runtime to
|
|
||||||
ensure that PortAudio was configured correctly, and raises an assertion if
|
|
||||||
they don't match the expected values. <assert.h> must be included in the
|
|
||||||
context in which this macro is used.
|
|
||||||
*/
|
|
||||||
#define PA_VALIDATE_TYPE_SIZES \
|
|
||||||
{ \
|
|
||||||
assert( "PortAudio: type sizes are not correct in pa_types.h" && sizeof( PaUint16 ) == 2 ); \
|
|
||||||
assert( "PortAudio: type sizes are not correct in pa_types.h" && sizeof( PaInt16 ) == 2 ); \
|
|
||||||
assert( "PortAudio: type sizes are not correct in pa_types.h" && sizeof( PaUint32 ) == 4 ); \
|
|
||||||
assert( "PortAudio: type sizes are not correct in pa_types.h" && sizeof( PaInt32 ) == 4 ); \
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* PA_TYPES_H */
|
|
159
third_party/portAudio/src/common/pa_util.h
vendored
159
third_party/portAudio/src/common/pa_util.h
vendored
@ -1,159 +0,0 @@
|
|||||||
#ifndef PA_UTIL_H
|
|
||||||
#define PA_UTIL_H
|
|
||||||
/*
|
|
||||||
* $Id$
|
|
||||||
* Portable Audio I/O Library implementation utilities header
|
|
||||||
* common implementation utilities and interfaces
|
|
||||||
*
|
|
||||||
* Based on the Open Source API proposed by Ross Bencina
|
|
||||||
* Copyright (c) 1999-2008 Ross Bencina, Phil Burk
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files
|
|
||||||
* (the "Software"), to deal in the Software without restriction,
|
|
||||||
* including without limitation the rights to use, copy, modify, merge,
|
|
||||||
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
||||||
* and to permit persons to whom the Software is furnished to do so,
|
|
||||||
* subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be
|
|
||||||
* included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
||||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
|
|
||||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
|
||||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The text above constitutes the entire PortAudio license; however,
|
|
||||||
* the PortAudio community also makes the following non-binding requests:
|
|
||||||
*
|
|
||||||
* Any person wishing to distribute modifications to the Software is
|
|
||||||
* requested to send the modifications to the original developer so that
|
|
||||||
* they can be incorporated into the canonical version. It is also
|
|
||||||
* requested that these non-binding requests be included along with the
|
|
||||||
* license above.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @file
|
|
||||||
@ingroup common_src
|
|
||||||
|
|
||||||
@brief Prototypes for utility functions used by PortAudio implementations.
|
|
||||||
|
|
||||||
Some functions declared here are defined in pa_front.c while others
|
|
||||||
are implemented separately for each platform.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include "portaudio.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#endif /* __cplusplus */
|
|
||||||
|
|
||||||
|
|
||||||
struct PaUtilHostApiRepresentation;
|
|
||||||
|
|
||||||
|
|
||||||
/** Retrieve a specific host API representation. This function can be used
|
|
||||||
by implementations to retrieve a pointer to their representation in
|
|
||||||
host api specific extension functions which aren't passed a rep pointer
|
|
||||||
by pa_front.c.
|
|
||||||
|
|
||||||
@param hostApi A pointer to a host API representation pointer. Upon success
|
|
||||||
this will receive the requested representation pointer.
|
|
||||||
|
|
||||||
@param type A valid host API type identifier.
|
|
||||||
|
|
||||||
@returns An error code. If the result is PaNoError then a pointer to the
|
|
||||||
requested host API representation will be stored in *hostApi. If the host API
|
|
||||||
specified by type is not found, this function returns paHostApiNotFound.
|
|
||||||
*/
|
|
||||||
PaError PaUtil_GetHostApiRepresentation( struct PaUtilHostApiRepresentation **hostApi,
|
|
||||||
PaHostApiTypeId type );
|
|
||||||
|
|
||||||
|
|
||||||
/** Convert a PortAudio device index into a host API specific device index.
|
|
||||||
@param hostApiDevice Pointer to a device index, on success this will receive the
|
|
||||||
converted device index value.
|
|
||||||
@param device The PortAudio device index to convert.
|
|
||||||
@param hostApi The host api which the index should be converted for.
|
|
||||||
|
|
||||||
@returns On success returns PaNoError and places the converted index in the
|
|
||||||
hostApiDevice parameter.
|
|
||||||
*/
|
|
||||||
PaError PaUtil_DeviceIndexToHostApiDeviceIndex(
|
|
||||||
PaDeviceIndex *hostApiDevice, PaDeviceIndex device,
|
|
||||||
struct PaUtilHostApiRepresentation *hostApi );
|
|
||||||
|
|
||||||
|
|
||||||
/** Set the host error information returned by Pa_GetLastHostErrorInfo. This
|
|
||||||
function and the paUnanticipatedHostError error code should be used as a
|
|
||||||
last resort. Implementors should use existing PA error codes where possible,
|
|
||||||
or nominate new ones. Note that at it is always better to use
|
|
||||||
PaUtil_SetLastHostErrorInfo() and paUnanticipatedHostError than to return an
|
|
||||||
ambiguous or inaccurate PaError code.
|
|
||||||
|
|
||||||
@param hostApiType The host API which encountered the error (ie of the caller)
|
|
||||||
|
|
||||||
@param errorCode The error code returned by the native API function.
|
|
||||||
|
|
||||||
@param errorText A string describing the error. PaUtil_SetLastHostErrorInfo
|
|
||||||
makes a copy of the string, so it is not necessary for the pointer to remain
|
|
||||||
valid after the call to PaUtil_SetLastHostErrorInfo() returns.
|
|
||||||
|
|
||||||
*/
|
|
||||||
void PaUtil_SetLastHostErrorInfo( PaHostApiTypeId hostApiType, long errorCode,
|
|
||||||
const char *errorText );
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* the following functions are implemented in a platform platform specific
|
|
||||||
.c file
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** Allocate size bytes, guaranteed to be aligned to a FIXME byte boundary */
|
|
||||||
void *PaUtil_AllocateMemory( long size );
|
|
||||||
|
|
||||||
|
|
||||||
/** Release block if non-NULL. block may be NULL */
|
|
||||||
void PaUtil_FreeMemory( void *block );
|
|
||||||
|
|
||||||
|
|
||||||
/** Return the number of currently allocated blocks. This function can be
|
|
||||||
used for detecting memory leaks.
|
|
||||||
|
|
||||||
@note Allocations will only be tracked if PA_TRACK_MEMORY is #defined. If
|
|
||||||
it isn't, this function will always return 0.
|
|
||||||
*/
|
|
||||||
int PaUtil_CountCurrentlyAllocatedBlocks( void );
|
|
||||||
|
|
||||||
|
|
||||||
/** Initialize the clock used by PaUtil_GetTime(). Call this before calling
|
|
||||||
PaUtil_GetTime.
|
|
||||||
|
|
||||||
@see PaUtil_GetTime
|
|
||||||
*/
|
|
||||||
void PaUtil_InitializeClock( void );
|
|
||||||
|
|
||||||
|
|
||||||
/** Return the system time in seconds. Used to implement CPU load functions
|
|
||||||
|
|
||||||
@see PaUtil_InitializeClock
|
|
||||||
*/
|
|
||||||
double PaUtil_GetTime( void );
|
|
||||||
|
|
||||||
|
|
||||||
/* void Pa_Sleep( long msec ); must also be implemented in per-platform .c file */
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif /* __cplusplus */
|
|
||||||
#endif /* PA_UTIL_H */
|
|
4659
third_party/portAudio/src/hostapi/alsa/pa_linux_alsa.c
vendored
4659
third_party/portAudio/src/hostapi/alsa/pa_linux_alsa.c
vendored
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,147 +0,0 @@
|
|||||||
ASIO-README.txt
|
|
||||||
|
|
||||||
This document contains information to help you compile PortAudio with
|
|
||||||
ASIO support. If you find any omissions or errors in this document
|
|
||||||
please notify us on the PortAudio mailing list.
|
|
||||||
|
|
||||||
NOTE: The Macintosh sections of this document are provided for historical
|
|
||||||
reference. They refer to pre-OS X Macintosh. PortAudio no longer
|
|
||||||
supports pre-OS X Macintosh. Steinberg does not support ASIO on Mac OS X.
|
|
||||||
|
|
||||||
|
|
||||||
Building PortAudio with ASIO support
|
|
||||||
------------------------------------
|
|
||||||
|
|
||||||
To build PortAudio with ASIO support you need to compile and link with
|
|
||||||
pa_asio.c, and files from the ASIO SDK (see below), along with the common
|
|
||||||
PortAudio files from src/common/ and platform specific files from
|
|
||||||
src/os/win/ (for Win32).
|
|
||||||
|
|
||||||
If you are compiling with a non-Microsoft compiler on Windows, also
|
|
||||||
compile and link with iasiothiscallresolver.cpp (see below for
|
|
||||||
an explanation).
|
|
||||||
|
|
||||||
For some platforms (MingW, Cygwin/MingW), you may simply
|
|
||||||
be able to type:
|
|
||||||
|
|
||||||
./configure --with-host_os=mingw --with-winapi=asio [--with-asiodir=/usr/local/asiosdk2]
|
|
||||||
make
|
|
||||||
|
|
||||||
and life will be good. Make sure you update the above with the correct local
|
|
||||||
path to the ASIO SDK.
|
|
||||||
|
|
||||||
|
|
||||||
For Microsoft Visual C++ there is an build tutorial here:
|
|
||||||
http://www.portaudio.com/trac/wiki/TutorialDir/Compile/WindowsASIOMSVC
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Obtaining the ASIO SDK
|
|
||||||
----------------------
|
|
||||||
|
|
||||||
In order to build PortAudio with ASIO support, you need to download
|
|
||||||
the ASIO SDK (version 2.0 or later) from Steinberg. Steinberg makes the ASIO
|
|
||||||
SDK available to anyone free of charge, however they do not permit its
|
|
||||||
source code to be distributed.
|
|
||||||
|
|
||||||
NOTE: In some cases the ASIO SDK may require patching, see below
|
|
||||||
for further details.
|
|
||||||
|
|
||||||
http://www.steinberg.net/en/company/developer.html
|
|
||||||
|
|
||||||
If the above link is broken search Google for:
|
|
||||||
"download steinberg ASIO SDK"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Building the ASIO SDK on Windows
|
|
||||||
--------------------------------
|
|
||||||
|
|
||||||
To build the ASIO SDK on Windows you need to compile and link with the
|
|
||||||
following files from the ASIO SDK:
|
|
||||||
|
|
||||||
asio_sdk\common\asio.cpp
|
|
||||||
asio_sdk\host\asiodrivers.cpp
|
|
||||||
asio_sdk\host\pc\asiolist.cpp
|
|
||||||
|
|
||||||
You may also need to adjust your include paths to support inclusion of
|
|
||||||
header files from the above directories.
|
|
||||||
|
|
||||||
The ASIO SDK depends on the following COM API functions:
|
|
||||||
CoInitialize, CoUninitialize, CoCreateInstance, CLSIDFromString
|
|
||||||
For compilation with MinGW you will need to link with -lole32, for
|
|
||||||
Borland compilers link with Import32.lib.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Non-Microsoft (MSVC) Compilers on Windows including Borland and GCC
|
|
||||||
-------------------------------------------------------------------
|
|
||||||
|
|
||||||
Steinberg did not specify a calling convention in the IASIO interface
|
|
||||||
definition. This causes the Microsoft compiler to use the proprietary
|
|
||||||
thiscall convention which is not compatible with other compilers, such
|
|
||||||
as compilers from Borland (BCC and C++Builder) and GNU (gcc).
|
|
||||||
Steinberg's ASIO SDK will compile but crash on initialization if
|
|
||||||
compiled with a non-Microsoft compiler on Windows.
|
|
||||||
|
|
||||||
PortAudio solves this problem using the iasiothiscallresolver library
|
|
||||||
which is included in the distribution. When building ASIO support for
|
|
||||||
non-Microsoft compilers, be sure to compile and link with
|
|
||||||
iasiothiscallresolver.cpp. Note that iasiothiscallresolver includes
|
|
||||||
conditional directives which cause it to have no effect if it is
|
|
||||||
compiled with a Microsoft compiler, or on the Macintosh.
|
|
||||||
|
|
||||||
If you use configure and make (see above), this should be handled
|
|
||||||
automatically for you.
|
|
||||||
|
|
||||||
For further information about the IASIO thiscall problem see this page:
|
|
||||||
http://www.rossbencina.com/code/iasio-thiscall-resolver
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Building the ASIO SDK on (Pre-OS X) Macintosh
|
|
||||||
---------------------------------------------
|
|
||||||
|
|
||||||
To build the ASIO SDK on Macintosh you need to compile and link with the
|
|
||||||
following files from the ASIO SDK:
|
|
||||||
|
|
||||||
host/asiodrivers.cpp
|
|
||||||
host/mac/asioshlib.cpp
|
|
||||||
host/mac/codefragements.cpp
|
|
||||||
|
|
||||||
You may also need to adjust your include paths to support inclusion of
|
|
||||||
header files from the above directories.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(Pre-OS X) Macintosh ASIO SDK Bug Patch
|
|
||||||
---------------------------------------
|
|
||||||
|
|
||||||
There is a bug in the ASIO SDK that causes the Macintosh version to
|
|
||||||
often fail during initialization. Below is a patch that you can apply.
|
|
||||||
|
|
||||||
In codefragments.cpp replace getFrontProcessDirectory function with
|
|
||||||
the following one (GetFrontProcess replaced by GetCurrentProcess).
|
|
||||||
|
|
||||||
|
|
||||||
bool CodeFragments::getFrontProcessDirectory(void *specs)
|
|
||||||
{
|
|
||||||
FSSpec *fss = (FSSpec *)specs;
|
|
||||||
ProcessInfoRec pif;
|
|
||||||
ProcessSerialNumber psn;
|
|
||||||
|
|
||||||
memset(&psn,0,(long)sizeof(ProcessSerialNumber));
|
|
||||||
// if(GetFrontProcess(&psn) == noErr) // wrong !!!
|
|
||||||
if(GetCurrentProcess(&psn) == noErr) // correct !!!
|
|
||||||
{
|
|
||||||
pif.processName = 0;
|
|
||||||
pif.processAppSpec = fss;
|
|
||||||
pif.processInfoLength = sizeof(ProcessInfoRec);
|
|
||||||
if(GetProcessInformation(&psn, &pif) == noErr)
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
###
|
|
Binary file not shown.
BIN
third_party/portAudio/src/hostapi/asio/Pa_ASIO.pdf
vendored
BIN
third_party/portAudio/src/hostapi/asio/Pa_ASIO.pdf
vendored
Binary file not shown.
@ -1,572 +0,0 @@
|
|||||||
/*
|
|
||||||
IASIOThiscallResolver.cpp see the comments in iasiothiscallresolver.h for
|
|
||||||
the top level description - this comment describes the technical details of
|
|
||||||
the implementation.
|
|
||||||
|
|
||||||
The latest version of this file is available from:
|
|
||||||
http://www.audiomulch.com/~rossb/code/calliasio
|
|
||||||
|
|
||||||
please email comments to Ross Bencina <rossb@audiomulch.com>
|
|
||||||
|
|
||||||
BACKGROUND
|
|
||||||
|
|
||||||
The IASIO interface declared in the Steinberg ASIO 2 SDK declares
|
|
||||||
functions with no explicit calling convention. This causes MSVC++ to default
|
|
||||||
to using the thiscall convention, which is a proprietary convention not
|
|
||||||
implemented by some non-microsoft compilers - notably borland BCC,
|
|
||||||
C++Builder, and gcc. MSVC++ is the defacto standard compiler used by
|
|
||||||
Steinberg. As a result of this situation, the ASIO sdk will compile with
|
|
||||||
any compiler, however attempting to execute the compiled code will cause a
|
|
||||||
crash due to different default calling conventions on non-Microsoft
|
|
||||||
compilers.
|
|
||||||
|
|
||||||
IASIOThiscallResolver solves the problem by providing an adapter class that
|
|
||||||
delegates to the IASIO interface using the correct calling convention
|
|
||||||
(thiscall). Due to the lack of support for thiscall in the Borland and GCC
|
|
||||||
compilers, the calls have been implemented in assembly language.
|
|
||||||
|
|
||||||
A number of macros are defined for thiscall function calls with different
|
|
||||||
numbers of parameters, with and without return values - it may be possible
|
|
||||||
to modify the format of these macros to make them work with other inline
|
|
||||||
assemblers.
|
|
||||||
|
|
||||||
|
|
||||||
THISCALL DEFINITION
|
|
||||||
|
|
||||||
A number of definitions of the thiscall calling convention are floating
|
|
||||||
around the internet. The following definition has been validated against
|
|
||||||
output from the MSVC++ compiler:
|
|
||||||
|
|
||||||
For non-vararg functions, thiscall works as follows: the object (this)
|
|
||||||
pointer is passed in ECX. All arguments are passed on the stack in
|
|
||||||
right to left order. The return value is placed in EAX. The callee
|
|
||||||
clears the passed arguments from the stack.
|
|
||||||
|
|
||||||
|
|
||||||
FINDING FUNCTION POINTERS FROM AN IASIO POINTER
|
|
||||||
|
|
||||||
The first field of a COM object is a pointer to its vtble. Thus a pointer
|
|
||||||
to an object implementing the IASIO interface also points to a pointer to
|
|
||||||
that object's vtbl. The vtble is a table of function pointers for all of
|
|
||||||
the virtual functions exposed by the implemented interfaces.
|
|
||||||
|
|
||||||
If we consider a variable declared as a pointer to IASO:
|
|
||||||
|
|
||||||
IASIO *theAsioDriver
|
|
||||||
|
|
||||||
theAsioDriver points to:
|
|
||||||
|
|
||||||
object implementing IASIO
|
|
||||||
{
|
|
||||||
IASIOvtbl *vtbl
|
|
||||||
other data
|
|
||||||
}
|
|
||||||
|
|
||||||
in other words, theAsioDriver points to a pointer to an IASIOvtbl
|
|
||||||
|
|
||||||
vtbl points to a table of function pointers:
|
|
||||||
|
|
||||||
IASIOvtbl ( interface IASIO : public IUnknown )
|
|
||||||
{
|
|
||||||
(IUnknown functions)
|
|
||||||
0 virtual HRESULT STDMETHODCALLTYPE (*QueryInterface)(REFIID riid, void **ppv) = 0;
|
|
||||||
4 virtual ULONG STDMETHODCALLTYPE (*AddRef)() = 0;
|
|
||||||
8 virtual ULONG STDMETHODCALLTYPE (*Release)() = 0;
|
|
||||||
|
|
||||||
(IASIO functions)
|
|
||||||
12 virtual ASIOBool (*init)(void *sysHandle) = 0;
|
|
||||||
16 virtual void (*getDriverName)(char *name) = 0;
|
|
||||||
20 virtual long (*getDriverVersion)() = 0;
|
|
||||||
24 virtual void (*getErrorMessage)(char *string) = 0;
|
|
||||||
28 virtual ASIOError (*start)() = 0;
|
|
||||||
32 virtual ASIOError (*stop)() = 0;
|
|
||||||
36 virtual ASIOError (*getChannels)(long *numInputChannels, long *numOutputChannels) = 0;
|
|
||||||
40 virtual ASIOError (*getLatencies)(long *inputLatency, long *outputLatency) = 0;
|
|
||||||
44 virtual ASIOError (*getBufferSize)(long *minSize, long *maxSize,
|
|
||||||
long *preferredSize, long *granularity) = 0;
|
|
||||||
48 virtual ASIOError (*canSampleRate)(ASIOSampleRate sampleRate) = 0;
|
|
||||||
52 virtual ASIOError (*getSampleRate)(ASIOSampleRate *sampleRate) = 0;
|
|
||||||
56 virtual ASIOError (*setSampleRate)(ASIOSampleRate sampleRate) = 0;
|
|
||||||
60 virtual ASIOError (*getClockSources)(ASIOClockSource *clocks, long *numSources) = 0;
|
|
||||||
64 virtual ASIOError (*setClockSource)(long reference) = 0;
|
|
||||||
68 virtual ASIOError (*getSamplePosition)(ASIOSamples *sPos, ASIOTimeStamp *tStamp) = 0;
|
|
||||||
72 virtual ASIOError (*getChannelInfo)(ASIOChannelInfo *info) = 0;
|
|
||||||
76 virtual ASIOError (*createBuffers)(ASIOBufferInfo *bufferInfos, long numChannels,
|
|
||||||
long bufferSize, ASIOCallbacks *callbacks) = 0;
|
|
||||||
80 virtual ASIOError (*disposeBuffers)() = 0;
|
|
||||||
84 virtual ASIOError (*controlPanel)() = 0;
|
|
||||||
88 virtual ASIOError (*future)(long selector,void *opt) = 0;
|
|
||||||
92 virtual ASIOError (*outputReady)() = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
The numbers in the left column show the byte offset of each function ptr
|
|
||||||
from the beginning of the vtbl. These numbers are used in the code below
|
|
||||||
to select different functions.
|
|
||||||
|
|
||||||
In order to find the address of a particular function, theAsioDriver
|
|
||||||
must first be dereferenced to find the value of the vtbl pointer:
|
|
||||||
|
|
||||||
mov eax, theAsioDriver
|
|
||||||
mov edx, [theAsioDriver] // edx now points to vtbl[0]
|
|
||||||
|
|
||||||
Then an offset must be added to the vtbl pointer to select a
|
|
||||||
particular function, for example vtbl+44 points to the slot containing
|
|
||||||
a pointer to the getBufferSize function.
|
|
||||||
|
|
||||||
Finally vtbl+x must be dereferenced to obtain the value of the function
|
|
||||||
pointer stored in that address:
|
|
||||||
|
|
||||||
call [edx+44] // call the function pointed to by
|
|
||||||
// the value in the getBufferSize field of the vtbl
|
|
||||||
|
|
||||||
|
|
||||||
SEE ALSO
|
|
||||||
|
|
||||||
Martin Fay's OpenASIO DLL at http://www.martinfay.com solves the same
|
|
||||||
problem by providing a new COM interface which wraps IASIO with an
|
|
||||||
interface that uses portable calling conventions. OpenASIO must be compiled
|
|
||||||
with MSVC, and requires that you ship the OpenASIO DLL with your
|
|
||||||
application.
|
|
||||||
|
|
||||||
|
|
||||||
ACKNOWLEDGEMENTS
|
|
||||||
|
|
||||||
Ross Bencina: worked out the thiscall details above, wrote the original
|
|
||||||
Borland asm macros, and a patch for asio.cpp (which is no longer needed).
|
|
||||||
Thanks to Martin Fay for introducing me to the issues discussed here,
|
|
||||||
and to Rene G. Ceballos for assisting with asm dumps from MSVC++.
|
|
||||||
|
|
||||||
Antti Silvast: converted the original calliasio to work with gcc and NASM
|
|
||||||
by implementing the asm code in a separate file.
|
|
||||||
|
|
||||||
Fraser Adams: modified the original calliasio containing the Borland inline
|
|
||||||
asm to add inline asm for gcc i.e. Intel syntax for Borland and AT&T syntax
|
|
||||||
for gcc. This seems a neater approach for gcc than to have a separate .asm
|
|
||||||
file and it means that we only need one version of the thiscall patch.
|
|
||||||
|
|
||||||
Fraser Adams: rewrote the original calliasio patch in the form of the
|
|
||||||
IASIOThiscallResolver class in order to avoid modifications to files from
|
|
||||||
the Steinberg SDK, which may have had potential licence issues.
|
|
||||||
|
|
||||||
Andrew Baldwin: contributed fixes for compatibility problems with more
|
|
||||||
recent versions of the gcc assembler.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
// We only need IASIOThiscallResolver at all if we are on Win32. For other
|
|
||||||
// platforms we simply bypass the IASIOThiscallResolver definition to allow us
|
|
||||||
// to be safely #include'd whatever the platform to keep client code portable
|
|
||||||
#if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__)) && !defined(_WIN64)
|
|
||||||
|
|
||||||
|
|
||||||
// If microsoft compiler we can call IASIO directly so IASIOThiscallResolver
|
|
||||||
// is not used.
|
|
||||||
#if !defined(_MSC_VER)
|
|
||||||
|
|
||||||
|
|
||||||
#include <new>
|
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
// We have a mechanism in iasiothiscallresolver.h to ensure that asio.h is
|
|
||||||
// #include'd before it in client code, we do NOT want to do this test here.
|
|
||||||
#define iasiothiscallresolver_sourcefile 1
|
|
||||||
#include "iasiothiscallresolver.h"
|
|
||||||
#undef iasiothiscallresolver_sourcefile
|
|
||||||
|
|
||||||
// iasiothiscallresolver.h redefines ASIOInit for clients, but we don't want
|
|
||||||
// this macro defined in this translation unit.
|
|
||||||
#undef ASIOInit
|
|
||||||
|
|
||||||
|
|
||||||
// theAsioDriver is a global pointer to the current IASIO instance which the
|
|
||||||
// ASIO SDK uses to perform all actions on the IASIO interface. We substitute
|
|
||||||
// our own forwarding interface into this pointer.
|
|
||||||
extern IASIO* theAsioDriver;
|
|
||||||
|
|
||||||
|
|
||||||
// The following macros define the inline assembler for BORLAND first then gcc
|
|
||||||
|
|
||||||
#if defined(__BCPLUSPLUS__) || defined(__BORLANDC__)
|
|
||||||
|
|
||||||
|
|
||||||
#define CALL_THISCALL_0( resultName, thisPtr, funcOffset )\
|
|
||||||
void *this_ = (thisPtr); \
|
|
||||||
__asm { \
|
|
||||||
mov ecx, this_ ; \
|
|
||||||
mov eax, [ecx] ; \
|
|
||||||
call [eax+funcOffset] ; \
|
|
||||||
mov resultName, eax ; \
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#define CALL_VOID_THISCALL_1( thisPtr, funcOffset, param1 )\
|
|
||||||
void *this_ = (thisPtr); \
|
|
||||||
__asm { \
|
|
||||||
mov eax, param1 ; \
|
|
||||||
push eax ; \
|
|
||||||
mov ecx, this_ ; \
|
|
||||||
mov eax, [ecx] ; \
|
|
||||||
call [eax+funcOffset] ; \
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#define CALL_THISCALL_1( resultName, thisPtr, funcOffset, param1 )\
|
|
||||||
void *this_ = (thisPtr); \
|
|
||||||
__asm { \
|
|
||||||
mov eax, param1 ; \
|
|
||||||
push eax ; \
|
|
||||||
mov ecx, this_ ; \
|
|
||||||
mov eax, [ecx] ; \
|
|
||||||
call [eax+funcOffset] ; \
|
|
||||||
mov resultName, eax ; \
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#define CALL_THISCALL_1_DOUBLE( resultName, thisPtr, funcOffset, param1 )\
|
|
||||||
void *this_ = (thisPtr); \
|
|
||||||
void *doubleParamPtr_ (¶m1); \
|
|
||||||
__asm { \
|
|
||||||
mov eax, doubleParamPtr_ ; \
|
|
||||||
push [eax+4] ; \
|
|
||||||
push [eax] ; \
|
|
||||||
mov ecx, this_ ; \
|
|
||||||
mov eax, [ecx] ; \
|
|
||||||
call [eax+funcOffset] ; \
|
|
||||||
mov resultName, eax ; \
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#define CALL_THISCALL_2( resultName, thisPtr, funcOffset, param1, param2 )\
|
|
||||||
void *this_ = (thisPtr); \
|
|
||||||
__asm { \
|
|
||||||
mov eax, param2 ; \
|
|
||||||
push eax ; \
|
|
||||||
mov eax, param1 ; \
|
|
||||||
push eax ; \
|
|
||||||
mov ecx, this_ ; \
|
|
||||||
mov eax, [ecx] ; \
|
|
||||||
call [eax+funcOffset] ; \
|
|
||||||
mov resultName, eax ; \
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#define CALL_THISCALL_4( resultName, thisPtr, funcOffset, param1, param2, param3, param4 )\
|
|
||||||
void *this_ = (thisPtr); \
|
|
||||||
__asm { \
|
|
||||||
mov eax, param4 ; \
|
|
||||||
push eax ; \
|
|
||||||
mov eax, param3 ; \
|
|
||||||
push eax ; \
|
|
||||||
mov eax, param2 ; \
|
|
||||||
push eax ; \
|
|
||||||
mov eax, param1 ; \
|
|
||||||
push eax ; \
|
|
||||||
mov ecx, this_ ; \
|
|
||||||
mov eax, [ecx] ; \
|
|
||||||
call [eax+funcOffset] ; \
|
|
||||||
mov resultName, eax ; \
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#elif defined(__GNUC__)
|
|
||||||
|
|
||||||
|
|
||||||
#define CALL_THISCALL_0( resultName, thisPtr, funcOffset ) \
|
|
||||||
__asm__ __volatile__ ("movl (%1), %%edx\n\t" \
|
|
||||||
"call *"#funcOffset"(%%edx)\n\t" \
|
|
||||||
:"=a"(resultName) /* Output Operands */ \
|
|
||||||
:"c"(thisPtr) /* Input Operands */ \
|
|
||||||
: "%edx" /* Clobbered Registers */ \
|
|
||||||
); \
|
|
||||||
|
|
||||||
|
|
||||||
#define CALL_VOID_THISCALL_1( thisPtr, funcOffset, param1 ) \
|
|
||||||
__asm__ __volatile__ ("pushl %0\n\t" \
|
|
||||||
"movl (%1), %%edx\n\t" \
|
|
||||||
"call *"#funcOffset"(%%edx)\n\t" \
|
|
||||||
: /* Output Operands */ \
|
|
||||||
:"r"(param1), /* Input Operands */ \
|
|
||||||
"c"(thisPtr) \
|
|
||||||
: "%edx" /* Clobbered Registers */ \
|
|
||||||
); \
|
|
||||||
|
|
||||||
|
|
||||||
#define CALL_THISCALL_1( resultName, thisPtr, funcOffset, param1 ) \
|
|
||||||
__asm__ __volatile__ ("pushl %1\n\t" \
|
|
||||||
"movl (%2), %%edx\n\t" \
|
|
||||||
"call *"#funcOffset"(%%edx)\n\t" \
|
|
||||||
:"=a"(resultName) /* Output Operands */ \
|
|
||||||
:"r"(param1), /* Input Operands */ \
|
|
||||||
"c"(thisPtr) \
|
|
||||||
: "%edx" /* Clobbered Registers */ \
|
|
||||||
); \
|
|
||||||
|
|
||||||
|
|
||||||
#define CALL_THISCALL_1_DOUBLE( resultName, thisPtr, funcOffset, param1 ) \
|
|
||||||
do { \
|
|
||||||
double param1f64 = param1; /* Cast explicitly to double */ \
|
|
||||||
double *param1f64Ptr = ¶m1f64; /* Make pointer to address */ \
|
|
||||||
__asm__ __volatile__ ("pushl 4(%1)\n\t" \
|
|
||||||
"pushl (%1)\n\t" \
|
|
||||||
"movl (%2), %%edx\n\t" \
|
|
||||||
"call *"#funcOffset"(%%edx);\n\t" \
|
|
||||||
: "=a"(resultName) /* Output Operands */ \
|
|
||||||
: "r"(param1f64Ptr), /* Input Operands */ \
|
|
||||||
"c"(thisPtr), \
|
|
||||||
"m"(*param1f64Ptr) /* Using address */ \
|
|
||||||
: "%edx" /* Clobbered Registers */ \
|
|
||||||
); \
|
|
||||||
} while (0); \
|
|
||||||
|
|
||||||
|
|
||||||
#define CALL_THISCALL_2( resultName, thisPtr, funcOffset, param1, param2 ) \
|
|
||||||
__asm__ __volatile__ ("pushl %1\n\t" \
|
|
||||||
"pushl %2\n\t" \
|
|
||||||
"movl (%3), %%edx\n\t" \
|
|
||||||
"call *"#funcOffset"(%%edx)\n\t" \
|
|
||||||
:"=a"(resultName) /* Output Operands */ \
|
|
||||||
:"r"(param2), /* Input Operands */ \
|
|
||||||
"r"(param1), \
|
|
||||||
"c"(thisPtr) \
|
|
||||||
: "%edx" /* Clobbered Registers */ \
|
|
||||||
); \
|
|
||||||
|
|
||||||
|
|
||||||
#define CALL_THISCALL_4( resultName, thisPtr, funcOffset, param1, param2, param3, param4 )\
|
|
||||||
__asm__ __volatile__ ("pushl %1\n\t" \
|
|
||||||
"pushl %2\n\t" \
|
|
||||||
"pushl %3\n\t" \
|
|
||||||
"pushl %4\n\t" \
|
|
||||||
"movl (%5), %%edx\n\t" \
|
|
||||||
"call *"#funcOffset"(%%edx)\n\t" \
|
|
||||||
:"=a"(resultName) /* Output Operands */ \
|
|
||||||
:"r"(param4), /* Input Operands */ \
|
|
||||||
"r"(param3), \
|
|
||||||
"r"(param2), \
|
|
||||||
"r"(param1), \
|
|
||||||
"c"(thisPtr) \
|
|
||||||
: "%edx" /* Clobbered Registers */ \
|
|
||||||
); \
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Our static singleton instance.
|
|
||||||
IASIOThiscallResolver IASIOThiscallResolver::instance;
|
|
||||||
|
|
||||||
// Constructor called to initialize static Singleton instance above. Note that
|
|
||||||
// it is important not to clear that_ incase it has already been set by the call
|
|
||||||
// to placement new in ASIOInit().
|
|
||||||
IASIOThiscallResolver::IASIOThiscallResolver()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// Constructor called from ASIOInit() below
|
|
||||||
IASIOThiscallResolver::IASIOThiscallResolver(IASIO* that)
|
|
||||||
: that_( that )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// Implement IUnknown methods as assert(false). IASIOThiscallResolver is not
|
|
||||||
// really a COM object, just a wrapper which will work with the ASIO SDK.
|
|
||||||
// If you wanted to use ASIO without the SDK you might want to implement COM
|
|
||||||
// aggregation in these methods.
|
|
||||||
HRESULT STDMETHODCALLTYPE IASIOThiscallResolver::QueryInterface(REFIID riid, void **ppv)
|
|
||||||
{
|
|
||||||
(void)riid; // suppress unused variable warning
|
|
||||||
|
|
||||||
assert( false ); // this function should never be called by the ASIO SDK.
|
|
||||||
|
|
||||||
*ppv = NULL;
|
|
||||||
return E_NOINTERFACE;
|
|
||||||
}
|
|
||||||
|
|
||||||
ULONG STDMETHODCALLTYPE IASIOThiscallResolver::AddRef()
|
|
||||||
{
|
|
||||||
assert( false ); // this function should never be called by the ASIO SDK.
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
ULONG STDMETHODCALLTYPE IASIOThiscallResolver::Release()
|
|
||||||
{
|
|
||||||
assert( false ); // this function should never be called by the ASIO SDK.
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Implement the IASIO interface methods by performing the vptr manipulation
|
|
||||||
// described above then delegating to the real implementation.
|
|
||||||
ASIOBool IASIOThiscallResolver::init(void *sysHandle)
|
|
||||||
{
|
|
||||||
ASIOBool result;
|
|
||||||
CALL_THISCALL_1( result, that_, 12, sysHandle );
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
void IASIOThiscallResolver::getDriverName(char *name)
|
|
||||||
{
|
|
||||||
CALL_VOID_THISCALL_1( that_, 16, name );
|
|
||||||
}
|
|
||||||
|
|
||||||
long IASIOThiscallResolver::getDriverVersion()
|
|
||||||
{
|
|
||||||
ASIOBool result;
|
|
||||||
CALL_THISCALL_0( result, that_, 20 );
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
void IASIOThiscallResolver::getErrorMessage(char *string)
|
|
||||||
{
|
|
||||||
CALL_VOID_THISCALL_1( that_, 24, string );
|
|
||||||
}
|
|
||||||
|
|
||||||
ASIOError IASIOThiscallResolver::start()
|
|
||||||
{
|
|
||||||
ASIOBool result;
|
|
||||||
CALL_THISCALL_0( result, that_, 28 );
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
ASIOError IASIOThiscallResolver::stop()
|
|
||||||
{
|
|
||||||
ASIOBool result;
|
|
||||||
CALL_THISCALL_0( result, that_, 32 );
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
ASIOError IASIOThiscallResolver::getChannels(long *numInputChannels, long *numOutputChannels)
|
|
||||||
{
|
|
||||||
ASIOBool result;
|
|
||||||
CALL_THISCALL_2( result, that_, 36, numInputChannels, numOutputChannels );
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
ASIOError IASIOThiscallResolver::getLatencies(long *inputLatency, long *outputLatency)
|
|
||||||
{
|
|
||||||
ASIOBool result;
|
|
||||||
CALL_THISCALL_2( result, that_, 40, inputLatency, outputLatency );
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
ASIOError IASIOThiscallResolver::getBufferSize(long *minSize, long *maxSize,
|
|
||||||
long *preferredSize, long *granularity)
|
|
||||||
{
|
|
||||||
ASIOBool result;
|
|
||||||
CALL_THISCALL_4( result, that_, 44, minSize, maxSize, preferredSize, granularity );
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
ASIOError IASIOThiscallResolver::canSampleRate(ASIOSampleRate sampleRate)
|
|
||||||
{
|
|
||||||
ASIOBool result;
|
|
||||||
CALL_THISCALL_1_DOUBLE( result, that_, 48, sampleRate );
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
ASIOError IASIOThiscallResolver::getSampleRate(ASIOSampleRate *sampleRate)
|
|
||||||
{
|
|
||||||
ASIOBool result;
|
|
||||||
CALL_THISCALL_1( result, that_, 52, sampleRate );
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
ASIOError IASIOThiscallResolver::setSampleRate(ASIOSampleRate sampleRate)
|
|
||||||
{
|
|
||||||
ASIOBool result;
|
|
||||||
CALL_THISCALL_1_DOUBLE( result, that_, 56, sampleRate );
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
ASIOError IASIOThiscallResolver::getClockSources(ASIOClockSource *clocks, long *numSources)
|
|
||||||
{
|
|
||||||
ASIOBool result;
|
|
||||||
CALL_THISCALL_2( result, that_, 60, clocks, numSources );
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
ASIOError IASIOThiscallResolver::setClockSource(long reference)
|
|
||||||
{
|
|
||||||
ASIOBool result;
|
|
||||||
CALL_THISCALL_1( result, that_, 64, reference );
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
ASIOError IASIOThiscallResolver::getSamplePosition(ASIOSamples *sPos, ASIOTimeStamp *tStamp)
|
|
||||||
{
|
|
||||||
ASIOBool result;
|
|
||||||
CALL_THISCALL_2( result, that_, 68, sPos, tStamp );
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
ASIOError IASIOThiscallResolver::getChannelInfo(ASIOChannelInfo *info)
|
|
||||||
{
|
|
||||||
ASIOBool result;
|
|
||||||
CALL_THISCALL_1( result, that_, 72, info );
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
ASIOError IASIOThiscallResolver::createBuffers(ASIOBufferInfo *bufferInfos,
|
|
||||||
long numChannels, long bufferSize, ASIOCallbacks *callbacks)
|
|
||||||
{
|
|
||||||
ASIOBool result;
|
|
||||||
CALL_THISCALL_4( result, that_, 76, bufferInfos, numChannels, bufferSize, callbacks );
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
ASIOError IASIOThiscallResolver::disposeBuffers()
|
|
||||||
{
|
|
||||||
ASIOBool result;
|
|
||||||
CALL_THISCALL_0( result, that_, 80 );
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
ASIOError IASIOThiscallResolver::controlPanel()
|
|
||||||
{
|
|
||||||
ASIOBool result;
|
|
||||||
CALL_THISCALL_0( result, that_, 84 );
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
ASIOError IASIOThiscallResolver::future(long selector,void *opt)
|
|
||||||
{
|
|
||||||
ASIOBool result;
|
|
||||||
CALL_THISCALL_2( result, that_, 88, selector, opt );
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
ASIOError IASIOThiscallResolver::outputReady()
|
|
||||||
{
|
|
||||||
ASIOBool result;
|
|
||||||
CALL_THISCALL_0( result, that_, 92 );
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Implement our substitute ASIOInit() method
|
|
||||||
ASIOError IASIOThiscallResolver::ASIOInit(ASIODriverInfo *info)
|
|
||||||
{
|
|
||||||
// To ensure that our instance's vptr is correctly constructed, even if
|
|
||||||
// ASIOInit is called prior to main(), we explicitly call its constructor
|
|
||||||
// (potentially over the top of an existing instance). Note that this is
|
|
||||||
// pretty ugly, and is only safe because IASIOThiscallResolver has no
|
|
||||||
// destructor and contains no objects with destructors.
|
|
||||||
new((void*)&instance) IASIOThiscallResolver( theAsioDriver );
|
|
||||||
|
|
||||||
// Interpose between ASIO client code and the real driver.
|
|
||||||
theAsioDriver = &instance;
|
|
||||||
|
|
||||||
// Note that we never need to switch theAsioDriver back to point to the
|
|
||||||
// real driver because theAsioDriver is reset to zero in ASIOExit().
|
|
||||||
|
|
||||||
// Delegate to the real ASIOInit
|
|
||||||
return ::ASIOInit(info);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* !defined(_MSC_VER) */
|
|
||||||
|
|
||||||
#endif /* Win32 */
|
|
||||||
|
|
@ -1,197 +0,0 @@
|
|||||||
// ****************************************************************************
|
|
||||||
// File: IASIOThiscallResolver.h
|
|
||||||
// Description: The IASIOThiscallResolver class implements the IASIO
|
|
||||||
// interface and acts as a proxy to the real IASIO interface by
|
|
||||||
// calling through its vptr table using the thiscall calling
|
|
||||||
// convention. To put it another way, we interpose
|
|
||||||
// IASIOThiscallResolver between ASIO SDK code and the driver.
|
|
||||||
// This is necessary because most non-Microsoft compilers don't
|
|
||||||
// implement the thiscall calling convention used by IASIO.
|
|
||||||
//
|
|
||||||
// iasiothiscallresolver.cpp contains the background of this
|
|
||||||
// problem plus a technical description of the vptr
|
|
||||||
// manipulations.
|
|
||||||
//
|
|
||||||
// In order to use this mechanism one simply has to add
|
|
||||||
// iasiothiscallresolver.cpp to the list of files to compile
|
|
||||||
// and #include <iasiothiscallresolver.h>
|
|
||||||
//
|
|
||||||
// Note that this #include must come after the other ASIO SDK
|
|
||||||
// #includes, for example:
|
|
||||||
//
|
|
||||||
// #include <windows.h>
|
|
||||||
// #include <asiosys.h>
|
|
||||||
// #include <asio.h>
|
|
||||||
// #include <asiodrivers.h>
|
|
||||||
// #include <iasiothiscallresolver.h>
|
|
||||||
//
|
|
||||||
// Actually the important thing is to #include
|
|
||||||
// <iasiothiscallresolver.h> after <asio.h>. We have
|
|
||||||
// incorporated a test to enforce this ordering.
|
|
||||||
//
|
|
||||||
// The code transparently takes care of the interposition by
|
|
||||||
// using macro substitution to intercept calls to ASIOInit()
|
|
||||||
// and ASIOExit(). We save the original ASIO global
|
|
||||||
// "theAsioDriver" in our "that" variable, and then set
|
|
||||||
// "theAsioDriver" to equal our IASIOThiscallResolver instance.
|
|
||||||
//
|
|
||||||
// Whilst this method of resolving the thiscall problem requires
|
|
||||||
// the addition of #include <iasiothiscallresolver.h> to client
|
|
||||||
// code it has the advantage that it does not break the terms
|
|
||||||
// of the ASIO licence by publishing it. We are NOT modifying
|
|
||||||
// any Steinberg code here, we are merely implementing the IASIO
|
|
||||||
// interface in the same way that we would need to do if we
|
|
||||||
// wished to provide an open source ASIO driver.
|
|
||||||
//
|
|
||||||
// For compilation with MinGW -lole32 needs to be added to the
|
|
||||||
// linker options. For BORLAND, linking with Import32.lib is
|
|
||||||
// sufficient.
|
|
||||||
//
|
|
||||||
// The dependencies are with: CoInitialize, CoUninitialize,
|
|
||||||
// CoCreateInstance, CLSIDFromString - used by asiolist.cpp
|
|
||||||
// and are required on Windows whether ThiscallResolver is used
|
|
||||||
// or not.
|
|
||||||
//
|
|
||||||
// Searching for the above strings in the root library path
|
|
||||||
// of your compiler should enable the correct libraries to be
|
|
||||||
// identified if they aren't immediately obvious.
|
|
||||||
//
|
|
||||||
// Note that the current implementation of IASIOThiscallResolver
|
|
||||||
// is not COM compliant - it does not correctly implement the
|
|
||||||
// IUnknown interface. Implementing it is not necessary because
|
|
||||||
// it is not called by parts of the ASIO SDK which call through
|
|
||||||
// theAsioDriver ptr. The IUnknown methods are implemented as
|
|
||||||
// assert(false) to ensure that the code fails if they are
|
|
||||||
// ever called.
|
|
||||||
// Restrictions: None. Public Domain & Open Source distribute freely
|
|
||||||
// You may use IASIOThiscallResolver commercially as well as
|
|
||||||
// privately.
|
|
||||||
// You the user assume the responsibility for the use of the
|
|
||||||
// files, binary or text, and there is no guarantee or warranty,
|
|
||||||
// expressed or implied, including but not limited to the
|
|
||||||
// implied warranties of merchantability and fitness for a
|
|
||||||
// particular purpose. You assume all responsibility and agree
|
|
||||||
// to hold no entity, copyright holder or distributors liable
|
|
||||||
// for any loss of data or inaccurate representations of data
|
|
||||||
// as a result of using IASIOThiscallResolver.
|
|
||||||
// Version: 1.4 Added separate macro CALL_THISCALL_1_DOUBLE from
|
|
||||||
// Andrew Baldwin, and volatile for whole gcc asm blocks,
|
|
||||||
// both for compatibility with newer gcc versions. Cleaned up
|
|
||||||
// Borland asm to use one less register.
|
|
||||||
// 1.3 Switched to including assert.h for better compatibility.
|
|
||||||
// Wrapped entire .h and .cpp contents with a check for
|
|
||||||
// _MSC_VER to provide better compatibility with MS compilers.
|
|
||||||
// Changed Singleton implementation to use static instance
|
|
||||||
// instead of freestore allocated instance. Removed ASIOExit
|
|
||||||
// macro as it is no longer needed.
|
|
||||||
// 1.2 Removed semicolons from ASIOInit and ASIOExit macros to
|
|
||||||
// allow them to be embedded in expressions (if statements).
|
|
||||||
// Cleaned up some comments. Removed combase.c dependency (it
|
|
||||||
// doesn't compile with BCB anyway) by stubbing IUnknown.
|
|
||||||
// 1.1 Incorporated comments from Ross Bencina including things
|
|
||||||
// such as changing name from ThiscallResolver to
|
|
||||||
// IASIOThiscallResolver, tidying up the constructor, fixing
|
|
||||||
// a bug in IASIOThiscallResolver::ASIOExit() and improving
|
|
||||||
// portability through the use of conditional compilation
|
|
||||||
// 1.0 Initial working version.
|
|
||||||
// Created: 6/09/2003
|
|
||||||
// Authors: Fraser Adams
|
|
||||||
// Ross Bencina
|
|
||||||
// Rene G. Ceballos
|
|
||||||
// Martin Fay
|
|
||||||
// Antti Silvast
|
|
||||||
// Andrew Baldwin
|
|
||||||
//
|
|
||||||
// ****************************************************************************
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef included_iasiothiscallresolver_h
|
|
||||||
#define included_iasiothiscallresolver_h
|
|
||||||
|
|
||||||
// We only need IASIOThiscallResolver at all if we are on Win32. For other
|
|
||||||
// platforms we simply bypass the IASIOThiscallResolver definition to allow us
|
|
||||||
// to be safely #include'd whatever the platform to keep client code portable
|
|
||||||
#if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__)) && !defined(_WIN64)
|
|
||||||
|
|
||||||
|
|
||||||
// If microsoft compiler we can call IASIO directly so IASIOThiscallResolver
|
|
||||||
// is not used.
|
|
||||||
#if !defined(_MSC_VER)
|
|
||||||
|
|
||||||
|
|
||||||
// The following is in order to ensure that this header is only included after
|
|
||||||
// the other ASIO headers (except for the case of iasiothiscallresolver.cpp).
|
|
||||||
// We need to do this because IASIOThiscallResolver works by eclipsing the
|
|
||||||
// original definition of ASIOInit() with a macro (see below).
|
|
||||||
#if !defined(iasiothiscallresolver_sourcefile)
|
|
||||||
#if !defined(__ASIO_H)
|
|
||||||
#error iasiothiscallresolver.h must be included AFTER asio.h
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <windows.h>
|
|
||||||
#include <asiodrvr.h> /* From ASIO SDK */
|
|
||||||
|
|
||||||
|
|
||||||
class IASIOThiscallResolver : public IASIO {
|
|
||||||
private:
|
|
||||||
IASIO* that_; // Points to the real IASIO
|
|
||||||
|
|
||||||
static IASIOThiscallResolver instance; // Singleton instance
|
|
||||||
|
|
||||||
// Constructors - declared private so construction is limited to
|
|
||||||
// our Singleton instance
|
|
||||||
IASIOThiscallResolver();
|
|
||||||
IASIOThiscallResolver(IASIO* that);
|
|
||||||
public:
|
|
||||||
|
|
||||||
// Methods from the IUnknown interface. We don't fully implement IUnknown
|
|
||||||
// because the ASIO SDK never calls these methods through theAsioDriver ptr.
|
|
||||||
// These methods are implemented as assert(false).
|
|
||||||
virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppv);
|
|
||||||
virtual ULONG STDMETHODCALLTYPE AddRef();
|
|
||||||
virtual ULONG STDMETHODCALLTYPE Release();
|
|
||||||
|
|
||||||
// Methods from the IASIO interface, implemented as forwarning calls to that.
|
|
||||||
virtual ASIOBool init(void *sysHandle);
|
|
||||||
virtual void getDriverName(char *name);
|
|
||||||
virtual long getDriverVersion();
|
|
||||||
virtual void getErrorMessage(char *string);
|
|
||||||
virtual ASIOError start();
|
|
||||||
virtual ASIOError stop();
|
|
||||||
virtual ASIOError getChannels(long *numInputChannels, long *numOutputChannels);
|
|
||||||
virtual ASIOError getLatencies(long *inputLatency, long *outputLatency);
|
|
||||||
virtual ASIOError getBufferSize(long *minSize, long *maxSize, long *preferredSize, long *granularity);
|
|
||||||
virtual ASIOError canSampleRate(ASIOSampleRate sampleRate);
|
|
||||||
virtual ASIOError getSampleRate(ASIOSampleRate *sampleRate);
|
|
||||||
virtual ASIOError setSampleRate(ASIOSampleRate sampleRate);
|
|
||||||
virtual ASIOError getClockSources(ASIOClockSource *clocks, long *numSources);
|
|
||||||
virtual ASIOError setClockSource(long reference);
|
|
||||||
virtual ASIOError getSamplePosition(ASIOSamples *sPos, ASIOTimeStamp *tStamp);
|
|
||||||
virtual ASIOError getChannelInfo(ASIOChannelInfo *info);
|
|
||||||
virtual ASIOError createBuffers(ASIOBufferInfo *bufferInfos, long numChannels, long bufferSize, ASIOCallbacks *callbacks);
|
|
||||||
virtual ASIOError disposeBuffers();
|
|
||||||
virtual ASIOError controlPanel();
|
|
||||||
virtual ASIOError future(long selector,void *opt);
|
|
||||||
virtual ASIOError outputReady();
|
|
||||||
|
|
||||||
// Class method, see ASIOInit() macro below.
|
|
||||||
static ASIOError ASIOInit(ASIODriverInfo *info); // Delegates to ::ASIOInit
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// Replace calls to ASIOInit with our interposing version.
|
|
||||||
// This macro enables us to perform thiscall resolution simply by #including
|
|
||||||
// <iasiothiscallresolver.h> after the asio #includes (this file _must_ be
|
|
||||||
// included _after_ the asio #includes)
|
|
||||||
|
|
||||||
#define ASIOInit(name) IASIOThiscallResolver::ASIOInit((name))
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* !defined(_MSC_VER) */
|
|
||||||
|
|
||||||
#endif /* Win32 */
|
|
||||||
|
|
||||||
#endif /* included_iasiothiscallresolver_h */
|
|
||||||
|
|
||||||
|
|
4250
third_party/portAudio/src/hostapi/asio/pa_asio.cpp
vendored
4250
third_party/portAudio/src/hostapi/asio/pa_asio.cpp
vendored
File diff suppressed because it is too large
Load Diff
@ -1,196 +0,0 @@
|
|||||||
Notes on status of CoreAudio Implementation of PortAudio
|
|
||||||
|
|
||||||
Document Last Updated December 9, 2005
|
|
||||||
|
|
||||||
There are currently two implementations of PortAudio for Mac Core Audio.
|
|
||||||
|
|
||||||
The original is in pa_mac_core_old.c, and the newer, default implementation
|
|
||||||
is in pa_mac_core.c.
|
|
||||||
Only pa_mac_core.c is currently developed and supported as it uses apple's
|
|
||||||
current core audio technology. To select use the old implementation, replace
|
|
||||||
pa_mac_core.c with pa_mac_core_old.c (eg. "cp pa_mac_core_auhal.c
|
|
||||||
pa_mac_core.c"), then run configure and make as usual.
|
|
||||||
|
|
||||||
-------------------------------------------
|
|
||||||
|
|
||||||
Notes on Newer/Default AUHAL implementation:
|
|
||||||
|
|
||||||
by Bjorn Roche
|
|
||||||
|
|
||||||
Last Updated December 9, 2005
|
|
||||||
|
|
||||||
Principle of Operation:
|
|
||||||
|
|
||||||
This implementation uses AUHAL for audio I/O. To some extent, it also
|
|
||||||
operates at the "HAL" Layer, though this behavior can be limited by
|
|
||||||
platform specific flags (see pa_mac_core.h for details). The default
|
|
||||||
settings should be reasonable: they don't change the SR of the device and
|
|
||||||
don't cause interruptions if other devices are using the device.
|
|
||||||
|
|
||||||
Major Software Elements Used: Apple's HAL AUs provide output SR
|
|
||||||
conversion transparently, however, only on output, so this
|
|
||||||
implementation uses AudioConverters to convert the sample rate on input.
|
|
||||||
A PortAudio ring buffer is used to buffer input when sample rate
|
|
||||||
conversion is required or when separate audio units are used for duplex
|
|
||||||
IO. Finally, a PortAudio buffer processor is used to convert formats and
|
|
||||||
provide additional buffers if needed. Internally, interleaved floating
|
|
||||||
point data streams are used exclusively - the audio unit converts from
|
|
||||||
the audio hardware's native format to interleaved float PCM and
|
|
||||||
PortAudio's Buffer processor is used for conversion to user formats.
|
|
||||||
|
|
||||||
Simplex Input: Simplex input uses a single callback. If sample rate
|
|
||||||
conversion is required, a ring buffer and AudioConverter are used as
|
|
||||||
well.
|
|
||||||
|
|
||||||
Simplex output: Simplex output uses a single callback. No ring buffer or
|
|
||||||
audio converter is used because AUHAL does its own output SR conversion.
|
|
||||||
|
|
||||||
Duplex, one device (no SR conversion): When one device is used, a single
|
|
||||||
callback is used. This achieves very low latency.
|
|
||||||
|
|
||||||
Duplex, separate devices or SR conversion: When SR conversion is
|
|
||||||
required, data must be buffered before it is converted and data is not
|
|
||||||
always available at the same times on input and output, so SR conversion
|
|
||||||
requires the same treatment as separate devices. The input callback
|
|
||||||
reads data and puts it in the ring buffer. The output callback reads the
|
|
||||||
data off the ring buffer, into an audio converter and finally to the
|
|
||||||
buffer processor.
|
|
||||||
|
|
||||||
Platform Specific Options:
|
|
||||||
|
|
||||||
By using the flags in pa_mac_core.h, the user may specify several options.
|
|
||||||
For example, the user can specify the sample-rate conversion quality, and
|
|
||||||
the extent to which PA will attempt to "play nice" and to what extent it
|
|
||||||
will interrupt other apps to improve performance. For example, if 44100 Hz
|
|
||||||
sample rate is requested but the device is set at 48000 Hz, PA can either
|
|
||||||
change the device for optimal playback ("Pro" mode), which may interrupt
|
|
||||||
other programs playing back audio, or simple use a sample-rate conversion,
|
|
||||||
which allows for friendlier sharing of the device ("Play Nice" mode).
|
|
||||||
|
|
||||||
Additionally, the user may define a "channel mapping" by calling
|
|
||||||
paSetupMacCoreChannelMap() on their stream info structure before opening
|
|
||||||
the stream with it. See below for creating a channel map.
|
|
||||||
|
|
||||||
Known issues:
|
|
||||||
|
|
||||||
- Buffering: No buffering beyond that provided by core audio is provided
|
|
||||||
except where absolutely needed for the implementation to work. This may cause
|
|
||||||
issues with large framesPerBuffer settings and it also means that no additional
|
|
||||||
latency will be provided even if a large latency setting is selected.
|
|
||||||
|
|
||||||
- Latency: Latency settings are generally ignored. They may be used as a
|
|
||||||
hint for buffer size in paHostFramesPerBufferUnspecified, or the value may
|
|
||||||
be used in cases where additional buffering is needed, such as doing input and
|
|
||||||
output on separate devices. Latency settings are always automatically bound
|
|
||||||
to "safe" values, however, so setting extreme values here should not be
|
|
||||||
an issue.
|
|
||||||
|
|
||||||
- Buffer Size: paHostFramesPerBufferUnspecified and specific host buffer sizes
|
|
||||||
are supported. paHostFramesPerBufferUnspecified works best in "pro" mode,
|
|
||||||
where the buffer size and sample rate of the audio device is most likely
|
|
||||||
to match the expected values. In the case of paHostFramesPerBuffer, an
|
|
||||||
appropriate framesPerBuffer value will be used that guarantees minimum
|
|
||||||
requested latency if that's possible.
|
|
||||||
|
|
||||||
- Timing info. It reports on stream time, but I'm probably doing something
|
|
||||||
wrong since patest_sine_time often reports negative latency numbers. Also,
|
|
||||||
there are currently issues with some devices whehn plugging/unplugging
|
|
||||||
devices.
|
|
||||||
|
|
||||||
- xrun detection: The only xrun detection performed is when reading
|
|
||||||
and writing the ring buffer. There is probably more that can be done.
|
|
||||||
|
|
||||||
- abort/stop issues: stopping a stream is always a complete operation,
|
|
||||||
but latency should be low enough to make the lack of a separate abort
|
|
||||||
unnecessary. Apple clarifies its AudioOutputUnitStop() call here:
|
|
||||||
http://lists.apple.com/archives/coreaudio-api/2005/Dec/msg00055.html
|
|
||||||
|
|
||||||
- blocking interface: should work fine.
|
|
||||||
|
|
||||||
- multichannel: It has been tested successfully on multichannel hardware
|
|
||||||
from MOTU: traveler and 896HD. Also Presonus firepod and others. It is
|
|
||||||
believed to work with all Core Audio devices, including virtual devices
|
|
||||||
such as soundflower.
|
|
||||||
|
|
||||||
- sample rate conversion quality: By default, SR conversion is the maximum
|
|
||||||
available. This can be tweaked using flags pa_mac_core.h. Note that the AU
|
|
||||||
render quyality property is used to set the sample rate conversion quality
|
|
||||||
as "documented" here:
|
|
||||||
http://lists.apple.com/archives/coreaudio-api/2004/Jan/msg00141.html
|
|
||||||
|
|
||||||
- x86/Universal Binary: Universal binaries can be build.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Creating a channel map:
|
|
||||||
|
|
||||||
How to create the map array - Text taken From AUHAL.rtfd :
|
|
||||||
[3] Channel Maps
|
|
||||||
Clients can tell the AUHAL units which channels of the device they are interested in. For example, the client may be processing stereo data, but outputting to a six-channel device. This is done by using the kAudioOutputUnitProperty_ChannelMap property. To use this property:
|
|
||||||
|
|
||||||
For Output:
|
|
||||||
Create an array of SInt32 that is the size of the number of channels of the device (Get the Format of the AUHAL's output Element == 0)
|
|
||||||
Initialize each of the array's values to -1 (-1 indicates that that channel is NOT to be presented in the conversion.)
|
|
||||||
|
|
||||||
Next, for each channel of your app's output, set:
|
|
||||||
channelMapArray[deviceOutputChannel] = desiredAppOutputChannel.
|
|
||||||
|
|
||||||
For example: we have a 6 channel output device and our application has a stereo source it wants to provide to the device. Suppose we want that stereo source to go to the 3rd and 4th channels of the device. The channel map would look like this: { -1, -1, 0, 1, -1, -1 }
|
|
||||||
|
|
||||||
Where the formats are:
|
|
||||||
Input Element == 0: 2 channels (- client format - settable)
|
|
||||||
Output Element == 0: 6 channels (- device format - NOT settable)
|
|
||||||
|
|
||||||
So channel 2 (zero-based) of the device will take the first channel of output and channel 3 will take the second channel of output. (This translates to the 3rd and 4th plugs of the 6 output plugs of the device of course!)
|
|
||||||
|
|
||||||
For Input:
|
|
||||||
Create an array of SInt32 that is the size of the number of channels of the format you require for input. Get (or Set in this case as needed) the AUHAL's output Element == 1.
|
|
||||||
|
|
||||||
Next, for each channel of input you require, set:
|
|
||||||
channelMapArray[desiredAppInputChannel] = deviceOutputChannel;
|
|
||||||
|
|
||||||
For example: we have a 6 channel input device from which we wish to receive stereo input from the 3rd and 4th channels. The channel map looks like this: { 2, 3 }
|
|
||||||
|
|
||||||
Where the formats are:
|
|
||||||
Input Element == 0: 2 channels (- device format - NOT settable)
|
|
||||||
Output Element == 0: 6 channels (- client format - settable)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
----------------------------------------
|
|
||||||
|
|
||||||
Notes on Original implementation:
|
|
||||||
|
|
||||||
by Phil Burk and Darren Gibbs
|
|
||||||
|
|
||||||
Last updated March 20, 2002
|
|
||||||
|
|
||||||
WHAT WORKS
|
|
||||||
|
|
||||||
Output with very low latency, <10 msec.
|
|
||||||
Half duplex input or output.
|
|
||||||
Full duplex on the same CoreAudio device.
|
|
||||||
The paFLoat32, paInt16, paInt8, paUInt8 sample formats.
|
|
||||||
Pa_GetCPULoad()
|
|
||||||
Pa_StreamTime()
|
|
||||||
|
|
||||||
KNOWN BUGS OR LIMITATIONS
|
|
||||||
|
|
||||||
We do not yet support simultaneous input and output on different
|
|
||||||
devices. Note that some CoreAudio devices like the Roland UH30 look
|
|
||||||
like one device but are actually two different CoreAudio devices. The
|
|
||||||
Built-In audio is typically one CoreAudio device.
|
|
||||||
|
|
||||||
Mono doesn't work.
|
|
||||||
|
|
||||||
DEVICE MAPPING
|
|
||||||
|
|
||||||
CoreAudio devices can support both input and output. But the sample
|
|
||||||
rates supported may be different. So we have map one or two PortAudio
|
|
||||||
device to each CoreAudio device depending on whether it supports
|
|
||||||
input, output or both.
|
|
||||||
|
|
||||||
When we query devices, we first get a list of CoreAudio devices. Then
|
|
||||||
we scan the list and add a PortAudio device for each CoreAudio device
|
|
||||||
that supports input. Then we make a scan for output devices.
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
@ -1,638 +0,0 @@
|
|||||||
/*
|
|
||||||
* Implementation of the PortAudio API for Apple AUHAL
|
|
||||||
*
|
|
||||||
* PortAudio Portable Real-Time Audio Library
|
|
||||||
* Latest Version at: http://www.portaudio.com
|
|
||||||
*
|
|
||||||
* Written by Bjorn Roche of XO Audio LLC, from PA skeleton code.
|
|
||||||
* Portions copied from code by Dominic Mazzoni (who wrote a HAL implementation)
|
|
||||||
*
|
|
||||||
* Dominic's code was based on code by Phil Burk, Darren Gibbs,
|
|
||||||
* Gord Peters, Stephane Letz, and Greg Pfiel.
|
|
||||||
*
|
|
||||||
* The following people also deserve acknowledgements:
|
|
||||||
*
|
|
||||||
* Olivier Tristan for feedback and testing
|
|
||||||
* Glenn Zelniker and Z-Systems engineering for sponsoring the Blocking I/O
|
|
||||||
* interface.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* Based on the Open Source API proposed by Ross Bencina
|
|
||||||
* Copyright (c) 1999-2002 Ross Bencina, Phil Burk
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files
|
|
||||||
* (the "Software"), to deal in the Software without restriction,
|
|
||||||
* including without limitation the rights to use, copy, modify, merge,
|
|
||||||
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
||||||
* and to permit persons to whom the Software is furnished to do so,
|
|
||||||
* subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be
|
|
||||||
* included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
||||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
|
|
||||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
|
||||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The text above constitutes the entire PortAudio license; however,
|
|
||||||
* the PortAudio community also makes the following non-binding requests:
|
|
||||||
*
|
|
||||||
* Any person wishing to distribute modifications to the Software is
|
|
||||||
* requested to send the modifications to the original developer so that
|
|
||||||
* they can be incorporated into the canonical version. It is also
|
|
||||||
* requested that these non-binding requests be included along with the
|
|
||||||
* license above.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
@file
|
|
||||||
@ingroup hostapi_src
|
|
||||||
|
|
||||||
This file contains the implementation
|
|
||||||
required for blocking I/O. It is separated from pa_mac_core.c simply to ease
|
|
||||||
development.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "pa_mac_core_blocking.h"
|
|
||||||
#include "pa_mac_core_internal.h"
|
|
||||||
#include <assert.h>
|
|
||||||
#ifdef MOSX_USE_NON_ATOMIC_FLAG_BITS
|
|
||||||
# define OSAtomicOr32( a, b ) ( (*(b)) |= (a) )
|
|
||||||
# define OSAtomicAnd32( a, b ) ( (*(b)) &= (a) )
|
|
||||||
#else
|
|
||||||
# include <libkern/OSAtomic.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This function determines the size of a particular sample format.
|
|
||||||
* if the format is not recognized, this returns zero.
|
|
||||||
*/
|
|
||||||
static size_t computeSampleSizeFromFormat( PaSampleFormat format )
|
|
||||||
{
|
|
||||||
switch( format & (~paNonInterleaved) ) {
|
|
||||||
case paFloat32: return 4;
|
|
||||||
case paInt32: return 4;
|
|
||||||
case paInt24: return 3;
|
|
||||||
case paInt16: return 2;
|
|
||||||
case paInt8:
|
|
||||||
case paUInt8: return 1;
|
|
||||||
default: return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Same as computeSampleSizeFromFormat, except that if
|
|
||||||
* the size is not a power of two, it returns the next power of two up
|
|
||||||
*/
|
|
||||||
static size_t computeSampleSizeFromFormatPow2( PaSampleFormat format )
|
|
||||||
{
|
|
||||||
switch( format & (~paNonInterleaved) ) {
|
|
||||||
case paFloat32: return 4;
|
|
||||||
case paInt32: return 4;
|
|
||||||
case paInt24: return 4;
|
|
||||||
case paInt16: return 2;
|
|
||||||
case paInt8:
|
|
||||||
case paUInt8: return 1;
|
|
||||||
default: return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Functions for initializing, resetting, and destroying BLIO structures.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This should be called with the relevant info when initializing a stream for callback.
|
|
||||||
*
|
|
||||||
* @param ringBufferSizeInFrames must be a power of 2
|
|
||||||
*/
|
|
||||||
PaError initializeBlioRingBuffers(
|
|
||||||
PaMacBlio *blio,
|
|
||||||
PaSampleFormat inputSampleFormat,
|
|
||||||
PaSampleFormat outputSampleFormat,
|
|
||||||
long ringBufferSizeInFrames,
|
|
||||||
int inChan,
|
|
||||||
int outChan )
|
|
||||||
{
|
|
||||||
void *data;
|
|
||||||
int result;
|
|
||||||
OSStatus err;
|
|
||||||
|
|
||||||
/* zeroify things */
|
|
||||||
bzero( blio, sizeof( PaMacBlio ) );
|
|
||||||
/* this is redundant, but the buffers are used to check
|
|
||||||
if the buffers have been initialized, so we do it explicitly. */
|
|
||||||
blio->inputRingBuffer.buffer = NULL;
|
|
||||||
blio->outputRingBuffer.buffer = NULL;
|
|
||||||
|
|
||||||
/* initialize simple data */
|
|
||||||
blio->ringBufferFrames = ringBufferSizeInFrames;
|
|
||||||
blio->inputSampleFormat = inputSampleFormat;
|
|
||||||
blio->inputSampleSizeActual = computeSampleSizeFromFormat(inputSampleFormat);
|
|
||||||
blio->inputSampleSizePow2 = computeSampleSizeFromFormatPow2(inputSampleFormat); // FIXME: WHY?
|
|
||||||
blio->outputSampleFormat = outputSampleFormat;
|
|
||||||
blio->outputSampleSizeActual = computeSampleSizeFromFormat(outputSampleFormat);
|
|
||||||
blio->outputSampleSizePow2 = computeSampleSizeFromFormatPow2(outputSampleFormat);
|
|
||||||
|
|
||||||
blio->inChan = inChan;
|
|
||||||
blio->outChan = outChan;
|
|
||||||
blio->statusFlags = 0;
|
|
||||||
blio->errors = paNoError;
|
|
||||||
#ifdef PA_MAC_BLIO_MUTEX
|
|
||||||
blio->isInputEmpty = false;
|
|
||||||
blio->isOutputFull = false;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* setup ring buffers */
|
|
||||||
#ifdef PA_MAC_BLIO_MUTEX
|
|
||||||
result = PaMacCore_SetUnixError( pthread_mutex_init(&(blio->inputMutex),NULL), 0 );
|
|
||||||
if( result )
|
|
||||||
goto error;
|
|
||||||
result = UNIX_ERR( pthread_cond_init( &(blio->inputCond), NULL ) );
|
|
||||||
if( result )
|
|
||||||
goto error;
|
|
||||||
result = UNIX_ERR( pthread_mutex_init(&(blio->outputMutex),NULL) );
|
|
||||||
if( result )
|
|
||||||
goto error;
|
|
||||||
result = UNIX_ERR( pthread_cond_init( &(blio->outputCond), NULL ) );
|
|
||||||
#endif
|
|
||||||
if( inChan ) {
|
|
||||||
data = calloc( ringBufferSizeInFrames, blio->inputSampleSizePow2 * inChan );
|
|
||||||
if( !data )
|
|
||||||
{
|
|
||||||
result = paInsufficientMemory;
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
err = PaUtil_InitializeRingBuffer(
|
|
||||||
&blio->inputRingBuffer,
|
|
||||||
blio->inputSampleSizePow2 * inChan,
|
|
||||||
ringBufferSizeInFrames,
|
|
||||||
data );
|
|
||||||
assert( !err );
|
|
||||||
}
|
|
||||||
if( outChan ) {
|
|
||||||
data = calloc( ringBufferSizeInFrames, blio->outputSampleSizePow2 * outChan );
|
|
||||||
if( !data )
|
|
||||||
{
|
|
||||||
result = paInsufficientMemory;
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
err = PaUtil_InitializeRingBuffer(
|
|
||||||
&blio->outputRingBuffer,
|
|
||||||
blio->outputSampleSizePow2 * outChan,
|
|
||||||
ringBufferSizeInFrames,
|
|
||||||
data );
|
|
||||||
assert( !err );
|
|
||||||
}
|
|
||||||
|
|
||||||
result = resetBlioRingBuffers( blio );
|
|
||||||
if( result )
|
|
||||||
goto error;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
error:
|
|
||||||
destroyBlioRingBuffers( blio );
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef PA_MAC_BLIO_MUTEX
|
|
||||||
PaError blioSetIsInputEmpty( PaMacBlio *blio, bool isEmpty )
|
|
||||||
{
|
|
||||||
PaError result = paNoError;
|
|
||||||
if( isEmpty == blio->isInputEmpty )
|
|
||||||
goto done;
|
|
||||||
|
|
||||||
/* we need to update the value. Here's what we do:
|
|
||||||
* - Lock the mutex, so no one else can write.
|
|
||||||
* - update the value.
|
|
||||||
* - unlock.
|
|
||||||
* - broadcast to all listeners.
|
|
||||||
*/
|
|
||||||
result = UNIX_ERR( pthread_mutex_lock( &blio->inputMutex ) );
|
|
||||||
if( result )
|
|
||||||
goto done;
|
|
||||||
blio->isInputEmpty = isEmpty;
|
|
||||||
result = UNIX_ERR( pthread_mutex_unlock( &blio->inputMutex ) );
|
|
||||||
if( result )
|
|
||||||
goto done;
|
|
||||||
result = UNIX_ERR( pthread_cond_broadcast( &blio->inputCond ) );
|
|
||||||
if( result )
|
|
||||||
goto done;
|
|
||||||
|
|
||||||
done:
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
PaError blioSetIsOutputFull( PaMacBlio *blio, bool isFull )
|
|
||||||
{
|
|
||||||
PaError result = paNoError;
|
|
||||||
if( isFull == blio->isOutputFull )
|
|
||||||
goto done;
|
|
||||||
|
|
||||||
/* we need to update the value. Here's what we do:
|
|
||||||
* - Lock the mutex, so no one else can write.
|
|
||||||
* - update the value.
|
|
||||||
* - unlock.
|
|
||||||
* - broadcast to all listeners.
|
|
||||||
*/
|
|
||||||
result = UNIX_ERR( pthread_mutex_lock( &blio->outputMutex ) );
|
|
||||||
if( result )
|
|
||||||
goto done;
|
|
||||||
blio->isOutputFull = isFull;
|
|
||||||
result = UNIX_ERR( pthread_mutex_unlock( &blio->outputMutex ) );
|
|
||||||
if( result )
|
|
||||||
goto done;
|
|
||||||
result = UNIX_ERR( pthread_cond_broadcast( &blio->outputCond ) );
|
|
||||||
if( result )
|
|
||||||
goto done;
|
|
||||||
|
|
||||||
done:
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* This should be called after stopping or aborting the stream, so that on next
|
|
||||||
start, the buffers will be ready. */
|
|
||||||
PaError resetBlioRingBuffers( PaMacBlio *blio )
|
|
||||||
{
|
|
||||||
#ifdef PA_MAC__BLIO_MUTEX
|
|
||||||
int result;
|
|
||||||
#endif
|
|
||||||
blio->statusFlags = 0;
|
|
||||||
if( blio->outputRingBuffer.buffer ) {
|
|
||||||
PaUtil_FlushRingBuffer( &blio->outputRingBuffer );
|
|
||||||
/* Fill the buffer with zeros. */
|
|
||||||
bzero( blio->outputRingBuffer.buffer,
|
|
||||||
blio->outputRingBuffer.bufferSize * blio->outputRingBuffer.elementSizeBytes );
|
|
||||||
PaUtil_AdvanceRingBufferWriteIndex( &blio->outputRingBuffer, blio->ringBufferFrames );
|
|
||||||
|
|
||||||
/* Update isOutputFull. */
|
|
||||||
#ifdef PA_MAC__BLIO_MUTEX
|
|
||||||
result = blioSetIsOutputFull( blio, toAdvance == blio->outputRingBuffer.bufferSize );
|
|
||||||
if( result )
|
|
||||||
goto error;
|
|
||||||
#endif
|
|
||||||
/*
|
|
||||||
printf( "------%d\n" , blio->outChan );
|
|
||||||
printf( "------%d\n" , blio->outputSampleSize );
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
if( blio->inputRingBuffer.buffer ) {
|
|
||||||
PaUtil_FlushRingBuffer( &blio->inputRingBuffer );
|
|
||||||
bzero( blio->inputRingBuffer.buffer,
|
|
||||||
blio->inputRingBuffer.bufferSize * blio->inputRingBuffer.elementSizeBytes );
|
|
||||||
/* Update isInputEmpty. */
|
|
||||||
#ifdef PA_MAC__BLIO_MUTEX
|
|
||||||
result = blioSetIsInputEmpty( blio, true );
|
|
||||||
if( result )
|
|
||||||
goto error;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
return paNoError;
|
|
||||||
#ifdef PA_MAC__BLIO_MUTEX
|
|
||||||
error:
|
|
||||||
return result;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/*This should be called when you are done with the blio. It can safely be called
|
|
||||||
multiple times if there are no exceptions. */
|
|
||||||
PaError destroyBlioRingBuffers( PaMacBlio *blio )
|
|
||||||
{
|
|
||||||
PaError result = paNoError;
|
|
||||||
if( blio->inputRingBuffer.buffer ) {
|
|
||||||
free( blio->inputRingBuffer.buffer );
|
|
||||||
#ifdef PA_MAC__BLIO_MUTEX
|
|
||||||
result = UNIX_ERR( pthread_mutex_destroy( & blio->inputMutex ) );
|
|
||||||
if( result ) return result;
|
|
||||||
result = UNIX_ERR( pthread_cond_destroy( & blio->inputCond ) );
|
|
||||||
if( result ) return result;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
blio->inputRingBuffer.buffer = NULL;
|
|
||||||
if( blio->outputRingBuffer.buffer ) {
|
|
||||||
free( blio->outputRingBuffer.buffer );
|
|
||||||
#ifdef PA_MAC__BLIO_MUTEX
|
|
||||||
result = UNIX_ERR( pthread_mutex_destroy( & blio->outputMutex ) );
|
|
||||||
if( result ) return result;
|
|
||||||
result = UNIX_ERR( pthread_cond_destroy( & blio->outputCond ) );
|
|
||||||
if( result ) return result;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
blio->outputRingBuffer.buffer = NULL;
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* this is the BlioCallback function. It expects to receive a PaMacBlio Object
|
|
||||||
* pointer as userData.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
int BlioCallback( const void *input, void *output, unsigned long frameCount,
|
|
||||||
const PaStreamCallbackTimeInfo* timeInfo,
|
|
||||||
PaStreamCallbackFlags statusFlags,
|
|
||||||
void *userData )
|
|
||||||
{
|
|
||||||
PaMacBlio *blio = (PaMacBlio*)userData;
|
|
||||||
ring_buffer_size_t framesAvailable;
|
|
||||||
ring_buffer_size_t framesToTransfer;
|
|
||||||
ring_buffer_size_t framesTransferred;
|
|
||||||
|
|
||||||
/* set flags returned by OS: */
|
|
||||||
OSAtomicOr32( statusFlags, &blio->statusFlags ) ;
|
|
||||||
|
|
||||||
/* --- Handle Input Buffer --- */
|
|
||||||
if( blio->inChan ) {
|
|
||||||
framesAvailable = PaUtil_GetRingBufferWriteAvailable( &blio->inputRingBuffer );
|
|
||||||
|
|
||||||
/* check for underflow */
|
|
||||||
if( framesAvailable < frameCount )
|
|
||||||
{
|
|
||||||
OSAtomicOr32( paInputOverflow, &blio->statusFlags );
|
|
||||||
framesToTransfer = framesAvailable;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
framesToTransfer = (ring_buffer_size_t)frameCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Copy the data from the audio input to the application ring buffer. */
|
|
||||||
/*printf( "reading %d\n", toRead );*/
|
|
||||||
framesTransferred = PaUtil_WriteRingBuffer( &blio->inputRingBuffer, input, framesToTransfer );
|
|
||||||
assert( framesToTransfer == framesTransferred );
|
|
||||||
#ifdef PA_MAC__BLIO_MUTEX
|
|
||||||
/* Priority inversion. See notes below. */
|
|
||||||
blioSetIsInputEmpty( blio, false );
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* --- Handle Output Buffer --- */
|
|
||||||
if( blio->outChan ) {
|
|
||||||
framesAvailable = PaUtil_GetRingBufferReadAvailable( &blio->outputRingBuffer );
|
|
||||||
|
|
||||||
/* check for underflow */
|
|
||||||
if( framesAvailable < frameCount )
|
|
||||||
{
|
|
||||||
/* zero out the end of the output buffer that we do not have data for */
|
|
||||||
framesToTransfer = framesAvailable;
|
|
||||||
|
|
||||||
size_t bytesPerFrame = blio->outputSampleSizeActual * blio->outChan;
|
|
||||||
size_t offsetInBytes = framesToTransfer * bytesPerFrame;
|
|
||||||
size_t countInBytes = (frameCount - framesToTransfer) * bytesPerFrame;
|
|
||||||
bzero( ((char *)output) + offsetInBytes, countInBytes );
|
|
||||||
|
|
||||||
OSAtomicOr32( paOutputUnderflow, &blio->statusFlags );
|
|
||||||
framesToTransfer = framesAvailable;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
framesToTransfer = (ring_buffer_size_t)frameCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* copy the data */
|
|
||||||
/*printf( "writing %d\n", toWrite );*/
|
|
||||||
framesTransferred = PaUtil_ReadRingBuffer( &blio->outputRingBuffer, output, framesToTransfer );
|
|
||||||
assert( framesToTransfer == framesTransferred );
|
|
||||||
#ifdef PA_MAC__BLIO_MUTEX
|
|
||||||
/* We have a priority inversion here. However, we will only have to
|
|
||||||
wait if this was true and is now false, which means we've got
|
|
||||||
some room in the buffer.
|
|
||||||
Hopefully problems will be minimized. */
|
|
||||||
blioSetIsOutputFull( blio, false );
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
return paContinue;
|
|
||||||
}
|
|
||||||
|
|
||||||
PaError ReadStream( PaStream* stream,
|
|
||||||
void *buffer,
|
|
||||||
unsigned long framesRequested )
|
|
||||||
{
|
|
||||||
PaMacBlio *blio = & ((PaMacCoreStream*)stream) -> blio;
|
|
||||||
char *cbuf = (char *) buffer;
|
|
||||||
PaError ret = paNoError;
|
|
||||||
VVDBUG(("ReadStream()\n"));
|
|
||||||
|
|
||||||
while( framesRequested > 0 ) {
|
|
||||||
ring_buffer_size_t framesAvailable;
|
|
||||||
ring_buffer_size_t framesToTransfer;
|
|
||||||
ring_buffer_size_t framesTransferred;
|
|
||||||
do {
|
|
||||||
framesAvailable = PaUtil_GetRingBufferReadAvailable( &blio->inputRingBuffer );
|
|
||||||
/*
|
|
||||||
printf( "Read Buffer is %%%g full: %ld of %ld.\n",
|
|
||||||
100 * (float)avail / (float) blio->inputRingBuffer.bufferSize,
|
|
||||||
framesAvailable, blio->inputRingBuffer.bufferSize );
|
|
||||||
*/
|
|
||||||
if( framesAvailable == 0 ) {
|
|
||||||
#ifdef PA_MAC_BLIO_MUTEX
|
|
||||||
/**block when empty*/
|
|
||||||
ret = UNIX_ERR( pthread_mutex_lock( &blio->inputMutex ) );
|
|
||||||
if( ret )
|
|
||||||
return ret;
|
|
||||||
while( blio->isInputEmpty ) {
|
|
||||||
ret = UNIX_ERR( pthread_cond_wait( &blio->inputCond, &blio->inputMutex ) );
|
|
||||||
if( ret )
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
ret = UNIX_ERR( pthread_mutex_unlock( &blio->inputMutex ) );
|
|
||||||
if( ret )
|
|
||||||
return ret;
|
|
||||||
#else
|
|
||||||
Pa_Sleep( PA_MAC_BLIO_BUSY_WAIT_SLEEP_INTERVAL );
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
} while( framesAvailable == 0 );
|
|
||||||
framesToTransfer = (ring_buffer_size_t) MIN( framesAvailable, framesRequested );
|
|
||||||
framesTransferred = PaUtil_ReadRingBuffer( &blio->inputRingBuffer, (void *)cbuf, framesToTransfer );
|
|
||||||
cbuf += framesTransferred * blio->inputSampleSizeActual * blio->inChan;
|
|
||||||
framesRequested -= framesTransferred;
|
|
||||||
|
|
||||||
if( framesToTransfer == framesAvailable ) {
|
|
||||||
#ifdef PA_MAC_BLIO_MUTEX
|
|
||||||
/* we just emptied the buffer, so we need to mark it as empty. */
|
|
||||||
ret = blioSetIsInputEmpty( blio, true );
|
|
||||||
if( ret )
|
|
||||||
return ret;
|
|
||||||
/* of course, in the meantime, the callback may have put some sats
|
|
||||||
in, so
|
|
||||||
so check for that, too, to avoid a race condition. */
|
|
||||||
/* FIXME - this does not seem to fix any race condition. */
|
|
||||||
if( PaUtil_GetRingBufferReadAvailable( &blio->inputRingBuffer ) ) {
|
|
||||||
blioSetIsInputEmpty( blio, false );
|
|
||||||
/* FIXME - why check? ret has not been set? */
|
|
||||||
if( ret )
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Report either paNoError or paInputOverflowed. */
|
|
||||||
/* may also want to report other errors, but this is non-standard. */
|
|
||||||
/* FIXME should not clobber ret, use if(blio->statusFlags & paInputOverflow) */
|
|
||||||
ret = blio->statusFlags & paInputOverflow;
|
|
||||||
|
|
||||||
/* report underflow only once: */
|
|
||||||
if( ret ) {
|
|
||||||
OSAtomicAnd32( (uint32_t)(~paInputOverflow), &blio->statusFlags );
|
|
||||||
ret = paInputOverflowed;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
PaError WriteStream( PaStream* stream,
|
|
||||||
const void *buffer,
|
|
||||||
unsigned long framesRequested )
|
|
||||||
{
|
|
||||||
PaMacCoreStream *macStream = (PaMacCoreStream*)stream;
|
|
||||||
PaMacBlio *blio = &macStream->blio;
|
|
||||||
char *cbuf = (char *) buffer;
|
|
||||||
PaError ret = paNoError;
|
|
||||||
VVDBUG(("WriteStream()\n"));
|
|
||||||
|
|
||||||
while( framesRequested > 0 && macStream->state != STOPPING ) {
|
|
||||||
ring_buffer_size_t framesAvailable;
|
|
||||||
ring_buffer_size_t framesToTransfer;
|
|
||||||
ring_buffer_size_t framesTransferred;
|
|
||||||
|
|
||||||
do {
|
|
||||||
framesAvailable = PaUtil_GetRingBufferWriteAvailable( &blio->outputRingBuffer );
|
|
||||||
/*
|
|
||||||
printf( "Write Buffer is %%%g full: %ld of %ld.\n",
|
|
||||||
100 - 100 * (float)avail / (float) blio->outputRingBuffer.bufferSize,
|
|
||||||
framesAvailable, blio->outputRingBuffer.bufferSize );
|
|
||||||
*/
|
|
||||||
if( framesAvailable == 0 ) {
|
|
||||||
#ifdef PA_MAC_BLIO_MUTEX
|
|
||||||
/*block while full*/
|
|
||||||
ret = UNIX_ERR( pthread_mutex_lock( &blio->outputMutex ) );
|
|
||||||
if( ret )
|
|
||||||
return ret;
|
|
||||||
while( blio->isOutputFull ) {
|
|
||||||
ret = UNIX_ERR( pthread_cond_wait( &blio->outputCond, &blio->outputMutex ) );
|
|
||||||
if( ret )
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
ret = UNIX_ERR( pthread_mutex_unlock( &blio->outputMutex ) );
|
|
||||||
if( ret )
|
|
||||||
return ret;
|
|
||||||
#else
|
|
||||||
Pa_Sleep( PA_MAC_BLIO_BUSY_WAIT_SLEEP_INTERVAL );
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
} while( framesAvailable == 0 && macStream->state != STOPPING );
|
|
||||||
|
|
||||||
if( macStream->state == STOPPING )
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
framesToTransfer = MIN( framesAvailable, framesRequested );
|
|
||||||
framesTransferred = PaUtil_WriteRingBuffer( &blio->outputRingBuffer, (void *)cbuf, framesToTransfer );
|
|
||||||
cbuf += framesTransferred * blio->outputSampleSizeActual * blio->outChan;
|
|
||||||
framesRequested -= framesTransferred;
|
|
||||||
|
|
||||||
#ifdef PA_MAC_BLIO_MUTEX
|
|
||||||
if( framesToTransfer == framesAvailable ) {
|
|
||||||
/* we just filled up the buffer, so we need to mark it as filled. */
|
|
||||||
ret = blioSetIsOutputFull( blio, true );
|
|
||||||
if( ret )
|
|
||||||
return ret;
|
|
||||||
/* of course, in the meantime, we may have emptied the buffer, so
|
|
||||||
so check for that, too, to avoid a race condition. */
|
|
||||||
if( PaUtil_GetRingBufferWriteAvailable( &blio->outputRingBuffer ) ) {
|
|
||||||
blioSetIsOutputFull( blio, false );
|
|
||||||
/* FIXME remove or review this code, does not fix race, ret not set! */
|
|
||||||
if( ret )
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( macStream->state == STOPPING )
|
|
||||||
{
|
|
||||||
ret = paInternalError;
|
|
||||||
}
|
|
||||||
else if (ret == paNoError )
|
|
||||||
{
|
|
||||||
/* Test for underflow. */
|
|
||||||
ret = blio->statusFlags & paOutputUnderflow;
|
|
||||||
|
|
||||||
/* report underflow only once: */
|
|
||||||
if( ret )
|
|
||||||
{
|
|
||||||
OSAtomicAnd32( (uint32_t)(~paOutputUnderflow), &blio->statusFlags );
|
|
||||||
ret = paOutputUnderflowed;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Wait until the data in the buffer has finished playing.
|
|
||||||
*/
|
|
||||||
PaError waitUntilBlioWriteBufferIsEmpty( PaMacBlio *blio, double sampleRate,
|
|
||||||
size_t framesPerBuffer )
|
|
||||||
{
|
|
||||||
PaError result = paNoError;
|
|
||||||
if( blio->outputRingBuffer.buffer ) {
|
|
||||||
ring_buffer_size_t framesLeft = PaUtil_GetRingBufferReadAvailable( &blio->outputRingBuffer );
|
|
||||||
|
|
||||||
/* Calculate when we should give up waiting. To be safe wait for two extra periods. */
|
|
||||||
PaTime now = PaUtil_GetTime();
|
|
||||||
PaTime startTime = now;
|
|
||||||
PaTime timeoutTime = startTime + (framesLeft + (2 * framesPerBuffer)) / sampleRate;
|
|
||||||
|
|
||||||
long msecPerBuffer = 1 + (long)( 1000.0 * framesPerBuffer / sampleRate);
|
|
||||||
while( framesLeft > 0 && now < timeoutTime ) {
|
|
||||||
VDBUG(( "waitUntilBlioWriteBufferIsFlushed: framesLeft = %d, framesPerBuffer = %ld\n",
|
|
||||||
framesLeft, framesPerBuffer ));
|
|
||||||
Pa_Sleep( msecPerBuffer );
|
|
||||||
framesLeft = PaUtil_GetRingBufferReadAvailable( &blio->outputRingBuffer );
|
|
||||||
now = PaUtil_GetTime();
|
|
||||||
}
|
|
||||||
|
|
||||||
if( framesLeft > 0 )
|
|
||||||
{
|
|
||||||
VDBUG(( "waitUntilBlioWriteBufferIsFlushed: TIMED OUT - framesLeft = %d\n", framesLeft ));
|
|
||||||
result = paTimedOut;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
signed long GetStreamReadAvailable( PaStream* stream )
|
|
||||||
{
|
|
||||||
PaMacBlio *blio = & ((PaMacCoreStream*)stream) -> blio;
|
|
||||||
VVDBUG(("GetStreamReadAvailable()\n"));
|
|
||||||
|
|
||||||
return PaUtil_GetRingBufferReadAvailable( &blio->inputRingBuffer );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
signed long GetStreamWriteAvailable( PaStream* stream )
|
|
||||||
{
|
|
||||||
PaMacBlio *blio = & ((PaMacCoreStream*)stream) -> blio;
|
|
||||||
VVDBUG(("GetStreamWriteAvailable()\n"));
|
|
||||||
|
|
||||||
return PaUtil_GetRingBufferWriteAvailable( &blio->outputRingBuffer );
|
|
||||||
}
|
|
@ -1,134 +0,0 @@
|
|||||||
/*
|
|
||||||
* Internal blocking interfaces for PortAudio Apple AUHAL implementation
|
|
||||||
*
|
|
||||||
* PortAudio Portable Real-Time Audio Library
|
|
||||||
* Latest Version at: http://www.portaudio.com
|
|
||||||
*
|
|
||||||
* Written by Bjorn Roche of XO Audio LLC, from PA skeleton code.
|
|
||||||
* Portions copied from code by Dominic Mazzoni (who wrote a HAL implementation)
|
|
||||||
*
|
|
||||||
* Dominic's code was based on code by Phil Burk, Darren Gibbs,
|
|
||||||
* Gord Peters, Stephane Letz, and Greg Pfiel.
|
|
||||||
*
|
|
||||||
* The following people also deserve acknowledgements:
|
|
||||||
*
|
|
||||||
* Olivier Tristan for feedback and testing
|
|
||||||
* Glenn Zelniker and Z-Systems engineering for sponsoring the Blocking I/O
|
|
||||||
* interface.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* Based on the Open Source API proposed by Ross Bencina
|
|
||||||
* Copyright (c) 1999-2002 Ross Bencina, Phil Burk
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files
|
|
||||||
* (the "Software"), to deal in the Software without restriction,
|
|
||||||
* including without limitation the rights to use, copy, modify, merge,
|
|
||||||
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
||||||
* and to permit persons to whom the Software is furnished to do so,
|
|
||||||
* subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be
|
|
||||||
* included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
||||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
|
|
||||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
|
||||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The text above constitutes the entire PortAudio license; however,
|
|
||||||
* the PortAudio community also makes the following non-binding requests:
|
|
||||||
*
|
|
||||||
* Any person wishing to distribute modifications to the Software is
|
|
||||||
* requested to send the modifications to the original developer so that
|
|
||||||
* they can be incorporated into the canonical version. It is also
|
|
||||||
* requested that these non-binding requests be included along with the
|
|
||||||
* license above.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
@file
|
|
||||||
@ingroup hostapi_src
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef PA_MAC_CORE_BLOCKING_H_
|
|
||||||
#define PA_MAC_CORE_BLOCKING_H_
|
|
||||||
|
|
||||||
#include "pa_ringbuffer.h"
|
|
||||||
#include "portaudio.h"
|
|
||||||
#include "pa_mac_core_utilities.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Number of milliseconds to busy wait while waiting for data in blocking calls.
|
|
||||||
*/
|
|
||||||
#define PA_MAC_BLIO_BUSY_WAIT_SLEEP_INTERVAL (5)
|
|
||||||
/*
|
|
||||||
* Define exactly one of these blocking methods
|
|
||||||
* PA_MAC_BLIO_MUTEX is not actively maintained.
|
|
||||||
*/
|
|
||||||
#define PA_MAC_BLIO_BUSY_WAIT
|
|
||||||
/*
|
|
||||||
#define PA_MAC_BLIO_MUTEX
|
|
||||||
*/
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
PaUtilRingBuffer inputRingBuffer;
|
|
||||||
PaUtilRingBuffer outputRingBuffer;
|
|
||||||
ring_buffer_size_t ringBufferFrames;
|
|
||||||
PaSampleFormat inputSampleFormat;
|
|
||||||
size_t inputSampleSizeActual;
|
|
||||||
size_t inputSampleSizePow2;
|
|
||||||
PaSampleFormat outputSampleFormat;
|
|
||||||
size_t outputSampleSizeActual;
|
|
||||||
size_t outputSampleSizePow2;
|
|
||||||
|
|
||||||
int inChan;
|
|
||||||
int outChan;
|
|
||||||
|
|
||||||
//PaStreamCallbackFlags statusFlags;
|
|
||||||
uint32_t statusFlags;
|
|
||||||
PaError errors;
|
|
||||||
|
|
||||||
/* Here we handle blocking, using condition variables. */
|
|
||||||
#ifdef PA_MAC_BLIO_MUTEX
|
|
||||||
volatile bool isInputEmpty;
|
|
||||||
pthread_mutex_t inputMutex;
|
|
||||||
pthread_cond_t inputCond;
|
|
||||||
|
|
||||||
volatile bool isOutputFull;
|
|
||||||
pthread_mutex_t outputMutex;
|
|
||||||
pthread_cond_t outputCond;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
PaMacBlio;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* These functions operate on condition and related variables.
|
|
||||||
*/
|
|
||||||
|
|
||||||
PaError initializeBlioRingBuffers(
|
|
||||||
PaMacBlio *blio,
|
|
||||||
PaSampleFormat inputSampleFormat,
|
|
||||||
PaSampleFormat outputSampleFormat,
|
|
||||||
long ringBufferSizeInFrames,
|
|
||||||
int inChan,
|
|
||||||
int outChan );
|
|
||||||
PaError destroyBlioRingBuffers( PaMacBlio *blio );
|
|
||||||
PaError resetBlioRingBuffers( PaMacBlio *blio );
|
|
||||||
|
|
||||||
int BlioCallback(
|
|
||||||
const void *input, void *output,
|
|
||||||
unsigned long frameCount,
|
|
||||||
const PaStreamCallbackTimeInfo* timeInfo,
|
|
||||||
PaStreamCallbackFlags statusFlags,
|
|
||||||
void *userData );
|
|
||||||
|
|
||||||
PaError waitUntilBlioWriteBufferIsEmpty( PaMacBlio *blio, double sampleRate,
|
|
||||||
size_t framesPerBuffer );
|
|
||||||
|
|
||||||
#endif /*PA_MAC_CORE_BLOCKING_H_*/
|
|
@ -1,193 +0,0 @@
|
|||||||
/*
|
|
||||||
* Internal interfaces for PortAudio Apple AUHAL implementation
|
|
||||||
*
|
|
||||||
* PortAudio Portable Real-Time Audio Library
|
|
||||||
* Latest Version at: http://www.portaudio.com
|
|
||||||
*
|
|
||||||
* Written by Bjorn Roche of XO Audio LLC, from PA skeleton code.
|
|
||||||
* Portions copied from code by Dominic Mazzoni (who wrote a HAL implementation)
|
|
||||||
*
|
|
||||||
* Dominic's code was based on code by Phil Burk, Darren Gibbs,
|
|
||||||
* Gord Peters, Stephane Letz, and Greg Pfiel.
|
|
||||||
*
|
|
||||||
* The following people also deserve acknowledgements:
|
|
||||||
*
|
|
||||||
* Olivier Tristan for feedback and testing
|
|
||||||
* Glenn Zelniker and Z-Systems engineering for sponsoring the Blocking I/O
|
|
||||||
* interface.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* Based on the Open Source API proposed by Ross Bencina
|
|
||||||
* Copyright (c) 1999-2002 Ross Bencina, Phil Burk
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files
|
|
||||||
* (the "Software"), to deal in the Software without restriction,
|
|
||||||
* including without limitation the rights to use, copy, modify, merge,
|
|
||||||
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
||||||
* and to permit persons to whom the Software is furnished to do so,
|
|
||||||
* subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be
|
|
||||||
* included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
||||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
|
|
||||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
|
||||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The text above constitutes the entire PortAudio license; however,
|
|
||||||
* the PortAudio community also makes the following non-binding requests:
|
|
||||||
*
|
|
||||||
* Any person wishing to distribute modifications to the Software is
|
|
||||||
* requested to send the modifications to the original developer so that
|
|
||||||
* they can be incorporated into the canonical version. It is also
|
|
||||||
* requested that these non-binding requests be included along with the
|
|
||||||
* license above.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
@file pa_mac_core
|
|
||||||
@ingroup hostapi_src
|
|
||||||
@author Bjorn Roche
|
|
||||||
@brief AUHAL implementation of PortAudio
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef PA_MAC_CORE_INTERNAL_H__
|
|
||||||
#define PA_MAC_CORE_INTERNAL_H__
|
|
||||||
|
|
||||||
#include <CoreAudio/CoreAudio.h>
|
|
||||||
#include <CoreServices/CoreServices.h>
|
|
||||||
#include <AudioUnit/AudioUnit.h>
|
|
||||||
#include <AudioToolbox/AudioToolbox.h>
|
|
||||||
|
|
||||||
#include "portaudio.h"
|
|
||||||
#include "pa_util.h"
|
|
||||||
#include "pa_hostapi.h"
|
|
||||||
#include "pa_stream.h"
|
|
||||||
#include "pa_allocation.h"
|
|
||||||
#include "pa_cpuload.h"
|
|
||||||
#include "pa_process.h"
|
|
||||||
#include "pa_ringbuffer.h"
|
|
||||||
|
|
||||||
#include "pa_mac_core_blocking.h"
|
|
||||||
|
|
||||||
/* function prototypes */
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#endif /* __cplusplus */
|
|
||||||
|
|
||||||
PaError PaMacCore_Initialize( PaUtilHostApiRepresentation **hostApi, PaHostApiIndex index );
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif /* __cplusplus */
|
|
||||||
|
|
||||||
#define RING_BUFFER_ADVANCE_DENOMINATOR (4)
|
|
||||||
|
|
||||||
PaError ReadStream( PaStream* stream, void *buffer, unsigned long frames );
|
|
||||||
PaError WriteStream( PaStream* stream, const void *buffer, unsigned long frames );
|
|
||||||
signed long GetStreamReadAvailable( PaStream* stream );
|
|
||||||
signed long GetStreamWriteAvailable( PaStream* stream );
|
|
||||||
/* PaMacAUHAL - host api datastructure specific to this implementation */
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
PaUtilHostApiRepresentation inheritedHostApiRep;
|
|
||||||
PaUtilStreamInterface callbackStreamInterface;
|
|
||||||
PaUtilStreamInterface blockingStreamInterface;
|
|
||||||
|
|
||||||
PaUtilAllocationGroup *allocations;
|
|
||||||
|
|
||||||
/* implementation specific data goes here */
|
|
||||||
long devCount;
|
|
||||||
AudioDeviceID *devIds; /*array of all audio devices*/
|
|
||||||
AudioDeviceID defaultIn;
|
|
||||||
AudioDeviceID defaultOut;
|
|
||||||
}
|
|
||||||
PaMacAUHAL;
|
|
||||||
|
|
||||||
typedef struct PaMacCoreDeviceProperties
|
|
||||||
{
|
|
||||||
/* Values in Frames from property queries. */
|
|
||||||
UInt32 safetyOffset;
|
|
||||||
UInt32 bufferFrameSize;
|
|
||||||
// UInt32 streamLatency; // Seems to be the same as deviceLatency!?
|
|
||||||
UInt32 deviceLatency;
|
|
||||||
/* Current device sample rate. May change!
|
|
||||||
These are initialized to the nominal device sample rate,
|
|
||||||
and updated with the actual sample rate, when/where available.
|
|
||||||
Note that these are the *device* sample rates, prior to any required
|
|
||||||
SR conversion. */
|
|
||||||
Float64 sampleRate;
|
|
||||||
Float64 samplePeriod; // reciprocal
|
|
||||||
}
|
|
||||||
PaMacCoreDeviceProperties;
|
|
||||||
|
|
||||||
/* stream data structure specifically for this implementation */
|
|
||||||
typedef struct PaMacCoreStream
|
|
||||||
{
|
|
||||||
PaUtilStreamRepresentation streamRepresentation;
|
|
||||||
PaUtilCpuLoadMeasurer cpuLoadMeasurer;
|
|
||||||
PaUtilBufferProcessor bufferProcessor;
|
|
||||||
|
|
||||||
/* implementation specific data goes here */
|
|
||||||
bool bufferProcessorIsInitialized;
|
|
||||||
AudioUnit inputUnit;
|
|
||||||
AudioUnit outputUnit;
|
|
||||||
AudioDeviceID inputDevice;
|
|
||||||
AudioDeviceID outputDevice;
|
|
||||||
size_t userInChan;
|
|
||||||
size_t userOutChan;
|
|
||||||
size_t inputFramesPerBuffer;
|
|
||||||
size_t outputFramesPerBuffer;
|
|
||||||
PaMacBlio blio;
|
|
||||||
/* We use this ring buffer when input and out devs are different. */
|
|
||||||
PaUtilRingBuffer inputRingBuffer;
|
|
||||||
/* We may need to do SR conversion on input. */
|
|
||||||
AudioConverterRef inputSRConverter;
|
|
||||||
/* We need to preallocate an inputBuffer for reading data. */
|
|
||||||
AudioBufferList inputAudioBufferList;
|
|
||||||
AudioTimeStamp startTime;
|
|
||||||
/* FIXME: instead of volatile, these should be properly memory barriered */
|
|
||||||
volatile uint32_t xrunFlags; /*PaStreamCallbackFlags*/
|
|
||||||
volatile enum {
|
|
||||||
STOPPED = 0, /* playback is completely stopped,
|
|
||||||
and the user has called StopStream(). */
|
|
||||||
CALLBACK_STOPPED = 1, /* callback has requested stop,
|
|
||||||
but user has not yet called StopStream(). */
|
|
||||||
STOPPING = 2, /* The stream is in the process of closing
|
|
||||||
because the user has called StopStream.
|
|
||||||
This state is just used internally;
|
|
||||||
externally it is indistinguishable from
|
|
||||||
ACTIVE.*/
|
|
||||||
ACTIVE = 3 /* The stream is active and running. */
|
|
||||||
} state;
|
|
||||||
double sampleRate;
|
|
||||||
PaMacCoreDeviceProperties inputProperties;
|
|
||||||
PaMacCoreDeviceProperties outputProperties;
|
|
||||||
|
|
||||||
/* data updated by main thread and notifications, protected by timingInformationMutex */
|
|
||||||
int timingInformationMutexIsInitialized;
|
|
||||||
pthread_mutex_t timingInformationMutex;
|
|
||||||
|
|
||||||
/* These are written by the PA thread or from CoreAudio callbacks. Protected by the mutex. */
|
|
||||||
Float64 timestampOffsetCombined;
|
|
||||||
Float64 timestampOffsetInputDevice;
|
|
||||||
Float64 timestampOffsetOutputDevice;
|
|
||||||
|
|
||||||
/* Offsets in seconds to be applied to Apple timestamps to convert them to PA timestamps.
|
|
||||||
* While the io proc is active, the following values are only accessed and manipulated by the ioproc */
|
|
||||||
Float64 timestampOffsetCombined_ioProcCopy;
|
|
||||||
Float64 timestampOffsetInputDevice_ioProcCopy;
|
|
||||||
Float64 timestampOffsetOutputDevice_ioProcCopy;
|
|
||||||
}
|
|
||||||
PaMacCoreStream;
|
|
||||||
|
|
||||||
#endif /* PA_MAC_CORE_INTERNAL_H__ */
|
|
@ -1,814 +0,0 @@
|
|||||||
/*
|
|
||||||
* Helper and utility functions for pa_mac_core.c (Apple AUHAL implementation)
|
|
||||||
*
|
|
||||||
* PortAudio Portable Real-Time Audio Library
|
|
||||||
* Latest Version at: http://www.portaudio.com
|
|
||||||
*
|
|
||||||
* Written by Bjorn Roche of XO Audio LLC, from PA skeleton code.
|
|
||||||
* Portions copied from code by Dominic Mazzoni (who wrote a HAL implementation)
|
|
||||||
*
|
|
||||||
* Dominic's code was based on code by Phil Burk, Darren Gibbs,
|
|
||||||
* Gord Peters, Stephane Letz, and Greg Pfiel.
|
|
||||||
*
|
|
||||||
* The following people also deserve acknowledgements:
|
|
||||||
*
|
|
||||||
* Olivier Tristan for feedback and testing
|
|
||||||
* Glenn Zelniker and Z-Systems engineering for sponsoring the Blocking I/O
|
|
||||||
* interface.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* Based on the Open Source API proposed by Ross Bencina
|
|
||||||
* Copyright (c) 1999-2002 Ross Bencina, Phil Burk
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files
|
|
||||||
* (the "Software"), to deal in the Software without restriction,
|
|
||||||
* including without limitation the rights to use, copy, modify, merge,
|
|
||||||
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
||||||
* and to permit persons to whom the Software is furnished to do so,
|
|
||||||
* subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be
|
|
||||||
* included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
||||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
|
|
||||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
|
||||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The text above constitutes the entire PortAudio license; however,
|
|
||||||
* the PortAudio community also makes the following non-binding requests:
|
|
||||||
*
|
|
||||||
* Any person wishing to distribute modifications to the Software is
|
|
||||||
* requested to send the modifications to the original developer so that
|
|
||||||
* they can be incorporated into the canonical version. It is also
|
|
||||||
* requested that these non-binding requests be included along with the
|
|
||||||
* license above.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
@file
|
|
||||||
@ingroup hostapi_src
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "pa_mac_core_utilities.h"
|
|
||||||
#include "pa_mac_core_internal.h"
|
|
||||||
#include <libkern/OSAtomic.h>
|
|
||||||
#include <strings.h>
|
|
||||||
#include <pthread.h>
|
|
||||||
#include <sys/time.h>
|
|
||||||
|
|
||||||
OSStatus PaMacCore_AudioHardwareGetProperty(
|
|
||||||
AudioHardwarePropertyID inPropertyID,
|
|
||||||
UInt32* ioPropertyDataSize,
|
|
||||||
void* outPropertyData )
|
|
||||||
{
|
|
||||||
AudioObjectPropertyAddress address = { inPropertyID, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster };
|
|
||||||
return AudioObjectGetPropertyData(kAudioObjectSystemObject, &address, 0, NULL, ioPropertyDataSize, outPropertyData);
|
|
||||||
}
|
|
||||||
|
|
||||||
OSStatus PaMacCore_AudioHardwareGetPropertySize(
|
|
||||||
AudioHardwarePropertyID inPropertyID,
|
|
||||||
UInt32* outSize )
|
|
||||||
{
|
|
||||||
AudioObjectPropertyAddress address = { inPropertyID, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster };
|
|
||||||
return AudioObjectGetPropertyDataSize(kAudioObjectSystemObject, &address, 0, NULL, outSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
OSStatus PaMacCore_AudioDeviceGetProperty(
|
|
||||||
AudioDeviceID inDevice,
|
|
||||||
UInt32 inChannel,
|
|
||||||
Boolean isInput,
|
|
||||||
AudioDevicePropertyID inPropertyID,
|
|
||||||
UInt32* ioPropertyDataSize,
|
|
||||||
void* outPropertyData )
|
|
||||||
{
|
|
||||||
AudioObjectPropertyScope scope = isInput ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput;
|
|
||||||
AudioObjectPropertyAddress address = { inPropertyID, scope, inChannel };
|
|
||||||
return AudioObjectGetPropertyData(inDevice, &address, 0, NULL, ioPropertyDataSize, outPropertyData);
|
|
||||||
}
|
|
||||||
|
|
||||||
OSStatus PaMacCore_AudioDeviceSetProperty(
|
|
||||||
AudioDeviceID inDevice,
|
|
||||||
const AudioTimeStamp* inWhen,
|
|
||||||
UInt32 inChannel,
|
|
||||||
Boolean isInput,
|
|
||||||
AudioDevicePropertyID inPropertyID,
|
|
||||||
UInt32 inPropertyDataSize,
|
|
||||||
const void* inPropertyData )
|
|
||||||
{
|
|
||||||
AudioObjectPropertyScope scope = isInput ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput;
|
|
||||||
AudioObjectPropertyAddress address = { inPropertyID, scope, inChannel };
|
|
||||||
return AudioObjectSetPropertyData(inDevice, &address, 0, NULL, inPropertyDataSize, inPropertyData);
|
|
||||||
}
|
|
||||||
|
|
||||||
OSStatus PaMacCore_AudioDeviceGetPropertySize(
|
|
||||||
AudioDeviceID inDevice,
|
|
||||||
UInt32 inChannel,
|
|
||||||
Boolean isInput,
|
|
||||||
AudioDevicePropertyID inPropertyID,
|
|
||||||
UInt32* outSize )
|
|
||||||
{
|
|
||||||
AudioObjectPropertyScope scope = isInput ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput;
|
|
||||||
AudioObjectPropertyAddress address = { inPropertyID, scope, inChannel };
|
|
||||||
return AudioObjectGetPropertyDataSize(inDevice, &address, 0, NULL, outSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
OSStatus PaMacCore_AudioDeviceAddPropertyListener(
|
|
||||||
AudioDeviceID inDevice,
|
|
||||||
UInt32 inChannel,
|
|
||||||
Boolean isInput,
|
|
||||||
AudioDevicePropertyID inPropertyID,
|
|
||||||
AudioObjectPropertyListenerProc inProc,
|
|
||||||
void* inClientData )
|
|
||||||
{
|
|
||||||
AudioObjectPropertyScope scope = isInput ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput;
|
|
||||||
AudioObjectPropertyAddress address = { inPropertyID, scope, inChannel };
|
|
||||||
return AudioObjectAddPropertyListener(inDevice, &address, inProc, inClientData);
|
|
||||||
}
|
|
||||||
|
|
||||||
OSStatus PaMacCore_AudioDeviceRemovePropertyListener(
|
|
||||||
AudioDeviceID inDevice,
|
|
||||||
UInt32 inChannel,
|
|
||||||
Boolean isInput,
|
|
||||||
AudioDevicePropertyID inPropertyID,
|
|
||||||
AudioObjectPropertyListenerProc inProc,
|
|
||||||
void* inClientData )
|
|
||||||
{
|
|
||||||
AudioObjectPropertyScope scope = isInput ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput;
|
|
||||||
AudioObjectPropertyAddress address = { inPropertyID, scope, inChannel };
|
|
||||||
return AudioObjectRemovePropertyListener(inDevice, &address, inProc, inClientData);
|
|
||||||
}
|
|
||||||
|
|
||||||
OSStatus PaMacCore_AudioStreamGetProperty(
|
|
||||||
AudioStreamID inStream,
|
|
||||||
UInt32 inChannel,
|
|
||||||
AudioDevicePropertyID inPropertyID,
|
|
||||||
UInt32* ioPropertyDataSize,
|
|
||||||
void* outPropertyData )
|
|
||||||
{
|
|
||||||
AudioObjectPropertyAddress address = { inPropertyID, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster };
|
|
||||||
return AudioObjectGetPropertyData(inStream, &address, 0, NULL, ioPropertyDataSize, outPropertyData);
|
|
||||||
}
|
|
||||||
|
|
||||||
PaError PaMacCore_SetUnixError( int err, int line )
|
|
||||||
{
|
|
||||||
PaError ret;
|
|
||||||
const char *errorText;
|
|
||||||
|
|
||||||
if( err == 0 )
|
|
||||||
{
|
|
||||||
return paNoError;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = paNoError;
|
|
||||||
errorText = strerror( err );
|
|
||||||
|
|
||||||
/** Map Unix error to PaError. Pretty much the only one that maps
|
|
||||||
is ENOMEM. */
|
|
||||||
if( err == ENOMEM )
|
|
||||||
ret = paInsufficientMemory;
|
|
||||||
else
|
|
||||||
ret = paInternalError;
|
|
||||||
|
|
||||||
DBUG(("%d on line %d: msg='%s'\n", err, line, errorText));
|
|
||||||
PaUtil_SetLastHostErrorInfo( paCoreAudio, err, errorText );
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Translates MacOS generated errors into PaErrors
|
|
||||||
*/
|
|
||||||
PaError PaMacCore_SetError(OSStatus error, int line, int isError)
|
|
||||||
{
|
|
||||||
/*FIXME: still need to handle possible ComponentResult values.*/
|
|
||||||
/* unfortunately, they don't seem to be documented anywhere.*/
|
|
||||||
PaError result;
|
|
||||||
const char *errorType;
|
|
||||||
const char *errorText;
|
|
||||||
|
|
||||||
switch (error) {
|
|
||||||
case kAudioHardwareNoError:
|
|
||||||
return paNoError;
|
|
||||||
case kAudioHardwareNotRunningError:
|
|
||||||
errorText = "Audio Hardware Not Running";
|
|
||||||
result = paInternalError;
|
|
||||||
break;
|
|
||||||
case kAudioHardwareUnspecifiedError:
|
|
||||||
errorText = "Unspecified Audio Hardware Error";
|
|
||||||
result = paInternalError;
|
|
||||||
break;
|
|
||||||
case kAudioHardwareUnknownPropertyError:
|
|
||||||
errorText = "Audio Hardware: Unknown Property";
|
|
||||||
result = paInternalError;
|
|
||||||
break;
|
|
||||||
case kAudioHardwareBadPropertySizeError:
|
|
||||||
errorText = "Audio Hardware: Bad Property Size";
|
|
||||||
result = paInternalError;
|
|
||||||
break;
|
|
||||||
case kAudioHardwareIllegalOperationError:
|
|
||||||
errorText = "Audio Hardware: Illegal Operation";
|
|
||||||
result = paInternalError;
|
|
||||||
break;
|
|
||||||
case kAudioHardwareBadDeviceError:
|
|
||||||
errorText = "Audio Hardware: Bad Device";
|
|
||||||
result = paInvalidDevice;
|
|
||||||
break;
|
|
||||||
case kAudioHardwareBadStreamError:
|
|
||||||
errorText = "Audio Hardware: BadStream";
|
|
||||||
result = paBadStreamPtr;
|
|
||||||
break;
|
|
||||||
case kAudioHardwareUnsupportedOperationError:
|
|
||||||
errorText = "Audio Hardware: Unsupported Operation";
|
|
||||||
result = paInternalError;
|
|
||||||
break;
|
|
||||||
case kAudioDeviceUnsupportedFormatError:
|
|
||||||
errorText = "Audio Device: Unsupported Format";
|
|
||||||
result = paSampleFormatNotSupported;
|
|
||||||
break;
|
|
||||||
case kAudioDevicePermissionsError:
|
|
||||||
errorText = "Audio Device: Permissions Error";
|
|
||||||
result = paDeviceUnavailable;
|
|
||||||
break;
|
|
||||||
/* Audio Unit Errors: http://developer.apple.com/documentation/MusicAudio/Reference/CoreAudio/audio_units/chapter_5_section_3.html */
|
|
||||||
case kAudioUnitErr_InvalidProperty:
|
|
||||||
errorText = "Audio Unit: Invalid Property";
|
|
||||||
result = paInternalError;
|
|
||||||
break;
|
|
||||||
case kAudioUnitErr_InvalidParameter:
|
|
||||||
errorText = "Audio Unit: Invalid Parameter";
|
|
||||||
result = paInternalError;
|
|
||||||
break;
|
|
||||||
case kAudioUnitErr_NoConnection:
|
|
||||||
errorText = "Audio Unit: No Connection";
|
|
||||||
result = paInternalError;
|
|
||||||
break;
|
|
||||||
case kAudioUnitErr_FailedInitialization:
|
|
||||||
errorText = "Audio Unit: Initialization Failed";
|
|
||||||
result = paInternalError;
|
|
||||||
break;
|
|
||||||
case kAudioUnitErr_TooManyFramesToProcess:
|
|
||||||
errorText = "Audio Unit: Too Many Frames";
|
|
||||||
result = paInternalError;
|
|
||||||
break;
|
|
||||||
case kAudioUnitErr_InvalidFile:
|
|
||||||
errorText = "Audio Unit: Invalid File";
|
|
||||||
result = paInternalError;
|
|
||||||
break;
|
|
||||||
case kAudioUnitErr_UnknownFileType:
|
|
||||||
errorText = "Audio Unit: Unknown File Type";
|
|
||||||
result = paInternalError;
|
|
||||||
break;
|
|
||||||
case kAudioUnitErr_FileNotSpecified:
|
|
||||||
errorText = "Audio Unit: File Not Specified";
|
|
||||||
result = paInternalError;
|
|
||||||
break;
|
|
||||||
case kAudioUnitErr_FormatNotSupported:
|
|
||||||
errorText = "Audio Unit: Format Not Supported";
|
|
||||||
result = paInternalError;
|
|
||||||
break;
|
|
||||||
case kAudioUnitErr_Uninitialized:
|
|
||||||
errorText = "Audio Unit: Uninitialized";
|
|
||||||
result = paInternalError;
|
|
||||||
break;
|
|
||||||
case kAudioUnitErr_InvalidScope:
|
|
||||||
errorText = "Audio Unit: Invalid Scope";
|
|
||||||
result = paInternalError;
|
|
||||||
break;
|
|
||||||
case kAudioUnitErr_PropertyNotWritable:
|
|
||||||
errorText = "Audio Unit: PropertyNotWritable";
|
|
||||||
result = paInternalError;
|
|
||||||
break;
|
|
||||||
case kAudioUnitErr_InvalidPropertyValue:
|
|
||||||
errorText = "Audio Unit: Invalid Property Value";
|
|
||||||
result = paInternalError;
|
|
||||||
break;
|
|
||||||
case kAudioUnitErr_PropertyNotInUse:
|
|
||||||
errorText = "Audio Unit: Property Not In Use";
|
|
||||||
result = paInternalError;
|
|
||||||
break;
|
|
||||||
case kAudioUnitErr_Initialized:
|
|
||||||
errorText = "Audio Unit: Initialized";
|
|
||||||
result = paInternalError;
|
|
||||||
break;
|
|
||||||
case kAudioUnitErr_InvalidOfflineRender:
|
|
||||||
errorText = "Audio Unit: Invalid Offline Render";
|
|
||||||
result = paInternalError;
|
|
||||||
break;
|
|
||||||
case kAudioUnitErr_Unauthorized:
|
|
||||||
errorText = "Audio Unit: Unauthorized";
|
|
||||||
result = paInternalError;
|
|
||||||
break;
|
|
||||||
case kAudioUnitErr_CannotDoInCurrentContext:
|
|
||||||
errorText = "Audio Unit: cannot do in current context";
|
|
||||||
result = paInternalError;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
errorText = "Unknown Error";
|
|
||||||
result = paInternalError;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isError)
|
|
||||||
errorType = "Error";
|
|
||||||
else
|
|
||||||
errorType = "Warning";
|
|
||||||
|
|
||||||
char str[20];
|
|
||||||
// see if it appears to be a 4-char-code
|
|
||||||
*(UInt32 *)(str + 1) = CFSwapInt32HostToBig(error);
|
|
||||||
if (isprint(str[1]) && isprint(str[2]) && isprint(str[3]) && isprint(str[4]))
|
|
||||||
{
|
|
||||||
str[0] = str[5] = '\'';
|
|
||||||
str[6] = '\0';
|
|
||||||
} else {
|
|
||||||
// no, format it as an integer
|
|
||||||
sprintf(str, "%d", (int)error);
|
|
||||||
}
|
|
||||||
|
|
||||||
DBUG(("%s on line %d: err='%s', msg=%s\n", errorType, line, str, errorText));
|
|
||||||
|
|
||||||
PaUtil_SetLastHostErrorInfo( paCoreAudio, error, errorText );
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This function computes an appropriate ring buffer size given
|
|
||||||
* a requested latency (in seconds), sample rate and framesPerBuffer.
|
|
||||||
*
|
|
||||||
* The returned ringBufferSize is computed using the following
|
|
||||||
* constraints:
|
|
||||||
* - it must be at least 4.
|
|
||||||
* - it must be at least 3x framesPerBuffer.
|
|
||||||
* - it must be at least 2x the suggestedLatency.
|
|
||||||
* - it must be a power of 2.
|
|
||||||
* This function attempts to compute the minimum such size.
|
|
||||||
*
|
|
||||||
* FEEDBACK: too liberal/conservative/another way?
|
|
||||||
*/
|
|
||||||
long computeRingBufferSize( const PaStreamParameters *inputParameters,
|
|
||||||
const PaStreamParameters *outputParameters,
|
|
||||||
long inputFramesPerBuffer,
|
|
||||||
long outputFramesPerBuffer,
|
|
||||||
double sampleRate )
|
|
||||||
{
|
|
||||||
long ringSize;
|
|
||||||
int index;
|
|
||||||
int i;
|
|
||||||
double latency ;
|
|
||||||
long framesPerBuffer ;
|
|
||||||
|
|
||||||
VVDBUG(( "computeRingBufferSize()\n" ));
|
|
||||||
|
|
||||||
assert( inputParameters || outputParameters );
|
|
||||||
|
|
||||||
if( outputParameters && inputParameters )
|
|
||||||
{
|
|
||||||
latency = MAX( inputParameters->suggestedLatency, outputParameters->suggestedLatency );
|
|
||||||
framesPerBuffer = MAX( inputFramesPerBuffer, outputFramesPerBuffer );
|
|
||||||
}
|
|
||||||
else if( outputParameters )
|
|
||||||
{
|
|
||||||
latency = outputParameters->suggestedLatency;
|
|
||||||
framesPerBuffer = outputFramesPerBuffer ;
|
|
||||||
}
|
|
||||||
else /* we have inputParameters */
|
|
||||||
{
|
|
||||||
latency = inputParameters->suggestedLatency;
|
|
||||||
framesPerBuffer = inputFramesPerBuffer ;
|
|
||||||
}
|
|
||||||
|
|
||||||
ringSize = (long) ( latency * sampleRate * 2 + .5);
|
|
||||||
VDBUG( ( "suggested latency : %d\n", (int) (latency*sampleRate) ) );
|
|
||||||
if( ringSize < framesPerBuffer * 3 )
|
|
||||||
ringSize = framesPerBuffer * 3 ;
|
|
||||||
VDBUG(("framesPerBuffer:%d\n",(int)framesPerBuffer));
|
|
||||||
VDBUG(("Ringbuffer size (1): %d\n", (int)ringSize ));
|
|
||||||
|
|
||||||
/* make sure it's at least 4 */
|
|
||||||
ringSize = MAX( ringSize, 4 );
|
|
||||||
|
|
||||||
/* round up to the next power of 2 */
|
|
||||||
index = -1;
|
|
||||||
for( i=0; i<sizeof(long)*8; ++i )
|
|
||||||
if( ringSize >> i & 0x01 )
|
|
||||||
index = i;
|
|
||||||
assert( index > 0 );
|
|
||||||
if( ringSize <= ( 0x01 << index ) )
|
|
||||||
ringSize = 0x01 << index ;
|
|
||||||
else
|
|
||||||
ringSize = 0x01 << ( index + 1 );
|
|
||||||
|
|
||||||
VDBUG(( "Final Ringbuffer size (2): %d\n", (int)ringSize ));
|
|
||||||
return ringSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* During testing of core audio, I found that serious crashes could occur
|
|
||||||
* if properties such as sample rate were changed multiple times in rapid
|
|
||||||
* succession. The function below could be used to with a condition variable.
|
|
||||||
* to prevent propertychanges from happening until the last property
|
|
||||||
* change is acknowledged. Instead, I implemented a busy-wait, which is simpler
|
|
||||||
* to implement b/c in second round of testing (nov '09) property changes occurred
|
|
||||||
* quickly and so there was no real way to test the condition variable implementation.
|
|
||||||
* therefore, this function is not used, but it is aluded to in commented code below,
|
|
||||||
* since it represents a theoretically better implementation.
|
|
||||||
*/
|
|
||||||
|
|
||||||
OSStatus propertyProc(
|
|
||||||
AudioObjectID inObjectID,
|
|
||||||
UInt32 inNumberAddresses,
|
|
||||||
const AudioObjectPropertyAddress* inAddresses,
|
|
||||||
void* inClientData )
|
|
||||||
{
|
|
||||||
// this is where we would set the condition variable
|
|
||||||
return noErr;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* sets the value of the given property and waits for the change to
|
|
||||||
be acknowledged, and returns the final value, which is not guaranteed
|
|
||||||
by this function to be the same as the desired value. Obviously, this
|
|
||||||
function can only be used for data whose input and output are the
|
|
||||||
same size and format, and their size and format are known in advance.
|
|
||||||
whether or not the call succeeds, if the data is successfully read,
|
|
||||||
it is returned in outPropertyData. If it is not read successfully,
|
|
||||||
outPropertyData is zeroed, which may or may not be useful in
|
|
||||||
determining if the property was read. */
|
|
||||||
PaError AudioDeviceSetPropertyNowAndWaitForChange(
|
|
||||||
AudioDeviceID inDevice,
|
|
||||||
UInt32 inChannel,
|
|
||||||
Boolean isInput,
|
|
||||||
AudioDevicePropertyID inPropertyID,
|
|
||||||
UInt32 inPropertyDataSize,
|
|
||||||
const void *inPropertyData,
|
|
||||||
void *outPropertyData )
|
|
||||||
{
|
|
||||||
OSStatus macErr;
|
|
||||||
UInt32 outPropertyDataSize = inPropertyDataSize;
|
|
||||||
|
|
||||||
/* First, see if it already has that value. If so, return. */
|
|
||||||
macErr = PaMacCore_AudioDeviceGetProperty( inDevice, inChannel,
|
|
||||||
isInput, inPropertyID,
|
|
||||||
&outPropertyDataSize, outPropertyData );
|
|
||||||
if( macErr ) {
|
|
||||||
memset( outPropertyData, 0, inPropertyDataSize );
|
|
||||||
goto failMac;
|
|
||||||
}
|
|
||||||
if( inPropertyDataSize!=outPropertyDataSize )
|
|
||||||
return paInternalError;
|
|
||||||
if( 0==memcmp( outPropertyData, inPropertyData, outPropertyDataSize ) )
|
|
||||||
return paNoError;
|
|
||||||
|
|
||||||
/* Ideally, we'd use a condition variable to determine changes.
|
|
||||||
we could set that up here. */
|
|
||||||
|
|
||||||
/* If we were using a cond variable, we'd do something useful here,
|
|
||||||
but for now, this is just to make 10.6 happy. */
|
|
||||||
macErr = PaMacCore_AudioDeviceAddPropertyListener( inDevice, inChannel, isInput,
|
|
||||||
inPropertyID, propertyProc,
|
|
||||||
NULL );
|
|
||||||
if( macErr )
|
|
||||||
/* we couldn't add a listener. */
|
|
||||||
goto failMac;
|
|
||||||
|
|
||||||
/* set property */
|
|
||||||
macErr = PaMacCore_AudioDeviceSetProperty( inDevice, NULL, inChannel,
|
|
||||||
isInput, inPropertyID,
|
|
||||||
inPropertyDataSize, inPropertyData );
|
|
||||||
if( macErr )
|
|
||||||
goto failMac;
|
|
||||||
|
|
||||||
/* busy-wait up to 30 seconds for the property to change */
|
|
||||||
/* busy-wait is justified here only because the correct alternative (condition variable)
|
|
||||||
was hard to test, since most of the waiting ended up being for setting rather than
|
|
||||||
getting in OS X 10.5. This was not the case in earlier OS versions. */
|
|
||||||
struct timeval tv1, tv2;
|
|
||||||
gettimeofday( &tv1, NULL );
|
|
||||||
memcpy( &tv2, &tv1, sizeof( struct timeval ) );
|
|
||||||
while( tv2.tv_sec - tv1.tv_sec < 30 ) {
|
|
||||||
/* now read the property back out */
|
|
||||||
macErr = PaMacCore_AudioDeviceGetProperty( inDevice, inChannel,
|
|
||||||
isInput, inPropertyID,
|
|
||||||
&outPropertyDataSize, outPropertyData );
|
|
||||||
if( macErr ) {
|
|
||||||
memset( outPropertyData, 0, inPropertyDataSize );
|
|
||||||
goto failMac;
|
|
||||||
}
|
|
||||||
/* and compare... */
|
|
||||||
if( 0==memcmp( outPropertyData, inPropertyData, outPropertyDataSize ) ) {
|
|
||||||
PaMacCore_AudioDeviceRemovePropertyListener( inDevice, inChannel, isInput, inPropertyID, propertyProc, NULL);
|
|
||||||
return paNoError;
|
|
||||||
}
|
|
||||||
/* No match yet, so let's sleep and try again. */
|
|
||||||
Pa_Sleep( 100 );
|
|
||||||
gettimeofday( &tv2, NULL );
|
|
||||||
}
|
|
||||||
DBUG( ("Timeout waiting for device setting.\n" ) );
|
|
||||||
|
|
||||||
PaMacCore_AudioDeviceRemovePropertyListener( inDevice, inChannel, isInput, inPropertyID, propertyProc, NULL );
|
|
||||||
return paNoError;
|
|
||||||
|
|
||||||
failMac:
|
|
||||||
PaMacCore_AudioDeviceRemovePropertyListener( inDevice, inChannel, isInput, inPropertyID, propertyProc, NULL );
|
|
||||||
return ERR( macErr );
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Sets the sample rate the HAL device.
|
|
||||||
* if requireExact: set the sample rate or fail.
|
|
||||||
*
|
|
||||||
* otherwise : set the exact sample rate.
|
|
||||||
* If that fails, check for available sample rates, and choose one
|
|
||||||
* higher than the requested rate. If there isn't a higher one,
|
|
||||||
* just use the highest available.
|
|
||||||
*/
|
|
||||||
PaError setBestSampleRateForDevice( const AudioDeviceID device,
|
|
||||||
const bool isOutput,
|
|
||||||
const bool requireExact,
|
|
||||||
const Float64 desiredSrate )
|
|
||||||
{
|
|
||||||
const bool isInput = isOutput ? 0 : 1;
|
|
||||||
Float64 srate;
|
|
||||||
UInt32 propsize = sizeof( Float64 );
|
|
||||||
OSErr err;
|
|
||||||
AudioValueRange *ranges;
|
|
||||||
int i=0;
|
|
||||||
Float64 max = -1; /*the maximum rate available*/
|
|
||||||
Float64 best = -1; /*the lowest sample rate still greater than desired rate*/
|
|
||||||
VDBUG(("Setting sample rate for device %ld to %g.\n",(long)device,(float)desiredSrate));
|
|
||||||
|
|
||||||
/* -- try setting the sample rate -- */
|
|
||||||
srate = 0;
|
|
||||||
err = AudioDeviceSetPropertyNowAndWaitForChange(
|
|
||||||
device, 0, isInput,
|
|
||||||
kAudioDevicePropertyNominalSampleRate,
|
|
||||||
propsize, &desiredSrate, &srate );
|
|
||||||
|
|
||||||
/* -- if the rate agrees, and was changed, we are done -- */
|
|
||||||
if( srate != 0 && srate == desiredSrate )
|
|
||||||
return paNoError;
|
|
||||||
/* -- if the rate agrees, and we got no errors, we are done -- */
|
|
||||||
if( !err && srate == desiredSrate )
|
|
||||||
return paNoError;
|
|
||||||
/* -- we've failed if the rates disagree and we are setting input -- */
|
|
||||||
if( requireExact )
|
|
||||||
return paInvalidSampleRate;
|
|
||||||
|
|
||||||
/* -- generate a list of available sample rates -- */
|
|
||||||
err = PaMacCore_AudioDeviceGetPropertySize( device, 0, isInput,
|
|
||||||
kAudioDevicePropertyAvailableNominalSampleRates,
|
|
||||||
&propsize );
|
|
||||||
if( err )
|
|
||||||
return ERR( err );
|
|
||||||
ranges = (AudioValueRange *)calloc( 1, propsize );
|
|
||||||
if( !ranges )
|
|
||||||
return paInsufficientMemory;
|
|
||||||
err = PaMacCore_AudioDeviceGetProperty( device, 0, isInput,
|
|
||||||
kAudioDevicePropertyAvailableNominalSampleRates,
|
|
||||||
&propsize, ranges );
|
|
||||||
if( err )
|
|
||||||
{
|
|
||||||
free( ranges );
|
|
||||||
return ERR( err );
|
|
||||||
}
|
|
||||||
VDBUG(("Requested sample rate of %g was not available.\n", (float)desiredSrate));
|
|
||||||
VDBUG(("%lu Available Sample Rates are:\n",propsize/sizeof(AudioValueRange)));
|
|
||||||
#ifdef MAC_CORE_VERBOSE_DEBUG
|
|
||||||
for( i=0; i<propsize/sizeof(AudioValueRange); ++i )
|
|
||||||
VDBUG( ("\t%g-%g\n",
|
|
||||||
(float) ranges[i].mMinimum,
|
|
||||||
(float) ranges[i].mMaximum ) );
|
|
||||||
#endif
|
|
||||||
VDBUG(("-----\n"));
|
|
||||||
|
|
||||||
/* -- now pick the best available sample rate -- */
|
|
||||||
for( i=0; i<propsize/sizeof(AudioValueRange); ++i )
|
|
||||||
{
|
|
||||||
if( ranges[i].mMaximum > max ) max = ranges[i].mMaximum;
|
|
||||||
if( ranges[i].mMinimum > desiredSrate ) {
|
|
||||||
if( best < 0 )
|
|
||||||
best = ranges[i].mMinimum;
|
|
||||||
else if( ranges[i].mMinimum < best )
|
|
||||||
best = ranges[i].mMinimum;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if( best < 0 )
|
|
||||||
best = max;
|
|
||||||
VDBUG( ("Maximum Rate %g. best is %g.\n", max, best ) );
|
|
||||||
free( ranges );
|
|
||||||
|
|
||||||
/* -- set the sample rate -- */
|
|
||||||
propsize = sizeof( best );
|
|
||||||
srate = 0;
|
|
||||||
err = AudioDeviceSetPropertyNowAndWaitForChange(
|
|
||||||
device, 0, isInput,
|
|
||||||
kAudioDevicePropertyNominalSampleRate,
|
|
||||||
propsize, &best, &srate );
|
|
||||||
|
|
||||||
/* -- if the set rate matches, we are done -- */
|
|
||||||
if( srate != 0 && srate == best )
|
|
||||||
return paNoError;
|
|
||||||
|
|
||||||
if( err )
|
|
||||||
return ERR( err );
|
|
||||||
|
|
||||||
/* -- otherwise, something weird happened: we didn't set the rate, and we got no errors. Just bail. */
|
|
||||||
return paInternalError;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
Attempts to set the requestedFramesPerBuffer. If it can't set the exact
|
|
||||||
value, it settles for something smaller if available. If nothing smaller
|
|
||||||
is available, it uses the smallest available size.
|
|
||||||
actualFramesPerBuffer will be set to the actual value on successful return.
|
|
||||||
OK to pass NULL to actualFramesPerBuffer.
|
|
||||||
The logic is very similar too setBestSampleRate only failure here is
|
|
||||||
not usually catastrophic.
|
|
||||||
*/
|
|
||||||
PaError setBestFramesPerBuffer( const AudioDeviceID device,
|
|
||||||
const bool isOutput,
|
|
||||||
UInt32 requestedFramesPerBuffer,
|
|
||||||
UInt32 *actualFramesPerBuffer )
|
|
||||||
{
|
|
||||||
UInt32 afpb;
|
|
||||||
const bool isInput = !isOutput;
|
|
||||||
UInt32 propsize = sizeof(UInt32);
|
|
||||||
OSErr err;
|
|
||||||
AudioValueRange range;
|
|
||||||
|
|
||||||
if( actualFramesPerBuffer == NULL )
|
|
||||||
{
|
|
||||||
actualFramesPerBuffer = &afpb;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -- try and set exact FPB -- */
|
|
||||||
err = PaMacCore_AudioDeviceSetProperty( device, NULL, 0, isInput,
|
|
||||||
kAudioDevicePropertyBufferFrameSize,
|
|
||||||
propsize, &requestedFramesPerBuffer);
|
|
||||||
err = PaMacCore_AudioDeviceGetProperty( device, 0, isInput,
|
|
||||||
kAudioDevicePropertyBufferFrameSize,
|
|
||||||
&propsize, actualFramesPerBuffer);
|
|
||||||
if( err )
|
|
||||||
{
|
|
||||||
return ERR( err );
|
|
||||||
}
|
|
||||||
// Did we get the size we asked for?
|
|
||||||
if( *actualFramesPerBuffer == requestedFramesPerBuffer )
|
|
||||||
{
|
|
||||||
return paNoError; /* we are done */
|
|
||||||
}
|
|
||||||
|
|
||||||
// Clip requested value against legal range for the device.
|
|
||||||
propsize = sizeof(AudioValueRange);
|
|
||||||
err = PaMacCore_AudioDeviceGetProperty( device, 0, isInput,
|
|
||||||
kAudioDevicePropertyBufferFrameSizeRange,
|
|
||||||
&propsize, &range );
|
|
||||||
if( err )
|
|
||||||
{
|
|
||||||
return ERR( err );
|
|
||||||
}
|
|
||||||
if( requestedFramesPerBuffer < range.mMinimum )
|
|
||||||
{
|
|
||||||
requestedFramesPerBuffer = range.mMinimum;
|
|
||||||
}
|
|
||||||
else if( requestedFramesPerBuffer > range.mMaximum )
|
|
||||||
{
|
|
||||||
requestedFramesPerBuffer = range.mMaximum;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* --- set the buffer size (ignore errors) -- */
|
|
||||||
propsize = sizeof( UInt32 );
|
|
||||||
err = PaMacCore_AudioDeviceSetProperty( device, NULL, 0, isInput,
|
|
||||||
kAudioDevicePropertyBufferFrameSize,
|
|
||||||
propsize, &requestedFramesPerBuffer );
|
|
||||||
/* --- read the property to check that it was set -- */
|
|
||||||
err = PaMacCore_AudioDeviceGetProperty( device, 0, isInput,
|
|
||||||
kAudioDevicePropertyBufferFrameSize,
|
|
||||||
&propsize, actualFramesPerBuffer );
|
|
||||||
|
|
||||||
if( err )
|
|
||||||
return ERR( err );
|
|
||||||
|
|
||||||
return paNoError;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**********************
|
|
||||||
*
|
|
||||||
* XRun stuff
|
|
||||||
*
|
|
||||||
**********************/
|
|
||||||
|
|
||||||
struct PaMacXRunListNode_s {
|
|
||||||
PaMacCoreStream *stream;
|
|
||||||
struct PaMacXRunListNode_s *next;
|
|
||||||
} ;
|
|
||||||
|
|
||||||
typedef struct PaMacXRunListNode_s PaMacXRunListNode;
|
|
||||||
|
|
||||||
/** Always empty, so that it can always be the one returned by
|
|
||||||
addToXRunListenerList. note that it's not a pointer. */
|
|
||||||
static PaMacXRunListNode firstXRunListNode;
|
|
||||||
static int xRunListSize;
|
|
||||||
static pthread_mutex_t xrunMutex;
|
|
||||||
|
|
||||||
OSStatus xrunCallback(
|
|
||||||
AudioObjectID inDevice,
|
|
||||||
UInt32 inNumberAddresses,
|
|
||||||
const AudioObjectPropertyAddress* inAddresses,
|
|
||||||
void * inClientData)
|
|
||||||
{
|
|
||||||
PaMacXRunListNode *node = (PaMacXRunListNode *) inClientData;
|
|
||||||
bool isInput = inAddresses->mScope == kAudioDevicePropertyScopeInput;
|
|
||||||
|
|
||||||
int ret = pthread_mutex_trylock( &xrunMutex ) ;
|
|
||||||
|
|
||||||
if( ret == 0 ) {
|
|
||||||
|
|
||||||
node = node->next ; //skip the first node
|
|
||||||
|
|
||||||
for( ; node; node=node->next ) {
|
|
||||||
PaMacCoreStream *stream = node->stream;
|
|
||||||
|
|
||||||
if( stream->state != ACTIVE )
|
|
||||||
continue; //if the stream isn't active, we don't care if the device is dropping
|
|
||||||
|
|
||||||
if( isInput ) {
|
|
||||||
if( stream->inputDevice == inDevice )
|
|
||||||
OSAtomicOr32( paInputOverflow, &stream->xrunFlags );
|
|
||||||
} else {
|
|
||||||
if( stream->outputDevice == inDevice )
|
|
||||||
OSAtomicOr32( paOutputUnderflow, &stream->xrunFlags );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pthread_mutex_unlock( &xrunMutex );
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int initializeXRunListenerList( void )
|
|
||||||
{
|
|
||||||
xRunListSize = 0;
|
|
||||||
bzero( (void *) &firstXRunListNode, sizeof(firstXRunListNode) );
|
|
||||||
return pthread_mutex_init( &xrunMutex, NULL );
|
|
||||||
}
|
|
||||||
int destroyXRunListenerList( void )
|
|
||||||
{
|
|
||||||
PaMacXRunListNode *node;
|
|
||||||
node = firstXRunListNode.next;
|
|
||||||
while( node ) {
|
|
||||||
PaMacXRunListNode *tmp = node;
|
|
||||||
node = node->next;
|
|
||||||
free( tmp );
|
|
||||||
}
|
|
||||||
xRunListSize = 0;
|
|
||||||
return pthread_mutex_destroy( &xrunMutex );
|
|
||||||
}
|
|
||||||
|
|
||||||
void *addToXRunListenerList( void *stream )
|
|
||||||
{
|
|
||||||
pthread_mutex_lock( &xrunMutex );
|
|
||||||
PaMacXRunListNode *newNode;
|
|
||||||
// setup new node:
|
|
||||||
newNode = (PaMacXRunListNode *) malloc( sizeof( PaMacXRunListNode ) );
|
|
||||||
newNode->stream = (PaMacCoreStream *) stream;
|
|
||||||
newNode->next = firstXRunListNode.next;
|
|
||||||
// insert:
|
|
||||||
firstXRunListNode.next = newNode;
|
|
||||||
pthread_mutex_unlock( &xrunMutex );
|
|
||||||
|
|
||||||
return &firstXRunListNode;
|
|
||||||
}
|
|
||||||
|
|
||||||
int removeFromXRunListenerList( void *stream )
|
|
||||||
{
|
|
||||||
pthread_mutex_lock( &xrunMutex );
|
|
||||||
PaMacXRunListNode *node, *prev;
|
|
||||||
prev = &firstXRunListNode;
|
|
||||||
node = firstXRunListNode.next;
|
|
||||||
while( node ) {
|
|
||||||
if( node->stream == stream ) {
|
|
||||||
//found it:
|
|
||||||
--xRunListSize;
|
|
||||||
prev->next = node->next;
|
|
||||||
free( node );
|
|
||||||
pthread_mutex_unlock( &xrunMutex );
|
|
||||||
return xRunListSize;
|
|
||||||
}
|
|
||||||
prev = prev->next;
|
|
||||||
node = node->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
pthread_mutex_unlock( &xrunMutex );
|
|
||||||
// failure
|
|
||||||
return xRunListSize;
|
|
||||||
}
|
|
@ -1,268 +0,0 @@
|
|||||||
/*
|
|
||||||
* Helper and utility functions for pa_mac_core.c (Apple AUHAL implementation)
|
|
||||||
*
|
|
||||||
* PortAudio Portable Real-Time Audio Library
|
|
||||||
* Latest Version at: http://www.portaudio.com
|
|
||||||
*
|
|
||||||
* Written by Bjorn Roche of XO Audio LLC, from PA skeleton code.
|
|
||||||
* Portions copied from code by Dominic Mazzoni (who wrote a HAL implementation)
|
|
||||||
*
|
|
||||||
* Dominic's code was based on code by Phil Burk, Darren Gibbs,
|
|
||||||
* Gord Peters, Stephane Letz, and Greg Pfiel.
|
|
||||||
*
|
|
||||||
* The following people also deserve acknowledgements:
|
|
||||||
*
|
|
||||||
* Olivier Tristan for feedback and testing
|
|
||||||
* Glenn Zelniker and Z-Systems engineering for sponsoring the Blocking I/O
|
|
||||||
* interface.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* Based on the Open Source API proposed by Ross Bencina
|
|
||||||
* Copyright (c) 1999-2002 Ross Bencina, Phil Burk
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files
|
|
||||||
* (the "Software"), to deal in the Software without restriction,
|
|
||||||
* including without limitation the rights to use, copy, modify, merge,
|
|
||||||
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
||||||
* and to permit persons to whom the Software is furnished to do so,
|
|
||||||
* subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be
|
|
||||||
* included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
||||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
|
|
||||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
|
||||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The text above constitutes the entire PortAudio license; however,
|
|
||||||
* the PortAudio community also makes the following non-binding requests:
|
|
||||||
*
|
|
||||||
* Any person wishing to distribute modifications to the Software is
|
|
||||||
* requested to send the modifications to the original developer so that
|
|
||||||
* they can be incorporated into the canonical version. It is also
|
|
||||||
* requested that these non-binding requests be included along with the
|
|
||||||
* license above.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
@file
|
|
||||||
@ingroup hostapi_src
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef PA_MAC_CORE_UTILITIES_H__
|
|
||||||
#define PA_MAC_CORE_UTILITIES_H__
|
|
||||||
|
|
||||||
#include <pthread.h>
|
|
||||||
#include "portaudio.h"
|
|
||||||
#include "pa_util.h"
|
|
||||||
#include <AudioUnit/AudioUnit.h>
|
|
||||||
#include <AudioToolbox/AudioToolbox.h>
|
|
||||||
|
|
||||||
#ifndef MIN
|
|
||||||
#define MIN(a, b) (((a)<(b))?(a):(b))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef MAX
|
|
||||||
#define MAX(a, b) (((a)<(b))?(b):(a))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define ERR(mac_error) PaMacCore_SetError(mac_error, __LINE__, 1 )
|
|
||||||
#define WARNING(mac_error) PaMacCore_SetError(mac_error, __LINE__, 0 )
|
|
||||||
|
|
||||||
|
|
||||||
/* Help keep track of AUHAL element numbers */
|
|
||||||
#define INPUT_ELEMENT (1)
|
|
||||||
#define OUTPUT_ELEMENT (0)
|
|
||||||
|
|
||||||
/* Normal level of debugging: fine for most apps that don't mind the occasional warning being printf'ed */
|
|
||||||
/*
|
|
||||||
*/
|
|
||||||
#define MAC_CORE_DEBUG
|
|
||||||
#ifdef MAC_CORE_DEBUG
|
|
||||||
# define DBUG(MSG) do { printf("||PaMacCore (AUHAL)|| "); printf MSG ; fflush(stdout); } while(0)
|
|
||||||
#else
|
|
||||||
# define DBUG(MSG)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Verbose Debugging: useful for development */
|
|
||||||
/*
|
|
||||||
#define MAC_CORE_VERBOSE_DEBUG
|
|
||||||
*/
|
|
||||||
#ifdef MAC_CORE_VERBOSE_DEBUG
|
|
||||||
# define VDBUG(MSG) do { printf("||PaMacCore (v )|| "); printf MSG ; fflush(stdout); } while(0)
|
|
||||||
#else
|
|
||||||
# define VDBUG(MSG)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Very Verbose Debugging: Traces every call. */
|
|
||||||
/*
|
|
||||||
#define MAC_CORE_VERY_VERBOSE_DEBUG
|
|
||||||
*/
|
|
||||||
#ifdef MAC_CORE_VERY_VERBOSE_DEBUG
|
|
||||||
# define VVDBUG(MSG) do { printf("||PaMacCore (vv)|| "); printf MSG ; fflush(stdout); } while(0)
|
|
||||||
#else
|
|
||||||
# define VVDBUG(MSG)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
OSStatus PaMacCore_AudioHardwareGetProperty(
|
|
||||||
AudioHardwarePropertyID inPropertyID,
|
|
||||||
UInt32* ioPropertyDataSize,
|
|
||||||
void* outPropertyData );
|
|
||||||
|
|
||||||
OSStatus PaMacCore_AudioHardwareGetPropertySize(
|
|
||||||
AudioHardwarePropertyID inPropertyID,
|
|
||||||
UInt32* outSize );
|
|
||||||
|
|
||||||
OSStatus PaMacCore_AudioDeviceGetProperty(
|
|
||||||
AudioDeviceID inDevice,
|
|
||||||
UInt32 inChannel,
|
|
||||||
Boolean isInput,
|
|
||||||
AudioDevicePropertyID inPropertyID,
|
|
||||||
UInt32* ioPropertyDataSize,
|
|
||||||
void* outPropertyData );
|
|
||||||
|
|
||||||
OSStatus PaMacCore_AudioDeviceSetProperty(
|
|
||||||
AudioDeviceID inDevice,
|
|
||||||
const AudioTimeStamp* inWhen,
|
|
||||||
UInt32 inChannel,
|
|
||||||
Boolean isInput,
|
|
||||||
AudioDevicePropertyID inPropertyID,
|
|
||||||
UInt32 inPropertyDataSize,
|
|
||||||
const void* inPropertyData );
|
|
||||||
|
|
||||||
OSStatus PaMacCore_AudioDeviceGetPropertySize(
|
|
||||||
AudioDeviceID inDevice,
|
|
||||||
UInt32 inChannel,
|
|
||||||
Boolean isInput,
|
|
||||||
AudioDevicePropertyID inPropertyID,
|
|
||||||
UInt32* outSize );
|
|
||||||
|
|
||||||
OSStatus PaMacCore_AudioDeviceAddPropertyListener(
|
|
||||||
AudioDeviceID inDevice,
|
|
||||||
UInt32 inChannel,
|
|
||||||
Boolean isInput,
|
|
||||||
AudioDevicePropertyID inPropertyID,
|
|
||||||
AudioObjectPropertyListenerProc inProc,
|
|
||||||
void* inClientData );
|
|
||||||
|
|
||||||
OSStatus PaMacCore_AudioDeviceRemovePropertyListener(
|
|
||||||
AudioDeviceID inDevice,
|
|
||||||
UInt32 inChannel,
|
|
||||||
Boolean isInput,
|
|
||||||
AudioDevicePropertyID inPropertyID,
|
|
||||||
AudioObjectPropertyListenerProc inProc,
|
|
||||||
void* inClientData );
|
|
||||||
|
|
||||||
OSStatus PaMacCore_AudioStreamGetProperty(
|
|
||||||
AudioStreamID inStream,
|
|
||||||
UInt32 inChannel,
|
|
||||||
AudioDevicePropertyID inPropertyID,
|
|
||||||
UInt32* ioPropertyDataSize,
|
|
||||||
void* outPropertyData );
|
|
||||||
|
|
||||||
#define UNIX_ERR(err) PaMacCore_SetUnixError( err, __LINE__ )
|
|
||||||
|
|
||||||
PaError PaMacCore_SetUnixError( int err, int line );
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Translates MacOS generated errors into PaErrors
|
|
||||||
*/
|
|
||||||
PaError PaMacCore_SetError(OSStatus error, int line, int isError);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This function computes an appropriate ring buffer size given
|
|
||||||
* a requested latency (in seconds), sample rate and framesPerBuffer.
|
|
||||||
*
|
|
||||||
* The returned ringBufferSize is computed using the following
|
|
||||||
* constraints:
|
|
||||||
* - it must be at least 4.
|
|
||||||
* - it must be at least 3x framesPerBuffer.
|
|
||||||
* - it must be at least 2x the suggestedLatency.
|
|
||||||
* - it must be a power of 2.
|
|
||||||
* This function attempts to compute the minimum such size.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
long computeRingBufferSize( const PaStreamParameters *inputParameters,
|
|
||||||
const PaStreamParameters *outputParameters,
|
|
||||||
long inputFramesPerBuffer,
|
|
||||||
long outputFramesPerBuffer,
|
|
||||||
double sampleRate );
|
|
||||||
|
|
||||||
OSStatus propertyProc(
|
|
||||||
AudioObjectID inObjectID,
|
|
||||||
UInt32 inNumberAddresses,
|
|
||||||
const AudioObjectPropertyAddress* inAddresses,
|
|
||||||
void* inClientData );
|
|
||||||
|
|
||||||
/* sets the value of the given property and waits for the change to
|
|
||||||
be acknowledged, and returns the final value, which is not guaranteed
|
|
||||||
by this function to be the same as the desired value. Obviously, this
|
|
||||||
function can only be used for data whose input and output are the
|
|
||||||
same size and format, and their size and format are known in advance.*/
|
|
||||||
PaError AudioDeviceSetPropertyNowAndWaitForChange(
|
|
||||||
AudioDeviceID inDevice,
|
|
||||||
UInt32 inChannel,
|
|
||||||
Boolean isInput,
|
|
||||||
AudioDevicePropertyID inPropertyID,
|
|
||||||
UInt32 inPropertyDataSize,
|
|
||||||
const void *inPropertyData,
|
|
||||||
void *outPropertyData );
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Sets the sample rate the HAL device.
|
|
||||||
* if requireExact: set the sample rate or fail.
|
|
||||||
*
|
|
||||||
* otherwise : set the exact sample rate.
|
|
||||||
* If that fails, check for available sample rates, and choose one
|
|
||||||
* higher than the requested rate. If there isn't a higher one,
|
|
||||||
* just use the highest available.
|
|
||||||
*/
|
|
||||||
PaError setBestSampleRateForDevice( const AudioDeviceID device,
|
|
||||||
const bool isOutput,
|
|
||||||
const bool requireExact,
|
|
||||||
const Float64 desiredSrate );
|
|
||||||
/*
|
|
||||||
Attempts to set the requestedFramesPerBuffer. If it can't set the exact
|
|
||||||
value, it settles for something smaller if available. If nothing smaller
|
|
||||||
is available, it uses the smallest available size.
|
|
||||||
actualFramesPerBuffer will be set to the actual value on successful return.
|
|
||||||
OK to pass NULL to actualFramesPerBuffer.
|
|
||||||
The logic is very similar too setBestSampleRate only failure here is
|
|
||||||
not usually catastrophic.
|
|
||||||
*/
|
|
||||||
PaError setBestFramesPerBuffer( const AudioDeviceID device,
|
|
||||||
const bool isOutput,
|
|
||||||
UInt32 requestedFramesPerBuffer,
|
|
||||||
UInt32 *actualFramesPerBuffer );
|
|
||||||
|
|
||||||
|
|
||||||
/*********************
|
|
||||||
*
|
|
||||||
* xrun handling
|
|
||||||
*
|
|
||||||
*********************/
|
|
||||||
|
|
||||||
OSStatus xrunCallback(
|
|
||||||
AudioObjectID inObjectID,
|
|
||||||
UInt32 inNumberAddresses,
|
|
||||||
const AudioObjectPropertyAddress* inAddresses,
|
|
||||||
void * inClientData );
|
|
||||||
|
|
||||||
/** returns zero on success or a unix style error code. */
|
|
||||||
int initializeXRunListenerList( void );
|
|
||||||
/** returns zero on success or a unix style error code. */
|
|
||||||
int destroyXRunListenerList( void );
|
|
||||||
|
|
||||||
/**Returns the list, so that it can be passed to CorAudio.*/
|
|
||||||
void *addToXRunListenerList( void *stream );
|
|
||||||
/**Returns the number of Listeners in the list remaining.*/
|
|
||||||
int removeFromXRunListenerList( void *stream );
|
|
||||||
|
|
||||||
#endif /* PA_MAC_CORE_UTILITIES_H__*/
|
|
3259
third_party/portAudio/src/hostapi/dsound/pa_win_ds.c
vendored
3259
third_party/portAudio/src/hostapi/dsound/pa_win_ds.c
vendored
File diff suppressed because it is too large
Load Diff
@ -1,224 +0,0 @@
|
|||||||
/*
|
|
||||||
* Interface for dynamically loading directsound and providing a dummy
|
|
||||||
* implementation if it isn't present.
|
|
||||||
*
|
|
||||||
* Author: Ross Bencina (some portions Phil Burk & Robert Marsanyi)
|
|
||||||
*
|
|
||||||
* For PortAudio Portable Real-Time Audio Library
|
|
||||||
* For more information see: http://www.portaudio.com
|
|
||||||
* Copyright (c) 1999-2006 Phil Burk, Robert Marsanyi and Ross Bencina
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files
|
|
||||||
* (the "Software"), to deal in the Software without restriction,
|
|
||||||
* including without limitation the rights to use, copy, modify, merge,
|
|
||||||
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
||||||
* and to permit persons to whom the Software is furnished to do so,
|
|
||||||
* subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be
|
|
||||||
* included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
||||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
|
|
||||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
|
||||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The text above constitutes the entire PortAudio license; however,
|
|
||||||
* the PortAudio community also makes the following non-binding requests:
|
|
||||||
*
|
|
||||||
* Any person wishing to distribute modifications to the Software is
|
|
||||||
* requested to send the modifications to the original developer so that
|
|
||||||
* they can be incorporated into the canonical version. It is also
|
|
||||||
* requested that these non-binding requests be included along with the
|
|
||||||
* license above.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
@file
|
|
||||||
@ingroup hostapi_src
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "pa_win_ds_dynlink.h"
|
|
||||||
#include "pa_debugprint.h"
|
|
||||||
|
|
||||||
PaWinDsDSoundEntryPoints paWinDsDSoundEntryPoints = { 0, 0, 0, 0, 0, 0, 0 };
|
|
||||||
|
|
||||||
|
|
||||||
static HRESULT WINAPI DummyDllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
|
|
||||||
{
|
|
||||||
(void)rclsid; /* unused parameter */
|
|
||||||
(void)riid; /* unused parameter */
|
|
||||||
(void)ppv; /* unused parameter */
|
|
||||||
return CLASS_E_CLASSNOTAVAILABLE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static HRESULT WINAPI DummyDirectSoundCreate(LPGUID lpcGuidDevice, LPDIRECTSOUND *ppDS, LPUNKNOWN pUnkOuter)
|
|
||||||
{
|
|
||||||
(void)lpcGuidDevice; /* unused parameter */
|
|
||||||
(void)ppDS; /* unused parameter */
|
|
||||||
(void)pUnkOuter; /* unused parameter */
|
|
||||||
return E_NOTIMPL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static HRESULT WINAPI DummyDirectSoundEnumerateW(LPDSENUMCALLBACKW lpDSEnumCallback, LPVOID lpContext)
|
|
||||||
{
|
|
||||||
(void)lpDSEnumCallback; /* unused parameter */
|
|
||||||
(void)lpContext; /* unused parameter */
|
|
||||||
return E_NOTIMPL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static HRESULT WINAPI DummyDirectSoundEnumerateA(LPDSENUMCALLBACKA lpDSEnumCallback, LPVOID lpContext)
|
|
||||||
{
|
|
||||||
(void)lpDSEnumCallback; /* unused parameter */
|
|
||||||
(void)lpContext; /* unused parameter */
|
|
||||||
return E_NOTIMPL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static HRESULT WINAPI DummyDirectSoundCaptureCreate(LPGUID lpcGUID, LPDIRECTSOUNDCAPTURE *lplpDSC, LPUNKNOWN pUnkOuter)
|
|
||||||
{
|
|
||||||
(void)lpcGUID; /* unused parameter */
|
|
||||||
(void)lplpDSC; /* unused parameter */
|
|
||||||
(void)pUnkOuter; /* unused parameter */
|
|
||||||
return E_NOTIMPL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static HRESULT WINAPI DummyDirectSoundCaptureEnumerateW(LPDSENUMCALLBACKW lpDSCEnumCallback, LPVOID lpContext)
|
|
||||||
{
|
|
||||||
(void)lpDSCEnumCallback; /* unused parameter */
|
|
||||||
(void)lpContext; /* unused parameter */
|
|
||||||
return E_NOTIMPL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static HRESULT WINAPI DummyDirectSoundCaptureEnumerateA(LPDSENUMCALLBACKA lpDSCEnumCallback, LPVOID lpContext)
|
|
||||||
{
|
|
||||||
(void)lpDSCEnumCallback; /* unused parameter */
|
|
||||||
(void)lpContext; /* unused parameter */
|
|
||||||
return E_NOTIMPL;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef PAWIN_USE_DIRECTSOUNDFULLDUPLEXCREATE
|
|
||||||
static HRESULT WINAPI DummyDirectSoundFullDuplexCreate8(
|
|
||||||
LPCGUID pcGuidCaptureDevice,
|
|
||||||
LPCGUID pcGuidRenderDevice,
|
|
||||||
LPCDSCBUFFERDESC pcDSCBufferDesc,
|
|
||||||
LPCDSBUFFERDESC pcDSBufferDesc,
|
|
||||||
HWND hWnd,
|
|
||||||
DWORD dwLevel,
|
|
||||||
LPDIRECTSOUNDFULLDUPLEX * ppDSFD,
|
|
||||||
LPDIRECTSOUNDCAPTUREBUFFER8 * ppDSCBuffer8,
|
|
||||||
LPDIRECTSOUNDBUFFER8 * ppDSBuffer8,
|
|
||||||
LPUNKNOWN pUnkOuter)
|
|
||||||
{
|
|
||||||
(void)pcGuidCaptureDevice; /* unused parameter */
|
|
||||||
(void)pcGuidRenderDevice; /* unused parameter */
|
|
||||||
(void)pcDSCBufferDesc; /* unused parameter */
|
|
||||||
(void)pcDSBufferDesc; /* unused parameter */
|
|
||||||
(void)hWnd; /* unused parameter */
|
|
||||||
(void)dwLevel; /* unused parameter */
|
|
||||||
(void)ppDSFD; /* unused parameter */
|
|
||||||
(void)ppDSCBuffer8; /* unused parameter */
|
|
||||||
(void)ppDSBuffer8; /* unused parameter */
|
|
||||||
(void)pUnkOuter; /* unused parameter */
|
|
||||||
|
|
||||||
return E_NOTIMPL;
|
|
||||||
}
|
|
||||||
#endif /* PAWIN_USE_DIRECTSOUNDFULLDUPLEXCREATE */
|
|
||||||
|
|
||||||
void PaWinDs_InitializeDSoundEntryPoints(void)
|
|
||||||
{
|
|
||||||
paWinDsDSoundEntryPoints.hInstance_ = LoadLibraryA("dsound.dll");
|
|
||||||
if( paWinDsDSoundEntryPoints.hInstance_ != NULL )
|
|
||||||
{
|
|
||||||
paWinDsDSoundEntryPoints.DllGetClassObject =
|
|
||||||
(HRESULT (WINAPI *)(REFCLSID, REFIID , LPVOID *))
|
|
||||||
GetProcAddress( paWinDsDSoundEntryPoints.hInstance_, "DllGetClassObject" );
|
|
||||||
if( paWinDsDSoundEntryPoints.DllGetClassObject == NULL )
|
|
||||||
paWinDsDSoundEntryPoints.DllGetClassObject = DummyDllGetClassObject;
|
|
||||||
|
|
||||||
paWinDsDSoundEntryPoints.DirectSoundCreate =
|
|
||||||
(HRESULT (WINAPI *)(LPGUID, LPDIRECTSOUND *, LPUNKNOWN))
|
|
||||||
GetProcAddress( paWinDsDSoundEntryPoints.hInstance_, "DirectSoundCreate" );
|
|
||||||
if( paWinDsDSoundEntryPoints.DirectSoundCreate == NULL )
|
|
||||||
paWinDsDSoundEntryPoints.DirectSoundCreate = DummyDirectSoundCreate;
|
|
||||||
|
|
||||||
paWinDsDSoundEntryPoints.DirectSoundEnumerateW =
|
|
||||||
(HRESULT (WINAPI *)(LPDSENUMCALLBACKW, LPVOID))
|
|
||||||
GetProcAddress( paWinDsDSoundEntryPoints.hInstance_, "DirectSoundEnumerateW" );
|
|
||||||
if( paWinDsDSoundEntryPoints.DirectSoundEnumerateW == NULL )
|
|
||||||
paWinDsDSoundEntryPoints.DirectSoundEnumerateW = DummyDirectSoundEnumerateW;
|
|
||||||
|
|
||||||
paWinDsDSoundEntryPoints.DirectSoundEnumerateA =
|
|
||||||
(HRESULT (WINAPI *)(LPDSENUMCALLBACKA, LPVOID))
|
|
||||||
GetProcAddress( paWinDsDSoundEntryPoints.hInstance_, "DirectSoundEnumerateA" );
|
|
||||||
if( paWinDsDSoundEntryPoints.DirectSoundEnumerateA == NULL )
|
|
||||||
paWinDsDSoundEntryPoints.DirectSoundEnumerateA = DummyDirectSoundEnumerateA;
|
|
||||||
|
|
||||||
paWinDsDSoundEntryPoints.DirectSoundCaptureCreate =
|
|
||||||
(HRESULT (WINAPI *)(LPGUID, LPDIRECTSOUNDCAPTURE *, LPUNKNOWN))
|
|
||||||
GetProcAddress( paWinDsDSoundEntryPoints.hInstance_, "DirectSoundCaptureCreate" );
|
|
||||||
if( paWinDsDSoundEntryPoints.DirectSoundCaptureCreate == NULL )
|
|
||||||
paWinDsDSoundEntryPoints.DirectSoundCaptureCreate = DummyDirectSoundCaptureCreate;
|
|
||||||
|
|
||||||
paWinDsDSoundEntryPoints.DirectSoundCaptureEnumerateW =
|
|
||||||
(HRESULT (WINAPI *)(LPDSENUMCALLBACKW, LPVOID))
|
|
||||||
GetProcAddress( paWinDsDSoundEntryPoints.hInstance_, "DirectSoundCaptureEnumerateW" );
|
|
||||||
if( paWinDsDSoundEntryPoints.DirectSoundCaptureEnumerateW == NULL )
|
|
||||||
paWinDsDSoundEntryPoints.DirectSoundCaptureEnumerateW = DummyDirectSoundCaptureEnumerateW;
|
|
||||||
|
|
||||||
paWinDsDSoundEntryPoints.DirectSoundCaptureEnumerateA =
|
|
||||||
(HRESULT (WINAPI *)(LPDSENUMCALLBACKA, LPVOID))
|
|
||||||
GetProcAddress( paWinDsDSoundEntryPoints.hInstance_, "DirectSoundCaptureEnumerateA" );
|
|
||||||
if( paWinDsDSoundEntryPoints.DirectSoundCaptureEnumerateA == NULL )
|
|
||||||
paWinDsDSoundEntryPoints.DirectSoundCaptureEnumerateA = DummyDirectSoundCaptureEnumerateA;
|
|
||||||
|
|
||||||
#ifdef PAWIN_USE_DIRECTSOUNDFULLDUPLEXCREATE
|
|
||||||
paWinDsDSoundEntryPoints.DirectSoundFullDuplexCreate8 =
|
|
||||||
(HRESULT (WINAPI *)(LPCGUID, LPCGUID, LPCDSCBUFFERDESC, LPCDSBUFFERDESC,
|
|
||||||
HWND, DWORD, LPDIRECTSOUNDFULLDUPLEX *, LPDIRECTSOUNDCAPTUREBUFFER8 *,
|
|
||||||
LPDIRECTSOUNDBUFFER8 *, LPUNKNOWN))
|
|
||||||
GetProcAddress( paWinDsDSoundEntryPoints.hInstance_, "DirectSoundFullDuplexCreate" );
|
|
||||||
if( paWinDsDSoundEntryPoints.DirectSoundFullDuplexCreate8 == NULL )
|
|
||||||
paWinDsDSoundEntryPoints.DirectSoundFullDuplexCreate8 = DummyDirectSoundFullDuplexCreate8;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
DWORD errorCode = GetLastError(); // 126 (0x7E) == ERROR_MOD_NOT_FOUND
|
|
||||||
PA_DEBUG(("Couldn't load dsound.dll error code: %d \n",errorCode));
|
|
||||||
|
|
||||||
/* initialize with dummy entry points to make live easy when ds isn't present */
|
|
||||||
paWinDsDSoundEntryPoints.DirectSoundCreate = DummyDirectSoundCreate;
|
|
||||||
paWinDsDSoundEntryPoints.DirectSoundEnumerateW = DummyDirectSoundEnumerateW;
|
|
||||||
paWinDsDSoundEntryPoints.DirectSoundEnumerateA = DummyDirectSoundEnumerateA;
|
|
||||||
paWinDsDSoundEntryPoints.DirectSoundCaptureCreate = DummyDirectSoundCaptureCreate;
|
|
||||||
paWinDsDSoundEntryPoints.DirectSoundCaptureEnumerateW = DummyDirectSoundCaptureEnumerateW;
|
|
||||||
paWinDsDSoundEntryPoints.DirectSoundCaptureEnumerateA = DummyDirectSoundCaptureEnumerateA;
|
|
||||||
#ifdef PAWIN_USE_DIRECTSOUNDFULLDUPLEXCREATE
|
|
||||||
paWinDsDSoundEntryPoints.DirectSoundFullDuplexCreate8 = DummyDirectSoundFullDuplexCreate8;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void PaWinDs_TerminateDSoundEntryPoints(void)
|
|
||||||
{
|
|
||||||
if( paWinDsDSoundEntryPoints.hInstance_ != NULL )
|
|
||||||
{
|
|
||||||
/* ensure that we crash reliably if the entry points aren't initialised */
|
|
||||||
paWinDsDSoundEntryPoints.DirectSoundCreate = 0;
|
|
||||||
paWinDsDSoundEntryPoints.DirectSoundEnumerateW = 0;
|
|
||||||
paWinDsDSoundEntryPoints.DirectSoundEnumerateA = 0;
|
|
||||||
paWinDsDSoundEntryPoints.DirectSoundCaptureCreate = 0;
|
|
||||||
paWinDsDSoundEntryPoints.DirectSoundCaptureEnumerateW = 0;
|
|
||||||
paWinDsDSoundEntryPoints.DirectSoundCaptureEnumerateA = 0;
|
|
||||||
|
|
||||||
FreeLibrary( paWinDsDSoundEntryPoints.hInstance_ );
|
|
||||||
paWinDsDSoundEntryPoints.hInstance_ = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,106 +0,0 @@
|
|||||||
/*
|
|
||||||
* Interface for dynamically loading directsound and providing a dummy
|
|
||||||
* implementation if it isn't present.
|
|
||||||
*
|
|
||||||
* Author: Ross Bencina (some portions Phil Burk & Robert Marsanyi)
|
|
||||||
*
|
|
||||||
* For PortAudio Portable Real-Time Audio Library
|
|
||||||
* For more information see: http://www.portaudio.com
|
|
||||||
* Copyright (c) 1999-2006 Phil Burk, Robert Marsanyi and Ross Bencina
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files
|
|
||||||
* (the "Software"), to deal in the Software without restriction,
|
|
||||||
* including without limitation the rights to use, copy, modify, merge,
|
|
||||||
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
||||||
* and to permit persons to whom the Software is furnished to do so,
|
|
||||||
* subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be
|
|
||||||
* included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
||||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
|
|
||||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
|
||||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The text above constitutes the entire PortAudio license; however,
|
|
||||||
* the PortAudio community also makes the following non-binding requests:
|
|
||||||
*
|
|
||||||
* Any person wishing to distribute modifications to the Software is
|
|
||||||
* requested to send the modifications to the original developer so that
|
|
||||||
* they can be incorporated into the canonical version. It is also
|
|
||||||
* requested that these non-binding requests be included along with the
|
|
||||||
* license above.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
@file
|
|
||||||
@ingroup hostapi_src
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef INCLUDED_PA_DSOUND_DYNLINK_H
|
|
||||||
#define INCLUDED_PA_DSOUND_DYNLINK_H
|
|
||||||
|
|
||||||
/* on Borland compilers, WIN32 doesn't seem to be defined by default, which
|
|
||||||
breaks dsound.h. Adding the define here fixes the problem. - rossb. */
|
|
||||||
#ifdef __BORLANDC__
|
|
||||||
#if !defined(WIN32)
|
|
||||||
#define WIN32
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
Use the earliest version of DX required, no need to pollute the namespace
|
|
||||||
*/
|
|
||||||
#ifdef PAWIN_USE_DIRECTSOUNDFULLDUPLEXCREATE
|
|
||||||
#define DIRECTSOUND_VERSION 0x0800
|
|
||||||
#else
|
|
||||||
#define DIRECTSOUND_VERSION 0x0300
|
|
||||||
#endif
|
|
||||||
#include <dsound.h>
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#endif /* __cplusplus */
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
HINSTANCE hInstance_;
|
|
||||||
|
|
||||||
HRESULT (WINAPI *DllGetClassObject)(REFCLSID , REFIID , LPVOID *);
|
|
||||||
|
|
||||||
HRESULT (WINAPI *DirectSoundCreate)(LPGUID, LPDIRECTSOUND *, LPUNKNOWN);
|
|
||||||
HRESULT (WINAPI *DirectSoundEnumerateW)(LPDSENUMCALLBACKW, LPVOID);
|
|
||||||
HRESULT (WINAPI *DirectSoundEnumerateA)(LPDSENUMCALLBACKA, LPVOID);
|
|
||||||
|
|
||||||
HRESULT (WINAPI *DirectSoundCaptureCreate)(LPGUID, LPDIRECTSOUNDCAPTURE *, LPUNKNOWN);
|
|
||||||
HRESULT (WINAPI *DirectSoundCaptureEnumerateW)(LPDSENUMCALLBACKW, LPVOID);
|
|
||||||
HRESULT (WINAPI *DirectSoundCaptureEnumerateA)(LPDSENUMCALLBACKA, LPVOID);
|
|
||||||
|
|
||||||
#ifdef PAWIN_USE_DIRECTSOUNDFULLDUPLEXCREATE
|
|
||||||
HRESULT (WINAPI *DirectSoundFullDuplexCreate8)(
|
|
||||||
LPCGUID, LPCGUID, LPCDSCBUFFERDESC, LPCDSBUFFERDESC,
|
|
||||||
HWND, DWORD, LPDIRECTSOUNDFULLDUPLEX *, LPDIRECTSOUNDCAPTUREBUFFER8 *,
|
|
||||||
LPDIRECTSOUNDBUFFER8 *, LPUNKNOWN );
|
|
||||||
#endif
|
|
||||||
}PaWinDsDSoundEntryPoints;
|
|
||||||
|
|
||||||
extern PaWinDsDSoundEntryPoints paWinDsDSoundEntryPoints;
|
|
||||||
|
|
||||||
void PaWinDs_InitializeDSoundEntryPoints(void);
|
|
||||||
void PaWinDs_TerminateDSoundEntryPoints(void);
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif /* __cplusplus */
|
|
||||||
|
|
||||||
#endif /* INCLUDED_PA_DSOUND_DYNLINK_H */
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user