Commit 69d9f5f2 authored by Dipl.-Ing. Jonas Stienen's avatar Dipl.-Ing. Jonas Stienen
Browse files

Moving initialization method to init impl file in core

parent ecfcb587
...@@ -5,7 +5,7 @@ set( SubDirs ) ...@@ -5,7 +5,7 @@ set( SubDirs )
set( DirFiles set( DirFiles
impl.h impl.h
impl.cpp impl.cpp
core_init.cpp init.cpp
_SourceFiles.cmake _SourceFiles.cmake
) )
set( DirFiles_SourceGroup "${RelativeSourceGroup}" ) set( DirFiles_SourceGroup "${RelativeSourceGroup}" )
......
...@@ -276,198 +276,6 @@ int CVACoreImpl::GetState() const ...@@ -276,198 +276,6 @@ int CVACoreImpl::GetState() const
return m_iState; return m_iState;
} }
void CVACoreImpl::Initialize() {
VA_NO_REENTRANCE;
// TODO: Prfen ob im Fehlerfall zurck in den sauberen Grundzustand [WICHTIG!]
VA_VERBOSE( "Core", "Initializing core" );
VA_TRY
{
if( m_iState == VA_CORESTATE_READY )
VA_EXCEPT2( MODAL_ERROR, "Core already initialized." );
if( m_iState == VA_CORESTATE_FAIL )
VA_EXCEPT2( MODAL_ERROR, "Core corrupted, reinitialization impossible" );
m_pCoreThread = new CVACoreThread( this );
SetProgress( "Setting up audio hardware", "", 1 );
InitializeAudioDriver();
m_pR2RPatchbay = new ITAStreamPatchbay( m_oCoreConfig.oAudioDriverConfig.dSampleRate, m_oCoreConfig.oAudioDriverConfig.iBuffersize );
// Create output patch bay with a single output that uses all available physical audio outputs from sound card
m_pOutputPatchbay = new ITAStreamPatchbay( m_oCoreConfig.oAudioDriverConfig.dSampleRate, m_oCoreConfig.oAudioDriverConfig.iBuffersize );
int iPhysicalHardwareOutput = m_pOutputPatchbay->AddOutput( m_oCoreConfig.oAudioDriverConfig.iOutputChannels );
m_pOutputPatchbay->SetOutputGain( iPhysicalHardwareOutput, m_dOutputGain );
m_iGlobalAuralizationMode = VA_AURAMODE_ALL;
// Set up input stream network
ITADatasource* pInputTail = nullptr;
if( m_oCoreConfig.oAudioDriverConfig.iInputChannels > 0 )
{
pInputTail = m_pAudioDriverBackend->getInputStreamDatasource();
if( pInputTail )
{
m_pInputAmp = new ITAStreamAmplifier( pInputTail, ( float ) m_dInputGain );
m_pInputStreamDetector = new ITAStreamDetector( m_pInputAmp );
m_pInputStreamDetector->SetProfilerEnabled( true );
pInputTail = m_pInputStreamDetector;
if( m_oCoreConfig.bRecordDeviceInputEnabled )
{
VistaFileSystemFile oRecordFile( m_oCoreConfig.sRecordDeviceInputFileName );
VistaFileSystemDirectory oRecordBaseFolder( m_oCoreConfig.sRecordDeviceInputBaseFolder );
if( !oRecordBaseFolder.Exists() )
{
if( oRecordBaseFolder.CreateWithParentDirectories() )
{
VA_INFO( "Core", "Created device input record base folder " << oRecordBaseFolder.GetName() << " with parent directories" );
}
else
{
VA_EXCEPT2( INVALID_PARAMETER, "Could not create non-existent device input record base folder '" + oRecordBaseFolder.GetName() + "'" );
}
}
std::string sFilePath = oRecordBaseFolder.GetName() + "/" + oRecordFile.GetLocalName();
if( VistaFileSystemFile( sFilePath ).Exists() )
VA_INFO( "Core", "Device input record file '" << sFilePath << "' exists, will overwrite" );
m_pStreamProbeDeviceInput = new ITAStreamProbe( pInputTail, sFilePath );
pInputTail = m_pStreamProbeDeviceInput;
}
}
}
SetProgress( "Setting up resource managers", "", 2 );
assert( m_oCoreConfig.oAudioDriverConfig.iInputChannels >= 0 );
m_pSignalSourceManager = new CVAAudioSignalSourceManager( this, m_oCoreConfig.oAudioDriverConfig, pInputTail );
m_pGlobalSamplePool = ITASoundSamplePool::Create( 1, m_oCoreConfig.oAudioDriverConfig.dSampleRate );
m_pGlobalSampler = ITASoundSampler::Create( 1, m_oCoreConfig.oAudioDriverConfig.dSampleRate, m_oCoreConfig.oAudioDriverConfig.iBuffersize, m_pGlobalSamplePool );
m_pGlobalSampler->AddMonoTrack();
m_pDirectivityManager = new CVADirectivityManager( this, m_oCoreConfig.oAudioDriverConfig.dSampleRate );
m_pDirectivityManager->Initialize();
SetProgress( "Setting up scene management", "", 3 );
m_pSceneManager = new CVASceneManager( m_pClock );
m_pSceneManager->Initialize();
m_pCurSceneState = m_pSceneManager->GetHeadSceneState();
SetProgress( "Setting up medium environment", "", 4 );
oHomogeneousMedium = m_oCoreConfig.oInitialHomogeneousMedium;
SetProgress( "Initializing rendering modules", "", 5 );
// Register all renderers and initialize
CVAAudioRendererRegistry::GetInstance()->RegisterInternalCoreFactoryMethods();
InitializeAudioRenderers();
if( m_voRenderers.empty() )
VA_EXCEPT1( "No audio renderers created" );
SetProgress( "Initializing reproduction modules", "", 6 );
// Register all reproductions and initialize
CVAAudioReproductionRegistry::GetInstance()->RegisterInternalCoreFactoryMethods();
InitializeReproductionModules();
if( m_voReproductionModules.empty() )
VA_EXCEPT1( "No audio reproduction modules created" );
SetProgress( "Patching audio i/o of rendering and reproduction modules", "", 7 );
// Patch renderer and reproduction modules
PatchRendererToReproductionModules();
// Patch audio reproduction to output
PatchReproductionModulesToOutput();
// Create output peak detector that uses patch bay output stream
m_pOutputStreamDetector = new ITAStreamDetector( m_pOutputPatchbay->GetOutputDatasource( iPhysicalHardwareOutput ) );
m_pOutputStreamDetector->SetProfilerEnabled( true );
// Setup output dump (if set)
ITADatasource* pOutputTail = m_pOutputStreamDetector;
if( m_oCoreConfig.bRecordDeviceOutputEnabled )
{
VistaFileSystemFile oRecordFile( m_oCoreConfig.sRecordDeviceOutputFileName );
VistaFileSystemDirectory oRecordBaseFolder( m_oCoreConfig.sRecordDeviceOutputBaseFolder );
if( !oRecordBaseFolder.Exists() )
{
if( oRecordBaseFolder.CreateWithParentDirectories() )
{
VA_INFO( "Core", "Created device output record base folder " << oRecordBaseFolder.GetName() << " with parent directories" );
}
else
{
VA_EXCEPT2( INVALID_PARAMETER, "Could not create non-existent device output record base folder '" + oRecordBaseFolder.GetName() + "'" );
}
}
std::string sFilePath = oRecordBaseFolder.GetName() + "/" + oRecordFile.GetLocalName();
if( VistaFileSystemFile( sFilePath ).Exists() )
VA_INFO( "Core", "Device output record file '" << sFilePath << "' exists, will overwrite" );
m_pStreamProbeDeviceOutput = new ITAStreamProbe( pOutputTail, sFilePath );
pOutputTail = m_pStreamProbeDeviceOutput;
}
// Attach the stream tracker
m_pOutputTracker = new CVAAudiostreamTracker( pOutputTail, m_pClock, &m_fCoreClockOffset, &m_lSyncModOwner, m_pSignalSourceManager );
pOutputTail = m_pOutputTracker;
// Give output stream datasource to audio driver
m_pAudioDriverBackend->setOutputStreamDatasource( pOutputTail );
// Core-Clock auf 0 initialisieren
double dNow = m_pClock->getTime();
m_fCoreClockOffset = ( float ) dNow;
m_dStreamClockOffset = -1;
// Timer erzeugen und konfigurieren (wird fr Peak-Events benutzt)
m_pTicker = new VistaTicker();
m_pTicker->AddTrigger( new VistaTicker::TriggerContext( m_oCoreConfig.iTriggerUpdateMilliseconds, true ) );
m_pTicker->SetAfterPulseFunctor( this );
// Audio-Streaming starten
SetProgress( "Starting audio streaming", "", 8 );
m_pAudioDriverBackend->startStreaming();
// Timer fr Peak-Events starten
m_pTicker->StartTicker();
// Initialisierung erfolgreich!
m_iState = VA_CORESTATE_READY;
SetProgress( "Initialization finished", "", 9 );
FinishProgress();
}
VA_FINALLY
{
// Aufrumen und Exception weiterwerfen
Tidyup();
throw;
}
}
void CVACoreImpl::Reset() void CVACoreImpl::Reset()
{ {
VA_CHECK_INITIALIZED; VA_CHECK_INITIALIZED;
......
This diff is collapsed.
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