change the mechanism of how the LEDs are updated -> no window event posts anymore to avoid blocking in the critical audio thread
This commit is contained in:
parent
e9a5962ef1
commit
6e49e4e92c
16 changed files with 144 additions and 365 deletions
|
@ -58,6 +58,7 @@ CClient::CClient ( const quint16 iPortNumber ) :
|
|||
bFraSiFactSafeSupported ( false ),
|
||||
bOpenChatOnNewMessage ( true ),
|
||||
eGUIDesign ( GD_ORIGINAL ),
|
||||
bJitterBufferOK ( true ),
|
||||
strCentralServerAddress ( "" ),
|
||||
bUseDefaultCentralServerAddress ( true ),
|
||||
iServerSockBufNumFrames ( DEF_NET_BUF_SIZE_NUM_BL )
|
||||
|
@ -367,6 +368,29 @@ bool CClient::SetServerAddr ( QString strNAddr )
|
|||
}
|
||||
}
|
||||
|
||||
bool CClient::GetAndResetbJitterBufferOKFlag()
|
||||
{
|
||||
// get the socket buffer put status flag and reset it
|
||||
const bool bSocketJitBufOKFlag = Socket.GetAndResetbJitterBufferOKFlag();
|
||||
|
||||
if ( !bJitterBufferOK )
|
||||
{
|
||||
// our jitter buffer get status is not OK so the overall status of the
|
||||
// jitter buffer is also not OK (we do not have to consider the status
|
||||
// of the socket buffer put status flag)
|
||||
|
||||
// reset flag before returning the function
|
||||
bJitterBufferOK = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
// the jitter buffer get (our own status flag) is OK, the final status
|
||||
// now depends on the jitter buffer put status flag from the socket
|
||||
// since per definition the jitter buffer status is OK if both the
|
||||
// put and get status are OK
|
||||
return bSocketJitBufOKFlag;
|
||||
}
|
||||
|
||||
void CClient::SetSndCrdPrefFrameSizeFactor ( const int iNewFactor )
|
||||
{
|
||||
// first check new input parameter
|
||||
|
@ -659,8 +683,8 @@ void CClient::Stop()
|
|||
ConnLessProtocol.CreateCLDisconnection ( Channel.GetAddress() );
|
||||
|
||||
// reset current signal level and LEDs
|
||||
bJitterBufferOK = true;
|
||||
SignalLevelMeter.Reset();
|
||||
PostWinMessage ( MS_RESET_ALL, 0 );
|
||||
}
|
||||
|
||||
void CClient::Init()
|
||||
|
@ -854,7 +878,7 @@ void CClient::Init()
|
|||
void CClient::AudioCallback ( CVector<int16_t>& psData, void* arg )
|
||||
{
|
||||
// get the pointer to the object
|
||||
CClient* pMyClientObj = reinterpret_cast<CClient*> ( arg );
|
||||
CClient* pMyClientObj = static_cast<CClient*> ( arg );
|
||||
|
||||
// process audio data
|
||||
pMyClientObj->ProcessSndCrdAudioData ( psData );
|
||||
|
@ -1080,13 +1104,10 @@ void CClient::ProcessAudioDataIntern ( CVector<int16_t>& vecsStereoSndCrd )
|
|||
const bool bReceiveDataOk =
|
||||
( Channel.GetData ( vecbyNetwData ) == GS_BUFFER_OK );
|
||||
|
||||
if ( bReceiveDataOk )
|
||||
// invalidate the buffer OK status flag if necessary
|
||||
if ( !bReceiveDataOk )
|
||||
{
|
||||
PostWinMessage ( MS_JIT_BUF_GET, MUL_COL_LED_GREEN );
|
||||
}
|
||||
else
|
||||
{
|
||||
PostWinMessage ( MS_JIT_BUF_GET, MUL_COL_LED_RED );
|
||||
bJitterBufferOK = false;
|
||||
}
|
||||
|
||||
// CELT decoding
|
||||
|
|
|
@ -108,8 +108,12 @@ public:
|
|||
void Stop();
|
||||
bool IsRunning() { return Sound.IsRunning(); }
|
||||
bool SetServerAddr ( QString strNAddr );
|
||||
|
||||
double MicLevelL() { return SignalLevelMeter.MicLevelLeft(); }
|
||||
double MicLevelR() { return SignalLevelMeter.MicLevelRight(); }
|
||||
|
||||
bool GetAndResetbJitterBufferOKFlag();
|
||||
|
||||
bool IsConnected() { return Channel.IsConnected(); }
|
||||
|
||||
bool GetOpenChatOnNewMessage() const { return bOpenChatOnNewMessage; }
|
||||
|
@ -353,6 +357,8 @@ void SetAudoCompressiontype ( const EAudComprType eNAudCompressionType );
|
|||
bool bOpenChatOnNewMessage;
|
||||
EGUIDesign eGUIDesign;
|
||||
|
||||
bool bJitterBufferOK;
|
||||
|
||||
QString strCentralServerAddress;
|
||||
bool bUseDefaultCentralServerAddress;
|
||||
|
||||
|
|
|
@ -254,10 +254,10 @@ CClientDlg::CClientDlg ( CClient* pNCliP,
|
|||
lbrInputLevelR->setValue ( 0 );
|
||||
|
||||
// init status LEDs
|
||||
ledConnection->SetUpdateTime ( 2 * LED_BAR_UPDATE_TIME_MS );
|
||||
ledChat->SetUpdateTime ( 2 * LED_BAR_UPDATE_TIME_MS );
|
||||
ledDelay->SetUpdateTime ( 2 * PING_UPDATE_TIME_MS );
|
||||
ledConnection->Reset();
|
||||
ledBuffers->Reset();
|
||||
ledDelay->Reset();
|
||||
ledChat->Reset();
|
||||
|
||||
|
||||
// init slider controls ---
|
||||
|
@ -435,6 +435,9 @@ CClientDlg::CClientDlg ( CClient* pNCliP,
|
|||
QObject::connect ( &TimerSigMet, SIGNAL ( timeout() ),
|
||||
this, SLOT ( OnTimerSigMet() ) );
|
||||
|
||||
QObject::connect ( &TimerBuffersLED, SIGNAL ( timeout() ),
|
||||
this, SLOT ( OnTimerBuffersLED() ) );
|
||||
|
||||
QObject::connect ( &TimerStatus, SIGNAL ( timeout() ),
|
||||
this, SLOT ( OnTimerStatus() ) );
|
||||
|
||||
|
@ -903,6 +906,25 @@ void CClientDlg::OnTimerSigMet()
|
|||
lbrInputLevelR->setValue ( (int) ceil ( dCurSigLevelR ) );
|
||||
}
|
||||
|
||||
void CClientDlg::OnTimerBuffersLED()
|
||||
{
|
||||
int iCurStatus;
|
||||
|
||||
// get and reset current buffer state and set LED from that flag
|
||||
if ( pClient->GetAndResetbJitterBufferOKFlag() )
|
||||
{
|
||||
iCurStatus = MUL_COL_LED_GREEN;
|
||||
}
|
||||
else
|
||||
{
|
||||
iCurStatus = MUL_COL_LED_RED;
|
||||
}
|
||||
|
||||
// update the buffer LED and the general settings dialog, too
|
||||
ledBuffers->SetLight ( iCurStatus );
|
||||
ClientSettingsDlg.SetStatus ( iCurStatus );
|
||||
}
|
||||
|
||||
void CClientDlg::OnTimerPing()
|
||||
{
|
||||
// send ping message to the server
|
||||
|
@ -1005,6 +1027,7 @@ void CClientDlg::Connect ( const QString& strSelectedAddress,
|
|||
|
||||
// start timer for level meter bar and ping time measurement
|
||||
TimerSigMet.start ( LEVELMETER_UPDATE_TIME_MS );
|
||||
TimerBuffersLED.start ( BUFFER_LED_UPDATE_TIME_MS );
|
||||
TimerPing.start ( PING_UPDATE_TIME_MS );
|
||||
}
|
||||
else
|
||||
|
@ -1036,7 +1059,8 @@ void CClientDlg::Disconnect()
|
|||
lbrInputLevelL->setValue ( 0 );
|
||||
lbrInputLevelR->setValue ( 0 );
|
||||
|
||||
// stop ping time measurement timer
|
||||
// stop other timers
|
||||
TimerBuffersLED.stop();
|
||||
TimerPing.stop();
|
||||
|
||||
|
||||
|
@ -1044,13 +1068,13 @@ void CClientDlg::Disconnect()
|
|||
// immediately update status bar
|
||||
OnTimerStatus();
|
||||
|
||||
// TODO this seems not to work, LEDs are still updated afterwards...
|
||||
// reset LEDs
|
||||
ledConnection->Reset();
|
||||
ledBuffers->Reset();
|
||||
ledDelay->Reset();
|
||||
ledChat->Reset();
|
||||
|
||||
// reset LEDs
|
||||
ledConnection->Reset();
|
||||
ledBuffers->Reset();
|
||||
ledDelay->Reset();
|
||||
ledChat->Reset();
|
||||
ClientSettingsDlg.ResetStatus();
|
||||
|
||||
// clear mixer board (remove all faders)
|
||||
MainMixerBoard->HideAll();
|
||||
|
@ -1168,31 +1192,3 @@ rbtReverbSelR->setStyleSheet ( "" );
|
|||
// also apply GUI design to child GUI controls
|
||||
MainMixerBoard->SetGUIDesign ( eNewDesign );
|
||||
}
|
||||
|
||||
void CClientDlg::customEvent ( QEvent* Event )
|
||||
{
|
||||
if ( Event->type() == QEvent::User + 11 )
|
||||
{
|
||||
const int iMessType = ( (CCustomEvent*) Event )->iMessType;
|
||||
const int iStatus = ( (CCustomEvent*) Event )->iStatus;
|
||||
|
||||
switch ( iMessType )
|
||||
{
|
||||
case MS_JIT_BUF_PUT:
|
||||
case MS_JIT_BUF_GET:
|
||||
// buffer status -> if any buffer goes red, this LED will go red
|
||||
ledBuffers->SetLight ( iStatus );
|
||||
break;
|
||||
|
||||
case MS_RESET_ALL:
|
||||
ledConnection->Reset();
|
||||
ledBuffers->Reset();
|
||||
ledDelay->Reset();
|
||||
ledChat->Reset();
|
||||
break;
|
||||
}
|
||||
|
||||
// update general settings dialog, too
|
||||
ClientSettingsDlg.SetStatus ( iMessType, iStatus );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,6 +52,7 @@
|
|||
|
||||
// update time for GUI controls
|
||||
#define LEVELMETER_UPDATE_TIME_MS 100 // ms
|
||||
#define BUFFER_LED_UPDATE_TIME_MS 300 // ms
|
||||
#define LED_BAR_UPDATE_TIME_MS 1000 // ms
|
||||
|
||||
// range for signal level meter
|
||||
|
@ -96,10 +97,10 @@ protected:
|
|||
bool bConnected;
|
||||
bool bUnreadChatMessage;
|
||||
QTimer TimerSigMet;
|
||||
QTimer TimerBuffersLED;
|
||||
QTimer TimerStatus;
|
||||
QTimer TimerPing;
|
||||
|
||||
virtual void customEvent ( QEvent* Event );
|
||||
virtual void closeEvent ( QCloseEvent* Event );
|
||||
void UpdateDisplay();
|
||||
|
||||
|
@ -118,6 +119,7 @@ public slots:
|
|||
void OnConnectDisconBut();
|
||||
void OnInstPictureBut();
|
||||
void OnTimerSigMet();
|
||||
void OnTimerBuffersLED();
|
||||
|
||||
void OnTimerStatus() { UpdateDisplay(); }
|
||||
|
||||
|
|
|
@ -269,7 +269,7 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, QWidget* parent,
|
|||
#endif
|
||||
|
||||
// init delay and other information controls
|
||||
ledOverallDelay->SetUpdateTime ( 2 * PING_UPDATE_TIME_MS );
|
||||
ledNetw->Reset();
|
||||
ledOverallDelay->Reset();
|
||||
lblPingTimeValue->setText ( "---" );
|
||||
lblOverallDelayValue->setText ( "---" );
|
||||
|
@ -750,19 +750,3 @@ void CClientSettingsDlg::UpdateDisplay()
|
|||
QString().setNum ( pClient->GetUploadRateKbps() ) + " kbps" );
|
||||
}
|
||||
}
|
||||
|
||||
void CClientSettingsDlg::SetStatus ( const int iMessType, const int iStatus )
|
||||
{
|
||||
switch ( iMessType )
|
||||
{
|
||||
case MS_JIT_BUF_PUT:
|
||||
case MS_JIT_BUF_GET:
|
||||
// network LED shows combined status of put and get
|
||||
ledNetw->SetLight ( iStatus );
|
||||
break;
|
||||
|
||||
case MS_RESET_ALL:
|
||||
ledNetw->Reset();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,7 +55,9 @@ public:
|
|||
QWidget* parent = 0,
|
||||
Qt::WindowFlags f = 0 );
|
||||
|
||||
void SetStatus ( const int iMessType, const int iStatus );
|
||||
void SetStatus ( const int iStatus ) { ledNetw->SetLight ( iStatus ); }
|
||||
void ResetStatus() { ledNetw->Reset(); }
|
||||
|
||||
void SetPingTimeResult ( const int iPingTime,
|
||||
const int iOverallDelayMs,
|
||||
const int iOverallDelayLEDColor );
|
||||
|
|
16
src/global.h
16
src/global.h
|
@ -260,17 +260,14 @@ typedef unsigned char uint8_t;
|
|||
#endif
|
||||
|
||||
|
||||
/* Definitions for window message system ------------------------------------ */
|
||||
typedef unsigned int _MESSAGE_IDENT;
|
||||
#define MS_RESET_ALL 0 // MS: Message
|
||||
#define MS_JIT_BUF_PUT 1
|
||||
#define MS_JIT_BUF_GET 2
|
||||
#define MS_PACKET_RECEIVED 3
|
||||
|
||||
/* Pseudo enum definitions -------------------------------------------------- */
|
||||
#define MUL_COL_LED_RED 0
|
||||
#define MUL_COL_LED_YELLOW 1
|
||||
#define MUL_COL_LED_GREEN 2
|
||||
|
||||
// definition for custom event
|
||||
#define MS_PACKET_RECEIVED 0
|
||||
|
||||
|
||||
/* Classes ********************************************************************/
|
||||
class CGenErr
|
||||
|
@ -337,9 +334,4 @@ bool GetNumericArgument ( QTextStream& tsConsole,
|
|||
double rRangeStop,
|
||||
double& rValue);
|
||||
|
||||
// posting a window message
|
||||
void PostWinMessage ( const _MESSAGE_IDENT MessID,
|
||||
const int iMessageParam = 0,
|
||||
const int iChanNum = 0 );
|
||||
|
||||
#endif /* !defined ( GLOBAL_H__3B123453_4344_BB2B_23E7A0D31912__INCLUDED_ ) */
|
||||
|
|
19
src/main.cpp
19
src/main.cpp
|
@ -639,22 +639,3 @@ bool GetNumericArgument ( QTextStream& tsConsole,
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************\
|
||||
* Window Message System *
|
||||
\******************************************************************************/
|
||||
void PostWinMessage ( const _MESSAGE_IDENT MessID,
|
||||
const int iMessageParam,
|
||||
const int iChanNum )
|
||||
{
|
||||
// first check if application is initialized
|
||||
if ( pApp != NULL )
|
||||
{
|
||||
CCustomEvent* CustomEvent =
|
||||
new CCustomEvent ( MessID, iMessageParam, iChanNum );
|
||||
|
||||
// Qt will delete the event object when done
|
||||
QCoreApplication::postEvent ( pMainWindow, CustomEvent );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,25 +43,6 @@ CMultiColorLED::CMultiColorLED ( QWidget* parent, Qt::WindowFlags f )
|
|||
// set init bitmap
|
||||
setPixmap ( BitmCubeGrey );
|
||||
eColorFlag = RL_GREY;
|
||||
|
||||
// init update time
|
||||
SetUpdateTime ( DEFAULT_UPDATE_TIME );
|
||||
|
||||
// init timers -> we want to have single shot timers
|
||||
TimerRedLight.setSingleShot ( true );
|
||||
TimerGreenLight.setSingleShot ( true );
|
||||
TimerYellowLight.setSingleShot ( true );
|
||||
|
||||
// connect timer events to the desired slots
|
||||
connect ( &TimerRedLight, SIGNAL ( timeout() ),
|
||||
this, SLOT ( OnTimerRedLight() ) );
|
||||
connect ( &TimerGreenLight, SIGNAL ( timeout() ),
|
||||
this, SLOT ( OnTimerGreenLight() ) );
|
||||
connect ( &TimerYellowLight, SIGNAL ( timeout() ),
|
||||
this, SLOT ( OnTimerYellowLight() ) );
|
||||
|
||||
connect ( this, SIGNAL ( newPixmap ( const QPixmap& ) ),
|
||||
this, SLOT ( OnNewPixmap ( const QPixmap& ) ) );
|
||||
}
|
||||
|
||||
void CMultiColorLED::changeEvent ( QEvent* curEvent )
|
||||
|
@ -71,75 +52,56 @@ void CMultiColorLED::changeEvent ( QEvent* curEvent )
|
|||
{
|
||||
if ( this->isEnabled() )
|
||||
{
|
||||
emit newPixmap ( BitmCubeGrey );
|
||||
setPixmap ( BitmCubeGrey );
|
||||
eColorFlag = RL_GREY;
|
||||
}
|
||||
else
|
||||
{
|
||||
emit newPixmap ( BitmCubeDisabled );
|
||||
setPixmap ( BitmCubeDisabled );
|
||||
eColorFlag = RL_DISABLED;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CMultiColorLED::OnTimerRedLight()
|
||||
void CMultiColorLED::SetColor ( const ELightColor eNewColorFlag )
|
||||
{
|
||||
bFlagRedLi = false;
|
||||
UpdateColor();
|
||||
}
|
||||
|
||||
void CMultiColorLED::OnTimerGreenLight()
|
||||
{
|
||||
bFlagGreenLi = false;
|
||||
UpdateColor();
|
||||
}
|
||||
|
||||
void CMultiColorLED::OnTimerYellowLight()
|
||||
{
|
||||
bFlagYellowLi = false;
|
||||
UpdateColor();
|
||||
}
|
||||
|
||||
void CMultiColorLED::UpdateColor()
|
||||
{
|
||||
// Red light has highest priority, then comes yellow and at the end, we
|
||||
// decide to set green light. Allways check the current color of the
|
||||
// control before setting the color to prevent flickering
|
||||
if ( bFlagRedLi )
|
||||
switch ( eNewColorFlag )
|
||||
{
|
||||
case RL_RED:
|
||||
// red
|
||||
if ( eColorFlag != RL_RED )
|
||||
{
|
||||
emit newPixmap ( BitmCubeRed );
|
||||
setPixmap ( BitmCubeRed );
|
||||
eColorFlag = RL_RED;
|
||||
}
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
if ( bFlagYellowLi )
|
||||
{
|
||||
case RL_YELLOW:
|
||||
// yellow
|
||||
if ( eColorFlag != RL_YELLOW )
|
||||
{
|
||||
emit newPixmap ( BitmCubeYellow );
|
||||
setPixmap ( BitmCubeYellow );
|
||||
eColorFlag = RL_YELLOW;
|
||||
}
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
if ( bFlagGreenLi )
|
||||
{
|
||||
case RL_GREEN:
|
||||
// green
|
||||
if ( eColorFlag != RL_GREEN )
|
||||
{
|
||||
emit newPixmap ( BitmCubeGreen );
|
||||
setPixmap ( BitmCubeGreen );
|
||||
eColorFlag = RL_GREEN;
|
||||
}
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
// if no color is active, set control to grey light
|
||||
if ( eColorFlag != RL_GREY )
|
||||
{
|
||||
setPixmap ( BitmCubeGrey );
|
||||
eColorFlag = RL_GREY;
|
||||
default:
|
||||
// if no color is active, set control to grey light
|
||||
if ( eColorFlag != RL_GREY )
|
||||
{
|
||||
setPixmap ( BitmCubeGrey );
|
||||
eColorFlag = RL_GREY;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -147,12 +109,7 @@ void CMultiColorLED::Reset()
|
|||
{
|
||||
if ( this->isEnabled() )
|
||||
{
|
||||
// reset color flags
|
||||
bFlagRedLi = false;
|
||||
bFlagGreenLi = false;
|
||||
bFlagYellowLi = false;
|
||||
|
||||
UpdateColor();
|
||||
SetColor ( RL_GREY );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -163,41 +120,16 @@ void CMultiColorLED::SetLight ( const int iNewStatus )
|
|||
switch ( iNewStatus )
|
||||
{
|
||||
case MUL_COL_LED_GREEN:
|
||||
// green light
|
||||
bFlagGreenLi = true;
|
||||
TimerGreenLight.start();
|
||||
SetColor ( RL_GREEN );
|
||||
break;
|
||||
|
||||
case MUL_COL_LED_YELLOW:
|
||||
// yellow light
|
||||
bFlagYellowLi = true;
|
||||
TimerYellowLight.start();
|
||||
SetColor ( RL_YELLOW );
|
||||
break;
|
||||
|
||||
case MUL_COL_LED_RED:
|
||||
// red light
|
||||
bFlagRedLi = true;
|
||||
TimerRedLight.start();
|
||||
SetColor ( RL_RED );
|
||||
break;
|
||||
}
|
||||
|
||||
UpdateColor();
|
||||
}
|
||||
}
|
||||
|
||||
void CMultiColorLED::SetUpdateTime ( const int iNUTi )
|
||||
{
|
||||
// avoid too short intervals
|
||||
if ( iNUTi < MIN_TIME_FOR_RED_LIGHT )
|
||||
{
|
||||
iUpdateTime = MIN_TIME_FOR_RED_LIGHT;
|
||||
}
|
||||
else
|
||||
{
|
||||
iUpdateTime = iNUTi;
|
||||
}
|
||||
|
||||
TimerGreenLight.setInterval ( iUpdateTime );
|
||||
TimerYellowLight.setInterval ( iUpdateTime );
|
||||
TimerRedLight.setInterval ( iUpdateTime );
|
||||
}
|
||||
|
|
|
@ -34,29 +34,17 @@
|
|||
|
||||
#include <QLabel>
|
||||
#include <QPixmap>
|
||||
#include <QTimer>
|
||||
#include <QTreeWidget>
|
||||
#include <QIcon>
|
||||
#include "global.h"
|
||||
|
||||
|
||||
/* Definitions ****************************************************************/
|
||||
#define DEFAULT_UPDATE_TIME 300
|
||||
|
||||
// the red and yellow light should be on at least this interval
|
||||
#define MIN_TIME_FOR_RED_LIGHT 100
|
||||
|
||||
|
||||
/* Classes ********************************************************************/
|
||||
class CMultiColorLED : public QLabel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CMultiColorLED ( QWidget* parent = 0, Qt::WindowFlags f = 0 );
|
||||
|
||||
void Reset();
|
||||
void SetUpdateTime ( const int iNUTi );
|
||||
void SetLight ( const int iNewStatus );
|
||||
|
||||
protected:
|
||||
|
@ -71,7 +59,7 @@ protected:
|
|||
ELightColor eColorFlag;
|
||||
|
||||
virtual void changeEvent ( QEvent* curEvent );
|
||||
void UpdateColor();
|
||||
void SetColor ( const ELightColor eNewColorFlag );
|
||||
|
||||
QPixmap BitmCubeDisabled;
|
||||
QPixmap BitmCubeGrey;
|
||||
|
@ -79,89 +67,11 @@ protected:
|
|||
QPixmap BitmCubeYellow;
|
||||
QPixmap BitmCubeRed;
|
||||
|
||||
QTimer TimerRedLight;
|
||||
QTimer TimerGreenLight;
|
||||
QTimer TimerYellowLight;
|
||||
|
||||
int iUpdateTime;
|
||||
|
||||
bool bFlagRedLi;
|
||||
bool bFlagGreenLi;
|
||||
bool bFlagYellowLi;
|
||||
|
||||
protected slots:
|
||||
void OnTimerRedLight();
|
||||
void OnTimerGreenLight();
|
||||
void OnTimerYellowLight();
|
||||
virtual void OnNewPixmap ( const QPixmap& newPixmap ) { setPixmap ( newPixmap ); }
|
||||
|
||||
signals:
|
||||
void newPixmap ( const QPixmap& newPixmap );
|
||||
};
|
||||
|
||||
|
||||
class CMultColLEDListViewItem : public CMultiColorLED
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CMultColLEDListViewItem ( const int iNewCol )
|
||||
: pListViewItem ( NULL ), iColumn ( iNewCol ) {}
|
||||
|
||||
void SetListViewItemPointer ( QTreeWidgetItem* pNewListViewItem )
|
||||
{
|
||||
pListViewItem = pNewListViewItem;
|
||||
}
|
||||
|
||||
protected slots:
|
||||
virtual void OnNewPixmap ( const QPixmap& newPixmap )
|
||||
{
|
||||
if ( pListViewItem != NULL )
|
||||
{
|
||||
pListViewItem->setIcon ( iColumn, QIcon ( newPixmap ) );
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
QTreeWidgetItem* pListViewItem;
|
||||
int iColumn;
|
||||
};
|
||||
|
||||
|
||||
class CServerListViewItem : public QTreeWidgetItem
|
||||
{
|
||||
public:
|
||||
CServerListViewItem ( QTreeWidget* parent )
|
||||
: QTreeWidgetItem ( parent ), LED ( 2 )
|
||||
{
|
||||
LED.SetListViewItemPointer ( this );
|
||||
}
|
||||
|
||||
void SetLight ( int iNewStatus )
|
||||
{
|
||||
LED.SetLight ( iNewStatus );
|
||||
}
|
||||
|
||||
protected:
|
||||
CMultColLEDListViewItem LED;
|
||||
};
|
||||
|
||||
|
||||
class CConnectionServerListViewItem : public QTreeWidgetItem
|
||||
{
|
||||
public:
|
||||
CConnectionServerListViewItem ( QTreeWidget* parent )
|
||||
: QTreeWidgetItem ( parent ), LED ( 4 )
|
||||
{
|
||||
LED.SetListViewItemPointer ( this );
|
||||
}
|
||||
|
||||
void Reset() { LED.Reset(); }
|
||||
void SetUpdateTime ( const int iNUTi ) { LED.SetUpdateTime ( iNUTi ); }
|
||||
void SetLight ( int iNewStatus ) { LED.SetLight ( iNewStatus ); }
|
||||
|
||||
protected:
|
||||
CMultColLEDListViewItem LED;
|
||||
};
|
||||
|
||||
#endif // _MULTCOLORLED_H__FD6B49B5_87DF_48DD_A873_804E1606C2AC__INCLUDED_
|
||||
|
|
|
@ -798,16 +798,6 @@ void CServer::OnTimer()
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// send message for get status (for GUI)
|
||||
if ( eGetStat == GS_BUFFER_OK )
|
||||
{
|
||||
PostWinMessage ( MS_JIT_BUF_GET, MUL_COL_LED_GREEN, iCurChanID );
|
||||
}
|
||||
else
|
||||
{
|
||||
PostWinMessage ( MS_JIT_BUF_GET, MUL_COL_LED_RED, iCurChanID );
|
||||
}
|
||||
}
|
||||
|
||||
// a channel is now disconnected, take action on it
|
||||
|
@ -1287,28 +1277,10 @@ bool CServer::PutData ( const CVector<uint8_t>& vecbyRecBuf,
|
|||
if ( bChanOK )
|
||||
{
|
||||
// put packet in socket buffer
|
||||
switch ( vecChannels[iCurChanID].PutData ( vecbyRecBuf, iNumBytesRead ) )
|
||||
if ( vecChannels[iCurChanID].PutData ( vecbyRecBuf, iNumBytesRead ) == PS_PROT_OK_MESS_NOT_EVALUATED )
|
||||
{
|
||||
case PS_AUDIO_OK:
|
||||
PostWinMessage ( MS_JIT_BUF_PUT, MUL_COL_LED_GREEN, iCurChanID );
|
||||
break;
|
||||
|
||||
case PS_AUDIO_ERR:
|
||||
PostWinMessage ( MS_JIT_BUF_PUT, MUL_COL_LED_RED, iCurChanID );
|
||||
break;
|
||||
|
||||
case PS_PROT_ERR:
|
||||
PostWinMessage ( MS_JIT_BUF_PUT, MUL_COL_LED_YELLOW, iCurChanID );
|
||||
break;
|
||||
|
||||
case PS_PROT_OK_MESS_NOT_EVALUATED:
|
||||
bIsNotEvaluatedProtocolMessage = true; // set flag
|
||||
break;
|
||||
|
||||
case PS_GEN_ERROR:
|
||||
case PS_PROT_OK:
|
||||
// for these cases, do nothing
|
||||
break;
|
||||
// set flag
|
||||
bIsNotEvaluatedProtocolMessage = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -44,8 +44,8 @@ CServerDlg::CServerDlg ( CServer* pNServP,
|
|||
// client list
|
||||
lvwClients->setWhatsThis ( tr ( "<b>Client List:</b> The client list "
|
||||
"shows all clients which are currently connected to this server. Some "
|
||||
"informations about the clients like the IP address, name, buffer "
|
||||
"state are given for each connected client." ) );
|
||||
"informations about the clients like the IP address and name are given "
|
||||
"for each connected client." ) );
|
||||
|
||||
lvwClients->setAccessibleName ( tr ( "Connected clients list view" ) );
|
||||
|
||||
|
@ -161,7 +161,6 @@ CServerDlg::CServerDlg ( CServer* pNServP,
|
|||
// set up list view for connected clients
|
||||
lvwClients->setColumnWidth ( 0, 170 );
|
||||
lvwClients->setColumnWidth ( 1, 130 );
|
||||
lvwClients->setColumnWidth ( 2, 60 );
|
||||
lvwClients->clear();
|
||||
|
||||
|
||||
|
@ -175,7 +174,7 @@ lvwClients->setMinimumHeight ( 140 );
|
|||
vecpListViewItems.Init ( MAX_NUM_CHANNELS );
|
||||
for ( int i = MAX_NUM_CHANNELS - 1; i >= 0; i-- )
|
||||
{
|
||||
vecpListViewItems[i] = new CServerListViewItem ( lvwClients );
|
||||
vecpListViewItems[i] = new QTreeWidgetItem ( lvwClients );
|
||||
vecpListViewItems[i]->setHidden ( true );
|
||||
}
|
||||
|
||||
|
@ -461,11 +460,11 @@ void CServerDlg::OnTimer()
|
|||
vecpListViewItems[i]->setText ( 1, vecsName[i] );
|
||||
|
||||
// jitter buffer size (polling for updates)
|
||||
vecpListViewItems[i]->setText ( 3,
|
||||
vecpListViewItems[i]->setText ( 2,
|
||||
QString().setNum ( veciJitBufNumFrames[i] ) );
|
||||
|
||||
// out network block size
|
||||
vecpListViewItems[i]->setText ( 4,
|
||||
vecpListViewItems[i]->setText ( 3,
|
||||
QString().setNum ( static_cast<double> (
|
||||
veciNetwFrameSizeFact[i] * SYSTEM_BLOCK_DURATION_MS_FLOAT
|
||||
), 'f', 2 ) );
|
||||
|
@ -582,25 +581,3 @@ void CServerDlg::changeEvent ( QEvent* pEvent )
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CServerDlg::customEvent ( QEvent* pEvent )
|
||||
{
|
||||
if ( pEvent->type() == QEvent::User + 11 )
|
||||
{
|
||||
ListViewMutex.lock();
|
||||
{
|
||||
const int iMessType = ( (CCustomEvent*) pEvent )->iMessType;
|
||||
const int iStatus = ( (CCustomEvent*) pEvent )->iStatus;
|
||||
const int iChanNum = ( (CCustomEvent*) pEvent )->iChanNum;
|
||||
|
||||
switch(iMessType)
|
||||
{
|
||||
case MS_JIT_BUF_PUT:
|
||||
case MS_JIT_BUF_GET:
|
||||
vecpListViewItems[iChanNum]->SetLight ( iStatus );
|
||||
break;
|
||||
}
|
||||
}
|
||||
ListViewMutex.unlock();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,7 +36,6 @@
|
|||
#include "global.h"
|
||||
#include "server.h"
|
||||
#include "settings.h"
|
||||
#include "multicolorled.h"
|
||||
#include "ui_serverdlgbase.h"
|
||||
|
||||
|
||||
|
@ -58,7 +57,6 @@ public:
|
|||
Qt::WindowFlags f = 0 );
|
||||
|
||||
protected:
|
||||
virtual void customEvent ( QEvent* pEvent );
|
||||
virtual void changeEvent ( QEvent* pEvent );
|
||||
virtual void closeEvent ( QCloseEvent* Event );
|
||||
|
||||
|
@ -71,7 +69,7 @@ protected:
|
|||
CServer* pServer;
|
||||
CSettings* pSettings;
|
||||
|
||||
CVector<CServerListViewItem*> vecpListViewItems;
|
||||
CVector<QTreeWidgetItem*> vecpListViewItems;
|
||||
QMutex ListViewMutex;
|
||||
|
||||
QMenuBar* pMenu;
|
||||
|
|
|
@ -34,11 +34,6 @@
|
|||
<string>Name</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text" >
|
||||
<string>Buffers</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text" >
|
||||
<string>Jitter Buffer Size</string>
|
||||
|
|
|
@ -117,6 +117,21 @@ void CSocket::SendPacket ( const CVector<uint8_t>& vecbySendBuf,
|
|||
}
|
||||
}
|
||||
|
||||
bool CSocket::GetAndResetbJitterBufferOKFlag()
|
||||
{
|
||||
// check jitter buffer status
|
||||
if ( !bJitterBufferOK )
|
||||
{
|
||||
// reset flag and return "not OK" status
|
||||
bJitterBufferOK = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
// the buffer was OK, we do not have to reset anything and just return the
|
||||
// OK status
|
||||
return true;
|
||||
}
|
||||
|
||||
void CSocket::OnDataReceived()
|
||||
{
|
||||
while ( SocketDevice.hasPendingDatagrams() )
|
||||
|
@ -152,21 +167,9 @@ void CSocket::OnDataReceived()
|
|||
// this network packet is valid, put it in the channel
|
||||
switch ( pChannel->PutData ( vecbyRecBuf, iNumBytesRead ) )
|
||||
{
|
||||
case PS_AUDIO_OK:
|
||||
PostWinMessage ( MS_JIT_BUF_PUT, MUL_COL_LED_GREEN );
|
||||
break;
|
||||
|
||||
case PS_AUDIO_ERR:
|
||||
case PS_GEN_ERROR:
|
||||
PostWinMessage ( MS_JIT_BUF_PUT, MUL_COL_LED_RED );
|
||||
break;
|
||||
|
||||
case PS_PROT_ERR:
|
||||
PostWinMessage ( MS_JIT_BUF_PUT, MUL_COL_LED_YELLOW );
|
||||
break;
|
||||
|
||||
default:
|
||||
// other put data states need not to be considered here
|
||||
bJitterBufferOK = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
12
src/socket.h
12
src/socket.h
|
@ -57,15 +57,21 @@ class CSocket : public QObject
|
|||
public:
|
||||
CSocket ( CChannel* pNewChannel,
|
||||
const quint16 iPortNumber )
|
||||
: pChannel( pNewChannel ), bIsClient ( true ) { Init ( iPortNumber ); }
|
||||
: pChannel ( pNewChannel ),
|
||||
bIsClient ( true ),
|
||||
bJitterBufferOK ( true ) { Init ( iPortNumber ); }
|
||||
|
||||
CSocket ( CServer* pNServP,
|
||||
const quint16 iPortNumber )
|
||||
: pServer ( pNServP ), bIsClient ( false ) { Init ( iPortNumber ); }
|
||||
: pServer ( pNServP ),
|
||||
bIsClient ( false ),
|
||||
bJitterBufferOK ( true ) { Init ( iPortNumber ); }
|
||||
|
||||
void SendPacket ( const CVector<uint8_t>& vecbySendBuf,
|
||||
const CHostAddress& HostAddr );
|
||||
|
||||
bool GetAndResetbJitterBufferOKFlag();
|
||||
|
||||
protected:
|
||||
void Init ( const quint16 iPortNumber = LLCON_DEFAULT_PORT_NUMBER );
|
||||
|
||||
|
@ -80,6 +86,8 @@ protected:
|
|||
|
||||
bool bIsClient;
|
||||
|
||||
bool bJitterBufferOK;
|
||||
|
||||
public slots:
|
||||
void OnDataReceived();
|
||||
|
||||
|
|
Loading…
Reference in a new issue