Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 22 additions & 9 deletions src/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,8 @@ void CClient::SetAudioChannels ( const EAudChanConf eNAudChanConf )

QString CClient::SetSndCrdDev ( const QString strNewDev )
{
QString strError = "";

// if client was running then first
// stop it and restart again after new initialization
const bool bWasRunning = Sound.IsRunning();
Expand All @@ -746,16 +748,23 @@ QString CClient::SetSndCrdDev ( const QString strNewDev )
Sound.Stop();
}

const QString strError = Sound.SetDev ( strNewDev );
try
{
strError = Sound.SetDev ( strNewDev );

// init again because the sound card actual buffer size might
// be changed on new device
Init();
// init again because the sound card actual buffer size might
// be changed on new device
Init();

if ( bWasRunning )
if ( bWasRunning )
{
// restart client
Sound.Start();
}
}
catch ( const CGenErr& generr )
{
// restart client
Sound.Start();
strError = generr.GetErrorText();
}

// in case of an error inform the GUI about it
Expand Down Expand Up @@ -853,7 +862,8 @@ void CClient::OnSndCrdReinitRequest ( int iSndCrdResetType )

// audio device notifications can come at any time and they are in a
// different thread, therefore we need a mutex here
MutexDriverReinit.lock();
QMutexLocker locker ( &MutexDriverReinit );
try
{
// in older QT versions, enums cannot easily be used in signals without
// registering them -> workaroud: we use the int type and cast to the enum
Expand Down Expand Up @@ -888,7 +898,10 @@ void CClient::OnSndCrdReinitRequest ( int iSndCrdResetType )
Sound.Start();
}
}
MutexDriverReinit.unlock();
catch ( const CGenErr& generr )
{
strError = generr.GetErrorText();
}

// inform GUI about the sound card device change
emit SoundDeviceChanged ( strError );
Expand Down
2 changes: 1 addition & 1 deletion src/clientdlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,7 @@ void CClientDlg::OnCLVersionAndOSReceived ( CHostAddress InetAddr, COSUtil::EOpS
{
// show the label and hide it after one minute again
lblUpdateCheck->show();
QTimer::singleShot ( 60000, [this]() { lblUpdateCheck->hide(); } );
QTimer::singleShot ( 60000, this, [this]() { lblUpdateCheck->hide(); } );
}
#endif
}
Expand Down
Loading