diff --git a/src/client.cpp b/src/client.cpp index 6a1f8768..1e43203c 100755 --- a/src/client.cpp +++ b/src/client.cpp @@ -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 diff --git a/src/client.h b/src/client.h index 9386bcf2..69951c48 100755 --- a/src/client.h +++ b/src/client.h @@ -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,8 +151,7 @@ public: void SendPingMess() { Channel.CreatePingMes ( PreciseTime.elapsed() ); }; - CSound* GetSndInterface() { return &Sound; } - CChannel* GetChannel() { return &Channel; } + CChannel* GetChannel() { return &Channel; } // settings diff --git a/src/clientsettingsdlg.cpp b/src/clientsettingsdlg.cpp index e6f88bed..8f203d25 100755 --- a/src/clientsettingsdlg.cpp +++ b/src/clientsettingsdlg.cpp @@ -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(); } diff --git a/src/server.cpp b/src/server.cpp index 9cebb02f..e57ae89c 100755 --- a/src/server.cpp +++ b/src/server.cpp @@ -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 diff --git a/src/settings.cpp b/src/settings.cpp index da98d2fc..c7bffd8a 100755 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -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() ); diff --git a/src/util.h b/src/util.h index 23644cda..9dd8d555 100755 --- a/src/util.h +++ b/src/util.h @@ -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(); } }; diff --git a/windows/sound.cpp b/windows/sound.cpp index 7b19dc20..edd7b6c1 100755 --- a/windows/sound.cpp +++ b/windows/sound.cpp @@ -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