some more QT4 fixes

This commit is contained in:
Volker Fischer 2008-01-22 19:58:53 +00:00
parent b4f1dcca0d
commit 23e9f8e3f4
7 changed files with 49 additions and 148 deletions

View file

@ -31,29 +31,29 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, QWidget* parent,
{ {
setupUi ( this ); setupUi ( this );
/* Init timing jitter text label */ // init timing jitter text label
TextLabelStdDevTimer->setText ( "" ); TextLabelStdDevTimer->setText ( "" );
/* init slider controls --- */ // init slider controls ---
/* sound buffer in */ // sound buffer in
SliderSndBufIn->setRange ( 2, AUD_SLIDER_LENGTH ); SliderSndBufIn->setRange ( 2, AUD_SLIDER_LENGTH );
const int iCurNumInBuf = pClient->GetSndInterface()->GetInNumBuf(); const int iCurNumInBuf = pClient->GetSndInterface()->GetInNumBuf();
SliderSndBufIn->setValue ( iCurNumInBuf ); SliderSndBufIn->setValue ( iCurNumInBuf );
TextSndBufIn->setText ( "In: " + QString().setNum ( iCurNumInBuf ) ); TextSndBufIn->setText ( "In: " + QString().setNum ( iCurNumInBuf ) );
/* sound buffer out */ // sound buffer out
SliderSndBufOut->setRange ( 2, AUD_SLIDER_LENGTH ); SliderSndBufOut->setRange ( 2, AUD_SLIDER_LENGTH );
const int iCurNumOutBuf = pClient->GetSndInterface()->GetOutNumBuf(); const int iCurNumOutBuf = pClient->GetSndInterface()->GetOutNumBuf();
SliderSndBufOut->setValue ( iCurNumOutBuf ); SliderSndBufOut->setValue ( iCurNumOutBuf );
TextSndBufOut->setText ( "Out: " + QString().setNum ( 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 );
const int iCurNumNetBuf = pClient->GetSockBufSize(); const int iCurNumNetBuf = pClient->GetSockBufSize();
SliderNetBuf->setValue ( iCurNumNetBuf ); SliderNetBuf->setValue ( iCurNumNetBuf );
TextNetBuf->setText ( "Size: " + QString().setNum ( iCurNumNetBuf ) ); TextNetBuf->setText ( "Size: " + QString().setNum ( iCurNumNetBuf ) );
/* network buffer size factor in */ // network buffer size factor in
SliderNetBufSiFactIn->setRange ( 1, MAX_NET_BLOCK_SIZE_FACTOR ); SliderNetBufSiFactIn->setRange ( 1, MAX_NET_BLOCK_SIZE_FACTOR );
const int iCurNetBufSiFactIn = pClient->GetNetwBufSizeFactIn(); const int iCurNetBufSiFactIn = pClient->GetNetwBufSizeFactIn();
SliderNetBufSiFactIn->setValue ( iCurNetBufSiFactIn ); SliderNetBufSiFactIn->setValue ( iCurNetBufSiFactIn );
@ -61,7 +61,7 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, QWidget* parent,
double ( iCurNetBufSiFactIn * MIN_BLOCK_DURATION_MS ), 'f', 2 ) + double ( iCurNetBufSiFactIn * MIN_BLOCK_DURATION_MS ), 'f', 2 ) +
" ms" ); " ms" );
/* network buffer size factor out */ // network buffer size factor out
SliderNetBufSiFactOut->setRange ( 1, MAX_NET_BLOCK_SIZE_FACTOR ); SliderNetBufSiFactOut->setRange ( 1, MAX_NET_BLOCK_SIZE_FACTOR );
const int iCurNetBufSiFactOut = pClient->GetNetwBufSizeFactOut(); const int iCurNetBufSiFactOut = pClient->GetNetwBufSizeFactOut();
SliderNetBufSiFactOut->setValue ( iCurNetBufSiFactOut ); SliderNetBufSiFactOut->setValue ( iCurNetBufSiFactOut );
@ -70,12 +70,12 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, QWidget* parent,
" ms" ); " ms" );
/* connections ---------------------------------------------------------- */ // Connections -------------------------------------------------------------
/* timers */ // timers
QObject::connect ( &TimerStatus, SIGNAL ( timeout() ), QObject::connect ( &TimerStatus, SIGNAL ( timeout() ),
this, SLOT ( OnTimerStatus() ) ); this, SLOT ( OnTimerStatus() ) );
/* sliders */ // sliders
QObject::connect ( SliderSndBufIn, SIGNAL ( valueChanged ( int ) ), QObject::connect ( SliderSndBufIn, SIGNAL ( valueChanged ( int ) ),
this, SLOT ( OnSliderSndBufInChange ( int ) ) ); this, SLOT ( OnSliderSndBufInChange ( int ) ) );
QObject::connect ( SliderSndBufOut, SIGNAL ( valueChanged ( int ) ), QObject::connect ( SliderSndBufOut, SIGNAL ( valueChanged ( int ) ),
@ -90,8 +90,8 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, QWidget* parent,
this, SLOT ( OnSliderNetBufSiFactOut ( int ) ) ); this, SLOT ( OnSliderNetBufSiFactOut ( int ) ) );
/* timers --------------------------------------------------------------- */ // Timers ------------------------------------------------------------------
/* start timer for status bar */ // start timer for status bar
TimerStatus.start ( DISPLAY_UPDATE_TIME ); TimerStatus.start ( DISPLAY_UPDATE_TIME );
} }
@ -136,7 +136,7 @@ void CClientSettingsDlg::OnSliderNetBufSiFactOut ( int value )
void CClientSettingsDlg::UpdateDisplay() void CClientSettingsDlg::UpdateDisplay()
{ {
/* response time */ // response time
TextLabelStdDevTimer->setText ( QString(). TextLabelStdDevTimer->setText ( QString().
setNum ( pClient->GetTimingStdDev(), 'f', 2 ) + " ms" ); setNum ( pClient->GetTimingStdDev(), 'f', 2 ) + " ms" );
} }

View file

@ -137,35 +137,7 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP, QWidget* parent )
} }
// Settings menu ----------------------------------------------------------
// TODO check if code works and then clean up!!!!!!!
// TODO QT4
#if 0
/* Settings menu ------------------------------------------------------- */
pSettingsMenu = new QMenu ( this );
pSettingsMenu->addMenu ( tr ( "&General Settings..." ), this,
SLOT ( OnOpenGeneralSettings() ) );
pSettingsMenu->insertSeparator();
pSettingsMenu->addMenu ( tr ( "E&xit" ), this,
SLOT ( close() ), CTRL+Key_Q );
/* Main menu bar -------------------------------------------------------- */
pMenu = new QMenuBar ( this );
pMenu->addMenu ( tr ( "&Settings" ), pSettingsMenu );
pMenu->addMenu ( tr ( "&?"), new CLlconHelpMenu ( this ) );
pMenu->setSeparator ( QMenuBar::InWindowsStyle );
/* Now tell the layout about the menu */
CLlconClientDlgBaseLayout->setMenuBar ( pMenu );
#endif
/* Settings menu ------------------------------------------------------- */
pSettingsMenu = new QMenu ( "&Settings", this ); pSettingsMenu = new QMenu ( "&Settings", this );
pSettingsMenu->addAction ( tr ( "&General Settings..." ), this, pSettingsMenu->addAction ( tr ( "&General Settings..." ), this,
SLOT ( OnOpenGeneralSettings() ) ); SLOT ( OnOpenGeneralSettings() ) );
@ -175,76 +147,16 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP, QWidget* parent )
SLOT ( close() ), QKeySequence ( Qt::CTRL + Qt::Key_Q ) ); SLOT ( close() ), QKeySequence ( Qt::CTRL + Qt::Key_Q ) );
/* Main menu bar -------------------------------------------------------- */ // Main menu bar -----------------------------------------------------------
pMenu = new QMenuBar ( this ); pMenu = new QMenuBar ( this );
//pMenu->addMenu ( tr ( "&Settings" ), pSettingsMenu );
pMenu->addMenu ( pSettingsMenu ); pMenu->addMenu ( pSettingsMenu );
//pMenu->addMenu ( tr ( "&?" ), new CLlconHelpMenu ( this ) );
pMenu->addMenu ( new CLlconHelpMenu ( this ) ); pMenu->addMenu ( new CLlconHelpMenu ( this ) );
// pMenu->setSeparator ( QMenuBar::InWindowsStyle );
// Now tell the layout about the menu // Now tell the layout about the menu
layout()->setMenuBar ( pMenu ); layout()->setMenuBar ( pMenu );
// Connections -------------------------------------------------------------
/* Menu actions --------------------------------------------------------- */
/*
pActGeneralSettings = new QAction ( tr ( "&General Settings..."), this );
connect( pActGeneralSettings, SIGNAL ( triggered() ),
this, SLOT ( OnOpenGeneralSettings() ) );
pActExit = new QAction ( tr ( "&Quit" ), this );
pActExit->setShortcut ( tr ( "Ctrl+Q" ) );
connect ( pActExit, SIGNAL ( triggered() ), this, SLOT ( close() ) );
pActAbout = new QAction ( tr ( "&About" ), this );
connect(aboutAct, SIGNAL(triggered()), this, SLOT(about()));
pActAbout
pHelpMenu
*/
/* Main menu bar -------------------------------------------------------- */
/*
pMainMenuBar
pMainMenuBar = new QMenuBar ( this );
pMainMenuBar->addMenu ( tr ( "&Settings" ), pSettingsMenu );
pMenu->addMenu ( tr ( "&?"), new CLlconHelpMenu ( this ) );
pMenu->setSeparator ( QMenuBar::InWindowsStyle );
pSettingsMenu = menuBar()->addMenu ( tr ( "&Settings" ) );
pSettingsMenu->addAction(pActGeneralSettings);
pSettingsMenu->addSeparator();
pSettingsMenu->addAction(pActExit);
pMenu->addMenu ( tr ( "&?"), new CLlconHelpMenu ( this ) );
pMenu->setSeparator ( QMenuBar::InWindowsStyle );
// Now tell the layout about the menu
CLlconClientDlgBaseLayout->setMenuBar ( pMainMenuBar );
*/
// connections -------------------------------------------------------------
// push-buttons // push-buttons
QObject::connect ( PushButtonConnect, SIGNAL ( clicked() ), QObject::connect ( PushButtonConnect, SIGNAL ( clicked() ),
this, SLOT ( OnConnectDisconBut() ) ); this, SLOT ( OnConnectDisconBut() ) );
@ -279,7 +191,7 @@ pMainMenuBar
this, SLOT ( OnChangeChanGain ( int, double ) ) ); this, SLOT ( OnChangeChanGain ( int, double ) ) );
// timers ------------------------------------------------------------------ // Timers ------------------------------------------------------------------
// start timer for status bar // start timer for status bar
TimerStatus.start ( STATUSBAR_UPDATE_TIME ); TimerStatus.start ( STATUSBAR_UPDATE_TIME );
} }

View file

@ -32,11 +32,13 @@ CLlconServerDlg::CLlconServerDlg ( CServer* pNServP, QWidget* parent )
BitmCubeRed ( LED_WIDTH_HEIGHT_SIZE_PIXEL, LED_WIDTH_HEIGHT_SIZE_PIXEL ), BitmCubeRed ( LED_WIDTH_HEIGHT_SIZE_PIXEL, LED_WIDTH_HEIGHT_SIZE_PIXEL ),
BitmCubeYellow ( LED_WIDTH_HEIGHT_SIZE_PIXEL, LED_WIDTH_HEIGHT_SIZE_PIXEL ) BitmCubeYellow ( LED_WIDTH_HEIGHT_SIZE_PIXEL, LED_WIDTH_HEIGHT_SIZE_PIXEL )
{ {
/* set text for version and application name */ setupUi ( this );
// set text for version and application name
TextLabelNameVersion->setText ( QString ( APP_NAME ) + TextLabelNameVersion->setText ( QString ( APP_NAME ) +
tr ( " server " ) + QString ( VERSION ) ); tr ( " server " ) + QString ( VERSION ) );
/* Create bitmaps */ // create bitmaps
BitmCubeGreen.fill ( QColor ( 0, 255, 0 ) ); BitmCubeGreen.fill ( QColor ( 0, 255, 0 ) );
BitmCubeRed.fill ( QColor ( 255, 0, 0 ) ); BitmCubeRed.fill ( QColor ( 255, 0, 0 ) );
BitmCubeYellow.fill ( QColor ( 255, 255, 0 ) ); BitmCubeYellow.fill ( QColor ( 255, 255, 0 ) );
@ -68,25 +70,20 @@ CLlconServerDlg::CLlconServerDlg ( CServer* pNServP, QWidget* parent )
TextLabelResponseTime->setText ( "" ); TextLabelResponseTime->setText ( "" );
/* Main menu bar -------------------------------------------------------- */ // Main menu bar -----------------------------------------------------------
// TODO QT4
pMenu = new QMenuBar ( this ); pMenu = new QMenuBar ( this );
// pMenu->insertItem ( tr ( "&?" ), new CLlconHelpMenu ( this ) );
pMenu->addMenu ( new CLlconHelpMenu ( this ) ); pMenu->addMenu ( new CLlconHelpMenu ( this ) );
//pMenu->setSeparator ( QMenuBar::InWindowsStyle );
// Now tell the layout about the menu // Now tell the layout about the menu
layout()->setMenuBar ( pMenu ); layout()->setMenuBar ( pMenu );
/* connections ---------------------------------------------------------- */ // Connections -------------------------------------------------------------
// timers // timers
QObject::connect ( &Timer, SIGNAL ( timeout() ), this, SLOT ( OnTimer() ) ); QObject::connect ( &Timer, SIGNAL ( timeout() ), this, SLOT ( OnTimer() ) );
/* timers --------------------------------------------------------------- */ // Timers ------------------------------------------------------------------
// start timer for GUI controls // start timer for GUI controls
Timer.start ( GUI_CONTRL_UPDATE_TIME ); Timer.start ( GUI_CONTRL_UPDATE_TIME );
} }
@ -105,7 +102,7 @@ void CLlconServerDlg::OnTimer()
pServer->GetConCliParam ( vecHostAddresses, vecsName, veciJitBufSize, pServer->GetConCliParam ( vecHostAddresses, vecsName, veciJitBufSize,
veciNetwOutBlSiFact, veciNetwInBlSiFact ); veciNetwOutBlSiFact, veciNetwInBlSiFact );
/* fill list with connected clients */ // fill list with connected clients
for ( int i = 0; i < MAX_NUM_CHANNELS; i++ ) for ( int i = 0; i < MAX_NUM_CHANNELS; i++ )
{ {
if ( !( vecHostAddresses[i].InetAddr == QHostAddress ( (quint32) 0 ) ) ) if ( !( vecHostAddresses[i].InetAddr == QHostAddress ( (quint32) 0 ) ) )

View file

@ -31,8 +31,9 @@
/* Implementation *************************************************************/ /* Implementation *************************************************************/
/* This pointer is only used for the post-event routine */ // these pointers are only used for the post-event routine
QApplication* pApp = NULL; QApplication* pApp = NULL;
QDialog* pMainWindow = NULL;
int main ( int argc, char** argv ) int main ( int argc, char** argv )
@ -125,7 +126,7 @@ cerr << "logging ";
CLlconClientDlg ClientDlg ( &Client, 0 ); CLlconClientDlg ClientDlg ( &Client, 0 );
// set main window // set main window
app.setActiveWindow ( &ClientDlg ); pMainWindow = &ClientDlg;
pApp = &app; // Needed for post-event routine pApp = &app; // Needed for post-event routine
// show dialog // show dialog
@ -147,7 +148,7 @@ cerr << "logging ";
CLlconServerDlg ServerDlg ( &Server, 0 ); CLlconServerDlg ServerDlg ( &Server, 0 );
// set main window // set main window
app.setActiveWindow ( &ServerDlg ); pMainWindow = &ServerDlg;
pApp = &app; // needed for post-event routine pApp = &app; // needed for post-event routine
// show dialog // show dialog
@ -264,12 +265,7 @@ void PostWinMessage ( const _MESSAGE_IDENT MessID, const int iMessageParam,
CLlconEvent* LlconEv = CLlconEvent* LlconEv =
new CLlconEvent ( MessID, iMessageParam, iChanNum ); new CLlconEvent ( MessID, iMessageParam, iChanNum );
// TODO QT4
// Qt will delete the event object when done // Qt will delete the event object when done
// QThread::postEvent ( pApp->mainWidget(), LlconEv ); QCoreApplication::postEvent ( pMainWindow, LlconEv );
} }
} }

