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
|
#else
|
||||||
SliderSndBufIn->setRange ( 2, AUD_SLIDER_LENGTH );
|
SliderSndBufIn->setRange ( 2, AUD_SLIDER_LENGTH );
|
||||||
#endif
|
#endif
|
||||||
const int iCurNumInBuf = pClient->GetSndInterface()->GetInNumBuf();
|
UpdateSndBufInSlider ( pClient->GetSndInterface()->GetInNumBuf() );
|
||||||
SliderSndBufIn->setValue ( iCurNumInBuf );
|
|
||||||
TextSndBufIn->setText ( "In: " + QString().setNum ( iCurNumInBuf ) );
|
|
||||||
|
|
||||||
// sound buffer out
|
// sound buffer out
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
@ -81,9 +79,7 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, QWidget* parent,
|
||||||
#else
|
#else
|
||||||
SliderSndBufOut->setRange ( 2, AUD_SLIDER_LENGTH );
|
SliderSndBufOut->setRange ( 2, AUD_SLIDER_LENGTH );
|
||||||
#endif
|
#endif
|
||||||
const int iCurNumOutBuf = pClient->GetSndInterface()->GetOutNumBuf();
|
UpdateSndBufOutSlider ( pClient->GetSndInterface()->GetOutNumBuf() );
|
||||||
SliderSndBufOut->setValue ( iCurNumOutBuf );
|
|
||||||
TextSndBufOut->setText ( "Out: " + QString().setNum ( iCurNumOutBuf ) );
|
|
||||||
|
|
||||||
// network buffer
|
// network buffer
|
||||||
SliderNetBuf->setRange ( 0, MAX_NET_BUF_SIZE_NUM_BL );
|
SliderNetBuf->setRange ( 0, MAX_NET_BUF_SIZE_NUM_BL );
|
||||||
|
@ -188,6 +184,18 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, QWidget* parent,
|
||||||
TimerStatus.start ( DISPLAY_UPDATE_TIME );
|
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 )
|
void CClientSettingsDlg::showEvent ( QShowEvent* showEvent )
|
||||||
{
|
{
|
||||||
// only activate ping timer if window is actually shown
|
// only activate ping timer if window is actually shown
|
||||||
|
@ -255,6 +263,7 @@ void CClientSettingsDlg::OnSoundCrdSelection ( int iSndDevIdx )
|
||||||
// recover old selection
|
// recover old selection
|
||||||
cbSoundcard->setCurrentIndex ( pClient->GetSndInterface()->GetDev() );
|
cbSoundcard->setCurrentIndex ( pClient->GetSndInterface()->GetDev() );
|
||||||
}
|
}
|
||||||
|
UpdateDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CClientSettingsDlg::OnOpenChatOnNewMessageStateChanged ( int value )
|
void CClientSettingsDlg::OnOpenChatOnNewMessageStateChanged ( int value )
|
||||||
|
@ -338,6 +347,10 @@ void CClientSettingsDlg::OnPingTimeResult ( int iPingTime )
|
||||||
|
|
||||||
void CClientSettingsDlg::UpdateDisplay()
|
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() )
|
if ( !pClient->IsRunning() )
|
||||||
{
|
{
|
||||||
// clear text labels with client parameters
|
// clear text labels with client parameters
|
||||||
|
|
|
@ -72,6 +72,9 @@ protected:
|
||||||
virtual void showEvent ( QShowEvent* showEvent );
|
virtual void showEvent ( QShowEvent* showEvent );
|
||||||
virtual void hideEvent ( QHideEvent* hideEvent );
|
virtual void hideEvent ( QHideEvent* hideEvent );
|
||||||
|
|
||||||
|
void UpdateSndBufInSlider ( const int iCurNumInBuf );
|
||||||
|
void UpdateSndBufOutSlider ( const int iCurNumOutBuf );
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void OnTimerStatus() { UpdateDisplay(); }
|
void OnTimerStatus() { UpdateDisplay(); }
|
||||||
void OnTimerPing();
|
void OnTimerPing();
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>552</width>
|
<width>544</width>
|
||||||
<height>340</height>
|
<height>306</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle" >
|
<property name="windowTitle" >
|
||||||
|
@ -724,31 +724,27 @@
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" >
|
<layout class="QVBoxLayout" >
|
||||||
<item>
|
<item>
|
||||||
<layout class="QVBoxLayout" >
|
<widget class="QLabel" name="lSoundcard" >
|
||||||
<item>
|
<property name="text" >
|
||||||
<widget class="QLabel" name="lSoundcard" >
|
<string>Soundcard</string>
|
||||||
<property name="text" >
|
</property>
|
||||||
<string>Soundcard</string>
|
</widget>
|
||||||
</property>
|
</item>
|
||||||
</widget>
|
<item>
|
||||||
</item>
|
<widget class="QComboBox" name="cbSoundcard" >
|
||||||
<item>
|
<property name="sizePolicy" >
|
||||||
<widget class="QComboBox" name="cbSoundcard" >
|
<sizepolicy vsizetype="Fixed" hsizetype="Minimum" >
|
||||||
<property name="sizePolicy" >
|
<horstretch>0</horstretch>
|
||||||
<sizepolicy vsizetype="Fixed" hsizetype="Minimum" >
|
<verstretch>0</verstretch>
|
||||||
<horstretch>0</horstretch>
|
</sizepolicy>
|
||||||
<verstretch>0</verstretch>
|
</property>
|
||||||
</sizepolicy>
|
<property name="minimumSize" >
|
||||||
</property>
|
<size>
|
||||||
<property name="minimumSize" >
|
<width>153</width>
|
||||||
<size>
|
<height>0</height>
|
||||||
<width>153</width>
|
</size>
|
||||||
<height>0</height>
|
</property>
|
||||||
</size>
|
</widget>
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="groupBoxAudioCompressionType" >
|
<widget class="QGroupBox" name="groupBoxAudioCompressionType" >
|
||||||
|
@ -781,15 +777,11 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" >
|
<widget class="QCheckBox" name="cbOpenChatOnNewMessage" >
|
||||||
<item>
|
<property name="text" >
|
||||||
<widget class="QCheckBox" name="cbOpenChatOnNewMessage" >
|
<string>Open chat on new message</string>
|
||||||
<property name="text" >
|
</property>
|
||||||
<string>Open chat on new message</string>
|
</widget>
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer>
|
<spacer>
|
||||||
|
|
|
@ -66,6 +66,7 @@ short* psPlayBuffer;
|
||||||
int iBufferPosPlay;
|
int iBufferPosPlay;
|
||||||
bool bPlayBufferUnderrun;
|
bool bPlayBufferUnderrun;
|
||||||
|
|
||||||
|
int iMinNumSndBuf;
|
||||||
int iCurNumSndBufIn;
|
int iCurNumSndBufIn;
|
||||||
int iCurNumSndBufOut;
|
int iCurNumSndBufOut;
|
||||||
int iNewNumSndBufIn;
|
int iNewNumSndBufIn;
|
||||||
|
@ -164,16 +165,14 @@ bool CSound::Read ( CVector<short>& psData )
|
||||||
void CSound::SetInNumBuf ( int iNewNum )
|
void CSound::SetInNumBuf ( int iNewNum )
|
||||||
{
|
{
|
||||||
// check new parameter
|
// 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 != iNewNumSndBufIn )
|
||||||
|
{
|
||||||
// change only if parameter is different
|
iNewNumSndBufIn = iNewNum;
|
||||||
if ( iNewNum != iCurNumSndBufIn )
|
bChangParamIn = true;
|
||||||
{
|
}
|
||||||
iNewNumSndBufIn = iNewNum;
|
|
||||||
bChangParamIn = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -232,16 +231,14 @@ bool CSound::Write ( CVector<short>& psData )
|
||||||
void CSound::SetOutNumBuf ( int iNewNum )
|
void CSound::SetOutNumBuf ( int iNewNum )
|
||||||
{
|
{
|
||||||
// check new parameter
|
// 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 != iNewNumSndBufOut )
|
||||||
|
{
|
||||||
// change only if parameter is different
|
iNewNumSndBufOut = iNewNum;
|
||||||
if ( iNewNum != iCurNumSndBufOut )
|
bChangParamOut = true;
|
||||||
{
|
}
|
||||||
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
|
// prepare input channels
|
||||||
for ( i = 0; i < NUM_IN_OUT_CHANNELS; i++ )
|
for ( i = 0; i < NUM_IN_OUT_CHANNELS; i++ )
|
||||||
{
|
{
|
||||||
|
@ -536,7 +558,6 @@ void CSound::InitRecordingAndPlayback()
|
||||||
|
|
||||||
ASIOMutex.lock(); // get mutex lock
|
ASIOMutex.lock(); // get mutex lock
|
||||||
{
|
{
|
||||||
// Our buffer management -----------------------------------------------
|
|
||||||
// store new buffer number values
|
// store new buffer number values
|
||||||
iCurNumSndBufIn = iNewNumSndBufIn;
|
iCurNumSndBufIn = iNewNumSndBufIn;
|
||||||
iCurNumSndBufOut = iNewNumSndBufOut;
|
iCurNumSndBufOut = iNewNumSndBufOut;
|
||||||
|
@ -608,6 +629,7 @@ CSound::CSound ( const int iNewBufferSizeStereo )
|
||||||
iCurNumSndBufIn = NUM_SOUND_BUFFERS_IN;
|
iCurNumSndBufIn = NUM_SOUND_BUFFERS_IN;
|
||||||
iNewNumSndBufOut = NUM_SOUND_BUFFERS_OUT;
|
iNewNumSndBufOut = NUM_SOUND_BUFFERS_OUT;
|
||||||
iCurNumSndBufOut = NUM_SOUND_BUFFERS_OUT;
|
iCurNumSndBufOut = NUM_SOUND_BUFFERS_OUT;
|
||||||
|
iMinNumSndBuf = 1;
|
||||||
|
|
||||||
// should be initialized because an error can occur during init
|
// should be initialized because an error can occur during init
|
||||||
m_ASIOEvent = NULL;
|
m_ASIOEvent = NULL;
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <mmsystem.h>
|
#include <mmsystem.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <qmessagebox.h>
|
||||||
#include "../src/util.h"
|
#include "../src/util.h"
|
||||||
#include "../src/global.h"
|
#include "../src/global.h"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue