Commit 730761f0 authored by Jonas Stienen's avatar Jonas Stienen
Browse files

Trying out stuff for linux compat linker problems

parent 2a02c976
......@@ -11,11 +11,13 @@
// Mediator-Thread benutzen?
#define USE_MEDIATOR_THREAD
CVAASIOBackend::CVAASIOBackend(CVAAudioDriverConfig* pConfig)
: m_pMediator(nullptr), m_pConfig(pConfig), m_bStreaming(false)
CVAASIOBackend::CVAASIOBackend( CVAAudioDriverConfig* pConfig )
: m_pMediator( nullptr )
, m_pConfig( pConfig )
, m_bStreaming( false )
{
#ifdef USE_MEDIATOR_THREAD
m_pMediator = new MediatorThread(this);
m_pMediator = new MediatorThread( this );
#endif
}
......@@ -48,9 +50,9 @@ ITADatasource* CVAASIOBackend::getInputStreamDatasource() const {
return ITAsioGetRecordDatasource();
}
void CVAASIOBackend::setOutputStreamDatasource(ITADatasource* pDatasource)
void CVAASIOBackend::setOutputStreamDatasource( ITADatasource* pDatasource )
{
ITAsioSetPlaybackDatasource(pDatasource);
ITAsioSetPlaybackDatasource( pDatasource );
}
void CVAASIOBackend::initialize()
......@@ -62,68 +64,69 @@ void CVAASIOBackend::initialize()
#endif // USE_MEDIATOR_THREAD
}
void CVAASIOBackend::threadInitialize() {
void CVAASIOBackend::threadInitialize()
{
ASIOError ae;
ITAsioInitializeLibrary();
if ((ae = ITAsioInitializeDriver(m_pConfig->sDevice.c_str())) != ASE_OK)
ITA_EXCEPT1(INVALID_PARAMETER,
std::string("Failed to initialize the ASIO driver \"") + m_pConfig->sDevice +
std::string("\". ") + ITAsioGetErrorStr(ae) + std::string(" (ASIO Errorcode ") + IntToString(ae) + std::string(")"));
if( ( ae = ITAsioInitializeDriver( m_pConfig->sDevice.c_str() ) ) != ASE_OK )
ITA_EXCEPT1( INVALID_PARAMETER,
std::string( "Failed to initialize the ASIO driver \"" ) + m_pConfig->sDevice +
std::string( "\". " ) + ITAsioGetErrorStr( ae ) + std::string( " (ASIO Errorcode " ) + IntToString( ae ) + std::string( ")" ) );
// Anzahl der verfgbaren Kanle ermitteln
long lInputs, lOutputs;
if (ae = ITAsioGetChannels(&lInputs, &lOutputs))
ITA_EXCEPT1(INVALID_PARAMETER,
std::string("Failed to query the ASIO driver \"") + m_pConfig->sDevice +
std::string("\". ") + ITAsioGetErrorStr(ae) + std::string(" (ASIO Errorcode ") + IntToString(ae) + std::string(")"));
if( ae = ITAsioGetChannels( &lInputs, &lOutputs ) )
ITA_EXCEPT1( INVALID_PARAMETER,
std::string( "Failed to query the ASIO driver \"" ) + m_pConfig->sDevice +
std::string( "\". " ) + ITAsioGetErrorStr( ae ) + std::string( " (ASIO Errorcode " ) + IntToString( ae ) + std::string( ")" ) );
// Anzahlen der Kanle automatisch ermitteln
if (m_pConfig->iInputChannels == CVAAudioDriverConfig::AUTO)
if( m_pConfig->iInputChannels == CVAAudioDriverConfig::AUTO )
m_pConfig->iInputChannels = lInputs;
if (m_pConfig->iOutputChannels == CVAAudioDriverConfig::AUTO)
if( m_pConfig->iOutputChannels == CVAAudioDriverConfig::AUTO )
m_pConfig->iOutputChannels = lOutputs;
if ((m_pConfig->iInputChannels > lInputs) || (m_pConfig->iInputChannels > lOutputs))
ITA_EXCEPT1(INVALID_PARAMETER,
std::string("The ASIO driver \"") + m_pConfig->sDevice +
std::string("\" does not support for the desired number of inputs or outputs"));
if( ( m_pConfig->iInputChannels > lInputs ) || ( m_pConfig->iInputChannels > lOutputs ) )
ITA_EXCEPT1( INVALID_PARAMETER,
std::string( "The ASIO driver \"" ) + m_pConfig->sDevice +
std::string( "\" does not support for the desired number of inputs or outputs" ) );
// Abtastrate berprfen
if (ITAsioCanSampleRate(m_pConfig->dSampleRate) != ASE_OK)
ITA_EXCEPT1(INVALID_PARAMETER,
std::string("The ASIO driver \"") + m_pConfig->sDevice +
std::string("\" does not support the desired sampling rate"));
if( ITAsioCanSampleRate( m_pConfig->dSampleRate ) != ASE_OK )
ITA_EXCEPT1( INVALID_PARAMETER,
std::string( "The ASIO driver \"" ) + m_pConfig->sDevice +
std::string( "\" does not support the desired sampling rate" ) );
// Buffergre automatisch bestimmen, falls nicht vorgegeben
if (m_pConfig->iBuffersize == CVAAudioDriverConfig::AUTO) {
if( m_pConfig->iBuffersize == CVAAudioDriverConfig::AUTO ) {
long lMin, lMax, lPref, lGran;
if ((ae = ITAsioGetBufferSize(&lMin, &lMax, &lPref, &lGran)) != ASE_OK)
ITA_EXCEPT1(INVALID_PARAMETER,
std::string("Failed to query the buffersize of the ASIO driver \"") + m_pConfig->sDevice +
std::string("\". ") + ITAsioGetErrorStr(ae) + std::string(" (ASIO Errorcode ") + IntToString(ae) + std::string(")"));
if( ( ae = ITAsioGetBufferSize( &lMin, &lMax, &lPref, &lGran ) ) != ASE_OK )
ITA_EXCEPT1( INVALID_PARAMETER,
std::string( "Failed to query the buffersize of the ASIO driver \"" ) + m_pConfig->sDevice +
std::string( "\". " ) + ITAsioGetErrorStr( ae ) + std::string( " (ASIO Errorcode " ) + IntToString( ae ) + std::string( ")" ) );
// Wir nehmen die bevorzugte Puffergre
if (lPref == 0)
ITA_EXCEPT1(INVALID_PARAMETER,
std::string("Failed to query the buffersize of the ASIO driver \"") + m_pConfig->sDevice +
std::string("\". (Preferred buffersize 0)"));
if( lPref == 0 )
ITA_EXCEPT1( INVALID_PARAMETER,
std::string( "Failed to query the buffersize of the ASIO driver \"" ) + m_pConfig->sDevice +
std::string( "\". (Preferred buffersize 0)" ) );
m_pConfig->iBuffersize = lPref;
}
if ((ae = ITAsioCreateBuffers(m_pConfig->iInputChannels,
m_pConfig->iOutputChannels,
m_pConfig->iBuffersize)) != ASE_OK)
ITA_EXCEPT1(INVALID_PARAMETER,
std::string("Failed to setup the ASIO driver \"") + m_pConfig->sDevice +
std::string("\". ") + ITAsioGetErrorStr(ae) + std::string(" (ASIO Errorcode ") + IntToString(ae) + std::string(")"));
if( ( ae = ITAsioCreateBuffers( m_pConfig->iInputChannels,
m_pConfig->iOutputChannels,
m_pConfig->iBuffersize ) ) != ASE_OK )
ITA_EXCEPT1( INVALID_PARAMETER,
std::string( "Failed to setup the ASIO driver \"" ) + m_pConfig->sDevice +
std::string( "\". " ) + ITAsioGetErrorStr( ae ) + std::string( " (ASIO Errorcode " ) + IntToString( ae ) + std::string( ")" ) );
m_oOutputStreamProps.dSamplerate = m_pConfig->dSampleRate;
m_oOutputStreamProps.uiChannels = (unsigned int) m_pConfig->iOutputChannels;
m_oOutputStreamProps.uiBlocklength = (unsigned int) m_pConfig->iBuffersize;
m_oOutputStreamProps.uiChannels = ( unsigned int ) m_pConfig->iOutputChannels;
m_oOutputStreamProps.uiBlocklength = ( unsigned int ) m_pConfig->iBuffersize;
}
void CVAASIOBackend::finalize()
......@@ -159,13 +162,13 @@ void CVAASIOBackend::startStreaming()
void CVAASIOBackend::threadStartStreaming() {
ASIOError ae;
if ((ae = ITAsioStart()) != ASE_OK) {
if( ( ae = ITAsioStart() ) != ASE_OK ) {
// [fwe] Streaming-Flag lschen
m_bStreaming = false;
ITA_EXCEPT1(INVALID_PARAMETER,
std::string("Failed to start the ASIO streaming. ") +
ITAsioGetErrorStr(ae) + std::string(" (ASIO Errorcode ") + IntToString(ae) + std::string(")"));
ITA_EXCEPT1( INVALID_PARAMETER,
std::string( "Failed to start the ASIO streaming. " ) +
ITAsioGetErrorStr( ae ) + std::string( " (ASIO Errorcode " ) + IntToString( ae ) + std::string( ")" ) );
}
}
......@@ -192,30 +195,30 @@ void CVAASIOBackend::threadStopStreaming() {
//
CVAASIOBackend::MediatorThread::MediatorThread(CVAASIOBackend* pParent)
: m_pParent(pParent),
m_iOperation(OPERATION_NOTHING),
// TODO: What about the Posix-Flag in VistaThreadEvent?
m_evStart( VistaThreadEvent::NON_WAITABLE_EVENT ),
m_evFinish( VistaThreadEvent::NON_WAITABLE_EVENT )
CVAASIOBackend::MediatorThread::MediatorThread( CVAASIOBackend* pParent )
: m_pParent( pParent ),
m_iOperation( OPERATION_NOTHING ),
// TODO: What about the Posix-Flag in VistaThreadEvent?
m_evStart( VistaThreadEvent::NON_WAITABLE_EVENT ),
m_evFinish( VistaThreadEvent::NON_WAITABLE_EVENT )
{
SetThreadName("VACore::ASIOMediatorThread");
SetThreadName( "VACore::ASIOMediatorThread" );
Run();
}
CVAASIOBackend::MediatorThread::~MediatorThread() {
m_iOperation = OPERATION_STOP_THREAD;
m_evStart.SignalEvent();
StopGently(true);
StopGently( true );
}
int CVAASIOBackend::MediatorThread::doOperation(int iOperation) {
int CVAASIOBackend::MediatorThread::doOperation( int iOperation ) {
m_iOperation = iOperation;
m_evStart.SignalEvent();
m_evFinish.WaitForEvent(true);
m_evFinish.WaitForEvent( true );
m_evFinish.ResetThisEvent();
if (m_iResult != 0) {
if( m_iResult != 0 ) {
// Rethrow exception
throw m_oException;
}
......@@ -224,19 +227,19 @@ int CVAASIOBackend::MediatorThread::doOperation(int iOperation) {
}
int CVAASIOBackend::MediatorThread::doInitialize() {
return doOperation(OPERATION_INITIALIZE);
return doOperation( OPERATION_INITIALIZE );
}
int CVAASIOBackend::MediatorThread::doFinalize() {
return doOperation(OPERATION_FINALIZE);
return doOperation( OPERATION_FINALIZE );
}
int CVAASIOBackend::MediatorThread::doStartStreaming() {
return doOperation(OPERATION_START_STREAMING);
return doOperation( OPERATION_START_STREAMING );
}
int CVAASIOBackend::MediatorThread::doStopStreaming() {
return doOperation(OPERATION_STOP_STREAMING);
return doOperation( OPERATION_STOP_STREAMING );
}
ITAException CVAASIOBackend::MediatorThread::getException() const {
......@@ -244,8 +247,8 @@ ITAException CVAASIOBackend::MediatorThread::getException() const {
}
bool CVAASIOBackend::MediatorThread::LoopBody() {
m_evStart.WaitForEvent(true);
if (m_iOperation == OPERATION_STOP_THREAD) {
m_evStart.WaitForEvent( true );
if( m_iOperation == OPERATION_STOP_THREAD ) {
IndicateLoopEnd();
return true;
}
......@@ -254,8 +257,8 @@ bool CVAASIOBackend::MediatorThread::LoopBody() {
m_iResult = 0;
try {
switch (m_iOperation) {
try {
switch( m_iOperation ) {
case OPERATION_INITIALIZE:
m_pParent->threadInitialize();
break;
......@@ -273,10 +276,12 @@ bool CVAASIOBackend::MediatorThread::LoopBody() {
break;
}
} catch (ITAException& e) {
}
catch( ITAException& e ) {
m_iResult = -1;
m_oException = e;
} catch (...) {
}
catch( ... ) {
// Hier sollte nie etwas ankommen...
assert( false );
}
......
......@@ -3,30 +3,40 @@
#include <VAException.h>
#include "../../Utils/VAUtils.h"
const double CVAAudioDriverConfig::DEFAULT_SAMPLERATE = 44100.0;
double CVAAudioDriverConfig::DEFAULT_SAMPLERATE = 44100.0;
CVAAudioDriverConfig::CVAAudioDriverConfig() { }
CVAAudioDriverConfig::CVAAudioDriverConfig()
{
}
CVAAudioDriverConfig::~CVAAudioDriverConfig() { }
CVAAudioDriverConfig::~CVAAudioDriverConfig()
{
}
void CVAAudioDriverConfig::init( const CVAStruct& oArgs )
{
// Wichtig: Init muss immer alle Felder der Klasse setzen (auch defaults)
CVALiterals<int> lits;
lits.Add("AUTO", AUTO);
CVALiterals< int > lits;
lits.Add( "AUTO", AUTO );
CVAConfigInterpreter conf(oArgs);
CVAConfigInterpreter conf( oArgs );
conf.OptNonEmptyString( "Driver", sDriver );
conf.OptString("Device", sDevice, "AUTO");
conf.OptNumber("Samplerate", dSampleRate, DEFAULT_SAMPLERATE);
conf.OptInteger("Buffersize", iBuffersize, AUTO, &lits);
// TODO: Dieses Feature evtl. zuknftig entfernen und immer automatisch alle Kanle buchen
conf.OptInteger("InputChannels", iInputChannels, AUTO, &lits);
conf.OptInteger("OutputChannels", iOutputChannels, AUTO, &lits);
conf.OptString( "Device", sDevice, "AUTO" );
conf.OptNumber( "Samplerate", dSampleRate, DEFAULT_SAMPLERATE );
conf.OptInteger( "Buffersize", iBuffersize, AUTO, &lits );
conf.OptInteger( "InputChannels", iInputChannels, AUTO, &lits );
conf.OptInteger( "OutputChannels", iOutputChannels, AUTO, &lits );
// Parameter prfen
if (dSampleRate <= 0) VA_EXCEPT1("Invalid samplerate specified");
if ((iBuffersize < 0) && (iBuffersize != AUTO)) VA_EXCEPT1("Invalid buffersize specified");
if ((iInputChannels < 0) && (iInputChannels != AUTO)) VA_EXCEPT1("Invalid number of input channels specified");
if ((iOutputChannels < 2) && (iOutputChannels != AUTO)) VA_EXCEPT1("Invalid number of output channels specified (at least two)");
if( dSampleRate <= 0 )
VA_EXCEPT1( "Invalid samplerate specified" );
if( ( iBuffersize < 0 ) && ( iBuffersize != AUTO ) )
VA_EXCEPT1( "Invalid buffersize specified" );
if( ( iInputChannels < 0 ) && ( iInputChannels != AUTO ) )
VA_EXCEPT1( "Invalid number of input channels specified" );
// @todo: really?! I don't see a point why single channel output shouldn't be supported.
if( ( iOutputChannels < 2 ) && ( iOutputChannels != AUTO ) )
VA_EXCEPT1( "Invalid number of output channels specified (at least two)" );
}
......@@ -7,16 +7,16 @@
#include <string>
//! Audio driver configuration
/**
* Diese Datenklasse speichert die Parameter fr das Audio-Streaming in VA.
* Dies schliet ein: Die Treiber-Architektur, das Audio-Gert, usw.
*/
class VACORE_API CVAAudioDriverConfig
class CVAAudioDriverConfig
{
public:
static const int AUTO = -1; // Literal fr automatische Werte
static const double DEFAULT_SAMPLERATE; // Default sampling rate [Hz]
const static int AUTO = -1; // Literal fr automatische Werte
static double DEFAULT_SAMPLERATE; // Default sampling rate [Hz]
std::string sDriver; // Name der Treiber-Architektur (z.B. "ASIO")
std::string sDevice; // Name des Audiogertes (z.B. "RME Hammerfall DSP")
......@@ -26,10 +26,10 @@ public:
int iOutputChannels; // Anzahl Ausgangskanle
CVAAudioDriverConfig();
virtual ~CVAAudioDriverConfig();
virtual ~CVAAudioDriverConfig();
// Einstellungen aus einem Struct lesen
void init(const CVAStruct& oArgs);
void init( const CVAStruct& oArgs );
};
#endif // __VA_AUDIODRIVERCONFIG_H__
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment