From 42243e51d733f183ec6b4d2c759c8fdb1d734ace Mon Sep 17 00:00:00 2001 From: Volker Fischer Date: Mon, 9 Mar 2009 22:52:28 +0000 Subject: [PATCH] some cleanup and a possible fix in Jack interface --- linux/sound.cpp | 20 +++++++++----------- src/channel.cpp | 8 ++++---- src/clientsettingsdlg.cpp | 31 ++++++++++--------------------- 3 files changed, 23 insertions(+), 36 deletions(-) diff --git a/linux/sound.cpp b/linux/sound.cpp index 46fc44b5..0bd7885f 100755 --- a/linux/sound.cpp +++ b/linux/sound.cpp @@ -37,7 +37,7 @@ if ( jack_get_sample_rate ( pJackClient ) != SND_CRD_SAMPLE_RATE ) "required one" ); } - // create four ports + // create four ports (two for input, two for output -> stereo) input_port_left = jack_port_register ( pJackClient, "input left", JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput, 0 ); input_port_right = jack_port_register ( pJackClient, "input right", @@ -137,9 +137,7 @@ int CSound::Init ( const int iNewPrefMonoBufferSize ) // create memory for intermediate audio buffer vecsTmpAudioSndCrdStereo.Init ( iJACKBufferSizeStero ); -// TEST -return iJACKBufferSizeMono; - + return iJACKBufferSizeMono; } @@ -159,11 +157,8 @@ int CSound::process ( jack_nframes_t nframes, void* arg ) // copy input data for ( i = 0; i < pSound->iJACKBufferSizeMono; i++ ) { - -// TODO better conversion from float to short - - pSound->vecsTmpAudioSndCrdStereo[2 * i] = (short) in_left[i]; - pSound->vecsTmpAudioSndCrdStereo[2 * i + 1] = (short) in_right[i]; + pSound->vecsTmpAudioSndCrdStereo[2 * i] = (short) ( in_left[i] * _MAXSHORT ); + pSound->vecsTmpAudioSndCrdStereo[2 * i + 1] = (short) ( in_right[i] * _MAXSHORT ); } // call processing callback function @@ -179,8 +174,11 @@ int CSound::process ( jack_nframes_t nframes, void* arg ) // copy output data for ( i = 0; i < pSound->iJACKBufferSizeMono; i++ ) { - out_left[i] = pSound->vecsTmpAudioSndCrdStereo[2 * i]; - out_right[i] = pSound->vecsTmpAudioSndCrdStereo[2 * i + 1]; + out_left[i] = (jack_default_audio_sample_t) + pSound->vecsTmpAudioSndCrdStereo[2 * i] / _MAXSHORT; + + out_right[i] = (jack_default_audio_sample_t) + pSound->vecsTmpAudioSndCrdStereo[2 * i + 1] / _MAXSHORT; } return 0; // zero on success, non-zero on error diff --git a/src/channel.cpp b/src/channel.cpp index ffa7c81b..f5e4f729 100755 --- a/src/channel.cpp +++ b/src/channel.cpp @@ -372,7 +372,7 @@ void CChannelSet::GetBlockAllConC ( CVector& vecChanID, CVector >& vecvecdGains ) { int i, j; - bool bCreateChanList = false; + bool bChannelIsNowDisconnected = false; // init temporal data vector and clear input buffers CVector vecdData ( MIN_SERVER_BLOCK_SIZE_SAMPLES ); @@ -396,7 +396,7 @@ void CChannelSet::GetBlockAllConC ( CVector& vecChanID, // client list is sent to all other clients if ( eGetStat == GS_CHAN_NOW_DISCONNECTED ) { - bCreateChanList = true; + bChannelIsNowDisconnected = true; } if ( vecChannels[i].IsConnected() ) @@ -435,12 +435,12 @@ void CChannelSet::GetBlockAllConC ( CVector& vecChanID, // the channel ID! Therefore we have to use "vecChanID" to // query the IDs of the currently connected channels vecvecdGains[i][j] = - vecChannels[ vecChanID[i] ].GetGain( vecChanID[j] ); + vecChannels[vecChanID[i]].GetGain( vecChanID[j] ); } } // create channel list message if requested - if ( bCreateChanList ) + if ( bChannelIsNowDisconnected ) { // update channel list for all currently connected clients CreateAndSendChanListForAllConChannels(); diff --git a/src/clientsettingsdlg.cpp b/src/clientsettingsdlg.cpp index dcee7e86..bc148155 100755 --- a/src/clientsettingsdlg.cpp +++ b/src/clientsettingsdlg.cpp @@ -139,8 +139,9 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, QWidget* parent, QObject::connect ( pClient, SIGNAL ( PingTimeReceived ( int ) ), this, SLOT ( OnPingTimeResult ( int ) ) ); - QObject::connect ( &AudioCompressionButtonGroup, SIGNAL ( buttonClicked ( QAbstractButton* ) ), - this, SLOT ( OnAudioCompressionButtonGroupClicked ( QAbstractButton* ) ) ); + QObject::connect ( &AudioCompressionButtonGroup, + SIGNAL ( buttonClicked ( QAbstractButton* ) ), this, + SLOT ( OnAudioCompressionButtonGroupClicked ( QAbstractButton* ) ) ); // Timers ------------------------------------------------------------------ @@ -222,7 +223,7 @@ void CClientSettingsDlg::OnSliderNetBuf ( int value ) void CClientSettingsDlg::OnSliderSndCrdBufferDelay ( int value ) { pClient->SetSndCrdPreferredMonoBlSizeIndex ( value ); - UpdateSoundCardFrame(); + UpdateDisplay(); } void CClientSettingsDlg::OnSoundCrdSelection ( int iSndDevIdx ) @@ -318,17 +319,18 @@ void CClientSettingsDlg::OnPingTimeResult ( int iPingTime ) else { TextLabelPingTime->setText ( QString().setNum ( iPingTime ) + " ms" ); - TextLabelOverallDelay->setText ( QString().setNum ( iOverallDelay ) + " ms" ); + TextLabelOverallDelay->setText ( + QString().setNum ( iOverallDelay ) + " ms" ); } - // color definition: < 40 ms green, < 60 ms yellow, otherwise red + // color definition: < 40 ms green, < 65 ms yellow, otherwise red if ( iOverallDelay <= 40 ) { CLEDOverallDelay->SetLight ( MUL_COL_LED_GREEN ); } else { - if ( iOverallDelay <= 60 ) + if ( iOverallDelay <= 65 ) { CLEDOverallDelay->SetLight ( MUL_COL_LED_YELLOW ); } @@ -355,7 +357,8 @@ void CClientSettingsDlg::UpdateDisplay() else { // update upstream rate information label (only if client is running) - TextUpstreamValue->setText ( QString().setNum ( pClient->GetUploadRateKbps() ) + " kbps" ); + TextUpstreamValue->setText ( + QString().setNum ( pClient->GetUploadRateKbps() ) + " kbps" ); } } @@ -363,16 +366,6 @@ void CClientSettingsDlg::SetStatus ( const int iMessType, const int iStatus ) { switch ( iMessType ) { -/* - case MS_SOUND_IN: - CLEDSoundIn->SetLight ( iStatus ); - break; - - case MS_SOUND_OUT: - CLEDSoundOut->SetLight ( iStatus ); - break; -*/ - case MS_JIT_BUF_PUT: case MS_JIT_BUF_GET: // network LED shows combined status of put and get @@ -380,10 +373,6 @@ void CClientSettingsDlg::SetStatus ( const int iMessType, const int iStatus ) break; case MS_RESET_ALL: -/* - CLEDSoundIn->Reset(); - CLEDSoundOut->Reset(); -*/ CLEDNetw->Reset(); break; }