summaryrefslogtreecommitdiff
path: root/portaudio/bindings/cpp/source/portaudiocpp/CppFunCallbackStream.cxx
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2022-08-27 23:52:56 -0500
committersanine <sanine.not@pm.me>2022-08-27 23:52:56 -0500
commita4dd0ad63c00f4dee3b86dfd3075d1d61b2b3180 (patch)
tree13bd5bfa15e6fea2a12f176bae79adf9c6fd0933 /portaudio/bindings/cpp/source/portaudiocpp/CppFunCallbackStream.cxx
parentbde3e4f1bb7b8f8abca0884a7d994ee1c17a66b1 (diff)
add plibsys
Diffstat (limited to 'portaudio/bindings/cpp/source/portaudiocpp/CppFunCallbackStream.cxx')
-rw-r--r--portaudio/bindings/cpp/source/portaudiocpp/CppFunCallbackStream.cxx81
1 files changed, 0 insertions, 81 deletions
diff --git a/portaudio/bindings/cpp/source/portaudiocpp/CppFunCallbackStream.cxx b/portaudio/bindings/cpp/source/portaudiocpp/CppFunCallbackStream.cxx
deleted file mode 100644
index fe0b4ab..0000000
--- a/portaudio/bindings/cpp/source/portaudiocpp/CppFunCallbackStream.cxx
+++ /dev/null
@@ -1,81 +0,0 @@
-#include "portaudiocpp/CppFunCallbackStream.hxx"
-
-#include "portaudiocpp/StreamParameters.hxx"
-#include "portaudiocpp/Exception.hxx"
-
-namespace portaudio
-{
- namespace impl
- {
- //////
- /// Adapts any a C++ callback to a C-callable function (ie this function). A
- /// pointer to a struct with the C++ function pointer and the actual user data should be
- /// passed as the ``userData'' parameter when setting up the callback.
- //////
- int cppCallbackToPaCallbackAdapter(const void *inputBuffer, void *outputBuffer, unsigned long numFrames,
- const PaStreamCallbackTimeInfo *timeInfo, PaStreamCallbackFlags statusFlags, void *userData)
- {
- FunCallbackStream::CppToCCallbackData *data = static_cast<FunCallbackStream::CppToCCallbackData *>(userData);
- return data->funPtr(inputBuffer, outputBuffer, numFrames, timeInfo, statusFlags, data->userData);
- }
- }
-
- // -----------------------------------------------------------------------------------
-
- FunCallbackStream::CppToCCallbackData::CppToCCallbackData()
- {
- }
-
- FunCallbackStream::CppToCCallbackData::CppToCCallbackData(CallbackFunPtr funPtr, void *userData) : funPtr(funPtr), userData(userData)
- {
- }
-
- void FunCallbackStream::CppToCCallbackData::init(CallbackFunPtr funPtr, void *userData)
- {
- this->funPtr = funPtr;
- this->userData = userData;
- }
-
- // -----------------------------------------------------------------------------------
-
- FunCallbackStream::FunCallbackStream()
- {
- }
-
- FunCallbackStream::FunCallbackStream(const StreamParameters &parameters, CallbackFunPtr funPtr, void *userData) : adapterData_(funPtr, userData)
- {
- open(parameters);
- }
-
- FunCallbackStream::~FunCallbackStream()
- {
- try
- {
- close();
- }
- catch (...)
- {
- // ignore all errors
- }
- }
-
- void FunCallbackStream::open(const StreamParameters &parameters, CallbackFunPtr funPtr, void *userData)
- {
- adapterData_.init(funPtr, userData);
- open(parameters);
- }
-
- void FunCallbackStream::open(const StreamParameters &parameters)
- {
- PaError err = Pa_OpenStream(&stream_, parameters.inputParameters().paStreamParameters(), parameters.outputParameters().paStreamParameters(),
- parameters.sampleRate(), parameters.framesPerBuffer(), parameters.flags(), &impl::cppCallbackToPaCallbackAdapter,
- static_cast<void *>(&adapterData_));
-
- if (err != paNoError)
- {
- throw PaException(err);
- }
- }
-
- // -----------------------------------------------------------------------------------
-}