From 00909b0543eaddf0ea652378e2983ca6eabb0050 Mon Sep 17 00:00:00 2001 From: yanmorin <yanmorin> Date: Mon, 7 Aug 2006 15:50:02 +0000 Subject: [PATCH] Removing portaudio cpp binding and debugging dtmf and audiolayer --- src/audio/audiolayer.cpp | 41 ++- src/audio/dtmf.cpp | 23 +- src/audio/dtmf.h | 18 +- src/audio/dtmfgenerator.h | 9 +- src/audio/pacpp/Makefile.am | 1 - src/audio/pacpp/example/devs.cxx | 177 ---------- src/audio/pacpp/example/sine.cxx | 137 -------- src/audio/pacpp/include/Makefile.am | 1 - .../portaudiocpp/AsioDeviceAdapter.hxx | 41 --- .../pacpp/include/portaudiocpp/AutoSystem.hxx | 62 ---- .../include/portaudiocpp/BlockingStream.hxx | 45 --- .../portaudiocpp/CFunCallbackStream.hxx | 49 --- .../portaudiocpp/CallbackInterface.hxx | 45 --- .../include/portaudiocpp/CallbackStream.hxx | 40 --- .../portaudiocpp/CppFunCallbackStream.hxx | 86 ----- .../pacpp/include/portaudiocpp/Device.hxx | 91 ------ .../DirectionSpecificStreamParameters.hxx | 77 ----- .../pacpp/include/portaudiocpp/Exception.hxx | 108 ------ .../pacpp/include/portaudiocpp/HostApi.hxx | 76 ----- .../portaudiocpp/InterfaceCallbackStream.hxx | 49 --- .../pacpp/include/portaudiocpp/Makefile.am | 20 -- .../portaudiocpp/MemFunCallbackStream.hxx | 107 ------ .../include/portaudiocpp/PortAudioCpp.hxx | 109 ------- .../include/portaudiocpp/SampleDataFormat.hxx | 35 -- .../pacpp/include/portaudiocpp/Stream.hxx | 82 ----- .../include/portaudiocpp/StreamParameters.hxx | 77 ----- .../pacpp/include/portaudiocpp/System.hxx | 107 ------ .../portaudiocpp/SystemDeviceIterator.hxx | 66 ---- .../portaudiocpp/SystemHostApiIterator.hxx | 61 ---- src/audio/pacpp/source/Makefile.am | 1 - .../source/portaudiocpp/AsioDeviceAdapter.cxx | 61 ---- .../source/portaudiocpp/BlockingStream.cxx | 100 ------ .../portaudiocpp/CFunCallbackStream.cxx | 41 --- .../source/portaudiocpp/CallbackInterface.cxx | 25 -- .../source/portaudiocpp/CallbackStream.cxx | 20 -- .../portaudiocpp/CppFunCallbackStream.cxx | 81 ----- .../pacpp/source/portaudiocpp/Device.cxx | 168 ---------- .../DirectionSpecificStreamParameters.cxx | 163 --------- .../pacpp/source/portaudiocpp/Exception.cxx | 123 ------- .../pacpp/source/portaudiocpp/HostApi.cxx | 121 ------- .../portaudiocpp/InterfaceCallbackStream.cxx | 45 --- .../pacpp/source/portaudiocpp/Makefile.am | 22 -- .../portaudiocpp/MemFunCallbackStream.cxx | 4 - .../pacpp/source/portaudiocpp/Stream.cxx | 195 ----------- .../source/portaudiocpp/StreamParameters.cxx | 165 ---------- .../pacpp/source/portaudiocpp/System.cxx | 308 ------------------ .../portaudiocpp/SystemDeviceIterator.cxx | 60 ---- .../portaudiocpp/SystemHostApiIterator.cxx | 59 ---- 48 files changed, 59 insertions(+), 3543 deletions(-) delete mode 100644 src/audio/pacpp/Makefile.am delete mode 100644 src/audio/pacpp/example/devs.cxx delete mode 100644 src/audio/pacpp/example/sine.cxx delete mode 100644 src/audio/pacpp/include/Makefile.am delete mode 100644 src/audio/pacpp/include/portaudiocpp/AsioDeviceAdapter.hxx delete mode 100644 src/audio/pacpp/include/portaudiocpp/AutoSystem.hxx delete mode 100644 src/audio/pacpp/include/portaudiocpp/BlockingStream.hxx delete mode 100644 src/audio/pacpp/include/portaudiocpp/CFunCallbackStream.hxx delete mode 100644 src/audio/pacpp/include/portaudiocpp/CallbackInterface.hxx delete mode 100644 src/audio/pacpp/include/portaudiocpp/CallbackStream.hxx delete mode 100644 src/audio/pacpp/include/portaudiocpp/CppFunCallbackStream.hxx delete mode 100644 src/audio/pacpp/include/portaudiocpp/Device.hxx delete mode 100644 src/audio/pacpp/include/portaudiocpp/DirectionSpecificStreamParameters.hxx delete mode 100644 src/audio/pacpp/include/portaudiocpp/Exception.hxx delete mode 100644 src/audio/pacpp/include/portaudiocpp/HostApi.hxx delete mode 100644 src/audio/pacpp/include/portaudiocpp/InterfaceCallbackStream.hxx delete mode 100644 src/audio/pacpp/include/portaudiocpp/Makefile.am delete mode 100644 src/audio/pacpp/include/portaudiocpp/MemFunCallbackStream.hxx delete mode 100644 src/audio/pacpp/include/portaudiocpp/PortAudioCpp.hxx delete mode 100644 src/audio/pacpp/include/portaudiocpp/SampleDataFormat.hxx delete mode 100644 src/audio/pacpp/include/portaudiocpp/Stream.hxx delete mode 100644 src/audio/pacpp/include/portaudiocpp/StreamParameters.hxx delete mode 100644 src/audio/pacpp/include/portaudiocpp/System.hxx delete mode 100644 src/audio/pacpp/include/portaudiocpp/SystemDeviceIterator.hxx delete mode 100644 src/audio/pacpp/include/portaudiocpp/SystemHostApiIterator.hxx delete mode 100644 src/audio/pacpp/source/Makefile.am delete mode 100644 src/audio/pacpp/source/portaudiocpp/AsioDeviceAdapter.cxx delete mode 100644 src/audio/pacpp/source/portaudiocpp/BlockingStream.cxx delete mode 100644 src/audio/pacpp/source/portaudiocpp/CFunCallbackStream.cxx delete mode 100644 src/audio/pacpp/source/portaudiocpp/CallbackInterface.cxx delete mode 100644 src/audio/pacpp/source/portaudiocpp/CallbackStream.cxx delete mode 100644 src/audio/pacpp/source/portaudiocpp/CppFunCallbackStream.cxx delete mode 100644 src/audio/pacpp/source/portaudiocpp/Device.cxx delete mode 100644 src/audio/pacpp/source/portaudiocpp/DirectionSpecificStreamParameters.cxx delete mode 100644 src/audio/pacpp/source/portaudiocpp/Exception.cxx delete mode 100644 src/audio/pacpp/source/portaudiocpp/HostApi.cxx delete mode 100644 src/audio/pacpp/source/portaudiocpp/InterfaceCallbackStream.cxx delete mode 100644 src/audio/pacpp/source/portaudiocpp/Makefile.am delete mode 100644 src/audio/pacpp/source/portaudiocpp/MemFunCallbackStream.cxx delete mode 100644 src/audio/pacpp/source/portaudiocpp/Stream.cxx delete mode 100644 src/audio/pacpp/source/portaudiocpp/StreamParameters.cxx delete mode 100644 src/audio/pacpp/source/portaudiocpp/System.cxx delete mode 100644 src/audio/pacpp/source/portaudiocpp/SystemDeviceIterator.cxx delete mode 100644 src/audio/pacpp/source/portaudiocpp/SystemHostApiIterator.cxx diff --git a/src/audio/audiolayer.cpp b/src/audio/audiolayer.cpp index e39c3ab3c9..9696c434de 100644 --- a/src/audio/audiolayer.cpp +++ b/src/audio/audiolayer.cpp @@ -112,9 +112,10 @@ AudioLayer::startStream(void) try { ost::MutexLock guard(_mutex); if (_stream && !_stream->isActive()) { - //_debug("Starting sound stream\n"); + _debug("Starting sound stream\n"); _stream->start(); - } + } + else { _debug ("stream doesn't exist or is already active\n"); } } catch (const portaudio::PaException &e) { _debugException("Portaudio error: error on starting audiolayer stream"); throw; @@ -136,7 +137,7 @@ AudioLayer::stopStream(void) _micRingBuffer.flush(); } } catch (const portaudio::PaException &e) { - _debugException("Portaudio error: error on stoping audiolayer stream"); + _debugException("Portaudio error: stoping audiolayer stream failed"); throw; } catch(...) { _debugException("stream stop error"); @@ -156,12 +157,14 @@ bool AudioLayer::isStreamActive (void) { ost::MutexLock guard(_mutex); - if(_stream && _stream->isActive()) { - return true; - } - else { - return false; + try { + if(_stream && _stream->isActive()) { + return true; + } + } catch (const portaudio::PaException &e) { + _debugException("Portaudio error: isActive returned an error"); } + return false; } int @@ -189,6 +192,7 @@ AudioLayer::flushMain() int AudioLayer::putUrgent(void* buffer, int toCopy) { + ost::MutexLock guard(_mutex); if (_stream) { int a = _urgentRingBuffer.AvailForPut(); if ( a >= toCopy ) { @@ -230,12 +234,14 @@ bool AudioLayer::isStreamStopped (void) { ost::MutexLock guard(_mutex); - if(_stream && _stream->isStopped()) { - return true; - } - else { - return false; + try { + if(_stream && _stream->isStopped()) { + return true; + } + } catch (const portaudio::PaException &e) { + _debugException("Portaudio error: isStopped returned an exception"); } + return false; } int @@ -261,9 +267,10 @@ AudioLayer::audioCallback (const void *inputBuffer, void *outputBuffer, // framePerBuffer are the number of int16 for one channel (left) urgentAvail = _urgentRingBuffer.AvailForGet(); if (urgentAvail > 0) { - // Urgent data (dtmf, incoming call signal) come first. + // Urgent data (dtmf, incoming call signal) come first. toGet = (urgentAvail < (int)(framesPerBuffer * sizeof(int16) * _outChannel)) ? urgentAvail : framesPerBuffer * sizeof(int16) * _outChannel; _urgentRingBuffer.Get(out, toGet, spkrVolume); + _debug("out: %p, toGet: %d, spkrVolume: %d\n", out, toGet, spkrVolume); // Consume the regular one as well (same amount of bytes) _mainSndRingBuffer.Discard(toGet); @@ -283,7 +290,9 @@ AudioLayer::audioCallback (const void *inputBuffer, void *outputBuffer, } else { //_debug("padding %d...\n", (int)(framesPerBuffer * sizeof(int16)*_outChannel)); //_mainSndRingBuffer.debug(); - bzero(out, framesPerBuffer * sizeof(int16) * _outChannel); + //portaudio::System::instance().sleep(framesPerBuffer*sizeof(int16)); + bzero(out, framesPerBuffer * sizeof(int16) * _outChannel); + } } } @@ -293,6 +302,8 @@ AudioLayer::audioCallback (const void *inputBuffer, void *outputBuffer, toPut = (micAvailPut <= (int)(framesPerBuffer * sizeof(int16) * _inChannel)) ? micAvailPut : framesPerBuffer * sizeof(int16) * _inChannel; _micRingBuffer.Put(in, toPut, micVolume ); + if (toPut==0 && toGet==0) { return 1; } + return paContinue; } diff --git a/src/audio/dtmf.cpp b/src/audio/dtmf.cpp index 9cdf2d8c5b..f7a205d449 100644 --- a/src/audio/dtmf.cpp +++ b/src/audio/dtmf.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2005 Savoir-Faire Linux inc. + * Copyright (C) 2004-2006 Savoir-Faire Linux inc. * Author : Yan Morin <yan.morin@savoirfairelinux.com> * Author : Laurielle Lea <laurielle.lea@savoirfairelinux.com> * @@ -23,33 +23,38 @@ #include "dtmf.h" -DTMF::DTMF (unsigned int sampleRate, unsigned int nbChannel) : dtmf(sampleRate, nbChannel) { +DTMF::DTMF (unsigned int sampleRate, unsigned int nbChannel) +: dtmfgenerator(sampleRate, nbChannel) +{ currentTone = 0; newTone = 0; } -DTMF::~DTMF (void) { +DTMF::~DTMF (void) +{ } void -DTMF::startTone (char code) { +DTMF::startTone (char code) +{ newTone = code; } bool -DTMF::generateDTMF (int16* buffer, size_t n) { - if (!buffer) return false; +DTMF::generateDTMF (int16* buffer, size_t n) +{ + if (!buffer) return false; try { if (currentTone != 0) { // Currently generating a DTMF tone if (currentTone == newTone) { // Continue generating the same tone - dtmf.getNextSamples(buffer, n); + dtmfgenerator.getNextSamples(buffer, n); return true; } else if (newTone != 0) { // New tone requested - dtmf.getSamples(buffer, n, newTone); + dtmfgenerator.getSamples(buffer, n, newTone); currentTone = newTone; return true; } else { @@ -61,7 +66,7 @@ DTMF::generateDTMF (int16* buffer, size_t n) { // Not generating any DTMF tone if (newTone) { // Requested to generate a DTMF tone - dtmf.getSamples(buffer, n, newTone); + dtmfgenerator.getSamples(buffer, n, newTone); currentTone = newTone; return true; } diff --git a/src/audio/dtmf.h b/src/audio/dtmf.h index ef20ba74c0..ab6a6e7c9d 100644 --- a/src/audio/dtmf.h +++ b/src/audio/dtmf.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2004-2005-2006 Savoir-Faire Linux inc. + * Author : Yan Morin <yan.morin@savoirfairelinux.com> * Author: Laurielle Lea <laurielle.lea@savoirfairelinux.com> * * Portions Copyright (c) 2000 Billy Biggs <bbiggs@div8.net> @@ -31,20 +32,25 @@ */ class DTMF { public: - /** - * Create a new DTMF. - * @param samplingRate frequency of the sample (ex: 8000 hz) - */ + /** + * Create a new DTMF. + * @param samplingRate frequency of the sample (ex: 8000 hz) + */ DTMF (unsigned int sampleRate, unsigned int nbChannel); ~DTMF (void); void startTone (char); - bool generateDTMF (int16*, size_t); + /** + * Copy the sound inside the int16* buffer + * @param buffer : a int16* buffer + * @param n : + */ + bool generateDTMF (int16* buffer, size_t n); char currentTone; char newTone; - DTMFGenerator dtmf; + DTMFGenerator dtmfgenerator; }; #endif // __KEY_DTMF_H_ diff --git a/src/audio/dtmfgenerator.h b/src/audio/dtmfgenerator.h index 894e7dd53c..9d48759ebe 100644 --- a/src/audio/dtmfgenerator.h +++ b/src/audio/dtmfgenerator.h @@ -1,5 +1,5 @@ -/** - * Copyright (C) 2004-2005 Savoir-Faire Linux inc. +/* + * Copyright (C) 2004-2006 Savoir-Faire Linux inc. * Author: Yan Morin <yan.morin@savoirfairelinux.com> * Author: Laurielle Lea <laurielle.lea@savoirfairelinux.com> * @@ -90,12 +90,17 @@ public: /* * Get n samples of the signal of code code + * @param buffer a int16 pointer to an allocated buffer + * @param n number of int16 to get, should be lower or equal to buffer size + * @parma code dtmf code to get sound */ void getSamples(int16* buffer, size_t n, unsigned char code) throw (DTMFException); /* * Get next n samples (continues where previous call to * genSample or genNextSamples stopped + * @param buffer a int16 pointer to an allocated buffer + * @param n number of int16 to get, should be lower or equal to buffer size */ void getNextSamples(int16* buffer, size_t n) throw (DTMFException); diff --git a/src/audio/pacpp/Makefile.am b/src/audio/pacpp/Makefile.am deleted file mode 100644 index 4f6f53c3b4..0000000000 --- a/src/audio/pacpp/Makefile.am +++ /dev/null @@ -1 +0,0 @@ -SUBDIRS = source include \ No newline at end of file diff --git a/src/audio/pacpp/example/devs.cxx b/src/audio/pacpp/example/devs.cxx deleted file mode 100644 index 31a560f884..0000000000 --- a/src/audio/pacpp/example/devs.cxx +++ /dev/null @@ -1,177 +0,0 @@ -#include <iostream> -#include "portaudiocpp/PortAudioCpp.hxx" - -#ifdef WIN32 -#include "portaudiocpp/AsioDeviceAdapter.hxx" -#endif - -// --------------------------------------------------------------------------------------- - -void printSupportedStandardSampleRates( - const portaudio::DirectionSpecificStreamParameters &inputParameters, - const portaudio::DirectionSpecificStreamParameters &outputParameters) -{ - static double STANDARD_SAMPLE_RATES[] = { - 8000.0, 9600.0, 11025.0, 12000.0, 16000.0, 22050.0, 24000.0, 32000.0, - 44100.0, 48000.0, 88200.0, 96000.0, -1 }; // negative terminated list - - int printCount = 0; - - for (int i = 0; STANDARD_SAMPLE_RATES[i] > 0; ++i) - { - portaudio::StreamParameters tmp = portaudio::StreamParameters(inputParameters, outputParameters, STANDARD_SAMPLE_RATES[i], 0, paNoFlag); - - if (tmp.isSupported()) - { - if (printCount == 0) - { - std::cout << " " << STANDARD_SAMPLE_RATES[i]; // 8.2 - printCount = 1; - } - else if (printCount == 4) - { - std::cout << "," << std::endl; - std::cout << " " << STANDARD_SAMPLE_RATES[i]; // 8.2 - printCount = 1; - } - else - { - std::cout << ", " << STANDARD_SAMPLE_RATES[i]; // 8.2 - ++printCount; - } - } - } - - if (printCount == 0) - std::cout << "None" << std::endl; - else - std::cout << std::endl; -} - -// --------------------------------------------------------------------------------------- - -int main(int, char*[]); -int main(int, char*[]) -{ - try - { - portaudio::AutoSystem autoSys; - - portaudio::System &sys = portaudio::System::instance(); - - std::cout << "PortAudio version number = " << sys.version() << std::endl; - std::cout << "PortAudio version text = '" << sys.versionText() << "'" << std::endl; - - int numDevices = sys.deviceCount(); - std::cout << "Number of devices = " << numDevices << std::endl; - - for (portaudio::System::DeviceIterator i = sys.devicesBegin(); i != sys.devicesEnd(); ++i) - { - std::cout << "--------------------------------------- device #" << (*i).index() << std::endl; - - // Mark global and API specific default devices: - bool defaultDisplayed = false; - - if ((*i).isSystemDefaultInputDevice()) - { - std::cout << "[ Default Input"; - defaultDisplayed = true; - } - else if ((*i).isHostApiDefaultInputDevice()) - { - std::cout << "[ Default " << (*i).hostApi().name() << " Input"; - defaultDisplayed = true; - } - - if ((*i).isSystemDefaultOutputDevice()) - { - std::cout << (defaultDisplayed ? "," : "["); - std::cout << " Default Output"; - defaultDisplayed = true; - } - else if ((*i).isHostApiDefaultOutputDevice()) - { - std::cout << (defaultDisplayed ? "," : "["); - std::cout << " Default " << (*i).hostApi().name() << " Output"; - defaultDisplayed = true; - } - - if (defaultDisplayed) - std::cout << " ]" << std::endl; - - // Print device info: - std::cout << "Name = " << (*i).name() << std::endl; - std::cout << "Host API = " << (*i).hostApi().name() << std::endl; - std::cout << "Max inputs = " << (*i).maxInputChannels() << ", Max outputs = " << (*i).maxOutputChannels() << std::endl; - - std::cout << "Default low input latency = " << (*i).defaultLowInputLatency() << std::endl; // 8.3 - std::cout << "Default low output latency = " << (*i).defaultLowOutputLatency() << std::endl; // 8.3 - std::cout << "Default high input latency = " << (*i).defaultHighInputLatency() << std::endl; // 8.3 - std::cout << "Default high output latency = " << (*i).defaultHighOutputLatency() << std::endl; // 8.3 - -#ifdef WIN32 - // ASIO specific latency information: - if ((*i).hostApi().typeId() == paASIO) - { - portaudio::AsioDeviceAdapter asioDevice((*i)); - - std::cout << "ASIO minimum buffer size = " << asioDevice.minBufferSize() << std::endl; - std::cout << "ASIO maximum buffer size = " << asioDevice.maxBufferSize() << std::endl; - std::cout << "ASIO preferred buffer size = " << asioDevice.preferredBufferSize() << std::endl; - - if (asioDevice.granularity() == -1) - std::cout << "ASIO buffer granularity = power of 2" << std::endl; - else - std::cout << "ASIO buffer granularity = " << asioDevice.granularity() << std::endl; - } -#endif // WIN32 - - std::cout << "Default sample rate = " << (*i).defaultSampleRate() << std::endl; // 8.2 - - // Poll for standard sample rates: - portaudio::DirectionSpecificStreamParameters inputParameters((*i), (*i).maxInputChannels(), portaudio::INT16, true, 0.0, NULL); - portaudio::DirectionSpecificStreamParameters outputParameters((*i), (*i).maxOutputChannels(), portaudio::INT16, true, 0.0, NULL); - - if (inputParameters.numChannels() > 0) - { - std::cout << "Supported standard sample rates" << std::endl; - std::cout << " for half-duplex 16 bit " << inputParameters.numChannels() << " channel input = " << std::endl; - printSupportedStandardSampleRates(inputParameters, portaudio::DirectionSpecificStreamParameters::null()); - } - - if (outputParameters.numChannels() > 0) - { - std::cout << "Supported standard sample rates" << std::endl; - std::cout << " for half-duplex 16 bit " << outputParameters.numChannels() << " channel output = " << std::endl; - printSupportedStandardSampleRates(portaudio::DirectionSpecificStreamParameters::null(), outputParameters); - } - - if (inputParameters.numChannels() > 0 && outputParameters.numChannels() > 0) - { - std::cout << "Supported standard sample rates" << std::endl; - std::cout << " for full-duplex 16 bit " << inputParameters.numChannels() << " channel input, " << outputParameters.numChannels() << " channel output = " << std::endl; - printSupportedStandardSampleRates(inputParameters, outputParameters); - } - } - - std::cout << "----------------------------------------------" << std::endl; - } - catch (const portaudio::PaException &e) - { - std::cout << "A PortAudio error occured: " << e.paErrorText() << std::endl; - } - catch (const portaudio::PaCppException &e) - { - std::cout << "A PortAudioCpp error occured: " << e.what() << std::endl; - } - catch (const std::exception &e) - { - std::cout << "A generic exception occured: " << e.what() << std::endl; - } - catch (...) - { - std::cout << "An unknown exception occured." << std::endl; - } - - return 0; -} diff --git a/src/audio/pacpp/example/sine.cxx b/src/audio/pacpp/example/sine.cxx deleted file mode 100644 index d13f765f93..0000000000 --- a/src/audio/pacpp/example/sine.cxx +++ /dev/null @@ -1,137 +0,0 @@ -// --------------------------------------------------------------------------------------- - -#include <iostream> -#include <cmath> -#include <cassert> -#include <cstddef> -#include "portaudiocpp/PortAudioCpp.hxx" - -// --------------------------------------------------------------------------------------- - -// Some constants: -const int NUM_SECONDS = 5; -const double SAMPLE_RATE = 44100.0; -const int FRAMES_PER_BUFFER = 64; -const int TABLE_SIZE = 200; - -// --------------------------------------------------------------------------------------- - -// SineGenerator class: -class SineGenerator -{ -public: - SineGenerator(int tableSize) : tableSize_(tableSize), leftPhase_(0), rightPhase_(0) - { - const double PI = 3.14159265; - table_ = new float[tableSize]; - for (int i = 0; i < tableSize; ++i) - { - table_[i] = 0.125f * (float)sin(((double)i/(double)tableSize)*PI*2.); - } - } - - ~SineGenerator() - { - delete[] table_; table_ = NULL; - } - - int generate(const void *inputBuffer, void *outputBuffer, unsigned long framesPerBuffer, - const PaStreamCallbackTimeInfo *timeInfo, PaStreamCallbackFlags statusFlags) - { - assert(outputBuffer != NULL); - - float **out = static_cast<float **>(outputBuffer); - - for (unsigned int i = 0; i < framesPerBuffer; ++i) - { - out[0][i] = table_[leftPhase_]; - out[1][i] = table_[rightPhase_]; - - leftPhase_ += 1; - if (leftPhase_ >= tableSize_) - leftPhase_ -= tableSize_; - - rightPhase_ += 3; - if (rightPhase_ >= tableSize_) - rightPhase_ -= tableSize_; - } - - return paContinue; - } - -private: - float *table_; - int tableSize_; - int leftPhase_; - int rightPhase_; -}; - -// --------------------------------------------------------------------------------------- - -// main: -int main(int, char *[]); -int main(int, char *[]) -{ - try - { - // Create a SineGenerator object: - SineGenerator sineGenerator(TABLE_SIZE); - - std::cout << "Setting up PortAudio..." << std::endl; - - // Set up the System: - portaudio::AutoSystem autoSys; - portaudio::System &sys = portaudio::System::instance(); - - // Set up the parameters required to open a (Callback)Stream: - portaudio::DirectionSpecificStreamParameters outParams(sys.defaultOutputDevice(), 2, portaudio::FLOAT32, false, sys.defaultOutputDevice().defaultLowOutputLatency(), NULL); - portaudio::StreamParameters params(portaudio::DirectionSpecificStreamParameters::null(), outParams, SAMPLE_RATE, FRAMES_PER_BUFFER, paClipOff); - - std::cout << "Opening stereo output stream..." << std::endl; - - // Create (and open) a new Stream, using the SineGenerator::generate function as a callback: - portaudio::MemFunCallbackStream<SineGenerator> stream(params, sineGenerator, &SineGenerator::generate); - - std::cout << "Starting playback for " << NUM_SECONDS << " seconds." << std::endl; - - // Start the Stream (audio playback starts): - stream.start(); - - // Wait for 5 seconds: - sys.sleep(NUM_SECONDS * 1000); - - std::cout << "Closing stream..." <<std::endl; - - // Stop the Stream (not strictly needed as termintating the System will also stop all open Streams): - stream.stop(); - - // Close the Stream (not strictly needed as terminating the System will also close all open Streams): - stream.close(); - - // Terminate the System (not strictly needed as the AutoSystem will also take care of this when it - // goes out of scope): - sys.terminate(); - - std::cout << "Test finished." << std::endl; - } - catch (const portaudio::PaException &e) - { - std::cout << "A PortAudio error occured: " << e.paErrorText() << std::endl; - } - catch (const portaudio::PaCppException &e) - { - std::cout << "A PortAudioCpp error occured: " << e.what() << std::endl; - } - catch (const std::exception &e) - { - std::cout << "A generic exception occured: " << e.what() << std::endl; - } - catch (...) - { - std::cout << "An unknown exception occured." << std::endl; - } - - return 0; -} - - diff --git a/src/audio/pacpp/include/Makefile.am b/src/audio/pacpp/include/Makefile.am deleted file mode 100644 index d8e4f6c804..0000000000 --- a/src/audio/pacpp/include/Makefile.am +++ /dev/null @@ -1 +0,0 @@ -SUBDIRS = portaudiocpp \ No newline at end of file diff --git a/src/audio/pacpp/include/portaudiocpp/AsioDeviceAdapter.hxx b/src/audio/pacpp/include/portaudiocpp/AsioDeviceAdapter.hxx deleted file mode 100644 index 3637c59747..0000000000 --- a/src/audio/pacpp/include/portaudiocpp/AsioDeviceAdapter.hxx +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef INCLUDED_PORTAUDIO_ASIODEVICEADAPTER_HXX -#define INCLUDED_PORTAUDIO_ASIODEVICEADAPTER_HXX - -namespace portaudio -{ - - // Forward declaration(s): - class Device; - - // Declaration(s): - ////// - /// @brief Adapts the given Device to an ASIO specific extension. - /// - /// Deleting the AsioDeviceAdapter does not affect the underlaying - /// Device. - ////// - class AsioDeviceAdapter - { - public: - AsioDeviceAdapter(Device &device); - - Device &device(); - - long minBufferSize() const; - long maxBufferSize() const; - long preferredBufferSize() const; - long granularity() const; - - void showControlPanel(void *systemSpecific); - - private: - Device *device_; - - long minBufferSize_; - long maxBufferSize_; - long preferredBufferSize_; - long granularity_; - }; -} - -#endif // INCLUDED_PORTAUDIO_ASIODEVICEADAPTER_HXX diff --git a/src/audio/pacpp/include/portaudiocpp/AutoSystem.hxx b/src/audio/pacpp/include/portaudiocpp/AutoSystem.hxx deleted file mode 100644 index 16cac5ed50..0000000000 --- a/src/audio/pacpp/include/portaudiocpp/AutoSystem.hxx +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef INCLUDED_PORTAUDIO_AUTOSYSTEM_HXX -#define INCLUDED_PORTAUDIO_AUTOSYSTEM_HXX - -// --------------------------------------------------------------------------------------- - -#include "portaudiocpp/System.hxx" - -// --------------------------------------------------------------------------------------- - -namespace portaudio -{ - - - ////// - /// @brief A RAII idiom class to ensure automatic clean-up when an exception is - /// raised. - /// - /// A simple helper class which uses the 'Resource Acquisition is Initialization' - /// idiom (RAII). Use this class to initialize/terminate the System rather than - /// using System directly. AutoSystem must be created on stack and must be valid - /// throughout the time you wish to use PortAudioCpp. Your 'main' function might be - /// a good place for it. - /// - /// To avoid having to type portaudio::System::instance().xyz() all the time, it's usually - /// a good idea to make a reference to the System which can be accessed directly. - /// @verbatim - /// portaudio::AutoSys autoSys; - /// portaudio::System &sys = portaudio::System::instance(); - /// @endverbatim - ////// - class AutoSystem - { - public: - AutoSystem(bool initialize = true) - { - if (initialize) - System::initialize(); - } - - ~AutoSystem() - { - if (System::exists()) - System::terminate(); - } - - void initialize() - { - System::initialize(); - } - - void terminate() - { - System::terminate(); - } - }; - - -} // namespace portaudio - -// --------------------------------------------------------------------------------------- - -#endif // INCLUDED_PORTAUDIO_AUTOSYSTEM_HXX diff --git a/src/audio/pacpp/include/portaudiocpp/BlockingStream.hxx b/src/audio/pacpp/include/portaudiocpp/BlockingStream.hxx deleted file mode 100644 index 37fa76652d..0000000000 --- a/src/audio/pacpp/include/portaudiocpp/BlockingStream.hxx +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef INCLUDED_PORTAUDIO_BLOCKINGSTREAM_HXX -#define INCLUDED_PORTAUDIO_BLOCKINGSTREAM_HXX - -// --------------------------------------------------------------------------------------- - -#include "portaudiocpp/Stream.hxx" - -// --------------------------------------------------------------------------------------- - -namespace portaudio -{ - - - - ////// - /// @brief Stream class for blocking read/write-style input and output. - ////// - class BlockingStream : public Stream - { - public: - BlockingStream(); - BlockingStream(const StreamParameters ¶meters); - ~BlockingStream(); - - void open(const StreamParameters ¶meters); - - void read(void *buffer, unsigned long numFrames); - void write(const void *buffer, unsigned long numFrames); - - signed long availableReadSize() const; - signed long availableWriteSize() const; - - private: - BlockingStream(const BlockingStream &); // non-copyable - BlockingStream &operator=(const BlockingStream &); // non-copyable - }; - - - -} // portaudio - -// --------------------------------------------------------------------------------------- - -#endif // INCLUDED_PORTAUDIO_BLOCKINGSTREAM_HXX - diff --git a/src/audio/pacpp/include/portaudiocpp/CFunCallbackStream.hxx b/src/audio/pacpp/include/portaudiocpp/CFunCallbackStream.hxx deleted file mode 100644 index b3e3b5c1b8..0000000000 --- a/src/audio/pacpp/include/portaudiocpp/CFunCallbackStream.hxx +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef INCLUDED_PORTAUDIO_CFUNCALLBACKSTREAM_HXX -#define INCLUDED_PORTAUDIO_CFUNCALLBACKSTREAM_HXX - -// --------------------------------------------------------------------------------------- - -#include "portaudio.h" - -#include "portaudiocpp/CallbackStream.hxx" - -// --------------------------------------------------------------------------------------- - -// Forward declaration(s) -namespace portaudio -{ - class StreamParameters; -} - -// --------------------------------------------------------------------------------------- - -// Declaration(s): -namespace portaudio -{ - // ----------------------------------------------------------------------------------- - - ////// - /// @brief Callback stream using a free function with C linkage. It's important that the function - /// the passed function pointer points to is declared ``extern "C"''. - ////// - class CFunCallbackStream : public CallbackStream - { - public: - CFunCallbackStream(); - CFunCallbackStream(const StreamParameters ¶meters, PaStreamCallback *funPtr, void *userData); - ~CFunCallbackStream(); - - void open(const StreamParameters ¶meters, PaStreamCallback *funPtr, void *userData); - - private: - CFunCallbackStream(const CFunCallbackStream &); // non-copyable - CFunCallbackStream &operator=(const CFunCallbackStream &); // non-copyable - }; - - // ----------------------------------------------------------------------------------- -} // portaudio - -// --------------------------------------------------------------------------------------- - -#endif // INCLUDED_PORTAUDIO_MEMFUNCALLBACKSTREAM_HXX - diff --git a/src/audio/pacpp/include/portaudiocpp/CallbackInterface.hxx b/src/audio/pacpp/include/portaudiocpp/CallbackInterface.hxx deleted file mode 100644 index d498ec5b78..0000000000 --- a/src/audio/pacpp/include/portaudiocpp/CallbackInterface.hxx +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef INCLUDED_PORTAUDIO_CALLBACKINTERFACE_HXX -#define INCLUDED_PORTAUDIO_CALLBACKINTERFACE_HXX - -// --------------------------------------------------------------------------------------- - -#include "portaudio.h" - -// --------------------------------------------------------------------------------------- - -namespace portaudio -{ - // ----------------------------------------------------------------------------------- - - ////// - /// @brief Interface for an object that's callable as a PortAudioCpp callback object (ie that implements the - /// paCallbackFun method). - ////// - class CallbackInterface - { - public: - virtual ~CallbackInterface() {} - - virtual int paCallbackFun(const void *inputBuffer, void *outputBuffer, unsigned long numFrames, - const PaStreamCallbackTimeInfo *timeInfo, PaStreamCallbackFlags statusFlags) = 0; - }; - - // ----------------------------------------------------------------------------------- - - namespace impl - { - extern "C" - { - int callbackInterfaceToPaCallbackAdapter(const void *inputBuffer, void *outputBuffer, unsigned long numFrames, - const PaStreamCallbackTimeInfo *timeInfo, PaStreamCallbackFlags statusFlags, - void *userData); - } // extern "C" - } - - // ----------------------------------------------------------------------------------- - -} // namespace portaudio - -// --------------------------------------------------------------------------------------- - -#endif // INCLUDED_PORTAUDIO_CALLBACKINTERFACE_HXX diff --git a/src/audio/pacpp/include/portaudiocpp/CallbackStream.hxx b/src/audio/pacpp/include/portaudiocpp/CallbackStream.hxx deleted file mode 100644 index 0382275e3a..0000000000 --- a/src/audio/pacpp/include/portaudiocpp/CallbackStream.hxx +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef INCLUDED_PORTAUDIO_CALLBACKSTREAM_HXX -#define INCLUDED_PORTAUDIO_CALLBACKSTREAM_HXX - -// --------------------------------------------------------------------------------------- - -#include "portaudio.h" - -#include "portaudiocpp/Stream.hxx" - -// --------------------------------------------------------------------------------------- - -// Declaration(s): -namespace portaudio -{ - - - ////// - /// @brief Base class for all Streams which use a callback-based mechanism. - ////// - class CallbackStream : public Stream - { - protected: - CallbackStream(); - virtual ~CallbackStream(); - - public: - // stream info (time-varying) - double cpuLoad() const; - - private: - CallbackStream(const CallbackStream &); // non-copyable - CallbackStream &operator=(const CallbackStream &); // non-copyable - }; - - -} // namespace portaudio - -// --------------------------------------------------------------------------------------- - -#endif // INCLUDED_PORTAUDIO_CALLBACKSTREAM_HXX diff --git a/src/audio/pacpp/include/portaudiocpp/CppFunCallbackStream.hxx b/src/audio/pacpp/include/portaudiocpp/CppFunCallbackStream.hxx deleted file mode 100644 index e0c001274d..0000000000 --- a/src/audio/pacpp/include/portaudiocpp/CppFunCallbackStream.hxx +++ /dev/null @@ -1,86 +0,0 @@ -#ifndef INCLUDED_PORTAUDIO_CPPFUNCALLBACKSTREAM_HXX -#define INCLUDED_PORTAUDIO_CPPFUNCALLBACKSTREAM_HXX - -// --------------------------------------------------------------------------------------- - -#include "portaudio.h" - -#include "portaudiocpp/CallbackStream.hxx" - -// --------------------------------------------------------------------------------------- - -// Forward declaration(s): -namespace portaudio -{ - class StreamParameters; -} - -// --------------------------------------------------------------------------------------- - -// Declaration(s): -namespace portaudio -{ - - - namespace impl - { - extern "C" - { - int cppCallbackToPaCallbackAdapter(const void *inputBuffer, void *outputBuffer, unsigned long numFrames, - const PaStreamCallbackTimeInfo *timeInfo, PaStreamCallbackFlags statusFlags, - void *userData); - } // extern "C" - } - - // ----------------------------------------------------------------------------------- - - ////// - /// @brief Callback stream using a C++ function (either a free function or a static function) - /// callback. - ////// - class FunCallbackStream : public CallbackStream - { - public: - typedef int (*CallbackFunPtr)(const void *inputBuffer, void *outputBuffer, unsigned long numFrames, - const PaStreamCallbackTimeInfo *timeInfo, PaStreamCallbackFlags statusFlags, - void *userData); - - // ------------------------------------------------------------------------------- - - ////// - /// @brief Simple structure containing a function pointer to the C++ callback function and a - /// (void) pointer to the user supplied data. - ////// - struct CppToCCallbackData - { - CppToCCallbackData(); - CppToCCallbackData(CallbackFunPtr funPtr, void *userData); - void init(CallbackFunPtr funPtr, void *userData); - - CallbackFunPtr funPtr; - void *userData; - }; - - // ------------------------------------------------------------------------------- - - FunCallbackStream(); - FunCallbackStream(const StreamParameters ¶meters, CallbackFunPtr funPtr, void *userData); - ~FunCallbackStream(); - - void open(const StreamParameters ¶meters, CallbackFunPtr funPtr, void *userData); - - private: - FunCallbackStream(const FunCallbackStream &); // non-copyable - FunCallbackStream &operator=(const FunCallbackStream &); // non-copyable - - CppToCCallbackData adapterData_; - - void open(const StreamParameters ¶meters); - }; - - -} // portaudio - -// --------------------------------------------------------------------------------------- - -#endif // INCLUDED_PORTAUDIO_CPPFUNCALLBACKSTREAM_HXX diff --git a/src/audio/pacpp/include/portaudiocpp/Device.hxx b/src/audio/pacpp/include/portaudiocpp/Device.hxx deleted file mode 100644 index ffde7aa8e3..0000000000 --- a/src/audio/pacpp/include/portaudiocpp/Device.hxx +++ /dev/null @@ -1,91 +0,0 @@ -#ifndef INCLUDED_PORTAUDIO_DEVICE_HXX -#define INCLUDED_PORTAUDIO_DEVICE_HXX - -// --------------------------------------------------------------------------------------- - -#include <iterator> - -#include "portaudio.h" - -#include "portaudiocpp/SampleDataFormat.hxx" - -// --------------------------------------------------------------------------------------- - -// Forward declaration(s): -namespace portaudio -{ - class System; - class HostApi; -} - -// --------------------------------------------------------------------------------------- - -// Declaration(s): -namespace portaudio -{ - - ////// - /// @brief Class which represents a PortAudio device in the System. - /// - /// A single physical device in the system may have multiple PortAudio - /// Device representations using different HostApi 's though. A Device - /// can be half-duplex or full-duplex. A half-duplex Device can be used - /// to create a half-duplex Stream. A full-duplex Device can be used to - /// create a full-duplex Stream. If supported by the HostApi, two - /// half-duplex Devices can even be used to create a full-duplex Stream. - /// - /// Note that Device objects are very light-weight and can be passed around - /// by-value. - ////// - class Device - { - public: - // query info: name, max in channels, max out channels, - // default low/hight input/output latency, default sample rate - PaDeviceIndex index() const; - const char *name() const; - int maxInputChannels() const; - int maxOutputChannels() const; - PaTime defaultLowInputLatency() const; - PaTime defaultHighInputLatency() const; - PaTime defaultLowOutputLatency() const; - PaTime defaultHighOutputLatency() const; - double defaultSampleRate() const; - - bool isInputOnlyDevice() const; // extended - bool isOutputOnlyDevice() const; // extended - bool isFullDuplexDevice() const; // extended - bool isSystemDefaultInputDevice() const; // extended - bool isSystemDefaultOutputDevice() const; // extended - bool isHostApiDefaultInputDevice() const; // extended - bool isHostApiDefaultOutputDevice() const; // extended - - bool operator==(const Device &rhs); - bool operator!=(const Device &rhs); - - // host api reference - HostApi &hostApi(); - const HostApi &hostApi() const; - - private: - PaDeviceIndex index_; - const PaDeviceInfo *info_; - - private: - friend class System; - - explicit Device(PaDeviceIndex index); - ~Device(); - - Device(const Device &); // non-copyable - Device &operator=(const Device &); // non-copyable - }; - - // ----------------------------------------------------------------------------------- - -} // namespace portaudio - -// --------------------------------------------------------------------------------------- - -#endif // INCLUDED_PORTAUDIO_DEVICE_HXX - diff --git a/src/audio/pacpp/include/portaudiocpp/DirectionSpecificStreamParameters.hxx b/src/audio/pacpp/include/portaudiocpp/DirectionSpecificStreamParameters.hxx deleted file mode 100644 index dd5ae0b908..0000000000 --- a/src/audio/pacpp/include/portaudiocpp/DirectionSpecificStreamParameters.hxx +++ /dev/null @@ -1,77 +0,0 @@ -#ifndef INCLUDED_PORTAUDIO_SINGLEDIRECTIONSTREAMPARAMETERS_HXX -#define INCLUDED_PORTAUDIO_SINGLEDIRECTIONSTREAMPARAMETERS_HXX - -// --------------------------------------------------------------------------------------- - -#include <cstddef> - -#include "portaudio.h" - -#include "portaudiocpp/System.hxx" -#include "portaudiocpp/SampleDataFormat.hxx" - -// --------------------------------------------------------------------------------------- - -// Forward declaration(s): -namespace portaudio -{ - class Device; -} - -// --------------------------------------------------------------------------------------- - -// Declaration(s): -namespace portaudio -{ - - ////// - /// @brief All parameters for one direction (either in or out) of a Stream. Together with - /// parameters common to both directions, two DirectionSpecificStreamParameters can make up - /// a StreamParameters object which contains all parameters for a Stream. - ////// - class DirectionSpecificStreamParameters - { - public: - static DirectionSpecificStreamParameters null(); - - DirectionSpecificStreamParameters(); - DirectionSpecificStreamParameters(const Device &device, int numChannels, SampleDataFormat format, - bool interleaved, PaTime suggestedLatency, void *hostApiSpecificStreamInfo); - - // Set up methods: - void setDevice(const Device &device); - void setNumChannels(int numChannels); - - void setSampleFormat(SampleDataFormat format, bool interleaved = true); - void setHostApiSpecificSampleFormat(PaSampleFormat format, bool interleaved = true); - - void setSuggestedLatency(PaTime latency); - - void setHostApiSpecificStreamInfo(void *streamInfo); - - // Accessor methods: - PaStreamParameters *paStreamParameters(); - const PaStreamParameters *paStreamParameters() const; - - Device &device() const; - int numChannels() const; - - SampleDataFormat sampleFormat() const; - bool isSampleFormatInterleaved() const; - bool isSampleFormatHostApiSpecific() const; - PaSampleFormat hostApiSpecificSampleFormat() const; - - PaTime suggestedLatency() const; - - void *hostApiSpecificStreamInfo() const; - - private: - PaStreamParameters paStreamParameters_; - }; - - -} // namespace portaudio - -// --------------------------------------------------------------------------------------- - -#endif // INCLUDED_PORTAUDIO_SINGLEDIRECTIONSTREAMPARAMETERS_HXX diff --git a/src/audio/pacpp/include/portaudiocpp/Exception.hxx b/src/audio/pacpp/include/portaudiocpp/Exception.hxx deleted file mode 100644 index a70c2f1d6e..0000000000 --- a/src/audio/pacpp/include/portaudiocpp/Exception.hxx +++ /dev/null @@ -1,108 +0,0 @@ -#ifndef INCLUDED_PORTAUDIO_EXCEPTION_HXX -#define INCLUDED_PORTAUDIO_EXCEPTION_HXX - -// --------------------------------------------------------------------------------------- - -#include <exception> - -#include "portaudio.h" - -// --------------------------------------------------------------------------------------- - -namespace portaudio -{ - - ////// - /// @brief Base class for all exceptions PortAudioCpp can throw. - /// - /// Class is derived from std::exception. - ////// - class Exception : public std::exception - { - public: - virtual ~Exception() throw() {} - - virtual const char *what() const throw() = 0; - }; - - // ----------------------------------------------------------------------------------- - - ////// - /// @brief Wrapper for PortAudio error codes to C++ exceptions. - /// - /// It wraps up PortAudio's error handling mechanism using - /// C++ exceptions and is derived from std::exception for - /// easy exception handling and to ease integration with - /// other code. - /// - /// To know what exceptions each function may throw, look up - /// the errors that can occure in the PortAudio documentation - /// for the equivalent functions. - /// - /// Some functions are likely to throw an exception (such as - /// Stream::open(), etc) and these should always be called in - /// try{} catch{} blocks and the thrown exceptions should be - /// handled properly (ie. the application shouldn't just abort, - /// but merely display a warning dialog to the user or something). - /// However nearly all functions in PortAudioCpp are capable - /// of throwing exceptions. When a function like Stream::isStopped() - /// throws an exception, it's such an exceptional state that it's - /// not likely that it can be recovered. PaExceptions such as these - /// can ``safely'' be left to be handled by some outer catch-all-like - /// mechanism for unrecoverable errors. - ////// - class PaException : public Exception - { - public: - explicit PaException(PaError error); - - const char *what() const throw(); - - PaError paError() const; - const char *paErrorText() const; - - bool isHostApiError() const; // extended - long lastHostApiError() const; - const char *lastHostApiErrorText() const; - - bool operator==(const PaException &rhs) const; - bool operator!=(const PaException &rhs) const; - - private: - PaError error_; - }; - - // ----------------------------------------------------------------------------------- - - ////// - /// @brief Exceptions specific to PortAudioCpp (ie. exceptions which do not have an - /// equivalent PortAudio error code). - ////// - class PaCppException : public Exception - { - public: - enum ExceptionSpecifier - { - UNABLE_TO_ADAPT_DEVICE - }; - - PaCppException(ExceptionSpecifier specifier); - - const char *what() const throw(); - - ExceptionSpecifier specifier() const; - - bool operator==(const PaCppException &rhs) const; - bool operator!=(const PaCppException &rhs) const; - - private: - ExceptionSpecifier specifier_; - }; - - -} // namespace portaudio - -// --------------------------------------------------------------------------------------- - -#endif // INCLUDED_PORTAUDIO_EXCEPTION_HXX - diff --git a/src/audio/pacpp/include/portaudiocpp/HostApi.hxx b/src/audio/pacpp/include/portaudiocpp/HostApi.hxx deleted file mode 100644 index 899fc42d76..0000000000 --- a/src/audio/pacpp/include/portaudiocpp/HostApi.hxx +++ /dev/null @@ -1,76 +0,0 @@ -#ifndef INCLUDED_PORTAUDIO_HOSTAPI_HXX -#define INCLUDED_PORTAUDIO_HOSTAPI_HXX - -// --------------------------------------------------------------------------------------- - -#include "portaudio.h" - -#include "portaudiocpp/System.hxx" - -// --------------------------------------------------------------------------------------- - -// Forward declaration(s): -namespace portaudio -{ - class Device; -} - -// --------------------------------------------------------------------------------------- - -// Declaration(s): -namespace portaudio -{ - - - ////// - /// @brief HostApi represents a host API (usually type of driver) in the System. - /// - /// A single System can support multiple HostApi's each one typically having - /// a set of Devices using that HostApi (usually driver type). All Devices in - /// the HostApi can be enumerated and the default input/output Device for this - /// HostApi can be retreived. - ////// - class HostApi - { - public: - typedef System::DeviceIterator DeviceIterator; - - // query info: id, name, numDevices - PaHostApiTypeId typeId() const; - PaHostApiIndex index() const; - const char *name() const; - int deviceCount() const; - - // iterate devices - DeviceIterator devicesBegin(); - DeviceIterator devicesEnd(); - - // default devices - Device &defaultInputDevice() const; - Device &defaultOutputDevice() const; - - // comparison operators - bool operator==(const HostApi &rhs) const; - bool operator!=(const HostApi &rhs) const; - - private: - const PaHostApiInfo *info_; - Device **devices_; - - private: - friend class System; - - explicit HostApi(PaHostApiIndex index); - ~HostApi(); - - HostApi(const HostApi &); // non-copyable - HostApi &operator=(const HostApi &); // non-copyable - }; - - -} - -// --------------------------------------------------------------------------------------- - -#endif // INCLUDED_PORTAUDIO_HOSTAPI_HXX - diff --git a/src/audio/pacpp/include/portaudiocpp/InterfaceCallbackStream.hxx b/src/audio/pacpp/include/portaudiocpp/InterfaceCallbackStream.hxx deleted file mode 100644 index e496dd272a..0000000000 --- a/src/audio/pacpp/include/portaudiocpp/InterfaceCallbackStream.hxx +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef INCLUDED_PORTAUDIO_INTERFACECALLBACKSTREAM_HXX -#define INCLUDED_PORTAUDIO_INTERFACECALLBACKSTREAM_HXX - -// --------------------------------------------------------------------------------------- - -#include "portaudio.h" - -#include "portaudiocpp/CallbackStream.hxx" - -// --------------------------------------------------------------------------------------- - -// Forward declaration(s) -namespace portaudio -{ - class StreamParameters; - class CallbackInterface; -} - -// --------------------------------------------------------------------------------------- - -// Declaration(s): -namespace portaudio -{ - - - ////// - /// @brief Callback stream using an instance of an object that's derived from the CallbackInterface - /// interface. - ////// - class InterfaceCallbackStream : public CallbackStream - { - public: - InterfaceCallbackStream(); - InterfaceCallbackStream(const StreamParameters ¶meters, CallbackInterface &instance); - ~InterfaceCallbackStream(); - - void open(const StreamParameters ¶meters, CallbackInterface &instance); - - private: - InterfaceCallbackStream(const InterfaceCallbackStream &); // non-copyable - InterfaceCallbackStream &operator=(const InterfaceCallbackStream &); // non-copyable - }; - - -} // portaudio - -// --------------------------------------------------------------------------------------- - -#endif // INCLUDED_PORTAUDIO_INTERFACECALLBACKSTREAM_HXX diff --git a/src/audio/pacpp/include/portaudiocpp/Makefile.am b/src/audio/pacpp/include/portaudiocpp/Makefile.am deleted file mode 100644 index c594894e3c..0000000000 --- a/src/audio/pacpp/include/portaudiocpp/Makefile.am +++ /dev/null @@ -1,20 +0,0 @@ -noinst_HEADERS = \ - AutoSystem.hxx \ - BlockingStream.hxx \ - CFunCallbackStream.hxx \ - CallbackInterface.hxx \ - CallbackStream.hxx \ - CppFunCallbackStream.hxx \ - Device.hxx \ - DirectionSpecificStreamParameters.hxx \ - Exception.hxx \ - HostApi.hxx \ - InterfaceCallbackStream.hxx \ - MemFunCallbackStream.hxx \ - PortAudioCpp.hxx \ - SampleDataFormat.hxx \ - Stream.hxx \ - StreamParameters.hxx \ - System.hxx \ - SystemDeviceIterator.hxx \ - SystemHostApiIterator.hxx diff --git a/src/audio/pacpp/include/portaudiocpp/MemFunCallbackStream.hxx b/src/audio/pacpp/include/portaudiocpp/MemFunCallbackStream.hxx deleted file mode 100644 index a9e50ca637..0000000000 --- a/src/audio/pacpp/include/portaudiocpp/MemFunCallbackStream.hxx +++ /dev/null @@ -1,107 +0,0 @@ -#ifndef INCLUDED_PORTAUDIO_MEMFUNCALLBACKSTREAM_HXX -#define INCLUDED_PORTAUDIO_MEMFUNCALLBACKSTREAM_HXX - -// --------------------------------------------------------------------------------------- - -#include "portaudio.h" - -#include "portaudiocpp/CallbackStream.hxx" -#include "portaudiocpp/CallbackInterface.hxx" -#include "portaudiocpp/StreamParameters.hxx" -#include "portaudiocpp/Exception.hxx" -#include "portaudiocpp/InterfaceCallbackStream.hxx" - -// --------------------------------------------------------------------------------------- - -namespace portaudio -{ - - - ////// - /// @brief Callback stream using a class's member function as a callback. Template argument T is the type of the - /// class of which a member function is going to be used. - /// - /// Example usage: - /// @verbatim MemFunCallback<MyClass> stream = MemFunCallbackStream(parameters, *this, &MyClass::myCallbackFunction); @endverbatim - ////// - template<typename T> - class MemFunCallbackStream : public CallbackStream - { - public: - typedef int (T::*CallbackFunPtr)(const void *, void *, unsigned long, const PaStreamCallbackTimeInfo *, - PaStreamCallbackFlags); - - // ------------------------------------------------------------------------------- - - MemFunCallbackStream() - { - } - - MemFunCallbackStream(const StreamParameters ¶meters, T &instance, CallbackFunPtr memFun) : adapter_(instance, memFun) - { - open(parameters); - } - - ~MemFunCallbackStream() - { - close(); - } - - void open(const StreamParameters ¶meters, T &instance, CallbackFunPtr memFun) - { - // XXX: need to check if already open? - - adapter_.init(instance, memFun); - open(parameters); - } - - private: - MemFunCallbackStream(const MemFunCallbackStream &); // non-copyable - MemFunCallbackStream &operator=(const MemFunCallbackStream &); // non-copyable - - ////// - /// @brief Inner class which adapts a member function callback to a CallbackInterface compliant - /// class (so it can be adapted using the paCallbackAdapter function). - ////// - class MemFunToCallbackInterfaceAdapter : public CallbackInterface - { - public: - MemFunToCallbackInterfaceAdapter() {} - MemFunToCallbackInterfaceAdapter(T &instance, CallbackFunPtr memFun) : instance_(&instance), memFun_(memFun) {} - - void init(T &instance, CallbackFunPtr memFun) - { - instance_ = &instance; - memFun_ = memFun; - } - - int paCallbackFun(const void *inputBuffer, void *outputBuffer, unsigned long numFrames, - const PaStreamCallbackTimeInfo *timeInfo, PaStreamCallbackFlags statusFlags) - { - return (instance_->*memFun_)(inputBuffer, outputBuffer, numFrames, timeInfo, statusFlags); - } - - private: - T *instance_; - CallbackFunPtr memFun_; - }; - - MemFunToCallbackInterfaceAdapter adapter_; - - void open(const StreamParameters ¶meters) - { - PaError err = Pa_OpenStream(&stream_, parameters.inputParameters().paStreamParameters(), parameters.outputParameters().paStreamParameters(), - parameters.sampleRate(), parameters.framesPerBuffer(), parameters.flags(), &impl::callbackInterfaceToPaCallbackAdapter, - static_cast<void *>(&adapter_)); - - if (err != paNoError) - throw PaException(err); - } - }; - - -} // portaudio - -// --------------------------------------------------------------------------------------- - -#endif // INCLUDED_PORTAUDIO_MEMFUNCALLBACKSTREAM_HXX diff --git a/src/audio/pacpp/include/portaudiocpp/PortAudioCpp.hxx b/src/audio/pacpp/include/portaudiocpp/PortAudioCpp.hxx deleted file mode 100644 index f11e7fb9f4..0000000000 --- a/src/audio/pacpp/include/portaudiocpp/PortAudioCpp.hxx +++ /dev/null @@ -1,109 +0,0 @@ -#ifndef INCLUDED_PORTAUDIO_PORTAUDIOCPP_HXX -#define INCLUDED_PORTAUDIO_PORTAUDIOCPP_HXX - -// --------------------------------------------------------------------------------------- - -////// -/// @mainpage PortAudioCpp -/// -/// <h1>PortAudioCpp - A Native C++ Binding of PortAudio V19</h1> -/// <h2>PortAudio</h2> -/// <p> -/// PortAudio is a portable and mature C API for accessing audio hardware. It offers both callback-based and blocking -/// style input and output, deals with sample data format conversions, dithering and much more. There are a large number -/// of implementations available for various platforms including Windows MME, Windows DirectX, Windows and MacOS (Classic) -/// ASIO, MacOS Classic SoundManager, MacOS X CoreAudio, OSS (Linux), Linux ALSA, JACK (MacOS X and Linux) and SGI Irix -/// AL. Note that, currently not all of these implementations are equally complete or up-to-date (as PortAudio V19 is -/// still in development). Because PortAudio has a C API, it can easily be called from a variety of other programming -/// languages. -/// </p> -/// <h2>PortAudioCpp</h2> -/// <p> -/// Although, it is possible to use PortAudio's C API from within a C++ program, this is usually a little awkward -/// as procedural and object-oriented paradigms need to be mixed. PortAudioCpp aims to resolve this by encapsulating -/// PortAudio's C API to form an equivalent object-oriented C++ API. It provides a more natural integration of PortAudio -/// into C++ programs as well as a more structured interface. PortAudio's concepts were preserved as much as possible and -/// no additional features were added except for some `convenience methods'. -/// </p> -/// <p> -/// PortAudioCpp's main features are: -/// <ul> -/// <li>Structured object model.</li> -/// <li>C++ exception handling instead of C-style error return codes.</li> -/// <li>Handling of callbacks using free functions (C and C++), static functions, member functions or instances of classes -/// derived from a given interface.</li> -/// <li>STL compliant iterators to host APIs and devices.</li> -/// <li>Some additional convenience functions to more easily set up and use PortAudio.</li> -/// </ul> -/// </p> -/// <p> -/// PortAudioCpp requires a recent version of the PortAudio V19 source code. This can be obtained from CVS or as a snapshot -/// from the website. The examples also require the ASIO 2 SDK which can be obtained from the Steinberg website. Alternatively, the -/// examples can easily be modified to compile without needing ASIO. -/// </p> -/// <p> -/// Supported platforms: -/// <ul> -/// <li>Microsoft Visual C++ 6.0, 7.0 (.NET 2002) and 7.1 (.NET 2003).</li> -/// <li>GNU G++ 2.95 and G++ 3.3.</li> -/// </ul> -/// Other platforms should be easily supported as PortAudioCpp is platform-independent and (reasonably) C++ standard compliant. -/// </p> -/// <p> -/// This documentation mainly provides information specific to PortAudioCpp. For a more complete explaination of all of the -/// concepts used, please consult the PortAudio documentation. -/// </p> -/// <p> -/// PortAudioCpp was developed by Merlijn Blaauw with many great suggestions and help from Ross Bencina. Ludwig Schwardt provided -/// GNU/Linux build files and checked G++ compatibility. PortAudioCpp may be used under the same licensing, conditions and -/// warranty as PortAudio. See <a href="http://www.portaudio.com/license.html">the PortAudio license</a> for more details. -/// </p> -/// <h2>Links</h2> -/// <p> -/// <a href="http://www.portaudio.com/">Official PortAudio site.</a><br> -/// </p> -////// - -// --------------------------------------------------------------------------------------- - -////// -/// @namespace portaudio -/// -/// To avoid name collision, everything in PortAudioCpp is in the portaudio -/// namespace. If this name is too long it's usually pretty safe to use an -/// alias like ``namespace pa = portaudio;''. -////// - -// --------------------------------------------------------------------------------------- - -////// -/// @file PortAudioCpp.hxx -/// An include-all header file (for lazy programmers and using pre-compiled headers). -////// - -// --------------------------------------------------------------------------------------- - -#include "portaudio.h" - -#include "portaudiocpp/AutoSystem.hxx" -#include "portaudiocpp/BlockingStream.hxx" -#include "portaudiocpp/CallbackInterface.hxx" -#include "portaudiocpp/CallbackStream.hxx" -#include "portaudiocpp/CFunCallbackStream.hxx" -#include "portaudiocpp/CppFunCallbackStream.hxx" -#include "portaudiocpp/Device.hxx" -#include "portaudiocpp/Exception.hxx" -#include "portaudiocpp/HostApi.hxx" -#include "portaudiocpp/InterfaceCallbackStream.hxx" -#include "portaudiocpp/MemFunCallbackStream.hxx" -#include "portaudiocpp/SampleDataFormat.hxx" -#include "portaudiocpp/DirectionSpecificStreamParameters.hxx" -#include "portaudiocpp/Stream.hxx" -#include "portaudiocpp/StreamParameters.hxx" -#include "portaudiocpp/System.hxx" -#include "portaudiocpp/SystemDeviceIterator.hxx" -#include "portaudiocpp/SystemHostApiIterator.hxx" - -// --------------------------------------------------------------------------------------- - -#endif // INCLUDED_PORTAUDIO_PORTAUDIOCPP_HXX diff --git a/src/audio/pacpp/include/portaudiocpp/SampleDataFormat.hxx b/src/audio/pacpp/include/portaudiocpp/SampleDataFormat.hxx deleted file mode 100644 index a7e25b2413..0000000000 --- a/src/audio/pacpp/include/portaudiocpp/SampleDataFormat.hxx +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef INCLUDED_PORTAUDIO_SAMPLEDATAFORMAT_HXX -#define INCLUDED_PORTAUDIO_SAMPLEDATAFORMAT_HXX - -// --------------------------------------------------------------------------------------- - -#include "portaudio.h" - -// --------------------------------------------------------------------------------------- - -namespace portaudio -{ - - - ////// - /// @brief PortAudio sample data formats. - /// - /// Small helper enum to wrap the PortAudio defines. - ////// - enum SampleDataFormat - { - INVALID_FORMAT = 0, - FLOAT32 = paFloat32, - INT32 = paInt32, - INT24 = paInt24, - INT16 = paInt16, - INT8 = paInt8, - UINT8 = paUInt8 - }; - - -} // namespace portaudio - -// --------------------------------------------------------------------------------------- - -#endif // INCLUDED_PORTAUDIO_SAMPLEDATAFORMAT_HXX diff --git a/src/audio/pacpp/include/portaudiocpp/Stream.hxx b/src/audio/pacpp/include/portaudiocpp/Stream.hxx deleted file mode 100644 index 8a255ec768..0000000000 --- a/src/audio/pacpp/include/portaudiocpp/Stream.hxx +++ /dev/null @@ -1,82 +0,0 @@ -#ifndef INCLUDED_PORTAUDIO_STREAM_HXX -#define INCLUDED_PORTAUDIO_STREAM_HXX - -#include "portaudio.h" - -// --------------------------------------------------------------------------------------- - -// Forward declaration(s): -namespace portaudio -{ - class StreamParameters; -} - -// --------------------------------------------------------------------------------------- - -// Declaration(s): -namespace portaudio -{ - - - ////// - /// @brief A Stream represents an active or inactive input and/or output data - /// stream in the System. - /// - /// Concrete Stream classes should ensure themselves being in a closed state at - /// destruction (i.e. by calling their own close() method in their deconstructor). - /// Following good C++ programming practices, care must be taken to ensure no - /// exceptions are thrown by the deconstructor of these classes. As a consequence, - /// clients need to explicitly call close() to ensure the stream closed successfully. - /// - /// The Stream object can be used to manipulate the Stream's state. Also, time-constant - /// and time-varying information about the Stream can be retreived. - ////// - class Stream - { - public: - // Opening/closing: - virtual ~Stream(); - - virtual void close(); - bool isOpen() const; - - // Additional set up: - void setStreamFinishedCallback(PaStreamFinishedCallback *callback); - - // State management: - void start(); - void stop(); - void abort(); - - bool isStopped() const; - bool isActive() const; - - // Stream info (time-constant, but might become time-variant soon): - PaTime inputLatency() const; - PaTime outputLatency() const; - double sampleRate() const; - - // Stream info (time-varying): - PaTime time() const; - - // Accessors for PortAudio PaStream, useful for interfacing - // with PortAudio add-ons (such as PortMixer) for instance: - const PaStream *paStream() const; - PaStream *paStream(); - - protected: - Stream(); // abstract class - - PaStream *stream_; - - private: - Stream(const Stream &); // non-copyable - Stream &operator=(const Stream &); // non-copyable - }; - - -} // namespace portaudio - - -#endif // INCLUDED_PORTAUDIO_STREAM_HXX - diff --git a/src/audio/pacpp/include/portaudiocpp/StreamParameters.hxx b/src/audio/pacpp/include/portaudiocpp/StreamParameters.hxx deleted file mode 100644 index 2b6aa2ef4c..0000000000 --- a/src/audio/pacpp/include/portaudiocpp/StreamParameters.hxx +++ /dev/null @@ -1,77 +0,0 @@ -#ifndef INCLUDED_PORTAUDIO_STREAMPARAMETERS_HXX -#define INCLUDED_PORTAUDIO_STREAMPARAMETERS_HXX - -// --------------------------------------------------------------------------------------- - -#include "portaudio.h" - -#include "portaudiocpp/DirectionSpecificStreamParameters.hxx" - -// --------------------------------------------------------------------------------------- - -// Declaration(s): -namespace portaudio -{ - - ////// - /// @brief The entire set of parameters needed to configure and open - /// a Stream. - /// - /// It contains parameters of input, output and shared parameters. - /// Using the isSupported() method, the StreamParameters can be - /// checked if opening a Stream using this StreamParameters would - /// succeed or not. Accessors are provided to higher-level parameters - /// aswell as the lower-level parameters which are mainly intended for - /// internal use. - ////// - class StreamParameters - { - public: - StreamParameters(); - StreamParameters(const DirectionSpecificStreamParameters &inputParameters, - const DirectionSpecificStreamParameters &outputParameters, double sampleRate, - unsigned long framesPerBuffer, PaStreamFlags flags); - - // Set up for direction-specific: - void setInputParameters(const DirectionSpecificStreamParameters ¶meters); - void setOutputParameters(const DirectionSpecificStreamParameters ¶meters); - - // Set up for common parameters: - void setSampleRate(double sampleRate); - void setFramesPerBuffer(unsigned long framesPerBuffer); - void setFlag(PaStreamFlags flag); - void unsetFlag(PaStreamFlags flag); - void clearFlags(); - - // Validation: - bool isSupported() const; - - // Accessors (direction-specific): - DirectionSpecificStreamParameters &inputParameters(); - const DirectionSpecificStreamParameters &inputParameters() const; - DirectionSpecificStreamParameters &outputParameters(); - const DirectionSpecificStreamParameters &outputParameters() const; - - // Accessors (common): - double sampleRate() const; - unsigned long framesPerBuffer() const; - PaStreamFlags flags() const; - bool isFlagSet(PaStreamFlags flag) const; - - private: - // Half-duplex specific parameters: - DirectionSpecificStreamParameters inputParameters_; - DirectionSpecificStreamParameters outputParameters_; - - // Common parameters: - double sampleRate_; - unsigned long framesPerBuffer_; - PaStreamFlags flags_; - }; - - -} // namespace portaudio - -// --------------------------------------------------------------------------------------- - -#endif // INCLUDED_PORTAUDIO_STREAMPARAMETERS_HXX diff --git a/src/audio/pacpp/include/portaudiocpp/System.hxx b/src/audio/pacpp/include/portaudiocpp/System.hxx deleted file mode 100644 index f5fb7132af..0000000000 --- a/src/audio/pacpp/include/portaudiocpp/System.hxx +++ /dev/null @@ -1,107 +0,0 @@ -#ifndef INCLUDED_PORTAUDIO_SYSTEM_HXX -#define INCLUDED_PORTAUDIO_SYSTEM_HXX - -// --------------------------------------------------------------------------------------- - -#include "portaudio.h" - -// --------------------------------------------------------------------------------------- - -// Forward declaration(s): -namespace portaudio -{ - class Device; - class Stream; - class HostApi; -} - -// --------------------------------------------------------------------------------------- - -// Declaration(s): -namespace portaudio -{ - - - ////// - /// @brief System singleton which represents the PortAudio system. - /// - /// The System is used to initialize/terminate PortAudio and provide - /// a single acccess point to the PortAudio System (instance()). - /// It can be used to iterate through all HostApi 's in the System as - /// well as all devices in the System. It also provides some utility - /// functionality of PortAudio. - /// - /// Terminating the System will also abort and close the open streams. - /// The Stream objects will need to be deallocated by the client though - /// (it's usually a good idea to have them cleaned up automatically). - ////// - class System - { - public: - class HostApiIterator; // forward declaration - class DeviceIterator; // forward declaration - - // ------------------------------------------------------------------------------- - - static int version(); - static const char *versionText(); - - static void initialize(); - static void terminate(); - - static System &instance(); - static bool exists(); - - // ------------------------------------------------------------------------------- - - // host apis: - HostApiIterator hostApisBegin(); - HostApiIterator hostApisEnd(); - - HostApi &defaultHostApi(); - - HostApi &hostApiByTypeId(PaHostApiTypeId type); - HostApi &hostApiByIndex(PaHostApiIndex index); - - int hostApiCount(); - - // ------------------------------------------------------------------------------- - - // devices: - DeviceIterator devicesBegin(); - DeviceIterator devicesEnd(); - - Device &defaultInputDevice(); - Device &defaultOutputDevice(); - - Device &deviceByIndex(PaDeviceIndex index); - - int deviceCount(); - - static Device &nullDevice(); - - // ------------------------------------------------------------------------------- - - // misc: - void sleep(long msec); - int sizeOfSample(PaSampleFormat format); - - private: - System(); - ~System(); - - static System *instance_; - static int initCount_; - - static HostApi **hostApis_; - static Device **devices_; - - static Device *nullDevice_; - }; - - -} // namespace portaudio - - -#endif // INCLUDED_PORTAUDIO_SYSTEM_HXX - diff --git a/src/audio/pacpp/include/portaudiocpp/SystemDeviceIterator.hxx b/src/audio/pacpp/include/portaudiocpp/SystemDeviceIterator.hxx deleted file mode 100644 index 613fc3db51..0000000000 --- a/src/audio/pacpp/include/portaudiocpp/SystemDeviceIterator.hxx +++ /dev/null @@ -1,66 +0,0 @@ -#ifndef INCLUDED_PORTAUDIO_SYSTEMDEVICEITERATOR_HXX -#define INCLUDED_PORTAUDIO_SYSTEMDEVICEITERATOR_HXX - -// --------------------------------------------------------------------------------------- - -#include <iterator> -#include <cstddef> - -#include "portaudiocpp/System.hxx" - -// --------------------------------------------------------------------------------------- - -// Forward declaration(s): -namespace portaudio -{ - class Device; - class HostApi; -} - -// --------------------------------------------------------------------------------------- - -// Declaration(s): -namespace portaudio -{ - - - ////// - /// @brief Iterator class for iterating through all Devices in a System. - /// - /// Devices will be iterated by iterating all Devices in each - /// HostApi in the System. Compliant with the STL bidirectional - /// iterator concept. - ////// - class System::DeviceIterator - { - public: - typedef std::bidirectional_iterator_tag iterator_category; - typedef Device value_type; - typedef ptrdiff_t difference_type; - typedef Device * pointer; - typedef Device & reference; - - Device &operator*() const; - Device *operator->() const; - - DeviceIterator &operator++(); - DeviceIterator operator++(int); - DeviceIterator &operator--(); - DeviceIterator operator--(int); - - bool operator==(const DeviceIterator &rhs); - bool operator!=(const DeviceIterator &rhs); - - private: - friend class System; - friend class HostApi; - Device **ptr_; - }; - - -} // namespace portaudio - -// --------------------------------------------------------------------------------------- - -#endif // INCLUDED_PORTAUDIO_SYSTEMDEVICEITERATOR_HXX - diff --git a/src/audio/pacpp/include/portaudiocpp/SystemHostApiIterator.hxx b/src/audio/pacpp/include/portaudiocpp/SystemHostApiIterator.hxx deleted file mode 100644 index b9b13b85eb..0000000000 --- a/src/audio/pacpp/include/portaudiocpp/SystemHostApiIterator.hxx +++ /dev/null @@ -1,61 +0,0 @@ -#ifndef INCLUDED_PORTAUDIO_SYSTEMHOSTAPIITERATOR_HXX -#define INCLUDED_PORTAUDIO_SYSTEMHOSTAPIITERATOR_HXX - -// --------------------------------------------------------------------------------------- - -#include <iterator> -#include <cstddef> - -#include "portaudiocpp/System.hxx" - -// --------------------------------------------------------------------------------------- - -// Forward declaration(s): -namespace portaudio -{ - class HostApi; -} - -// --------------------------------------------------------------------------------------- - -// Declaration(s): -namespace portaudio -{ - - - ////// - /// @brief Iterator class for iterating through all HostApis in a System. - /// - /// Compliant with the STL bidirectional iterator concept. - ////// - class System::HostApiIterator - { - public: - typedef std::bidirectional_iterator_tag iterator_category; - typedef Device value_type; - typedef ptrdiff_t difference_type; - typedef HostApi * pointer; - typedef HostApi & reference; - - HostApi &operator*() const; - HostApi *operator->() const; - - HostApiIterator &operator++(); - HostApiIterator operator++(int); - HostApiIterator &operator--(); - HostApiIterator operator--(int); - - bool operator==(const HostApiIterator &rhs); - bool operator!=(const HostApiIterator &rhs); - - private: - friend class System; - HostApi **ptr_; - }; - - -} // namespace portaudio - -// --------------------------------------------------------------------------------------- - -#endif // INCLUDED_PORTAUDIO_SYSTEMHOSTAPIITERATOR_HXX diff --git a/src/audio/pacpp/source/Makefile.am b/src/audio/pacpp/source/Makefile.am deleted file mode 100644 index d8e4f6c804..0000000000 --- a/src/audio/pacpp/source/Makefile.am +++ /dev/null @@ -1 +0,0 @@ -SUBDIRS = portaudiocpp \ No newline at end of file diff --git a/src/audio/pacpp/source/portaudiocpp/AsioDeviceAdapter.cxx b/src/audio/pacpp/source/portaudiocpp/AsioDeviceAdapter.cxx deleted file mode 100644 index 295c26709a..0000000000 --- a/src/audio/pacpp/source/portaudiocpp/AsioDeviceAdapter.cxx +++ /dev/null @@ -1,61 +0,0 @@ -#include "portaudiocpp/AsioDeviceAdapter.hxx" - -#include "portaudio.h" -#include "pa_asio/pa_asio.h" - -#include "portaudiocpp/Device.hxx" -#include "portaudiocpp/HostApi.hxx" -#include "portaudiocpp/Exception.hxx" - -namespace portaudio -{ - AsioDeviceAdapter::AsioDeviceAdapter(Device &device) - { - if (device.hostApi().typeId() != paASIO) - throw PaCppException(PaCppException::UNABLE_TO_ADAPT_DEVICE); - - device_ = &device; - - PaError err = PaAsio_GetAvailableLatencyValues(device_->index(), &minBufferSize_, &maxBufferSize_, - &preferredBufferSize_, &granularity_); - - if (err != paNoError) - throw PaException(err); - - } - - Device &AsioDeviceAdapter::device() - { - return *device_; - } - - long AsioDeviceAdapter::minBufferSize() const - { - return minBufferSize_; - } - - long AsioDeviceAdapter::maxBufferSize() const - { - return maxBufferSize_; - } - - long AsioDeviceAdapter::preferredBufferSize() const - { - return preferredBufferSize_; - } - - long AsioDeviceAdapter::granularity() const - { - return granularity_; - } - - void AsioDeviceAdapter::showControlPanel(void *systemSpecific) - { - PaError err = PaAsio_ShowControlPanel(device_->index(), systemSpecific); - - if (err != paNoError) - throw PaException(err); - } -} - - diff --git a/src/audio/pacpp/source/portaudiocpp/BlockingStream.cxx b/src/audio/pacpp/source/portaudiocpp/BlockingStream.cxx deleted file mode 100644 index c21535f061..0000000000 --- a/src/audio/pacpp/source/portaudiocpp/BlockingStream.cxx +++ /dev/null @@ -1,100 +0,0 @@ -#include "portaudiocpp/BlockingStream.hxx" - -#include "portaudio.h" - -#include "portaudiocpp/StreamParameters.hxx" -#include "portaudiocpp/Exception.hxx" - -namespace portaudio -{ - - // -------------------------------------------------------------------------------------- - - BlockingStream::BlockingStream() - { - } - - BlockingStream::BlockingStream(const StreamParameters ¶meters) - { - open(parameters); - } - - BlockingStream::~BlockingStream() - { - try - { - close(); - } - catch (...) - { - // ignore all errors - } - } - - // -------------------------------------------------------------------------------------- - - void BlockingStream::open(const StreamParameters ¶meters) - { - PaError err = Pa_OpenStream(&stream_, parameters.inputParameters().paStreamParameters(), parameters.outputParameters().paStreamParameters(), - parameters.sampleRate(), parameters.framesPerBuffer(), parameters.flags(), NULL, NULL); - - if (err != paNoError) - { - throw PaException(err); - } - } - - // -------------------------------------------------------------------------------------- - - void BlockingStream::read(void *buffer, unsigned long numFrames) - { - PaError err = Pa_ReadStream(stream_, buffer, numFrames); - - if (err != paNoError) - { - throw PaException(err); - } - } - - void BlockingStream::write(const void *buffer, unsigned long numFrames) - { - PaError err = Pa_WriteStream(stream_, buffer, numFrames); - - if (err != paNoError) - { - throw PaException(err); - } - } - - // -------------------------------------------------------------------------------------- - - signed long BlockingStream::availableReadSize() const - { - signed long avail = Pa_GetStreamReadAvailable(stream_); - - if (avail < 0) - { - throw PaException(avail); - } - - return avail; - } - - signed long BlockingStream::availableWriteSize() const - { - signed long avail = Pa_GetStreamWriteAvailable(stream_); - - if (avail < 0) - { - throw PaException(avail); - } - - return avail; - } - - // -------------------------------------------------------------------------------------- - -} // portaudio - - - diff --git a/src/audio/pacpp/source/portaudiocpp/CFunCallbackStream.cxx b/src/audio/pacpp/source/portaudiocpp/CFunCallbackStream.cxx deleted file mode 100644 index fd2fb53be7..0000000000 --- a/src/audio/pacpp/source/portaudiocpp/CFunCallbackStream.cxx +++ /dev/null @@ -1,41 +0,0 @@ -#include "portaudiocpp/CFunCallbackStream.hxx" - -#include "portaudiocpp/StreamParameters.hxx" -#include "portaudiocpp/Exception.hxx" - -namespace portaudio -{ - CFunCallbackStream::CFunCallbackStream() - { - } - - CFunCallbackStream::CFunCallbackStream(const StreamParameters ¶meters, PaStreamCallback *funPtr, void *userData) - { - open(parameters, funPtr, userData); - } - - CFunCallbackStream::~CFunCallbackStream() - { - try - { - close(); - } - catch (...) - { - // ignore all errors - } - } - - // ---------------------------------------------------------------------------------== - - void CFunCallbackStream::open(const StreamParameters ¶meters, PaStreamCallback *funPtr, void *userData) - { - PaError err = Pa_OpenStream(&stream_, parameters.inputParameters().paStreamParameters(), parameters.outputParameters().paStreamParameters(), - parameters.sampleRate(), parameters.framesPerBuffer(), parameters.flags(), funPtr, userData); - - if (err != paNoError) - { - throw PaException(err); - } - } -} diff --git a/src/audio/pacpp/source/portaudiocpp/CallbackInterface.cxx b/src/audio/pacpp/source/portaudiocpp/CallbackInterface.cxx deleted file mode 100644 index 7e343122f7..0000000000 --- a/src/audio/pacpp/source/portaudiocpp/CallbackInterface.cxx +++ /dev/null @@ -1,25 +0,0 @@ -#include "portaudiocpp/CallbackInterface.hxx" - -namespace portaudio -{ - - namespace impl - { - - ////// - /// Adapts any CallbackInterface object to a C-callable function (ie this function). A - /// pointer to the object should be passed as ``userData'' when setting up the callback. - ////// - int callbackInterfaceToPaCallbackAdapter(const void *inputBuffer, void *outputBuffer, unsigned long numFrames, - const PaStreamCallbackTimeInfo *timeInfo, PaStreamCallbackFlags statusFlags, void *userData) - { - CallbackInterface *cb = static_cast<CallbackInterface *>(userData); - return cb->paCallbackFun(inputBuffer, outputBuffer, numFrames, timeInfo, statusFlags); - } - - - } // namespace impl - -} // namespace portaudio - - diff --git a/src/audio/pacpp/source/portaudiocpp/CallbackStream.cxx b/src/audio/pacpp/source/portaudiocpp/CallbackStream.cxx deleted file mode 100644 index 4204dbba9b..0000000000 --- a/src/audio/pacpp/source/portaudiocpp/CallbackStream.cxx +++ /dev/null @@ -1,20 +0,0 @@ -#include "portaudiocpp/CallbackStream.hxx" - -namespace portaudio -{ - CallbackStream::CallbackStream() - { - } - - CallbackStream::~CallbackStream() - { - } - - // ----------------------------------------------------------------------------------- - - double CallbackStream::cpuLoad() const - { - return Pa_GetStreamCpuLoad(stream_); - } - -} // namespace portaudio diff --git a/src/audio/pacpp/source/portaudiocpp/CppFunCallbackStream.cxx b/src/audio/pacpp/source/portaudiocpp/CppFunCallbackStream.cxx deleted file mode 100644 index 95381398e3..0000000000 --- a/src/audio/pacpp/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 ¶meters, CallbackFunPtr funPtr, void *userData) : adapterData_(funPtr, userData) - { - open(parameters); - } - - FunCallbackStream::~FunCallbackStream() - { - try - { - close(); - } - catch (...) - { - // ignore all errors - } - } - - void FunCallbackStream::open(const StreamParameters ¶meters, CallbackFunPtr funPtr, void *userData) - { - adapterData_.init(funPtr, userData); - open(parameters); - } - - void FunCallbackStream::open(const StreamParameters ¶meters) - { - 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); - } - } - - // ----------------------------------------------------------------------------------- -} diff --git a/src/audio/pacpp/source/portaudiocpp/Device.cxx b/src/audio/pacpp/source/portaudiocpp/Device.cxx deleted file mode 100644 index cd7eb7cbd6..0000000000 --- a/src/audio/pacpp/source/portaudiocpp/Device.cxx +++ /dev/null @@ -1,168 +0,0 @@ -#include "portaudiocpp/Device.hxx" - -#include <cstddef> - -#include "portaudiocpp/HostApi.hxx" -#include "portaudiocpp/System.hxx" -#include "portaudiocpp/Exception.hxx" - -namespace portaudio -{ - - // ------------------------------------------------------------------------------- - - Device::Device(PaDeviceIndex index) : index_(index) - { - if (index == paNoDevice) - info_ = NULL; - else - info_ = Pa_GetDeviceInfo(index); - } - - Device::~Device() - { - } - - PaDeviceIndex Device::index() const - { - return index_; - } - - const char *Device::name() const - { - if (info_ == NULL) - return ""; - - return info_->name; - } - - int Device::maxInputChannels() const - { - if (info_ == NULL) - return 0; - - return info_->maxInputChannels; - } - - int Device::maxOutputChannels() const - { - if (info_ == NULL) - return 0; - - return info_->maxOutputChannels; - } - - PaTime Device::defaultLowInputLatency() const - { - if (info_ == NULL) - return static_cast<PaTime>(0.0); - - return info_->defaultLowInputLatency; - } - - PaTime Device::defaultHighInputLatency() const - { - if (info_ == NULL) - return static_cast<PaTime>(0.0); - - return info_->defaultHighInputLatency; - } - - PaTime Device::defaultLowOutputLatency() const - { - if (info_ == NULL) - return static_cast<PaTime>(0.0); - - return info_->defaultLowOutputLatency; - } - - PaTime Device::defaultHighOutputLatency() const - { - if (info_ == NULL) - return static_cast<PaTime>(0.0); - - return info_->defaultHighOutputLatency; - } - - double Device::defaultSampleRate() const - { - if (info_ == NULL) - return 0.0; - - return info_->defaultSampleRate; - } - - // ------------------------------------------------------------------------------- - - bool Device::isInputOnlyDevice() const - { - return (maxOutputChannels() == 0); - } - - bool Device::isOutputOnlyDevice() const - { - return (maxInputChannels() == 0); - } - - bool Device::isFullDuplexDevice() const - { - return (maxInputChannels() > 0 && maxOutputChannels() > 0); - } - - bool Device::isSystemDefaultInputDevice() const - { - return (System::instance().defaultInputDevice() == *this); - } - - bool Device::isSystemDefaultOutputDevice() const - { - return (System::instance().defaultOutputDevice() == *this); - } - - bool Device::isHostApiDefaultInputDevice() const - { - return (hostApi().defaultInputDevice() == *this); - } - - bool Device::isHostApiDefaultOutputDevice() const - { - return (hostApi().defaultOutputDevice() == *this); - } - - // ------------------------------------------------------------------------------- - - bool Device::operator==(const Device &rhs) - { - return (index_ == rhs.index_); - } - - bool Device::operator!=(const Device &rhs) - { - return !(*this == rhs); - } - - // ------------------------------------------------------------------------------- - - HostApi &Device::hostApi() - { - // NOTE: will cause an exception when called for the null device - if (info_ == NULL) - throw PaException(paInternalError); - - return System::instance().hostApiByIndex(info_->hostApi); - } - - const HostApi &Device::hostApi() const - { - // NOTE; will cause an exception when called for the null device - if (info_ == NULL) - throw PaException(paInternalError); - - return System::instance().hostApiByIndex(info_->hostApi); - } - - // ------------------------------------------------------------------------------- - -} // namespace portaudio - - diff --git a/src/audio/pacpp/source/portaudiocpp/DirectionSpecificStreamParameters.cxx b/src/audio/pacpp/source/portaudiocpp/DirectionSpecificStreamParameters.cxx deleted file mode 100644 index d3c307c311..0000000000 --- a/src/audio/pacpp/source/portaudiocpp/DirectionSpecificStreamParameters.cxx +++ /dev/null @@ -1,163 +0,0 @@ -#include "portaudiocpp/DirectionSpecificStreamParameters.hxx" - -#include "portaudiocpp/Device.hxx" - -namespace portaudio -{ - - // ----------------------------------------------------------------------------------- - - ////// - /// Returns a `nil' DirectionSpecificStreamParameters object. This can be used to - /// specify that one direction of a Stream is not required (i.e. when creating - /// a half-duplex Stream). All fields of the null DirectionSpecificStreamParameters - /// object are invalid except for the device and the number of channel, which are set - /// to paNoDevice and 0 respectively. - ////// - DirectionSpecificStreamParameters DirectionSpecificStreamParameters::null() - { - DirectionSpecificStreamParameters tmp; - tmp.paStreamParameters_.device = paNoDevice; - tmp.paStreamParameters_.channelCount = 0; - return tmp; - } - - // ----------------------------------------------------------------------------------- - - ////// - /// Default constructor -- all parameters will be uninitialized. - ////// - DirectionSpecificStreamParameters::DirectionSpecificStreamParameters() - { - } - - ////// - /// Constructor which sets all required fields. - ////// - DirectionSpecificStreamParameters::DirectionSpecificStreamParameters(const Device &device, int numChannels, - SampleDataFormat format, bool interleaved, PaTime suggestedLatency, void *hostApiSpecificStreamInfo) - { - setDevice(device); - setNumChannels(numChannels); - setSampleFormat(format, interleaved); - setSuggestedLatency(suggestedLatency); - setHostApiSpecificStreamInfo(hostApiSpecificStreamInfo); - } - - // ----------------------------------------------------------------------------------- - - void DirectionSpecificStreamParameters::setDevice(const Device &device) - { - paStreamParameters_.device = device.index(); - } - - void DirectionSpecificStreamParameters::setNumChannels(int numChannels) - { - paStreamParameters_.channelCount = numChannels; - } - - void DirectionSpecificStreamParameters::setSampleFormat(SampleDataFormat format, bool interleaved) - { - paStreamParameters_.sampleFormat = static_cast<PaSampleFormat>(format); - - if (!interleaved) - paStreamParameters_.sampleFormat |= paNonInterleaved; - } - - void DirectionSpecificStreamParameters::setHostApiSpecificSampleFormat(PaSampleFormat format, bool interleaved) - { - paStreamParameters_.sampleFormat = format; - - paStreamParameters_.sampleFormat |= paCustomFormat; - - if (!interleaved) - paStreamParameters_.sampleFormat |= paNonInterleaved; - } - - void DirectionSpecificStreamParameters::setSuggestedLatency(PaTime latency) - { - paStreamParameters_.suggestedLatency = latency; - } - - void DirectionSpecificStreamParameters::setHostApiSpecificStreamInfo(void *streamInfo) - { - paStreamParameters_.hostApiSpecificStreamInfo = streamInfo; - } - - // ----------------------------------------------------------------------------------- - - PaStreamParameters *DirectionSpecificStreamParameters::paStreamParameters() - { - if (paStreamParameters_.channelCount > 0 && paStreamParameters_.device != paNoDevice) - return &paStreamParameters_; - else - return NULL; - } - - const PaStreamParameters *DirectionSpecificStreamParameters::paStreamParameters() const - { - if (paStreamParameters_.channelCount > 0 && paStreamParameters_.device != paNoDevice) - return &paStreamParameters_; - else - return NULL; - } - - Device &DirectionSpecificStreamParameters::device() const - { - return System::instance().deviceByIndex(paStreamParameters_.device); - } - - int DirectionSpecificStreamParameters::numChannels() const - { - return paStreamParameters_.channelCount; - } - - ////// - /// Returns the (non host api-specific) sample format, without including - /// the paNonInterleaved flag. If the sample format is host api-spefific, - /// INVALID_FORMAT (0) will be returned. - ////// - SampleDataFormat DirectionSpecificStreamParameters::sampleFormat() const - { - if (isSampleFormatHostApiSpecific()) - return INVALID_FORMAT; - else - return static_cast<SampleDataFormat>(paStreamParameters_.sampleFormat & ~paNonInterleaved); - } - - bool DirectionSpecificStreamParameters::isSampleFormatInterleaved() const - { - return ((paStreamParameters_.sampleFormat & paNonInterleaved) == 0); - } - - bool DirectionSpecificStreamParameters::isSampleFormatHostApiSpecific() const - { - return ((paStreamParameters_.sampleFormat & paCustomFormat) == 0); - } - - ////// - /// Returns the host api-specific sample format, without including any - /// paCustomFormat or paNonInterleaved flags. Will return 0 if the sample format is - /// not host api-specific. - ////// - PaSampleFormat DirectionSpecificStreamParameters::hostApiSpecificSampleFormat() const - { - if (isSampleFormatHostApiSpecific()) - return paStreamParameters_.sampleFormat & ~paCustomFormat & ~paNonInterleaved; - else - return 0; - } - - PaTime DirectionSpecificStreamParameters::suggestedLatency() const - { - return paStreamParameters_.suggestedLatency; - } - - void *DirectionSpecificStreamParameters::hostApiSpecificStreamInfo() const - { - return paStreamParameters_.hostApiSpecificStreamInfo; - } - - // ----------------------------------------------------------------------------------- - -} // namespace portaudio diff --git a/src/audio/pacpp/source/portaudiocpp/Exception.cxx b/src/audio/pacpp/source/portaudiocpp/Exception.cxx deleted file mode 100644 index 2e7e70137c..0000000000 --- a/src/audio/pacpp/source/portaudiocpp/Exception.cxx +++ /dev/null @@ -1,123 +0,0 @@ -#include "portaudiocpp/Exception.hxx" - -namespace portaudio -{ - // ----------------------------------------------------------------------------------- - // PaException: - // ----------------------------------------------------------------------------------- - - ////// - /// Wraps a PortAudio error into a PortAudioCpp PaException. - ////// - PaException::PaException(PaError error) : error_(error) - { - } - - // ----------------------------------------------------------------------------------- - - ////// - /// Alias for paErrorText(), to have std::exception compliance. - ////// - const char *PaException::what() const throw() - { - return paErrorText(); - } - - // ----------------------------------------------------------------------------------- - - ////// - /// Returns the PortAudio error code (PaError). - ////// - PaError PaException::paError() const - { - return error_; - } - - ////// - /// Returns the error as a (zero-terminated) text string. - ////// - const char *PaException::paErrorText() const - { - return Pa_GetErrorText(error_); - } - - ////// - /// Returns true is the error is a HostApi error. - ////// - bool PaException::isHostApiError() const - { - return (error_ == paUnanticipatedHostError); - } - - ////// - /// Returns the last HostApi error (which is the current one if - /// isHostApiError() returns true) as an error code. - ////// - long PaException::lastHostApiError() const - { - return Pa_GetLastHostErrorInfo()->errorCode; - } - - ////// - /// Returns the last HostApi error (which is the current one if - /// isHostApiError() returns true) as a (zero-terminated) text - /// string, if it's available. - ////// - const char *PaException::lastHostApiErrorText() const - { - return Pa_GetLastHostErrorInfo()->errorText; - } - - // ----------------------------------------------------------------------------------- - - bool PaException::operator==(const PaException &rhs) const - { - return (error_ == rhs.error_); - } - - bool PaException::operator!=(const PaException &rhs) const - { - return !(*this == rhs); - } - - // ----------------------------------------------------------------------------------- - // PaCppException: - // ----------------------------------------------------------------------------------- - - PaCppException::PaCppException(ExceptionSpecifier specifier) : specifier_(specifier) - { - } - - const char *PaCppException::what() const throw() - { - switch (specifier_) - { - case UNABLE_TO_ADAPT_DEVICE: - { - return "Unable to adapt the given device to the specified host api specific device extension"; - } - } - - return "Unknown exception"; - } - - PaCppException::ExceptionSpecifier PaCppException::specifier() const - { - return specifier_; - } - - bool PaCppException::operator==(const PaCppException &rhs) const - { - return (specifier_ == rhs.specifier_); - } - - bool PaCppException::operator!=(const PaCppException &rhs) const - { - return !(*this == rhs); - } - - // ----------------------------------------------------------------------------------- - -} // namespace portaudio - - diff --git a/src/audio/pacpp/source/portaudiocpp/HostApi.cxx b/src/audio/pacpp/source/portaudiocpp/HostApi.cxx deleted file mode 100644 index c6ae019ad4..0000000000 --- a/src/audio/pacpp/source/portaudiocpp/HostApi.cxx +++ /dev/null @@ -1,121 +0,0 @@ -#include "portaudiocpp/HostApi.hxx" - -#include "portaudiocpp/System.hxx" -#include "portaudiocpp/Device.hxx" -#include "portaudiocpp/SystemDeviceIterator.hxx" -#include "portaudiocpp/Exception.hxx" - -namespace portaudio -{ - - // ----------------------------------------------------------------------------------- - - HostApi::HostApi(PaHostApiIndex index) : devices_(NULL) - { - try - { - info_ = Pa_GetHostApiInfo(index); - - // Create and populate devices array: - int numDevices = deviceCount(); - - devices_ = new Device*[numDevices]; - - for (int i = 0; i < numDevices; ++i) - { - PaDeviceIndex deviceIndex = Pa_HostApiDeviceIndexToDeviceIndex(index, i); - - if (deviceIndex < 0) - { - throw PaException(deviceIndex); - } - - devices_[i] = &System::instance().deviceByIndex(deviceIndex); - } - } - catch (const std::exception &e) - { - // Delete any (partially) constructed objects (deconstructor isn't called): - delete[] devices_; // devices_ is either NULL or valid - - // Re-throw exception: - throw e; - } - } - - HostApi::~HostApi() - { - // Destroy devices array: - delete[] devices_; - } - - // ----------------------------------------------------------------------------------- - - PaHostApiTypeId HostApi::typeId() const - { - return info_->type; - } - - PaHostApiIndex HostApi::index() const - { - PaHostApiIndex index = Pa_HostApiTypeIdToHostApiIndex(typeId()); - - if (index < 0) - throw PaException(index); - - return index; - } - - const char *HostApi::name() const - { - return info_->name; - } - - int HostApi::deviceCount() const - { - return info_->deviceCount; - } - - // ----------------------------------------------------------------------------------- - - HostApi::DeviceIterator HostApi::devicesBegin() - { - DeviceIterator tmp; - tmp.ptr_ = &devices_[0]; // begin (first element) - return tmp; - } - - HostApi::DeviceIterator HostApi::devicesEnd() - { - DeviceIterator tmp; - tmp.ptr_ = &devices_[deviceCount()]; // end (one past last element) - return tmp; - } - - // ----------------------------------------------------------------------------------- - - Device &HostApi::defaultInputDevice() const - { - return System::instance().deviceByIndex(info_->defaultInputDevice); - } - - Device &HostApi::defaultOutputDevice() const - { - return System::instance().deviceByIndex(info_->defaultOutputDevice); - } - - // ----------------------------------------------------------------------------------- - - bool HostApi::operator==(const HostApi &rhs) const - { - return (typeId() == rhs.typeId()); - } - - bool HostApi::operator!=(const HostApi &rhs) const - { - return !(*this == rhs); - } - - // ----------------------------------------------------------------------------------- - -} // namespace portaudio diff --git a/src/audio/pacpp/source/portaudiocpp/InterfaceCallbackStream.cxx b/src/audio/pacpp/source/portaudiocpp/InterfaceCallbackStream.cxx deleted file mode 100644 index 09e02de678..0000000000 --- a/src/audio/pacpp/source/portaudiocpp/InterfaceCallbackStream.cxx +++ /dev/null @@ -1,45 +0,0 @@ -#include "portaudiocpp/InterfaceCallbackStream.hxx" - -#include "portaudiocpp/StreamParameters.hxx" -#include "portaudiocpp/Exception.hxx" -#include "portaudiocpp/CallbackInterface.hxx" - -namespace portaudio -{ - - // ---------------------------------------------------------------------------------== - - InterfaceCallbackStream::InterfaceCallbackStream() - { - } - - InterfaceCallbackStream::InterfaceCallbackStream(const StreamParameters ¶meters, CallbackInterface &instance) - { - open(parameters, instance); - } - - InterfaceCallbackStream::~InterfaceCallbackStream() - { - try - { - close(); - } - catch (...) - { - // ignore all errors - } - } - - // ---------------------------------------------------------------------------------== - - void InterfaceCallbackStream::open(const StreamParameters ¶meters, CallbackInterface &instance) - { - PaError err = Pa_OpenStream(&stream_, parameters.inputParameters().paStreamParameters(), parameters.outputParameters().paStreamParameters(), - parameters.sampleRate(), parameters.framesPerBuffer(), parameters.flags(), &impl::callbackInterfaceToPaCallbackAdapter, static_cast<void *>(&instance)); - - if (err != paNoError) - { - throw PaException(err); - } - } -} diff --git a/src/audio/pacpp/source/portaudiocpp/Makefile.am b/src/audio/pacpp/source/portaudiocpp/Makefile.am deleted file mode 100644 index 94e80b56ec..0000000000 --- a/src/audio/pacpp/source/portaudiocpp/Makefile.am +++ /dev/null @@ -1,22 +0,0 @@ -noinst_LTLIBRARIES = libportaudiocpp.la - -libportaudiocpp_la_SOURCES = \ - BlockingStream.cxx \ - CallbackInterface.cxx \ - CallbackStream.cxx \ - CFunCallbackStream.cxx \ - CppFunCallbackStream.cxx \ - Device.cxx \ - DirectionSpecificStreamParameters.cxx \ - Exception.cxx \ - HostApi.cxx \ - InterfaceCallbackStream.cxx \ - MemFunCallbackStream.cxx \ - Stream.cxx \ - StreamParameters.cxx \ - System.cxx \ - SystemDeviceIterator.cxx \ - SystemHostApiIterator.cxx - - -AM_CXXFLAGS = -I$(top_srcdir) -I$(top_srcdir)/src/audio/pacpp/include -I$(top_srcdir)/libs/portaudio/pa_common/ diff --git a/src/audio/pacpp/source/portaudiocpp/MemFunCallbackStream.cxx b/src/audio/pacpp/source/portaudiocpp/MemFunCallbackStream.cxx deleted file mode 100644 index 113fe5a4dd..0000000000 --- a/src/audio/pacpp/source/portaudiocpp/MemFunCallbackStream.cxx +++ /dev/null @@ -1,4 +0,0 @@ -#include "portaudiocpp/MemFunCallbackStream.hxx" - -// (... template class ...) - diff --git a/src/audio/pacpp/source/portaudiocpp/Stream.cxx b/src/audio/pacpp/source/portaudiocpp/Stream.cxx deleted file mode 100644 index 3b21f09082..0000000000 --- a/src/audio/pacpp/source/portaudiocpp/Stream.cxx +++ /dev/null @@ -1,195 +0,0 @@ -#include "portaudiocpp/Stream.hxx" - -#include <cstddef> - -#include "portaudiocpp/Exception.hxx" -#include "portaudiocpp/System.hxx" - -namespace portaudio -{ - - // ----------------------------------------------------------------------------------- - - Stream::Stream() : stream_(NULL) - { - } - - Stream::~Stream() - { - // (can't call close here, - // the derived class should atleast call - // close() in it's deconstructor) - } - - // ----------------------------------------------------------------------------------- - - ////// - /// Closes the Stream if it's open, else does nothing. - ////// - void Stream::close() - { - if (isOpen() && System::exists()) - { - PaError err = Pa_CloseStream(stream_); - stream_ = NULL; - - if (err != paNoError) - throw PaException(err); - } - } - - ////// - /// Returns true if the Stream is open. - ////// - bool Stream::isOpen() const - { - return (stream_ != NULL); - } - - // ----------------------------------------------------------------------------------- - - void Stream::setStreamFinishedCallback(PaStreamFinishedCallback *callback) - { - PaError err = Pa_SetStreamFinishedCallback(stream_, callback); - - if (err != paNoError) - throw PaException(err); - } - - // ----------------------------------------------------------------------------------- - - void Stream::start() - { - PaError err = Pa_StartStream(stream_); - - if (err != paNoError) - throw PaException(err); - } - - void Stream::stop() - { - PaError err = Pa_StopStream(stream_); - - if (err != paNoError) - throw PaException(err); - } - - void Stream::abort() - { - PaError err = Pa_AbortStream(stream_); - - if (err != paNoError) - throw PaException(err); - } - - bool Stream::isStopped() const - { - PaError ret = Pa_IsStreamStopped(stream_); - - if (ret < 0) - throw PaException(ret); - - return (ret == 1); - } - - bool Stream::isActive() const - { - PaError ret = Pa_IsStreamActive(stream_); - - if (ret < 0) - throw PaException(ret); - - return (ret == 1); - } - - // ----------------------------------------------------------------------------------- - - ////// - /// Returns the best known input latency for the Stream. This value may differ from the - /// suggested input latency set in the StreamParameters. Includes all sources of - /// latency known to PortAudio such as internal buffering, and Host API reported latency. - /// Doesn't include any estimates of unknown latency. - ////// - PaTime Stream::inputLatency() const - { - const PaStreamInfo *info = Pa_GetStreamInfo(stream_); - if (info == NULL) - { - throw PaException(paInternalError); - return PaTime(0.0); - } - - return info->inputLatency; - } - - ////// - /// Returns the best known output latency for the Stream. This value may differ from the - /// suggested output latency set in the StreamParameters. Includes all sources of - /// latency known to PortAudio such as internal buffering, and Host API reported latency. - /// Doesn't include any estimates of unknown latency. - ////// - PaTime Stream::outputLatency() const - { - const PaStreamInfo *info = Pa_GetStreamInfo(stream_); - if (info == NULL) - { - throw PaException(paInternalError); - return PaTime(0.0); - } - - return info->outputLatency; - } - - ////// - /// Returns the sample rate of the Stream. Usually this will be the - /// best known estimate of the used sample rate. For instance when opening a - /// Stream setting 44100.0 Hz in the StreamParameters, the actual sample - /// rate might be something like 44103.2 Hz (due to imperfections in the - /// sound card hardware). - ////// - double Stream::sampleRate() const - { - const PaStreamInfo *info = Pa_GetStreamInfo(stream_); - if (info == NULL) - { - throw PaException(paInternalError); - return 0.0; - } - - return info->sampleRate; - } - - // ----------------------------------------------------------------------------------- - - PaTime Stream::time() const - { - return Pa_GetStreamTime(stream_); - } - - // ----------------------------------------------------------------------------------- - - ////// - /// Accessor (const) for PortAudio PaStream pointer, useful for interfacing with - /// PortAudio add-ons such as PortMixer for instance. Normally accessing this - /// pointer should not be needed as PortAudioCpp aims to provide all of PortAudio's - /// functionality. - ////// - const PaStream *Stream::paStream() const - { - return stream_; - } - - ////// - /// Accessor (non-const) for PortAudio PaStream pointer, useful for interfacing with - /// PortAudio add-ons such as PortMixer for instance. Normally accessing this - /// pointer should not be needed as PortAudioCpp aims to provide all of PortAudio's - /// functionality. - ////// - PaStream *Stream::paStream() - { - return stream_; - } - - // ----------------------------------------------------------------------------------- - -} // namespace portaudio diff --git a/src/audio/pacpp/source/portaudiocpp/StreamParameters.cxx b/src/audio/pacpp/source/portaudiocpp/StreamParameters.cxx deleted file mode 100644 index 670873bfdb..0000000000 --- a/src/audio/pacpp/source/portaudiocpp/StreamParameters.cxx +++ /dev/null @@ -1,165 +0,0 @@ -#include "portaudiocpp/StreamParameters.hxx" - -#include <cstddef> - -#include "portaudiocpp/Device.hxx" - -namespace portaudio -{ - // ----------------------------------------------------------------------------------- - - ////// - /// Default constructor; does nothing. - ////// - StreamParameters::StreamParameters() - { - } - - ////// - /// Sets up the all parameters needed to open either a half-duplex or full-duplex Stream. - /// - /// @param inputParameters The parameters for the input direction of the to-be opened - /// Stream or DirectionSpecificStreamParameters::null() for an output-only Stream. - /// @param outputParameters The parameters for the output direction of the to-be opened - /// Stream or DirectionSpecificStreamParameters::null() for an input-only Stream. - /// @param sampleRate The to-be opened Stream's sample rate in Hz. - /// @param framesPerBuffer The number of frames per buffer for a CallbackStream, or - /// the preferred buffer granularity for a BlockingStream. - /// @param flags The flags for the to-be opened Stream; default paNoFlag. - ////// - StreamParameters::StreamParameters(const DirectionSpecificStreamParameters &inputParameters, - const DirectionSpecificStreamParameters &outputParameters, double sampleRate, unsigned long framesPerBuffer, - PaStreamFlags flags) : inputParameters_(inputParameters), outputParameters_(outputParameters), - sampleRate_(sampleRate), framesPerBuffer_(framesPerBuffer), flags_(flags) - { - } - - // ----------------------------------------------------------------------------------- - - ////// - /// Sets the requested sample rate. If this sample rate isn't supported by the hardware, the - /// Stream will fail to open. The real-life sample rate used might differ slightly due to - /// imperfections in the sound card hardware; use Stream::sampleRate() to retreive the - /// best known estimate for this value. - ////// - void StreamParameters::setSampleRate(double sampleRate) - { - sampleRate_ = sampleRate; - } - - ////// - /// Either the number of frames per buffer for a CallbackStream, or - /// the preferred buffer granularity for a BlockingStream. See PortAudio - /// documentation. - ////// - void StreamParameters::setFramesPerBuffer(unsigned long framesPerBuffer) - { - framesPerBuffer_ = framesPerBuffer; - } - - ////// - /// Sets the specified flag or does nothing when the flag is already set. Doesn't - /// `unset' any previously existing flags (use clearFlags() for that). - ////// - void StreamParameters::setFlag(PaStreamFlags flag) - { - flags_ |= flag; - } - - ////// - /// Unsets the specified flag or does nothing if the flag isn't set. Doesn't affect - /// any other flags. - ////// - void StreamParameters::unsetFlag(PaStreamFlags flag) - { - flags_ &= ~flag; - } - - ////// - /// Clears or `unsets' all set flags. - ////// - void StreamParameters::clearFlags() - { - flags_ = paNoFlag; - } - - // ----------------------------------------------------------------------------------- - - void StreamParameters::setInputParameters(const DirectionSpecificStreamParameters ¶meters) - { - inputParameters_ = parameters; - } - - void StreamParameters::setOutputParameters(const DirectionSpecificStreamParameters ¶meters) - { - outputParameters_ = parameters; - } - - // ----------------------------------------------------------------------------------- - - bool StreamParameters::isSupported() const - { - return (Pa_IsFormatSupported(inputParameters_.paStreamParameters(), - outputParameters_.paStreamParameters(), sampleRate_) == paFormatIsSupported); - } - - // ----------------------------------------------------------------------------------- - - double StreamParameters::sampleRate() const - { - return sampleRate_; - } - - unsigned long StreamParameters::framesPerBuffer() const - { - return framesPerBuffer_; - } - - ////// - /// Returns all currently set flags as a binary combined - /// integer value (PaStreamFlags). Use isFlagSet() to - /// avoid dealing with the bitmasks. - ////// - PaStreamFlags StreamParameters::flags() const - { - return flags_; - } - - ////// - /// Returns true if the specified flag is currently set - /// or false if it isn't. - ////// - bool StreamParameters::isFlagSet(PaStreamFlags flag) const - { - return ((flags_ & flag) != 0); - } - - // ----------------------------------------------------------------------------------- - - DirectionSpecificStreamParameters &StreamParameters::inputParameters() - { - return inputParameters_; - } - - const DirectionSpecificStreamParameters &StreamParameters::inputParameters() const - { - return inputParameters_; - } - - DirectionSpecificStreamParameters &StreamParameters::outputParameters() - { - return outputParameters_; - } - - const DirectionSpecificStreamParameters &StreamParameters::outputParameters() const - { - return outputParameters_; - } - - // ----------------------------------------------------------------------------------- -} // namespace portaudio - - - - - diff --git a/src/audio/pacpp/source/portaudiocpp/System.cxx b/src/audio/pacpp/source/portaudiocpp/System.cxx deleted file mode 100644 index 692c7a10ac..0000000000 --- a/src/audio/pacpp/source/portaudiocpp/System.cxx +++ /dev/null @@ -1,308 +0,0 @@ -#include "portaudiocpp/System.hxx" - -#include <cstddef> -#include <cassert> - -#include "portaudiocpp/HostApi.hxx" -#include "portaudiocpp/Device.hxx" -#include "portaudiocpp/Stream.hxx" -#include "portaudiocpp/Exception.hxx" -#include "portaudiocpp/SystemHostApiIterator.hxx" -#include "portaudiocpp/SystemDeviceIterator.hxx" - -namespace portaudio -{ - // ----------------------------------------------------------------------------------- - - // Static members: - System *System::instance_ = NULL; - int System::initCount_ = 0; - HostApi **System::hostApis_ = NULL; - Device **System::devices_ = NULL; - Device *System::nullDevice_ = NULL; - - // ----------------------------------------------------------------------------------- - - int System::version() - { - return Pa_GetVersion(); - } - - const char *System::versionText() - { - return Pa_GetVersionText(); - } - - void System::initialize() - { - ++initCount_; - - if (initCount_ == 1) - { - // Create singleton: - assert(instance_ == NULL); - instance_ = new System(); - - // Initialize the PortAudio system: - { - PaError err = Pa_Initialize(); - - if (err != paNoError) - throw PaException(err); - } - - // Create and populate device array: - { - int numDevices = instance().deviceCount(); - - devices_ = new Device*[numDevices]; - - for (int i = 0; i < numDevices; ++i) - devices_[i] = new Device(i); - } - - // Create and populate host api array: - { - int numHostApis = instance().hostApiCount(); - - hostApis_ = new HostApi*[numHostApis]; - - for (int i = 0; i < numHostApis; ++i) - hostApis_[i] = new HostApi(i); - } - - // Create null device: - nullDevice_ = new Device(paNoDevice); - } - } - - void System::terminate() - { - PaError err = paNoError; - - if (initCount_ == 1) - { - // Destroy null device: - delete nullDevice_; - - // Destroy host api array: - { - if (hostApis_ != NULL) - { - int numHostApis = instance().hostApiCount(); - - for (int i = 0; i < numHostApis; ++i) - delete hostApis_[i]; - - delete[] hostApis_; - hostApis_ = NULL; - } - } - - // Destroy device array: - { - if (devices_ != NULL) - { - int numDevices = instance().deviceCount(); - - for (int i = 0; i < numDevices; ++i) - delete devices_[i]; - - delete[] devices_; - devices_ = NULL; - } - } - - // Terminate the PortAudio system: - assert(instance_ != NULL); - err = Pa_Terminate(); - - // Destroy singleton: - delete instance_; - instance_ = NULL; - } - - if (initCount_ > 0) - --initCount_; - - if (err != paNoError) - throw PaException(err); - } - - - System &System::instance() - { - assert(exists()); - - return *instance_; - } - - bool System::exists() - { - return (instance_ != NULL); - } - - // ----------------------------------------------------------------------------------- - - System::HostApiIterator System::hostApisBegin() - { - System::HostApiIterator tmp; - tmp.ptr_ = &hostApis_[0]; // begin (first element) - return tmp; - } - - System::HostApiIterator System::hostApisEnd() - { - int count = hostApiCount(); - - System::HostApiIterator tmp; - tmp.ptr_ = &hostApis_[count]; // end (one past last element) - return tmp; - } - - HostApi &System::defaultHostApi() - { - PaHostApiIndex defaultHostApi = Pa_GetDefaultHostApi(); - - if (defaultHostApi < 0) - throw PaException(defaultHostApi); - - return *hostApis_[defaultHostApi]; - } - - HostApi &System::hostApiByTypeId(PaHostApiTypeId type) - { - PaHostApiIndex index = Pa_HostApiTypeIdToHostApiIndex(type); - - if (index < 0) - throw PaException(index); - - return *hostApis_[index]; - } - - HostApi &System::hostApiByIndex(PaHostApiIndex index) - { - if (index < 0 || index >= hostApiCount()) - throw PaException(paInternalError); - - return *hostApis_[index]; - } - - int System::hostApiCount() - { - PaHostApiIndex count = Pa_GetHostApiCount(); - - if (count < 0) - throw PaException(count); - - return count; - } - - // ----------------------------------------------------------------------------------- - - System::DeviceIterator System::devicesBegin() - { - DeviceIterator tmp; - tmp.ptr_ = &devices_[0]; - - return tmp; - } - - System::DeviceIterator System::devicesEnd() - { - int count = deviceCount(); - - DeviceIterator tmp; - tmp.ptr_ = &devices_[count]; - - return tmp; - } - - ////// - /// Returns the System's default input Device, or the null Device if none - /// was available. - ////// - Device &System::defaultInputDevice() - { - PaDeviceIndex index = Pa_GetDefaultInputDevice(); - return deviceByIndex(index); - } - - ////// - /// Returns the System's default output Device, or the null Device if none - /// was available. - ////// - Device &System::defaultOutputDevice() - { - PaDeviceIndex index = Pa_GetDefaultOutputDevice(); - return deviceByIndex(index); - } - - ////// - /// Returns the Device for the given index. - /// Will throw a paInternalError equivalent PaException if the given index - /// is out of range. - ////// - Device &System::deviceByIndex(PaDeviceIndex index) - { - if (index < -1 || index >= deviceCount()) - { - throw PaException(paInternalError); - } - - if (index == -1) - return System::instance().nullDevice(); - - return *devices_[index]; - } - - int System::deviceCount() - { - PaDeviceIndex count = Pa_GetDeviceCount(); - - if (count < 0) - throw PaException(count); - - return count; - } - - Device &System::nullDevice() - { - return *nullDevice_; - } - - // ----------------------------------------------------------------------------------- - - void System::sleep(long msec) - { - Pa_Sleep(msec); - } - - int System::sizeOfSample(PaSampleFormat format) - { - PaError err = Pa_GetSampleSize(format); - if (err < 0) - { - throw PaException(err); - return 0; - } - - return err; - } - - // ----------------------------------------------------------------------------------- - - System::System() - { - // (left blank intentionally) - } - - System::~System() - { - // (left blank intentionally) - } - - // ----------------------------------------------------------------------------------- - -} // namespace portaudio - diff --git a/src/audio/pacpp/source/portaudiocpp/SystemDeviceIterator.cxx b/src/audio/pacpp/source/portaudiocpp/SystemDeviceIterator.cxx deleted file mode 100644 index c3c00f70e5..0000000000 --- a/src/audio/pacpp/source/portaudiocpp/SystemDeviceIterator.cxx +++ /dev/null @@ -1,60 +0,0 @@ -#include "portaudiocpp/SystemDeviceIterator.hxx" - -namespace portaudio -{ - // ----------------------------------------------------------------------------------- - - Device &System::DeviceIterator::operator*() const - { - return **ptr_; - } - - Device *System::DeviceIterator::operator->() const - { - return &**this; - } - - // ----------------------------------------------------------------------------------- - - System::DeviceIterator &System::DeviceIterator::operator++() - { - ++ptr_; - return *this; - } - - System::DeviceIterator System::DeviceIterator::operator++(int) - { - System::DeviceIterator prev = *this; - ++*this; - return prev; - } - - System::DeviceIterator &System::DeviceIterator::operator--() - { - --ptr_; - return *this; - } - - System::DeviceIterator System::DeviceIterator::operator--(int) - { - System::DeviceIterator prev = *this; - --*this; - return prev; - } - - // ----------------------------------------------------------------------------------- - - bool System::DeviceIterator::operator==(const System::DeviceIterator &rhs) - { - return (ptr_ == rhs.ptr_); - } - - bool System::DeviceIterator::operator!=(const System::DeviceIterator &rhs) - { - return !(*this == rhs); - } - - // ----------------------------------------------------------------------------------- -} // namespace portaudio - - diff --git a/src/audio/pacpp/source/portaudiocpp/SystemHostApiIterator.cxx b/src/audio/pacpp/source/portaudiocpp/SystemHostApiIterator.cxx deleted file mode 100644 index f34ca40c93..0000000000 --- a/src/audio/pacpp/source/portaudiocpp/SystemHostApiIterator.cxx +++ /dev/null @@ -1,59 +0,0 @@ -#include "portaudiocpp/SystemHostApiIterator.hxx" - -namespace portaudio -{ - // ----------------------------------------------------------------------------------- - - HostApi &System::HostApiIterator::operator*() const - { - return **ptr_; - } - - HostApi *System::HostApiIterator::operator->() const - { - return &**this; - } - - // ----------------------------------------------------------------------------------- - - System::HostApiIterator &System::HostApiIterator::operator++() - { - ++ptr_; - return *this; - } - - System::HostApiIterator System::HostApiIterator::operator++(int) - { - System::HostApiIterator prev = *this; - ++*this; - return prev; - } - - System::HostApiIterator &System::HostApiIterator::operator--() - { - --ptr_; - return *this; - } - - System::HostApiIterator System::HostApiIterator::operator--(int) - { - System::HostApiIterator prev = *this; - --*this; - return prev; - } - - // ----------------------------------------------------------------------------------- - - bool System::HostApiIterator::operator==(const System::HostApiIterator &rhs) - { - return (ptr_ == rhs.ptr_); - } - - bool System::HostApiIterator::operator!=(const System::HostApiIterator &rhs) - { - return !(*this == rhs); - } - - // ----------------------------------------------------------------------------------- -} // namespace portaudio - -- GitLab