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

Renaming internal map in sound source manager

parent c8eac9b8
......@@ -67,12 +67,12 @@ CVAAudioSignalSourceManager::~CVAAudioSignalSourceManager()
void CVAAudioSignalSourceManager::Reset() {
m_csRecords.enter();
m_csSignalSourceAccess.enter();
std::vector< IVAAudioSignalSource* > vpDelayedRemoveList;
// Alle gemanageten Quellen freigeben
for( RecordMapIt it = m_mRecords.begin(); it != m_mRecords.end(); )
for( SignalSourceMapIt it = m_mSignalSources.begin(); it != m_mSignalSources.end(); )
{
// Forced reference count reset - OK here
it->second.iRefCount = 0;
......@@ -88,7 +88,7 @@ void CVAAudioSignalSourceManager::Reset() {
vpDelayedRemoveList.push_back( it->second.pSource );
// Only remove from record list, save erase later
it = m_mRecords.erase( it );
it = m_mSignalSources.erase( it );
}
else
{
......@@ -120,7 +120,7 @@ void CVAAudioSignalSourceManager::Reset() {
m_mMnemonicCount.clear();
m_csRecords.leave();
m_csSignalSourceAccess.leave();
}
std::string CVAAudioSignalSourceManager::RegisterSignalSource( IVAAudioSignalSource* pSource, const std::string& sName, bool bManaged, bool bDynamic )
......@@ -129,12 +129,12 @@ std::string CVAAudioSignalSourceManager::RegisterSignalSource( IVAAudioSignalSou
if( ( pSource->GetAssociatedCore() != nullptr ) && ( pSource->GetAssociatedCore() != m_pParentCore ) )
ITA_EXCEPT1( INVALID_PARAMETER, "Audio signal already registered by another core instance" );
m_csRecords.enter();
m_csSignalSourceAccess.enter();
// Fehler, falls die Quelle bereits enthalten ist
if( FindSignalSource( pSource ) != m_mRecords.end() )
if( FindSignalSource( pSource ) != m_mSignalSources.end() )
{
m_csRecords.leave();
m_csSignalSourceAccess.leave();
ITA_EXCEPT1( INVALID_PARAMETER, "Audio signal source already contained" );
}
......@@ -158,9 +158,9 @@ std::string CVAAudioSignalSourceManager::RegisterSignalSource( IVAAudioSignalSou
std::string sID = sMnemonic + IntToString( iNumber );
// Quelle hinzufgen
RecordMapIt jt = m_mRecords.insert( m_mRecords.begin(), RecordItem( sID, CAudioSignalSourceRecord( pSource, sName, m_iBlocklength, bManaged, bDynamic ) ) );
SignalSourceMapIt jt = m_mSignalSources.insert( m_mSignalSources.begin(), SignalSourceItem( sID, CAudioSignalSource( pSource, sName, m_iBlocklength, bManaged, bDynamic ) ) );
m_csRecords.leave();
m_csSignalSourceAccess.leave();
// Quelle dem Audio-Streaming bergeben
m_qpNewSources.push( &( jt->second ) );
......@@ -173,19 +173,19 @@ std::string CVAAudioSignalSourceManager::RegisterSignalSource( IVAAudioSignalSou
void CVAAudioSignalSourceManager::UnregisterSignalSource( const std::string& sID )
{
m_csRecords.enter();
m_csSignalSourceAccess.enter();
RecordMapIt it = FindSignalSource( sID );
SignalSourceMapIt it = FindSignalSource( sID );
if( it == m_mRecords.end() )
if( it == m_mSignalSources.end() )
{
m_csRecords.leave();
m_csSignalSourceAccess.leave();
VA_EXCEPT2( INVALID_PARAMETER, "Unregister failed, audio signal source " + sID + "not found" );
}
if( !it->second.bDynamic )
{
m_csRecords.leave();
m_csSignalSourceAccess.leave();
VA_EXCEPT2( MODAL_ERROR, "Unregister failed, audio signal source is static and can't be removed" );
}
......@@ -193,14 +193,14 @@ void CVAAudioSignalSourceManager::UnregisterSignalSource( const std::string& sID
// In diesem Fall muss sie gelscht werden
if( it->second.bManaged )
{
m_csRecords.leave();
m_csSignalSourceAccess.leave();
VA_EXCEPT2( MODAL_ERROR, "Unregister failed, audio signal source is managed and can't be removed" );
}
// Entfernen nur erlaubt wenn keine Referenzen auf die Quelle mehr vorliegen
if( it->second.iRefCount > 0 )
{
m_csRecords.leave();
m_csSignalSourceAccess.leave();
VA_EXCEPT2( MODAL_ERROR, "Unregister failed, audio signal source has references and can't be removed right now" );
}
......@@ -215,9 +215,9 @@ void CVAAudioSignalSourceManager::UnregisterSignalSource( const std::string& sID
it->second.pSource->HandleUnregistration( m_pParentCore );
// TODO: Aufrumer muss noch sauber implementiert werden!!!
m_mRecords.erase( it );
m_mSignalSources.erase( it );
m_csRecords.leave();
m_csSignalSourceAccess.leave();
VA_VERBOSE( "UnregisterSignalSource", "Signal source " << sID << " unregistered" );
}
......@@ -289,19 +289,19 @@ std::string CVAAudioSignalSourceManager::CreateMachineSignalSource( const std::s
void CVAAudioSignalSourceManager::DeleteSignalSource( const std::string& sID )
{
m_csRecords.enter();
m_csSignalSourceAccess.enter();
RecordMapIt it = FindSignalSource( sID );
SignalSourceMapIt it = FindSignalSource( sID );
if( it == m_mRecords.end() )
if( it == m_mSignalSources.end() )
{
m_csRecords.leave();
m_csSignalSourceAccess.leave();
VA_EXCEPT2( INVALID_PARAMETER, "Deletion failed, audio signal source " + sID + " not found" );
}
if( !it->second.bDynamic )
{
m_csRecords.leave();
m_csSignalSourceAccess.leave();
VA_EXCEPT2( MODAL_ERROR, "Deletion failed, audio signal source is static and may not be deleted" );
}
......@@ -309,14 +309,14 @@ void CVAAudioSignalSourceManager::DeleteSignalSource( const std::string& sID )
// da die Freigabe der Quelle in anderer Hand liegt. Solche Quellen drfen nur entfernt werden.
if( !it->second.bManaged )
{
m_csRecords.leave();
m_csSignalSourceAccess.leave();
VA_EXCEPT2( MODAL_ERROR, "Deletion failed, audio signal source is not managed and may not be deleted" );
}
// Lschen nur erlaubt wenn keine Referenzen auf die Quelle mehr vorliegen
if( it->second.iRefCount > 0 )
{
m_csRecords.leave();
m_csSignalSourceAccess.leave();
VA_EXCEPT2( MODAL_ERROR, "Deletion failed, audio signal source has references and may not be deleted" );
}
......@@ -331,20 +331,20 @@ void CVAAudioSignalSourceManager::DeleteSignalSource( const std::string& sID )
// Quelle freigeben
delete it->second.pSource;
m_mRecords.erase( it );
m_mSignalSources.erase( it );
m_csRecords.leave();
m_csSignalSourceAccess.leave();
}
CVASignalSourceInfo CVAAudioSignalSourceManager::GetSignalSourceInfo( const std::string& sID ) const
{
m_csRecords.enter();
m_csSignalSourceAccess.enter();
RecordMapCit it = FindSignalSource( sID );
SignalSourceMapCit it = FindSignalSource( sID );
if( it == m_mRecords.end() )
if( it == m_mSignalSources.end() )
{
m_csRecords.leave();
m_csSignalSourceAccess.leave();
ITA_EXCEPT1( INVALID_PARAMETER, "Could not get information on " + sID + ", audio signal source not found" );
}
......@@ -359,18 +359,18 @@ CVASignalSourceInfo CVAAudioSignalSourceManager::GetSignalSourceInfo( const std:
oInfo.sState = pSource->GetStateString();
oInfo.iReferences = it->second.iRefCount;
m_csRecords.leave();
m_csSignalSourceAccess.leave();
return oInfo;
}
void CVAAudioSignalSourceManager::GetSignalSourceInfos( std::vector<CVASignalSourceInfo>& vssiDest ) const
{
m_csRecords.enter();
m_csSignalSourceAccess.enter();
// Alphabetisch sortierte Liste der IDs erzeugen
std::vector<std::string> vsIDs;
for( RecordMapCit cit = m_mRecords.begin(); cit != m_mRecords.end(); ++cit )
for( SignalSourceMapCit cit = m_mSignalSources.begin(); cit != m_mSignalSources.end(); ++cit )
vsIDs.push_back( cit->first );
std::sort( vsIDs.begin(), vsIDs.end() );
......@@ -378,7 +378,7 @@ void CVAAudioSignalSourceManager::GetSignalSourceInfos( std::vector<CVASignalSou
vssiDest.clear();
for( std::vector< std::string >::const_iterator cit = vsIDs.begin(); cit != vsIDs.end(); ++cit )
{
RecordMapCit cit2 = m_mRecords.find( *cit );
SignalSourceMapCit cit2 = m_mSignalSources.find( *cit );
IVAAudioSignalSource* pSource = cit2->second.pSource;
CVASignalSourceInfo oInfo;
......@@ -392,50 +392,50 @@ void CVAAudioSignalSourceManager::GetSignalSourceInfos( std::vector<CVASignalSou
vssiDest.push_back( oInfo );
}
m_csRecords.leave();
m_csSignalSourceAccess.leave();
}
std::string CVAAudioSignalSourceManager::GetSignalSourceID( IVAAudioSignalSource* pSource ) const {
m_csRecords.enter();
m_csSignalSourceAccess.enter();
for( RecordMapCit cit = m_mRecords.begin(); cit != m_mRecords.end(); ++cit )
for( SignalSourceMapCit cit = m_mSignalSources.begin(); cit != m_mSignalSources.end(); ++cit )
if( cit->second.pSource == pSource ) {
m_csRecords.leave();
m_csSignalSourceAccess.leave();
return cit->first;
}
m_csRecords.leave();
m_csSignalSourceAccess.leave();
// Methode wird extern benutzt. Exception falls nicht gefunden.
VA_EXCEPT2( INVALID_PARAMETER, "Invalid signal source ID" );
}
CVAAudioSignalSourceManager::RecordMapIt CVAAudioSignalSourceManager::FindSignalSource( const std::string& sID )
CVAAudioSignalSourceManager::SignalSourceMapIt CVAAudioSignalSourceManager::FindSignalSource( const std::string& sID )
{
return m_mRecords.find( toLowercase( sID ) );
return m_mSignalSources.find( toLowercase( sID ) );
}
CVAAudioSignalSourceManager::RecordMapCit CVAAudioSignalSourceManager::FindSignalSource( const std::string& sID ) const
CVAAudioSignalSourceManager::SignalSourceMapCit CVAAudioSignalSourceManager::FindSignalSource( const std::string& sID ) const
{
return m_mRecords.find( toLowercase( sID ) );
return m_mSignalSources.find( toLowercase( sID ) );
}
CVAAudioSignalSourceManager::RecordMapIt CVAAudioSignalSourceManager::FindSignalSource( IVAAudioSignalSource* pSource )
CVAAudioSignalSourceManager::SignalSourceMapIt CVAAudioSignalSourceManager::FindSignalSource( IVAAudioSignalSource* pSource )
{
for( RecordMapIt it = m_mRecords.begin(); it != m_mRecords.end(); ++it )
for( SignalSourceMapIt it = m_mSignalSources.begin(); it != m_mSignalSources.end(); ++it )
if( it->second.pSource == pSource )
return it;
return m_mRecords.end();
return m_mSignalSources.end();
}
IVAAudioSignalSource* CVAAudioSignalSourceManager::RequestSignalSource( const std::string& sID, const ITASampleBuffer** ppsbInputBuf ) {
m_csRecords.enter();
RecordMapIt it = m_mRecords.find( sID );
m_csSignalSourceAccess.enter();
SignalSourceMapIt it = m_mSignalSources.find( sID );
// Wird von externen Methoden benutzt. Deshalb Exception.
if( it == m_mRecords.end() ) {
m_csRecords.leave();
if( it == m_mSignalSources.end() ) {
m_csSignalSourceAccess.leave();
VA_EXCEPT2( INVALID_PARAMETER, "Invalid signal source ID" );
}
......@@ -443,16 +443,16 @@ IVAAudioSignalSource* CVAAudioSignalSourceManager::RequestSignalSource( const st
IVAAudioSignalSource* pResult = it->second.pSource;
ITASampleBuffer* psbInputBuffer = &( it->second.sbSampleBuffer );
if( ppsbInputBuf ) *ppsbInputBuf = psbInputBuffer;
m_csRecords.leave();
m_csSignalSourceAccess.leave();
return pResult;
}
void CVAAudioSignalSourceManager::ReleaseSignalSource( IVAAudioSignalSource* pSource ) {
RecordMapIt it = FindSignalSource( pSource );
SignalSourceMapIt it = FindSignalSource( pSource );
// Ungltiger Zeiger (weil nicht registriert)
assert( it != m_mRecords.end() );
assert( it != m_mSignalSources.end() );
it->second.iRefCount--;
}
......@@ -467,7 +467,7 @@ void CVAAudioSignalSourceManager::SyncSignalSources()
return;
// Keine Ketten => Nicht warten (sonst Deadlock)
if( m_mRecords.empty() )
if( m_mSignalSources.empty() )
return;
// Aktuellen Stream-Counter ermitteln
......@@ -493,7 +493,7 @@ void CVAAudioSignalSourceManager::SyncSignalSources()
void CVAAudioSignalSourceManager::FetchInputData( const CVAAudiostreamState* pStreamInfo )
{
CAudioSignalSourceRecord* pRecord;
CAudioSignalSource* pRecord;
// Interne Liste aktualisieren
while( m_qpNewSources.try_pop( pRecord ) )
......@@ -523,7 +523,7 @@ void CVAAudioSignalSourceManager::FetchInputData( const CVAAudiostreamState* pSt
// Danach von allen Datenquellen die Daten beziehen
// Wichtig: Zwei Phasen! 1. GetBlockPointer auf allen Quellen, 2. danach erst IncrementBlockPointer
for( std::set<CAudioSignalSourceRecord*>::iterator it = m_spIntSources.begin(); it != m_spIntSources.end(); ++it )
for( std::set<CAudioSignalSource*>::iterator it = m_spIntSources.begin(); it != m_spIntSources.end(); ++it )
{
const float* pfInputData = ( *it )->pSource->GetStreamBlock( pStreamInfo );
//DEBUG_PRINTF("Ptr = 0x%08Xh\n", pfInputData);
......
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