more ASIO interface changes (e.g. warning if ASIO buffer is too big, etc)
This commit is contained in:
parent
de13a71735
commit
78684feaf7
5 changed files with 92 additions and 61 deletions
|
@ -71,9 +71,7 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, QWidget* parent,
|
|||
#else
|
||||
SliderSndBufIn->setRange ( 2, AUD_SLIDER_LENGTH );
|
||||
#endif
|
||||
const int iCurNumInBuf = pClient->GetSndInterface()->GetInNumBuf();
|
||||
SliderSndBufIn->setValue ( iCurNumInBuf );
|
||||
TextSndBufIn->setText ( "In: " + QString().setNum ( iCurNumInBuf ) );
|
||||
UpdateSndBufInSlider ( pClient->GetSndInterface()->GetInNumBuf() );
|
||||
|
||||
// sound buffer out
|
||||
#ifdef _WIN32
|
||||
|
@ -81,9 +79,7 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, QWidget* parent,
|
|||
#else
|
||||
SliderSndBufOut->setRange ( 2, AUD_SLIDER_LENGTH );
|
||||
#endif
|
||||
const int iCurNumOutBuf = pClient->GetSndInterface()->GetOutNumBuf();
|
||||
SliderSndBufOut->setValue ( iCurNumOutBuf );
|
||||
TextSndBufOut->setText ( "Out: " + QString().setNum ( iCurNumOutBuf ) );
|
||||
UpdateSndBufOutSlider ( pClient->GetSndInterface()->GetOutNumBuf() );
|
||||
|
||||
// network buffer
|
||||
SliderNetBuf->setRange ( 0, MAX_NET_BUF_SIZE_NUM_BL );
|
||||
|
@ -188,6 +184,18 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, QWidget* parent,
|
|||
TimerStatus.start ( DISPLAY_UPDATE_TIME );
|
||||
}
|
||||
|
||||
void CClientSettingsDlg::UpdateSndBufInSlider ( const int iCurNumInBuf )
|
||||
{
|
||||
SliderSndBufIn->setValue ( iCurNumInBuf );
|
||||
TextSndBufIn->setText ( "In: " + QString().setNum ( iCurNumInBuf ) );
|
||||
}
|
||||
|
||||
void CClientSettingsDlg::UpdateSndBufOutSlider ( const int iCurNumOutBuf )
|
||||
{
|
||||
SliderSndBufOut->setValue ( iCurNumOutBuf );
|
||||
TextSndBufOut->setText ( "Out: " + QString().setNum ( iCurNumOutBuf ) );
|
||||
}
|
||||
|
||||
void CClientSettingsDlg::showEvent ( QShowEvent* showEvent )
|
||||
{
|
||||
// only activate ping timer if window is actually shown
|
||||
|
@ -255,6 +263,7 @@ void CClientSettingsDlg::OnSoundCrdSelection ( int iSndDevIdx )
|
|||
// recover old selection
|
||||
cbSoundcard->setCurrentIndex ( pClient->GetSndInterface()->GetDev() );
|
||||
}
|
||||
UpdateDisplay();
|
||||
}
|
||||
|
||||
void CClientSettingsDlg::OnOpenChatOnNewMessageStateChanged ( int value )
|
||||
|
@ -338,6 +347,10 @@ void CClientSettingsDlg::OnPingTimeResult ( int iPingTime )
|
|||
|
||||
void CClientSettingsDlg::UpdateDisplay()
|
||||
{
|
||||
// update slider controls (settings might have been changed by sound interface)
|
||||
UpdateSndBufInSlider ( pClient->GetSndInterface()->GetInNumBuf() );
|
||||
UpdateSndBufOutSlider ( pClient->GetSndInterface()->GetOutNumBuf() );
|
||||
|
||||
if ( !pClient->IsRunning() )
|
||||
{
|
||||
// clear text labels with client parameters
|
||||
|
|
|
@ -72,6 +72,9 @@ protected:
|
|||
virtual void showEvent ( QShowEvent* showEvent );
|
||||
virtual void hideEvent ( QHideEvent* hideEvent );
|
||||
|
||||
void UpdateSndBufInSlider ( const int iCurNumInBuf );
|
||||
void UpdateSndBufOutSlider ( const int iCurNumOutBuf );
|
||||
|
||||
public slots:
|
||||
void OnTimerStatus() { UpdateDisplay(); }
|
||||
void OnTimerPing();
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>552</width>
|
||||
<height>340</height>
|
||||
<width>544</width>
|
||||
<height>306</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
|
@ -722,8 +722,6 @@
|
|||
<property name="title" >
|
||||
<string>Misc</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" >
|
||||
<item>
|
||||
<layout class="QVBoxLayout" >
|
||||
<item>
|
||||
<widget class="QLabel" name="lSoundcard" >
|
||||
|
@ -748,8 +746,6 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBoxAudioCompressionType" >
|
||||
<property name="title" >
|
||||
|
@ -780,8 +776,6 @@
|
|||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" >
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cbOpenChatOnNewMessage" >
|
||||
<property name="text" >
|
||||
|
@ -789,8 +783,6 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
|
|
|
@ -66,6 +66,7 @@ short* psPlayBuffer;
|
|||
int iBufferPosPlay;
|
||||
bool bPlayBufferUnderrun;
|
||||
|
||||
int iMinNumSndBuf;
|
||||
int iCurNumSndBufIn;
|
||||
int iCurNumSndBufOut;
|
||||
int iNewNumSndBufIn;
|
||||
|
@ -164,18 +165,16 @@ bool CSound::Read ( CVector<short>& psData )
|
|||
void CSound::SetInNumBuf ( int iNewNum )
|
||||
{
|
||||
// check new parameter
|
||||
if ( ( iNewNum >= MAX_SND_BUF_IN ) || ( iNewNum < 1 ) )
|
||||
if ( ( iNewNum < MAX_SND_BUF_IN ) && ( iNewNum >= iMinNumSndBuf ) )
|
||||
{
|
||||
iNewNum = NUM_SOUND_BUFFERS_IN;
|
||||
}
|
||||
|
||||
// change only if parameter is different
|
||||
if ( iNewNum != iCurNumSndBufIn )
|
||||
if ( iNewNum != iNewNumSndBufIn )
|
||||
{
|
||||
iNewNumSndBufIn = iNewNum;
|
||||
bChangParamIn = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************\
|
||||
|
@ -232,18 +231,16 @@ bool CSound::Write ( CVector<short>& psData )
|
|||
void CSound::SetOutNumBuf ( int iNewNum )
|
||||
{
|
||||
// check new parameter
|
||||
if ( ( iNewNum >= MAX_SND_BUF_OUT ) || ( iNewNum < 1 ) )
|
||||
if ( ( iNewNum < MAX_SND_BUF_OUT ) && ( iNewNum >= iMinNumSndBuf ) )
|
||||
{
|
||||
iNewNum = NUM_SOUND_BUFFERS_OUT;
|
||||
}
|
||||
|
||||
// change only if parameter is different
|
||||
if ( iNewNum != iCurNumSndBufOut )
|
||||
if ( iNewNum != iNewNumSndBufOut )
|
||||
{
|
||||
iNewNumSndBufOut = iNewNum;
|
||||
bChangParamOut = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************\
|
||||
|
@ -480,6 +477,31 @@ std::string CSound::PrepareDriver()
|
|||
}
|
||||
}
|
||||
|
||||
// calculate the minimum required number of soundcard buffers
|
||||
iMinNumSndBuf = static_cast<int> (
|
||||
ceil ( static_cast<double> ( iASIOBufferSizeMono ) / iBufferSizeMono ) );
|
||||
|
||||
Q_ASSERT ( iMinNumSndBuf < MAX_SND_BUF_IN );
|
||||
Q_ASSERT ( iMinNumSndBuf < MAX_SND_BUF_OUT );
|
||||
|
||||
// correct number of sound card buffers if required
|
||||
iCurNumSndBufIn = max ( iMinNumSndBuf, iCurNumSndBufIn );
|
||||
iCurNumSndBufOut = max ( iMinNumSndBuf, iCurNumSndBufOut );
|
||||
iNewNumSndBufIn = iCurNumSndBufIn;
|
||||
iNewNumSndBufOut = iCurNumSndBufOut;
|
||||
|
||||
// display warning in case the ASIO buffer is too big
|
||||
if ( iMinNumSndBuf > 6 )
|
||||
{
|
||||
QMessageBox::critical ( 0, APP_NAME,
|
||||
QString ( "The ASIO buffer size of the selected audio driver is ") +
|
||||
QString().number ( iASIOBufferSizeMono ) +
|
||||
QString ( " samples which is too large. Please try to modify "
|
||||
"the ASIO buffer size value in your ASIO driver settings (most ASIO "
|
||||
"drivers like ASIO4All or kx allow to change the ASIO buffer size). "
|
||||
"Recommended settings are 96 or 128 samples." ), "Ok", 0 );
|
||||
}
|
||||
|
||||
// prepare input channels
|
||||
for ( i = 0; i < NUM_IN_OUT_CHANNELS; i++ )
|
||||
{
|
||||
|
@ -536,7 +558,6 @@ void CSound::InitRecordingAndPlayback()
|
|||
|
||||
ASIOMutex.lock(); // get mutex lock
|
||||
{
|
||||
// Our buffer management -----------------------------------------------
|
||||
// store new buffer number values
|
||||
iCurNumSndBufIn = iNewNumSndBufIn;
|
||||
iCurNumSndBufOut = iNewNumSndBufOut;
|
||||
|
@ -608,6 +629,7 @@ CSound::CSound ( const int iNewBufferSizeStereo )
|
|||
iCurNumSndBufIn = NUM_SOUND_BUFFERS_IN;
|
||||
iNewNumSndBufOut = NUM_SOUND_BUFFERS_OUT;
|
||||
iCurNumSndBufOut = NUM_SOUND_BUFFERS_OUT;
|
||||
iMinNumSndBuf = 1;
|
||||
|
||||
// should be initialized because an error can occur during init
|
||||
m_ASIOEvent = NULL;
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include <windows.h>
|
||||
#include <mmsystem.h>
|
||||
#include <string>
|
||||
#include <qmessagebox.h>
|
||||
#include "../src/util.h"
|
||||
#include "../src/global.h"
|
||||
|
||||
|
|
Loading…
Reference in a new issue