View file

@ -83,9 +83,15 @@ void CSocket::SendPacket ( const CVector<unsigned char>& vecbySendBuf,
void CSocket::OnDataReceived() void CSocket::OnDataReceived()
{ {
// read block from network interface QHostAddress SenderAddress;
quint16 SenderPort;
// read block from network interface and query address of sender
const int iNumBytesRead = SocketDevice.readDatagram ( (char*) &vecbyRecBuf[0], const int iNumBytesRead = SocketDevice.readDatagram ( (char*) &vecbyRecBuf[0],
MAX_SIZE_BYTES_NETW_BUF ); MAX_SIZE_BYTES_NETW_BUF, &SenderAddress, &SenderPort );
// convert address of client
CHostAddress RecHostAddr ( SenderAddress, SenderPort );
// check if an error occurred // check if an error occurred
if ( iNumBytesRead < 0 ) if ( iNumBytesRead < 0 )
@ -93,10 +99,6 @@ void CSocket::OnDataReceived()
return; return;
} }
// get host address of client
CHostAddress RecHostAddr ( SocketDevice.peerAddress(),
SocketDevice.peerPort() );
if ( bIsClient ) if ( bIsClient )
{ {
// client // client
@ -130,14 +132,8 @@ void CSocket::OnDataReceived()
// this was an audio packet, start server // this was an audio packet, start server
// tell the server object to wake up if it // tell the server object to wake up if it
// is in sleep mode (Qt will delete the event object when done) // is in sleep mode (Qt will delete the event object when done)
QCoreApplication::postEvent ( pServer,
new CLlconEvent ( MS_PACKET_RECEIVED, 0, 0 ) );
// TODO QT4
// QThread::postEvent ( pServer,
// new CLlconEvent ( MS_PACKET_RECEIVED, 0, 0 ) );
} }
} }
} }

