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

Setting output channel number after init in Portaudio (was skipped), also some style changes.

Current streaming output is now at log level "info" and not "trace".
parent 04736e33
......@@ -20,8 +20,7 @@ CVAPortaudioBackend::CVAPortaudioBackend(CVAAudioDriverConfig* pConfig)
if ( m_pConfig->iBuffersize <= 0 )
m_pConfig->iBuffersize = ITAPortaudioInterface::GetPreferredBufferSize();
// ITAPortaudioInterface erzeugen
m_pITAPA = new ITAPortaudioInterface(m_pConfig->dSamplerate, m_pConfig->iBuffersize);
m_pITAPA = new ITAPortaudioInterface( m_pConfig->dSamplerate, m_pConfig->iBuffersize );
// An diesen Einstellungen ist nicht mehr zu drehen ...
m_oOutputStreamProps.dSamplerate = m_pConfig->dSamplerate;
......@@ -37,7 +36,7 @@ CVAPortaudioBackend::~CVAPortaudioBackend()
std::string CVAPortaudioBackend::getDriverName() const
{
return "PortAudio";
return "Portaudio";
}
std::string CVAPortaudioBackend::getDeviceName() const
......@@ -75,43 +74,48 @@ void CVAPortaudioBackend::initialize()
#endif // USE_MEDIATOR_THREAD
}
void CVAPortaudioBackend::threadInitialize() {
void CVAPortaudioBackend::threadInitialize()
{
ITAPortaudioInterface::ITA_PA_ERRORCODE e;
int iDriverID = -1;
try {
iDriverID = StringToInt(m_pConfig->sDevice);
} catch( ITAException& e) {
if (e.iErrorCode != ITAException::PARSE_ERROR)
try
{
iDriverID = StringToInt( m_pConfig->sDevice );
}
catch( ITAException& e )
{
if( e.iErrorCode != ITAException::PARSE_ERROR )
throw e;
}
if (iDriverID == -1) {
if ((e = m_pITAPA->Initialize()) != ITAPortaudioInterface::ITA_PA_NO_ERROR)
ITA_EXCEPT1(INVALID_PARAMETER, ITAPortaudioInterface::GetErrorCodeString(e).c_str());
if( iDriverID == -1 )
{
if( ( e = m_pITAPA->Initialize() ) != ITAPortaudioInterface::ITA_PA_NO_ERROR )
ITA_EXCEPT1( INVALID_PARAMETER, ITAPortaudioInterface::GetErrorCodeString( e ).c_str() );
iDriverID = m_pITAPA->GetDefaultOutputDevice(); // Schneller, wenn Portaudio initialisiert ist
} else {
if ((e = m_pITAPA->Initialize(iDriverID)) != ITAPortaudioInterface::ITA_PA_NO_ERROR)
ITA_EXCEPT1(INVALID_PARAMETER, ITAPortaudioInterface::GetErrorCodeString(e).c_str());
}
else
{
if( ( e = m_pITAPA->Initialize( iDriverID ) ) != ITAPortaudioInterface::ITA_PA_NO_ERROR )
ITA_EXCEPT1( INVALID_PARAMETER, ITAPortaudioInterface::GetErrorCodeString( e ).c_str() );
}
// Anzahl Kanle in die Config bernehmen
m_pConfig->iInputChannels = m_pITAPA->GetNumInputChannels(iDriverID);
m_pConfig->iOutputChannels = m_pITAPA->GetNumOutputChannels(iDriverID);
m_pConfig->iInputChannels = m_pITAPA->GetNumInputChannels( iDriverID );
m_pConfig->iOutputChannels = m_pITAPA->GetNumOutputChannels( iDriverID );
m_pITAPA->SetRecordEnabled(m_pConfig->iInputChannels > 0);
m_pITAPA->SetPlaybackEnabled(m_pConfig->iOutputChannels > 0);
m_pITAPA->SetRecordEnabled( m_pConfig->iInputChannels > 0 );
m_pITAPA->SetPlaybackEnabled( m_pConfig->iOutputChannels > 0 );
double dSampleRate;
m_pITAPA->GetDriverSampleRate(iDriverID, dSampleRate);
if (m_pConfig->dSamplerate != dSampleRate)
ITA_EXCEPT1(INVALID_PARAMETER, "Samplerate "+DoubleToString(m_pConfig->dSamplerate)+" is invalid for this audio device.");
m_pITAPA->GetDriverSampleRate( iDriverID, dSampleRate );
m_oOutputStreamProps.uiBlocklength = (unsigned int) m_pConfig->iBuffersize;
//m_oOutputStreamProps.uiChannels = m_pITAPA->GetNumOutputChannels(iDriverID);
if( m_pConfig->dSamplerate != dSampleRate )
ITA_EXCEPT1( INVALID_PARAMETER, "Samplerate " + DoubleToString( m_pConfig->dSamplerate ) + " is invalid for this audio device." );
// TODO: (FWE) Bitte prfen, ob die Buffersize von PortAudio wirklich so genommen wird.
m_oOutputStreamProps.uiBlocklength = ( unsigned int ) m_pConfig->iBuffersize;
m_oOutputStreamProps.uiChannels = ( unsigned int )m_pITAPA->GetNumOutputChannels( iDriverID );
}
void CVAPortaudioBackend::finalize()
......
......@@ -3908,9 +3908,9 @@ void CVACoreImpl::InitializeAudioDriver()
m_oCoreConfig.oAudioDriverConfig.iOutputChannels = m_pAudioDriverBackend->getOutputStreamProperties()->uiChannels;
m_oCoreConfig.oAudioDriverConfig.iBuffersize = m_pAudioDriverBackend->getOutputStreamProperties()->uiBlocklength;
VA_INFO( "Core", "Audio device successfully initialized." );
VA_VERBOSE( "Core", "Streaming at " << std::fixed << std::setw( 3 ) << std::setprecision( 1 ) << ( m_oCoreConfig.oAudioDriverConfig.dSamplerate / 1000.0f ) << " kHz on " <<
m_oCoreConfig.oAudioDriverConfig.iInputChannels << " inputs and " << m_oCoreConfig.oAudioDriverConfig.iOutputChannels <<
VA_INFO( "Core", "Streaming at " << std::fixed << std::setw( 3 ) << std::setprecision( 1 ) << ( m_oCoreConfig.oAudioDriverConfig.dSamplerate / 1000.0f ) << " kHz on " <<
( m_oCoreConfig.oAudioDriverConfig.iInputChannels == 0 ? "no" : std::to_string( m_oCoreConfig.oAudioDriverConfig.iInputChannels ) ) << " inputs and " <<
( m_oCoreConfig.oAudioDriverConfig.iOutputChannels == 0 ? "no" : std::to_string( m_oCoreConfig.oAudioDriverConfig.iOutputChannels ) ) <<
" outputs with a buffer size of " << m_oCoreConfig.oAudioDriverConfig.iBuffersize << " samples." );
}
......
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