bug fix with sound card device selection, show red text if actual sound card buffer size differs from preffered value
This commit is contained in:
parent
81d119ba4a
commit
1697b8f9cd
6 changed files with 43 additions and 26 deletions
|
@ -58,7 +58,7 @@ public:
|
|||
// not implemented yet, always return one device and default string
|
||||
int GetNumDev() { return 1; }
|
||||
std::string GetDeviceName ( const int iDiD ) { return "wave mapper"; }
|
||||
int SetDev ( const int iNewDev ) {} // dummy
|
||||
std::string SetDev ( const int iNewDev ) { return ""; } // dummy
|
||||
int GetDev() { return 0; }
|
||||
|
||||
virtual int Init ( const int iNewPrefMonoBufferSize );
|
||||
|
@ -85,7 +85,7 @@ public:
|
|||
// not implemented yet, always return one device and default string
|
||||
int GetNumDev() { return 1; }
|
||||
std::string GetDeviceName ( const int iDiD ) { return "wave mapper"; }
|
||||
int SetDev ( const int iNewDev ) {} // dummy
|
||||
std::string SetDev ( const int iNewDev ) { return ""; } // dummy
|
||||
int GetDev() { return 0; }
|
||||
|
||||
virtual int Init ( const int iNewPrefMonoBufferSize )
|
||||
|
@ -136,7 +136,7 @@ public:
|
|||
// not used
|
||||
int GetNumDev() { return 1; }
|
||||
std::string GetDeviceName ( const int iDiD ) { return "wave mapper"; }
|
||||
int SetDev ( const int iNewDev ) {} // dummy
|
||||
std::string SetDev ( const int iNewDev ) { return ""; } // dummy
|
||||
int GetDev() { return 0; }
|
||||
|
||||
// dummy definitions
|
||||
|
|
|
@ -181,7 +181,7 @@ void CClient::SetSndCrdPreferredMonoBlSizeIndex ( const int iNewIdx )
|
|||
Channel.CreateNetTranspPropsMessFromCurrentSettings();
|
||||
}
|
||||
|
||||
void CClient::SetSndCrdDev ( const int iNewDev )
|
||||
QString CClient::SetSndCrdDev ( const int iNewDev )
|
||||
{
|
||||
// if client was running then first
|
||||
// stop it and restart again after new initialization
|
||||
|
@ -191,7 +191,7 @@ void CClient::SetSndCrdDev ( const int iNewDev )
|
|||
Sound.Stop();
|
||||
}
|
||||
|
||||
Sound.SetDev ( iNewDev );
|
||||
const QString strReturn = Sound.SetDev ( iNewDev ).c_str();
|
||||
|
||||
// init again because the sound card actual buffer size might
|
||||
// be changed on new device
|
||||
|
@ -201,6 +201,8 @@ void CClient::SetSndCrdDev ( const int iNewDev )
|
|||
{
|
||||
Sound.Start();
|
||||
}
|
||||
|
||||
return strReturn;
|
||||
}
|
||||
|
||||
void CClient::Start()
|
||||
|
|
|
@ -120,7 +120,7 @@ public:
|
|||
std::string GetSndCrdDeviceName ( const int iDiD )
|
||||
{ return Sound.GetDeviceName ( iDiD ); }
|
||||
|
||||
void SetSndCrdDev ( const int iNewDev );
|
||||
QString SetSndCrdDev ( const int iNewDev );
|
||||
int GetSndCrdDev() { return Sound.GetDev(); }
|
||||
void OpenSndCrdDriverSetup() { Sound.OpenDriverSetup(); }
|
||||
|
||||
|
|
|
@ -164,21 +164,34 @@ void CClientSettingsDlg::UpdateJitterBufferFrame()
|
|||
void CClientSettingsDlg::UpdateSoundCardFrame()
|
||||
{
|
||||
// update slider value and text
|
||||
const int iCurPrefBufIdx = pClient->GetSndCrdPreferredMonoBlSizeIndex();
|
||||
const int iCurActualBufIdx = pClient->GetSndCrdActualMonoBlSize();
|
||||
const int iCurPrefBufIdx = pClient->GetSndCrdPreferredMonoBlSizeIndex();
|
||||
const int iCurActualBufSize = pClient->GetSndCrdActualMonoBlSize();
|
||||
SliderSndCrdBufferDelay->setValue ( iCurPrefBufIdx );
|
||||
|
||||
// preferred size
|
||||
TextLabelPreferredSndCrdBufDelay->setText (
|
||||
QString().setNum ( (double) CSndCrdBufferSizes::GetBufferSizeFromIndex ( iCurPrefBufIdx ) *
|
||||
1000 / SND_CRD_SAMPLE_RATE, 'f', 2 ) + " ms (" +
|
||||
QString().setNum ( CSndCrdBufferSizes::GetBufferSizeFromIndex ( iCurPrefBufIdx ) ) + ")" );
|
||||
const int iPrefBufSize =
|
||||
CSndCrdBufferSizes::GetBufferSizeFromIndex ( iCurPrefBufIdx );
|
||||
|
||||
// actual size
|
||||
TextLabelActualSndCrdBufDelay->setText (
|
||||
QString().setNum ( (double) iCurActualBufIdx *
|
||||
TextLabelPreferredSndCrdBufDelay->setText (
|
||||
QString().setNum ( (double) iPrefBufSize *
|
||||
1000 / SND_CRD_SAMPLE_RATE, 'f', 2 ) + " ms (" +
|
||||
QString().setNum ( iCurActualBufIdx ) + ")" );
|
||||
QString().setNum ( iPrefBufSize ) + ")" );
|
||||
|
||||
// actual size (use yellow color if different from preferred size)
|
||||
const QString strActSizeValues =
|
||||
QString().setNum ( (double) iCurActualBufSize *
|
||||
1000 / SND_CRD_SAMPLE_RATE, 'f', 2 ) + " ms (" +
|
||||
QString().setNum ( iCurActualBufSize ) + ")";
|
||||
|
||||
if ( iPrefBufSize != iCurActualBufSize )
|
||||
{
|
||||
TextLabelActualSndCrdBufDelay->setText ( "<font color=""red"">" +
|
||||
strActSizeValues + "</font>" );
|
||||
}
|
||||
else
|
||||
{
|
||||
TextLabelActualSndCrdBufDelay->setText ( strActSizeValues );
|
||||
}
|
||||
}
|
||||
|
||||
void CClientSettingsDlg::showEvent ( QShowEvent* showEvent )
|
||||
|
@ -214,15 +227,13 @@ void CClientSettingsDlg::OnSliderSndCrdBufferDelay ( int value )
|
|||
|
||||
void CClientSettingsDlg::OnSoundCrdSelection ( int iSndDevIdx )
|
||||
{
|
||||
try
|
||||
{
|
||||
pClient->SetSndCrdDev ( iSndDevIdx );
|
||||
}
|
||||
catch ( CGenErr generr )
|
||||
const QString strError = pClient->SetSndCrdDev ( iSndDevIdx );
|
||||
|
||||
if ( !strError.isEmpty() )
|
||||
{
|
||||
QMessageBox::critical ( 0, APP_NAME,
|
||||
QString ( "The selected audio device could not be used because "
|
||||
"of the following error: " ) + generr.GetErrorText() +
|
||||
"of the following error: " ) + strError +
|
||||
QString ( " The previous driver will be selected." ), "Ok", 0 );
|
||||
|
||||
// recover old selection
|
||||
|
|
|
@ -57,8 +57,10 @@ CSound* pSound;
|
|||
/******************************************************************************\
|
||||
* Common *
|
||||
\******************************************************************************/
|
||||
void CSound::SetDev ( const int iNewDev )
|
||||
std::string CSound::SetDev ( const int iNewDev )
|
||||
{
|
||||
std::string strReturn = ""; // init with no error
|
||||
|
||||
// check if an ASIO driver was already initialized
|
||||
if ( lCurDev >= 0 )
|
||||
{
|
||||
|
@ -77,9 +79,9 @@ void CSound::SetDev ( const int iNewDev )
|
|||
// loading and initializing the new driver failed, go back to
|
||||
// original driver and display error message
|
||||
LoadAndInitializeDriver ( lCurDev );
|
||||
Init ( iASIOBufferSizeStereo );
|
||||
|
||||
throw CGenErr ( strErrorMessage.c_str() );
|
||||
// store error return message
|
||||
strReturn = strErrorMessage;
|
||||
}
|
||||
|
||||
Init ( iASIOBufferSizeStereo );
|
||||
|
@ -114,6 +116,8 @@ void CSound::SetDev ( const int iNewDev )
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
return strReturn;
|
||||
}
|
||||
|
||||
bool CSound::LoadAndInitializeFirstValidDriver()
|
||||
|
|
|
@ -68,7 +68,7 @@ public:
|
|||
int GetNumDev() { return lNumDevs; }
|
||||
std::string GetDeviceName ( const int iDiD ) { return cDriverNames[iDiD]; }
|
||||
|
||||
void SetDev ( const int iNewDev );
|
||||
std::string SetDev ( const int iNewDev );
|
||||
int GetDev() { return lCurDev; }
|
||||
|
||||
protected:
|
||||
|
|
Loading…
Reference in a new issue