View file

@ -914,7 +914,7 @@ void CSound::InitRecording ( int iNewBufferSize, bool bNewBlocking )
psSoundcardBuffer[i] = new short[iBufferSizeIn]; psSoundcardBuffer[i] = new short[iBufferSizeIn];
/* Send all buffers to driver for filling the queue ----------------- */ // Send all buffers to driver for filling the queue --------------------
// prepare buffers before sending them to the sound interface // prepare buffers before sending them to the sound interface
PrepareInBuffer ( i ); PrepareInBuffer ( i );
@ -1023,7 +1023,7 @@ bool CSound::Write ( CVector<short>& psData )
} }
else else
{ {
/* All buffers are filled, dump new block ----------------------- */ // All buffers are filled, dump new block --------------------------
// It would be better to kill half of the buffer blocks to set the start // It would be better to kill half of the buffer blocks to set the start
// back to the middle: TODO // back to the middle: TODO
return TRUE; // an error occurred return TRUE; // an error occurred
@ -1088,25 +1088,25 @@ void CSound::GetDoneBuffer ( int& iCntPrepBuf, int& iIndexDoneBuf )
void CSound::AddOutBuffer ( int iBufNum ) void CSound::AddOutBuffer ( int iBufNum )
{ {
// Unprepare old wave-header // unprepare old wave-header
waveOutUnprepareHeader ( waveOutUnprepareHeader (
m_WaveOut, &m_WaveOutHeader[iBufNum], sizeof ( WAVEHDR ) ); m_WaveOut, &m_WaveOutHeader[iBufNum], sizeof ( WAVEHDR ) );
// Prepare buffers for sending to sound interface // prepare buffers for sending to sound interface
PrepareOutBuffer ( iBufNum ); PrepareOutBuffer ( iBufNum );
// Send buffer to driver for filling with new data // send buffer to driver for filling with new data
waveOutWrite ( m_WaveOut, &m_WaveOutHeader[iBufNum], sizeof ( WAVEHDR ) ); waveOutWrite ( m_WaveOut, &m_WaveOutHeader[iBufNum], sizeof ( WAVEHDR ) );
} }
void CSound::PrepareOutBuffer ( int iBufNum ) void CSound::PrepareOutBuffer ( int iBufNum )
{ {
// Set Header data // set Header data
m_WaveOutHeader[iBufNum].lpData = (LPSTR) &psPlaybackBuffer[iBufNum][0]; m_WaveOutHeader[iBufNum].lpData = (LPSTR) &psPlaybackBuffer[iBufNum][0];
m_WaveOutHeader[iBufNum].dwBufferLength = iBufferSizeOut * BYTES_PER_SAMPLE; m_WaveOutHeader[iBufNum].dwBufferLength = iBufferSizeOut * BYTES_PER_SAMPLE;
m_WaveOutHeader[iBufNum].dwFlags = 0; m_WaveOutHeader[iBufNum].dwFlags = 0;
// Prepare wave-header // prepare wave-header
waveOutPrepareHeader ( m_WaveOut, &m_WaveOutHeader[iBufNum], sizeof ( WAVEHDR ) ); waveOutPrepareHeader ( m_WaveOut, &m_WaveOutHeader[iBufNum], sizeof ( WAVEHDR ) );
} }

View file

@ -36,7 +36,7 @@
/* Definitions ****************************************************************/ /* Definitions ****************************************************************/
// switch here between ASIO (Steinberg) or native Windows(TM) sound interface // switch here between ASIO (Steinberg) or native Windows(TM) sound interface
#undef USE_ASIO_SND_INTERFACE #undef USE_ASIO_SND_INTERFACE
//#define USE_ASIO_SND_INTERFACE #define USE_ASIO_SND_INTERFACE
#define NUM_IN_OUT_CHANNELS 2 /* Stereo recording (but we only #define NUM_IN_OUT_CHANNELS 2 /* Stereo recording (but we only