some more GUI work

This commit is contained in:
Volker Fischer 2009-08-02 19:18:19 +00:00
parent 9eb7bb9e1f
commit 22713c9c7a
4 changed files with 33 additions and 39 deletions

View file

@ -36,7 +36,7 @@ CClient::CClient ( const quint16 iPortNumber ) :
vstrIPAddress ( MAX_NUM_SERVER_ADDR_ITEMS, "" ), strName ( "" ), vstrIPAddress ( MAX_NUM_SERVER_ADDR_ITEMS, "" ), strName ( "" ),
bOpenChatOnNewMessage ( true ), bOpenChatOnNewMessage ( true ),
bDoAutoSockBufSize ( true ), bDoAutoSockBufSize ( true ),
iSndCrdPreferredMonoBlSizeIndex ( FRAME_SIZE_FACTOR_DEFAULT ) iSndCrdPrefMonoFrameSizeFactor ( FRAME_SIZE_FACTOR_DEFAULT )
{ {
// connection for protocol // connection for protocol
QObject::connect ( &Channel, QObject::connect ( &Channel,
@ -145,14 +145,14 @@ bool CClient::SetServerAddr ( QString strNAddr )
return true; return true;
} }
void CClient::SetSndCrdPreferredMonoBlSizeIndex ( const int iNewIdx ) void CClient::SetSndCrdPrefMonoFrameSizeFactor ( const int iNewFactor )
{ {
// right now we simply set the internal value // right now we simply set the internal value
if ( ( iNewIdx == FRAME_SIZE_FACTOR_PREFERRED ) || if ( ( iNewFactor == FRAME_SIZE_FACTOR_PREFERRED ) ||
( iNewIdx == FRAME_SIZE_FACTOR_DEFAULT ) || ( iNewFactor == FRAME_SIZE_FACTOR_DEFAULT ) ||
( iNewIdx == FRAME_SIZE_FACTOR_SAFE ) ) ( iNewFactor == FRAME_SIZE_FACTOR_SAFE ) )
{ {
iSndCrdPreferredMonoBlSizeIndex = iNewIdx; iSndCrdPrefMonoFrameSizeFactor = iNewFactor;
// init with new parameter, if client was running then first // init with new parameter, if client was running then first
// stop it and restart again after new initialization // stop it and restart again after new initialization
@ -163,7 +163,7 @@ void CClient::SetSndCrdPreferredMonoBlSizeIndex ( const int iNewIdx )
} }
// init with new block size index parameter // init with new block size index parameter
Init ( iSndCrdPreferredMonoBlSizeIndex ); Init();
if ( bWasRunning ) if ( bWasRunning )
{ {
@ -186,7 +186,7 @@ QString CClient::SetSndCrdDev ( const int iNewDev )
// init again because the sound card actual buffer size might // init again because the sound card actual buffer size might
// be changed on new device // be changed on new device
Init ( iSndCrdPreferredMonoBlSizeIndex ); Init();
if ( bWasRunning ) if ( bWasRunning )
{ {
@ -209,7 +209,7 @@ void CClient::OnSndCrdReinitRequest()
// reinit the driver (we use the currently selected driver) and // reinit the driver (we use the currently selected driver) and
// init client object, too // init client object, too
Sound.SetDev ( Sound.GetDev() ); Sound.SetDev ( Sound.GetDev() );
Init ( iSndCrdPreferredMonoBlSizeIndex ); Init();
if ( bWasRunning ) if ( bWasRunning )
{ {
@ -220,7 +220,7 @@ void CClient::OnSndCrdReinitRequest()
void CClient::Start() void CClient::Start()
{ {
// init object // init object
Init ( iSndCrdPreferredMonoBlSizeIndex ); Init();
// enable channel // enable channel
Channel.SetEnable ( true ); Channel.SetEnable ( true );
@ -258,14 +258,14 @@ void CClient::AudioCallback ( CVector<int16_t>& psData, void* arg )
pMyClientObj->ProcessAudioData ( psData ); pMyClientObj->ProcessAudioData ( psData );
} }
void CClient::Init ( const int iPrefMonoBlockSizeSamIndexAtSndCrdSamRate ) void CClient::Init()
{ {
// translate block size index in actual block size // translate block size index in actual block size
const int iPrefMonoBlockSizeSamAtSndCrdSamRate = const int iPrefMonoFrameSize =
iPrefMonoBlockSizeSamIndexAtSndCrdSamRate * SYSTEM_BLOCK_FRAME_SAMPLES; iSndCrdPrefMonoFrameSizeFactor * SYSTEM_BLOCK_FRAME_SAMPLES;
// get actual sound card buffer size using preferred size // get actual sound card buffer size using preferred size
iMonoBlockSizeSam = Sound.Init ( iPrefMonoBlockSizeSamAtSndCrdSamRate ); iMonoBlockSizeSam = Sound.Init ( iPrefMonoFrameSize );
iStereoBlockSizeSam = 2 * iMonoBlockSizeSam; iStereoBlockSizeSam = 2 * iMonoBlockSizeSam;
vecsAudioSndCrdStereo.Init ( iStereoBlockSizeSam ); vecsAudioSndCrdStereo.Init ( iStereoBlockSizeSam );
@ -299,11 +299,8 @@ void CClient::Init ( const int iPrefMonoBlockSizeSamIndexAtSndCrdSamRate )
vecbyNetwData.Init ( iCeltNumCodedBytes ); vecbyNetwData.Init ( iCeltNumCodedBytes );
// set the channel network properties // set the channel network properties
// TEST right now we only support 128 samples, later 256 and 512, too
Channel.SetNetwFrameSizeAndFact ( iCeltNumCodedBytes, Channel.SetNetwFrameSizeAndFact ( iCeltNumCodedBytes,
1 ); // TEST "1" iSndCrdPrefMonoFrameSizeFactor );
} }
void CClient::ProcessAudioData ( CVector<int16_t>& vecsStereoSndCrd ) void CClient::ProcessAudioData ( CVector<int16_t>& vecsStereoSndCrd )

View file

@ -119,9 +119,9 @@ public:
int GetSndCrdDev() { return Sound.GetDev(); } int GetSndCrdDev() { return Sound.GetDev(); }
void OpenSndCrdDriverSetup() { Sound.OpenDriverSetup(); } void OpenSndCrdDriverSetup() { Sound.OpenDriverSetup(); }
void SetSndCrdPreferredMonoBlSizeIndex ( const int iNewIdx ); void SetSndCrdPrefMonoFrameSizeFactor ( const int iNewFactor );
int GetSndCrdPreferredMonoBlSizeIndex() int GetSndCrdPrefMonoFrameSizeFactor()
{ return iSndCrdPreferredMonoBlSizeIndex; } { return iSndCrdPrefMonoFrameSizeFactor; }
int GetSndCrdActualMonoBlSize() { return iMonoBlockSizeSam; } int GetSndCrdActualMonoBlSize() { return iMonoBlockSizeSam; }
void SetRemoteChanGain ( const int iId, const double dGain ) void SetRemoteChanGain ( const int iId, const double dGain )
@ -146,7 +146,7 @@ protected:
// callback function must be static, otherwise it does not work // callback function must be static, otherwise it does not work
static void AudioCallback ( CVector<short>& psData, void* arg ); static void AudioCallback ( CVector<short>& psData, void* arg );
void Init ( const int iPrefMonoBlockSizeSamIndexAtSndCrdSamRate ); void Init();
void ProcessAudioData ( CVector<short>& vecsStereoSndCrd ); void ProcessAudioData ( CVector<short>& vecsStereoSndCrd );
void UpdateSocketBufferSize(); void UpdateSocketBufferSize();
@ -172,7 +172,7 @@ protected:
int iReverbLevel; int iReverbLevel;
CAudioReverb AudioReverb; CAudioReverb AudioReverb;
int iSndCrdPreferredMonoBlSizeIndex; int iSndCrdPrefMonoFrameSizeFactor;
int iMonoBlockSizeSam; int iMonoBlockSizeSam;
int iStereoBlockSizeSam; int iStereoBlockSizeSam;

View file

@ -95,23 +95,21 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, QWidget* parent,
rButBufferDelaySafe->setText ( GenSndCrdBufferDelayString ( rButBufferDelaySafe->setText ( GenSndCrdBufferDelayString (
FRAME_SIZE_FACTOR_SAFE * SYSTEM_BLOCK_FRAME_SAMPLES ) ); FRAME_SIZE_FACTOR_SAFE * SYSTEM_BLOCK_FRAME_SAMPLES ) );
/*
// sound card buffer delay // sound card buffer delay
switch ( pClient->[]() ) switch ( pClient->GetSndCrdPrefMonoFrameSizeFactor() )
{ {
case CT_NONE: case FRAME_SIZE_FACTOR_PREFERRED:
rButBufferDelayPreferred->setChecked ( true ); rButBufferDelayPreferred->setChecked ( true );
break; break;
case CT_IMAADPCM: case FRAME_SIZE_FACTOR_DEFAULT:
rButBufferDelayDefault->setChecked ( true ); rButBufferDelayDefault->setChecked ( true );
break; break;
case CT_MSADPCM: case FRAME_SIZE_FACTOR_SAFE:
rButBufferDelaySafe->setChecked ( true ); rButBufferDelaySafe->setChecked ( true );
break; break;
} }
*/
SndCrdBufferDelayButtonGroup.addButton ( rButBufferDelayPreferred ); SndCrdBufferDelayButtonGroup.addButton ( rButBufferDelayPreferred );
SndCrdBufferDelayButtonGroup.addButton ( rButBufferDelayDefault ); SndCrdBufferDelayButtonGroup.addButton ( rButBufferDelayDefault );
SndCrdBufferDelayButtonGroup.addButton ( rButBufferDelaySafe ); SndCrdBufferDelayButtonGroup.addButton ( rButBufferDelaySafe );
@ -182,7 +180,7 @@ QString CClientSettingsDlg::GenSndCrdBufferDelayString ( const int iFrameSize,
void CClientSettingsDlg::UpdateSoundCardFrame() void CClientSettingsDlg::UpdateSoundCardFrame()
{ {
// update slider value and text // update slider value and text
const int iCurPrefBufIdx = pClient->GetSndCrdPreferredMonoBlSizeIndex(); const int iCurPrefBufIdx = pClient->GetSndCrdPrefMonoFrameSizeFactor();
const int iCurActualBufSize = pClient->GetSndCrdActualMonoBlSize(); const int iCurActualBufSize = pClient->GetSndCrdActualMonoBlSize();
/* /*
@ -235,7 +233,7 @@ void CClientSettingsDlg::OnSliderNetBuf ( int value )
void CClientSettingsDlg::OnSliderSndCrdBufferDelay ( int value ) void CClientSettingsDlg::OnSliderSndCrdBufferDelay ( int value )
{ {
pClient->SetSndCrdPreferredMonoBlSizeIndex ( value ); pClient->SetSndCrdPrefMonoFrameSizeFactor ( value );
UpdateDisplay(); UpdateDisplay();
} }
@ -270,22 +268,21 @@ void CClientSettingsDlg::OnOpenChatOnNewMessageStateChanged ( int value )
void CClientSettingsDlg::OnSndCrdBufferDelayButtonGroupClicked ( QAbstractButton* button ) void CClientSettingsDlg::OnSndCrdBufferDelayButtonGroupClicked ( QAbstractButton* button )
{ {
/*
if ( button == rButBufferDelayPreferred ) if ( button == rButBufferDelayPreferred )
{ {
pClient->SetAudioCompressionOut ( CT_NONE ); pClient->SetSndCrdPrefMonoFrameSizeFactor ( FRAME_SIZE_FACTOR_PREFERRED );
} }
if ( button == rButBufferDelayDefault ) if ( button == rButBufferDelayDefault )
{ {
pClient->SetAudioCompressionOut ( CT_IMAADPCM ); pClient->SetSndCrdPrefMonoFrameSizeFactor ( FRAME_SIZE_FACTOR_DEFAULT );
} }
if ( button == rButBufferDelaySafe ) if ( button == rButBufferDelaySafe )
{ {
pClient->SetAudioCompressionOut ( CT_MSADPCM ); pClient->SetSndCrdPrefMonoFrameSizeFactor ( FRAME_SIZE_FACTOR_SAFE );
} }
*/
UpdateDisplay(); UpdateDisplay();
} }

View file

@ -118,7 +118,7 @@ void CSettings::ReadIniFile ( const QString& sFileName )
( iValue == FRAME_SIZE_FACTOR_DEFAULT ) || ( iValue == FRAME_SIZE_FACTOR_DEFAULT ) ||
( iValue == FRAME_SIZE_FACTOR_SAFE ) ) ( iValue == FRAME_SIZE_FACTOR_SAFE ) )
{ {
pClient->SetSndCrdPreferredMonoBlSizeIndex ( iValue ); pClient->SetSndCrdPrefMonoFrameSizeFactor ( iValue );
} }
} }
@ -179,7 +179,7 @@ void CSettings::WriteIniFile ( const QString& sFileName )
// sound card preferred buffer size index // sound card preferred buffer size index
SetNumericIniSet ( IniXMLDocument, "client", "prefsndcrdbufidx", SetNumericIniSet ( IniXMLDocument, "client", "prefsndcrdbufidx",
pClient->GetSndCrdPreferredMonoBlSizeIndex() ); pClient->GetSndCrdPrefMonoFrameSizeFactor() );
// automatic network jitter buffer size setting // automatic network jitter buffer size setting
SetFlagIniSet ( IniXMLDocument, "client", "autojitbuf", SetFlagIniSet ( IniXMLDocument, "client", "autojitbuf",