Refactoring and WIP dummy audio backend, which will be renamed to virtual audio backend

parent 227cbd4f
......@@ -29,7 +29,8 @@
* fr ASIO mittels des ITAsioInterface
*/
class CVAASIOBackend : public IVAAudioDriverBackend {
class CVAASIOBackend : public IVAAudioDriverBackend
{
public:
/**
* Ldt die Konfigurationsdatei "ASIO.ini" und liest diese ein.
......
......@@ -8,14 +8,15 @@
#include <cassert>
CVADummyAudioDriverBackend::CVADummyAudioDriverBackend(const CVAAudioDriverConfig& config)
: m_oConfig(config), m_pStreamPump(NULL)
CVADummyAudioDriverBackend::CVADummyAudioDriverBackend( const CVAAudioDriverConfig* pConfig )
: CVAObject( "VirtualAudioDriver" )
, m_oConfig( *pConfig )
, m_pDataSource( NULL )
, m_bStarted( false )
{
m_oOutputStreamProps.dSamplerate = config.dSamplerate;
m_oOutputStreamProps.uiChannels = (unsigned int) config.iOutputs;
m_oOutputStreamProps.uiBlocklength = (unsigned int) config.iBuffersize;
m_pStreamPump = new ITAStreamPump(
m_oOutputStreamProps.dSamplerate = m_oConfig.dSampleRate;
m_oOutputStreamProps.uiChannels = ( unsigned int ) m_oConfig.iOutputChannels;
m_oOutputStreamProps.uiBlocklength = ( unsigned int ) m_oConfig.iBuffersize;
}
CVADummyAudioDriverBackend::~CVADummyAudioDriverBackend()
......@@ -35,7 +36,7 @@ std::string CVADummyAudioDriverBackend::getDeviceName() const
int CVADummyAudioDriverBackend::getNumberOfInputs() const
{
return m_config.iInputs;
return m_oConfig.iInputChannels;
}
const ITAStreamProperties* CVADummyAudioDriverBackend::getOutputStreamProperties() const
......@@ -43,9 +44,14 @@ const ITAStreamProperties* CVADummyAudioDriverBackend::getOutputStreamProperties
return &m_oOutputStreamProps;
}
void CVADummyAudioDriverBackend::setOutputStreamDatasource(ITADatasource* pDatasource)
void CVADummyAudioDriverBackend::setOutputStreamDatasource( ITADatasource* pDatasource )
{
m_pDataSource = pDatasource;
}
ITADatasource* CVADummyAudioDriverBackend::getInputStreamDatasource() const
{
return nullptr;
}
void CVADummyAudioDriverBackend::initialize()
......@@ -60,10 +66,30 @@ void CVADummyAudioDriverBackend::finalize()
void CVADummyAudioDriverBackend::startStreaming()
{
m_bStarted = true;
}
bool CVADummyAudioDriverBackend::isStreaming()
{
return m_bStarted;
}
void CVADummyAudioDriverBackend::stopStreaming()
{
m_bStarted = false;
}
CVAStruct CVADummyAudioDriverBackend::CallObject( const CVAStruct& oArgs )
{
CVAStruct oReturn;
if( oArgs.HasKey( "trigger" ) && m_pDataSource )
m_pDataSource->IncrementBlockPointer();
if( oArgs.HasKey( "help" ) || oArgs.HasKey( "info" ) )
{
oReturn[ "usage" ] = "Call this virtual audio device with key 'trigger' to trigger another audio block increment";
}
return oReturn;
}
#ifndef __VA_DUMMYAUDIODRIVERBACKEND_H__
#define __VA_DUMMYAUDIODRIVERBACKEND_H__
/*
* --------------------------------------------------------------------------------------------
*
* VVV VVV A Virtual Acoustics (VA) | http://www.virtualacoustics.org
* VVV VVV AAA Licensed under the Apache License, Version 2.0
* VVV VVV AAA
* VVV VVV AAA Copyright 2015-2018
* VVVVVV AAA Institute of Technical Acoustics (ITA)
* VVVV AAA RWTH Aachen University
*
* --------------------------------------------------------------------------------------------
*/
#ifndef IW_VACORE_DUMMY_AUDIO_DRIVER_BACKEND
#define IW_VACORE_DUMMY_AUDIO_DRIVER_BACKEND
#include "VAAudioDriverBackend.h"
#include "VAAudioDriverConfig.h"
#include <VAObject.h>
#include <ITAStreamProperties.h>
#include <ITAStreamPump.h>
#include <ITADatasource.h>
class ITAStreamPump;
#pragma warning( disable : 4512 ) // yep no copy constructor
class CVADummyAudioDriverBackend : public IVAAudioDriverBackend {
class CVADummyAudioDriverBackend : public IVAAudioDriverBackend, public CVAObject
{
public:
CVADummyAudioDriverBackend(const CVAAudioDriverConfig& pConfig);
CVADummyAudioDriverBackend( const CVAAudioDriverConfig* pConfig );
~CVADummyAudioDriverBackend();
std::string getDriverName() const;
std::string getDeviceName() const;
int getNumberOfInputs() const;
const ITAStreamProperties* getOutputStreamProperties() const;
void setOutputStreamDatasource(ITADatasource* pDatasource);
void setOutputStreamDatasource( ITADatasource* pDatasource );
ITADatasource* getInputStreamDatasource() const;
void initialize();
void finalize();
void startStreaming();
bool isStreaming();
void stopStreaming();
CVAStruct CallObject( const CVAStruct& oArgs );
private:
const CVAAudioDriverConfig m_oConfig;
ITAStreamProperties m_oOutputStreamProps;
ITAStreamPump m_pStreamPump;
ITADatasource* m_pDataSource;
bool m_bStarted;
};
#endif // __VA_DUMMYAUDIODRIVERBACKEND_H__
#endif // IW_VACORE_DUMMY_AUDIO_DRIVER_BACKEND
......@@ -49,6 +49,9 @@
#ifdef VACORE_WITH_AUDIO_BACKEND_PORTAUDIO
#include "Drivers/Audio/VAPortaudioBackend.h"
#endif
#ifdef VACORE_WITH_AUDIO_BACKEND_DUMMY
#include "Drivers/Audio/VADummyAudioDriverBackend.h"
#endif
// ITA includes
#include <ITAASCIITable.h>
......@@ -223,7 +226,7 @@ CVAStruct VACore::LoadCoreConfigFromFile( const std::string& sConfigFilePath )
}
if( !oCurrentConfigFile.Exists() )
{
{
VA_EXCEPT2( FILE_NOT_FOUND, "Configuration file '" + oCurrentConfigFile.GetLocalName() + "' not found, aborting." );
}
}
......@@ -283,41 +286,40 @@ std::string VACore::GetCoreLibFilePath()
}
CVACoreImpl::CVACoreImpl( const CVAStruct& oArgs, std::ostream* pOutputStream )
: m_pAudioDriverBackend( nullptr ),
m_pGlobalSamplePool( nullptr ),
m_pGlobalSampler( nullptr ),
m_pSignalSourceManager( nullptr ),
m_pDirectivityManager( nullptr ),
m_pSceneManager( nullptr ),
m_pNewSceneState( nullptr ),
m_iCurActiveSoundReceiver( -1 ),
m_iNewActiveSoundReceiver( -1 ),
m_iUpdActiveSoundReceiver( -1 ),
m_pEventManager( nullptr ),
m_pCoreThread( nullptr ),
m_pInputAmp( nullptr ),
m_pR2RPatchbay( nullptr ),
m_pOutputPatchbay( nullptr ),
m_pInputStreamDetector( nullptr ),
m_pOutputStreamDetector( nullptr ),
m_pOutputTracker( nullptr ),
m_pStreamProbeDeviceInput( nullptr ),
m_pStreamProbeFinal( nullptr ),
m_pCurSceneState( nullptr ),
m_pClock( ITAClock::getDefaultClock() ),
m_pTicker( NULL ),
m_lSyncModOwner( -1 ),
m_lSyncModSpinCount( 0 ),
m_iState( VA_CORESTATE_CREATED ),
// TODO: Welche Default-Wert mssen erst in Initialize gesetzt werden?
m_iGlobalAuralizationMode( IVAInterface::VA_AURAMODE_ALL ),
m_dOutputGain( 1 ), m_dInputGain( 1 ),
m_bOutputMuted( false ), m_bInputMuted( false ),
m_dStreamClockOffset( 0 ), m_fCoreClockOffset( 0 ),
// --= Profiling =--
m_pmCoreThreadLoopTotalDuration( "Core thread loop" )
: m_pAudioDriverBackend( nullptr )
, m_pGlobalSamplePool( nullptr )
, m_pGlobalSampler( nullptr )
, m_pSignalSourceManager( nullptr )
, m_pDirectivityManager( nullptr )
, m_pSceneManager( nullptr )
, m_pNewSceneState( nullptr )
, m_iCurActiveSoundReceiver( -1 )
, m_iNewActiveSoundReceiver( -1 )
, m_iUpdActiveSoundReceiver( -1 )
, m_pEventManager( nullptr )
, m_pCoreThread( nullptr )
, m_pInputAmp( nullptr )
, m_pR2RPatchbay( nullptr )
, m_pOutputPatchbay( nullptr )
, m_pInputStreamDetector( nullptr )
, m_pOutputStreamDetector( nullptr )
, m_pOutputTracker( nullptr )
, m_pStreamProbeDeviceInput( nullptr )
, m_pStreamProbeFinal( nullptr )
, m_pCurSceneState( nullptr )
, m_pClock( ITAClock::getDefaultClock() )
, m_pTicker( NULL )
, m_lSyncModOwner( -1 )
, m_lSyncModSpinCount( 0 )
, m_iState( VA_CORESTATE_CREATED )
, m_iGlobalAuralizationMode( IVAInterface::VA_AURAMODE_ALL )
, m_dOutputGain( 1 )
, m_dInputGain( 1 )
, m_bOutputMuted( false )
, m_bInputMuted( false )
, m_dStreamClockOffset( 0 )
, m_fCoreClockOffset( 0 )
, m_oCoreThreadLoopTotalDuration( "Core thread loop" )
{
VA_NO_REENTRANCE;
......@@ -382,7 +384,7 @@ CVACoreImpl::~CVACoreImpl()
VA_TRACE( "Core", "CVACoreImpl instance deleted [" << this << "]" );
// Profiling ausgeben
VA_VERBOSE( "Core", m_pmCoreThreadLoopTotalDuration.ToString() );
VA_VERBOSE( "Core", m_oCoreThreadLoopTotalDuration.ToString() );
}
void CVACoreImpl::SetOutputStream( std::ostream* posDebug )
......@@ -893,7 +895,7 @@ void CVACoreImpl::GetModules( std::vector< CVAModuleInfo >& viModuleInfos ) cons
viModuleInfos[ i ].sName = v[ i ].sName;
viModuleInfos[ i ].sDesc = v[ i ].sDesc;
}
}
}
VA_RETHROW;
#else // VACORE_MODULE_INTERFACE_ENABLED
......@@ -902,7 +904,7 @@ void CVACoreImpl::GetModules( std::vector< CVAModuleInfo >& viModuleInfos ) cons
#endif // VACORE_MODULE_INTERFACE_ENABLED
}
}
CVAStruct CVACoreImpl::CallModule( const std::string& sModuleName, const CVAStruct& oArgs )
{
......@@ -4327,7 +4329,11 @@ void CVACoreImpl::InitializeAudioDriver()
#endif
#ifdef VACORE_WITH_AUDIO_BACKEND_DUMMY
if( m_oCoreConfig.oAudioDriverConfig.sDriver == "Dummy" )
m_pAudioDriverBackend = new CVADummyBackend( &m_oCoreConfig.oAudioDriverConfig );
{
CVADummyAudioDriverBackend* pAudioDriverBackend = new CVADummyAudioDriverBackend( &m_oCoreConfig.oAudioDriverConfig );
RegisterModule( pAudioDriverBackend );
m_pAudioDriverBackend = pAudioDriverBackend;
}
#endif
if( m_pAudioDriverBackend == nullptr )
......@@ -4871,7 +4877,7 @@ void CVACoreImpl::FinishProgress()
void CVACoreImpl::CoreThreadLoop()
{
m_pmCoreThreadLoopTotalDuration.start();
m_oCoreThreadLoopTotalDuration.start();
assert( m_pCurSceneState != nullptr );
assert( m_pCurSceneState->GetNumReferences() >= 1 );
......@@ -4940,7 +4946,7 @@ void CVACoreImpl::CoreThreadLoop()
pNewSceneState->RemoveReference();
}
m_pmCoreThreadLoopTotalDuration.stop();
m_oCoreThreadLoopTotalDuration.stop();
// @todo: signal event to process object calls (in-sync exec with internal core)
......
......@@ -455,7 +455,7 @@ private:
// --= Profiling =--
CVAProfilerMeasure m_pmCoreThreadLoopTotalDuration;
CVAProfilerMeasure m_oCoreThreadLoopTotalDuration;
// -------------------------------------------------
......
Markdown is supported
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