fix for setting sound card device
This commit is contained in:
parent
029719fd1d
commit
f38aa17ca6
7 changed files with 48 additions and 31 deletions
|
@ -181,6 +181,28 @@ void CClient::SetSndCrdPreferredMonoBlSizeIndex ( const int iNewIdx )
|
|||
Channel.CreateNetTranspPropsMessFromCurrentSettings();
|
||||
}
|
||||
|
||||
void CClient::SetSndCrdDev ( const int iNewDev )
|
||||
{
|
||||
// if client was running then first
|
||||
// stop it and restart again after new initialization
|
||||
const bool bWasRunning = Sound.IsRunning();
|
||||
if ( bWasRunning )
|
||||
{
|
||||
Sound.Stop();
|
||||
}
|
||||
|
||||
Sound.SetDev ( iNewDev );
|
||||
|
||||
// init again because the sound card actual buffer size might
|
||||
// be changed on new device
|
||||
Init ( iSndCrdPreferredMonoBlSizeIndex );
|
||||
|
||||
if ( bWasRunning )
|
||||
{
|
||||
Sound.Start();
|
||||
}
|
||||
}
|
||||
|
||||
void CClient::Start()
|
||||
{
|
||||
// init object
|
||||
|
|
|
@ -116,6 +116,14 @@ public:
|
|||
int GetAudioBlockSizeIn() { return Channel.GetAudioBlockSizeIn(); }
|
||||
int GetUploadRateKbps() { return Channel.GetUploadRateKbps(); }
|
||||
|
||||
int GetSndCrdNumDev() { return Sound.GetNumDev(); }
|
||||
std::string GetSndCrdDeviceName ( const int iDiD )
|
||||
{ return Sound.GetDeviceName ( iDiD ); }
|
||||
|
||||
void SetSndCrdDev ( const int iNewDev );
|
||||
int GetSndCrdDev() { return Sound.GetDev(); }
|
||||
void OpenSndCrdDriverSetup() { Sound.OpenDriverSetup(); }
|
||||
|
||||
void SetSndCrdPreferredMonoBlSizeIndex ( const int iNewIdx );
|
||||
int GetSndCrdPreferredMonoBlSizeIndex()
|
||||
{ return iSndCrdPreferredMonoBlSizeIndex; }
|
||||
|
@ -143,7 +151,6 @@ public:
|
|||
void SendPingMess()
|
||||
{ Channel.CreatePingMes ( PreciseTime.elapsed() ); };
|
||||
|
||||
CSound* GetSndInterface() { return &Sound; }
|
||||
CChannel* GetChannel() { return &Channel; }
|
||||
|
||||
|
||||
|
|
|
@ -71,11 +71,11 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, QWidget* parent,
|
|||
|
||||
// init combo box containing all available sound cards in the system
|
||||
cbSoundcard->clear();
|
||||
for ( int iSndDevIdx = 0; iSndDevIdx < pClient->GetSndInterface()->GetNumDev(); iSndDevIdx++ )
|
||||
for ( int iSndDevIdx = 0; iSndDevIdx < pClient->GetSndCrdNumDev(); iSndDevIdx++ )
|
||||
{
|
||||
cbSoundcard->addItem ( pClient->GetSndInterface()->GetDeviceName ( iSndDevIdx ).c_str() );
|
||||
cbSoundcard->addItem ( pClient->GetSndCrdDeviceName ( iSndDevIdx ).c_str() );
|
||||
}
|
||||
cbSoundcard->setCurrentIndex ( pClient->GetSndInterface()->GetDev() );
|
||||
cbSoundcard->setCurrentIndex ( pClient->GetSndCrdDev() );
|
||||
|
||||
// "OpenChatOnNewMessage" check box
|
||||
if ( pClient->GetOpenChatOnNewMessage() )
|
||||
|
@ -196,7 +196,7 @@ void CClientSettingsDlg::hideEvent ( QHideEvent* hideEvent )
|
|||
|
||||
void CClientSettingsDlg::OnDriverSetupBut()
|
||||
{
|
||||
pClient->GetSndInterface()->OpenDriverSetup();
|
||||
pClient->OpenSndCrdDriverSetup();
|
||||
}
|
||||
|
||||
void CClientSettingsDlg::OnSliderNetBuf ( int value )
|
||||
|
@ -215,7 +215,7 @@ void CClientSettingsDlg::OnSoundCrdSelection ( int iSndDevIdx )
|
|||
{
|
||||
try
|
||||
{
|
||||
pClient->GetSndInterface()->SetDev ( iSndDevIdx );
|
||||
pClient->SetSndCrdDev ( iSndDevIdx );
|
||||
}
|
||||
catch ( CGenErr generr )
|
||||
{
|
||||
|
@ -225,7 +225,7 @@ void CClientSettingsDlg::OnSoundCrdSelection ( int iSndDevIdx )
|
|||
QString ( " The previous driver will be selected." ), "Ok", 0 );
|
||||
|
||||
// recover old selection
|
||||
cbSoundcard->setCurrentIndex ( pClient->GetSndInterface()->GetDev() );
|
||||
cbSoundcard->setCurrentIndex ( pClient->GetSndCrdDev() );
|
||||
}
|
||||
UpdateDisplay();
|
||||
}
|
||||
|
|
|
@ -116,8 +116,8 @@ void CServer::Stop()
|
|||
Timer.stop();
|
||||
|
||||
// logging
|
||||
const QString strLogStr = CLogTimeDate::toString() + ": server stopped "
|
||||
"############################################";
|
||||
const QString strLogStr = CLogTimeDate::toString() + ",, server stopped "
|
||||
"-------------------------------------";
|
||||
|
||||
qDebug() << strLogStr; // on console
|
||||
Logging << strLogStr; // in log file
|
||||
|
@ -126,8 +126,8 @@ void CServer::Stop()
|
|||
void CServer::OnNewChannel ( CHostAddress ChanAddr )
|
||||
{
|
||||
// logging of new connected channel
|
||||
const QString strLogStr = CLogTimeDate::toString() + ": " +
|
||||
ChanAddr.InetAddr.toString() + " connected";
|
||||
const QString strLogStr = CLogTimeDate::toString() + ", " +
|
||||
ChanAddr.InetAddr.toString() + ", connected";
|
||||
|
||||
qDebug() << strLogStr; // on console
|
||||
Logging << strLogStr; // in log file
|
||||
|
|
|
@ -84,13 +84,13 @@ void CSettings::ReadIniFile ( const QString& sFileName )
|
|||
// initialized with a default setting defined here
|
||||
if ( GetNumericIniSet ( IniXMLDocument, "client", "auddevidx", 1, MAX_NUMBER_SOUND_CARDS, iValue ) )
|
||||
{
|
||||
pClient->GetSndInterface()->SetDev ( iValue );
|
||||
pClient->SetSndCrdDev ( iValue );
|
||||
}
|
||||
else
|
||||
{
|
||||
// use "INVALID_SNC_CARD_DEVICE" to tell the sound card driver that no
|
||||
// device selection was done previously
|
||||
pClient->GetSndInterface()->SetDev ( INVALID_SNC_CARD_DEVICE );
|
||||
pClient->SetSndCrdDev ( INVALID_SNC_CARD_DEVICE );
|
||||
}
|
||||
|
||||
// sound card preferred buffer size index
|
||||
|
@ -161,7 +161,7 @@ void CSettings::WriteIniFile ( const QString& sFileName )
|
|||
SetFlagIniSet ( IniXMLDocument, "client", "reverblchan", pClient->IsReverbOnLeftChan() );
|
||||
|
||||
// sound card selection
|
||||
SetNumericIniSet ( IniXMLDocument, "client", "auddevidx", pClient->GetSndInterface()->GetDev() );
|
||||
SetNumericIniSet ( IniXMLDocument, "client", "auddevidx", pClient->GetSndCrdDev() );
|
||||
|
||||
// sound card preferred buffer size index
|
||||
SetNumericIniSet ( IniXMLDocument, "client", "prefsndcrdbufidx", pClient->GetSndCrdPreferredMonoBlSizeIndex() );
|
||||
|
|
|
@ -550,10 +550,10 @@ public:
|
|||
{
|
||||
const QDateTime curDateTime = QDateTime::currentDateTime();
|
||||
|
||||
// format date and time output according to "3.9.2006 11:38:08: "
|
||||
// format date and time output according to "3.9.2006, 11:38:08"
|
||||
return QString().setNum ( curDateTime.date().day() ) + "." +
|
||||
QString().setNum ( curDateTime.date().month() ) + "." +
|
||||
QString().setNum ( curDateTime.date().year() ) + " " +
|
||||
QString().setNum ( curDateTime.date().year() ) + ", " +
|
||||
curDateTime.time().toString();
|
||||
}
|
||||
};
|
||||
|
|
|
@ -59,20 +59,10 @@ CSound* pSound;
|
|||
\******************************************************************************/
|
||||
void CSound::SetDev ( const int iNewDev )
|
||||
{
|
||||
|
||||
// TODO do check if sound interface is running here, take action
|
||||
|
||||
|
||||
|
||||
|
||||
// check if an ASIO driver was already initialized
|
||||
if ( lCurDev >= 0 )
|
||||
{
|
||||
// a device was already been initialized and is used, kill working
|
||||
// thread and clean up
|
||||
// stop driver
|
||||
ASIOStop();
|
||||
|
||||
// a device was already been initialized and is used, first clean up
|
||||
// dispose ASIO buffers
|
||||
ASIODisposeBuffers();
|
||||
|
||||
|
@ -103,9 +93,7 @@ void CSound::SetDev ( const int iNewDev )
|
|||
// available driver in the system. If this fails, too, we throw an error
|
||||
// that no driver is available -> it does not make sense to start the llcon
|
||||
// software if no audio hardware is available
|
||||
const std::string strErrorMessage = LoadAndInitializeDriver ( iNewDev );
|
||||
|
||||
if ( !strErrorMessage.empty() )
|
||||
if ( !LoadAndInitializeDriver ( iNewDev ).empty() )
|
||||
{
|
||||
// loading and initializing the new driver failed, try to find at
|
||||
// least one usable driver
|
||||
|
|
Loading…
Reference in a new issue