WSJT-X/portaudio-v19/bindings/cpp/source/portaudiocpp/InterfaceCallbackStream.cxx
Diane Bruce 39f88b793d - Add missing bits of portaudio
git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/trunk@249 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
2006-08-09 20:08:01 +00:00

46 lines
1.2 KiB
C++

#include "portaudiocpp/InterfaceCallbackStream.hxx"
#include "portaudiocpp/StreamParameters.hxx"
#include "portaudiocpp/Exception.hxx"
#include "portaudiocpp/CallbackInterface.hxx"
namespace portaudio
{
// ---------------------------------------------------------------------------------==
InterfaceCallbackStream::InterfaceCallbackStream()
{
}
InterfaceCallbackStream::InterfaceCallbackStream(const StreamParameters &parameters, CallbackInterface &instance)
{
open(parameters, instance);
}
InterfaceCallbackStream::~InterfaceCallbackStream()
{
try
{
close();
}
catch (...)
{
// ignore all errors
}
}
// ---------------------------------------------------------------------------------==
void InterfaceCallbackStream::open(const StreamParameters &parameters, 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);
}
}
}