some file writing issues, some other fixes

This commit is contained in:
Volker Fischer 2008-01-26 14:55:38 +00:00
parent 6b39825665
commit ccc664a084
6 changed files with 51 additions and 45 deletions

View file

@ -210,7 +210,7 @@ void CClient::run()
// TEST
Sleep(300);
//Sleep(300);
// copy data from one stereo buffer in two separate buffers

View file

@ -109,7 +109,7 @@ void CLlconServerDlg::OnTimer()
{
// IP, port number
vecpListViewItems[i]->setText ( 0, QString().sprintf ( "%s : %d",
vecHostAddresses[i].InetAddr.toString().toStdString(),
vecHostAddresses[i].InetAddr.toString(),
vecHostAddresses[i].iPort ) /* IP, port */);
// name
@ -122,10 +122,10 @@ void CLlconServerDlg::OnTimer()
// in/out network block sizes
vecpListViewItems[i]->setText ( 5,
QString().setNum (
double ( veciNetwInBlSiFact[i] * MIN_BLOCK_DURATION_MS), 'f', 2 ) );
double ( veciNetwInBlSiFact[i] * MIN_BLOCK_DURATION_MS ), 'f', 2 ) );
vecpListViewItems[i]->setText(6,
QString().setNum (
double ( veciNetwOutBlSiFact[i] * MIN_BLOCK_DURATION_MS), 'f', 2 ) );
double ( veciNetwOutBlSiFact[i] * MIN_BLOCK_DURATION_MS ), 'f', 2 ) );
vecpListViewItems[i]->setHidden ( true );
}

View file

@ -703,7 +703,7 @@ uint32_t CProtocol::GetValFromStream ( const CVector<uint8_t>& vecIn,
*/
// 4 bytes maximum since we return uint32
Q_ASSERT ( ( iNumOfBytes > 0 ) && ( iNumOfBytes <= 4 ) );
Q_ASSERT ( vecIn.Size() >= iPos + iNumOfBytes );
Q_ASSERT ( static_cast<unsigned int> ( vecIn.Size() ) >= iPos + iNumOfBytes );
uint32_t iRet = 0;
for ( unsigned int i = 0; i < iNumOfBytes; i++ )
@ -782,7 +782,7 @@ void CProtocol::PutValOnStream ( CVector<uint8_t>& vecIn,
*/
// 4 bytes maximum since we use uint32
Q_ASSERT ( ( iNumOfBytes > 0 ) && ( iNumOfBytes <= 4 ) );
Q_ASSERT ( vecIn.Size() >= iPos + iNumOfBytes );
Q_ASSERT ( static_cast<unsigned int> ( vecIn.Size() ) >= iPos + iNumOfBytes );
for ( unsigned int i = 0; i < iNumOfBytes; i++ )
{

View file

@ -1,5 +1,5 @@
/******************************************************************************\
* Copyright (c) 2004-2006
* Copyright (c) 2004-2008
*
* Author(s):
* Volker Fischer
@ -26,7 +26,7 @@
/* Implementation *************************************************************/
/* Input level meter implementation ------------------------------------------ */
// Input level meter implementation --------------------------------------------
void CSignalLevelMeter::Update ( CVector<double>& vecdAudio )
{
// do the update for entire vector
@ -72,7 +72,7 @@ double CSignalLevelMeter::MicLevel()
}
/* CRC ---------------------------------------------------------------------- */
// CRC -------------------------------------------------------------------------
void CCRC::Reset()
{
/* Init state shift-register with ones. Set all registers to "1" with
@ -268,7 +268,7 @@ double CAudioReverb::ProcessSample ( const double input )
/******************************************************************************\
* GUI utilities *
\******************************************************************************/
/* About dialog ------------------------------------------------------------- */
// About dialog ----------------------------------------------------------------
CAboutDlg::CAboutDlg ( QWidget* parent ) : QDialog ( parent )
{
setupUi ( this );
@ -352,7 +352,7 @@ QString CAboutDlg::GetVersionAndNameStr ( const bool bWithHtml )
}
/* Help menu ---------------------------------------------------------------- */
// Help menu -------------------------------------------------------------------
CLlconHelpMenu::CLlconHelpMenu ( QWidget* parent ) : QMenu ( "&?", parent )
{
// standard help menu consists of about and what's this help
@ -367,17 +367,23 @@ CLlconHelpMenu::CLlconHelpMenu ( QWidget* parent ) : QMenu ( "&?", parent )
/******************************************************************************\
* Global functions implementation *
\******************************************************************************/
void DebugError ( const char* pchErDescr, const char* pchPar1Descr,
const double dPar1, const char* pchPar2Descr,
void DebugError ( const QString& pchErDescr, const QString& pchPar1Descr,
const double dPar1, const QString& pchPar2Descr,
const double dPar2 )
{
FILE* pFile = fopen ( "DebugError.dat", "a" );
fprintf ( pFile, pchErDescr ); fprintf ( pFile, " ### " );
fprintf ( pFile, pchPar1Descr ); fprintf ( pFile, ": " );
fprintf ( pFile, "%e ### ", dPar1);
fprintf ( pFile, pchPar2Descr ); fprintf ( pFile, ": " );
fprintf ( pFile, "%e\n", dPar2 );
fclose ( pFile );
QFile File ( "DebugError.dat" );
if ( File.open ( QIODevice::Append ) )
{
// append new line in logging file
QTextStream out ( &File );
out << pchErDescr << " ### " <<
pchPar1Descr << ": " << QString().setNum ( dPar1, 'f', 2 ) <<
" ### " <<
pchPar2Descr << ": " << QString().setNum ( dPar2, 'f', 2 ) <<
endl;
File.close();
}
printf ( "\nDebug error! For more information see test/DebugError.dat\n" );
exit ( 1 );
}

View file

@ -31,6 +31,7 @@
#include <qtextbrowser.h>
#include <qlabel.h>
#include <qdatetime.h>
#include <qfile.h>
#include <vector>
#include "global.h"
using namespace std; // because of the library: "vector"
@ -65,8 +66,8 @@ inline short Double2Short ( const double dInput )
}
// debug error handling
void DebugError ( const char* pchErDescr, const char* pchPar1Descr,
const double dPar1, const char* pchPar2Descr,
void DebugError ( const QString& pchErDescr, const QString& pchPar1Descr,
const double dPar1, const QString& pchPar2Descr,
const double dPar2 );
@ -245,8 +246,8 @@ template<class TData> class CMovingAv : public CVector<TData>
public:
CMovingAv() : CVector<TData>(), iCurIdx ( 0 ), iNorm ( 0 ),
tCurAvResult ( TData ( 0 ) ) {}
CMovingAv ( const int iNeSi ) : CVector<TData> ( iNeSi ), iCurIdx ( 0 ), iNorm ( 0 ),
tCurAvResult ( TData ( 0 ) ) {}
CMovingAv ( const int iNeSi ) : CVector<TData> ( iNeSi ), iCurIdx ( 0 ),
iNorm ( 0 ), tCurAvResult ( TData ( 0 ) ) {}
CMovingAv ( const int iNeSi, const TData tInVa ) :
CVector<TData> ( iNeSi, tInVa ), iCurIdx ( 0 ), iNorm ( 0 ),
tCurAvResult ( TData ( 0 ) ) {}
@ -313,7 +314,7 @@ template<class TData> void CMovingAv<TData>::Add ( const TData tNewD )
/******************************************************************************\
* GUI utilities *
\******************************************************************************/
/* About dialog ------------------------------------------------------------- */
// About dialog ----------------------------------------------------------------
class CAboutDlg : public QDialog, private Ui_CAboutDlgBase
{
Q_OBJECT
@ -325,7 +326,7 @@ public:
};
/* Help menu ---------------------------------------------------------------- */
// Help menu -------------------------------------------------------------------
class CLlconHelpMenu : public QMenu
{
Q_OBJECT
@ -343,7 +344,7 @@ public slots:
/* Other Classes **************************************************************/
/* Signal Level Meter ------------------------------------------------------- */
// Signal Level Meter ----------------------------------------------------------
class CSignalLevelMeter
{
public:
@ -390,7 +391,7 @@ public:
};
/* Audio Reverbration ------------------------------------------------------- */
// Audio Reverbration ----------------------------------------------------------
class CAudioReverb
{
public:
@ -410,7 +411,7 @@ protected:
};
/* CRC ---------------------------------------------------------------------- */
// CRC -------------------------------------------------------------------------
class CCRC
{
public:
@ -430,7 +431,7 @@ protected:
};
/* Time conversion ---------------------------------------------------------- */
// Time conversion -------------------------------------------------------------
// needed for ping measurement
class CTimeConv
{
@ -467,7 +468,7 @@ public:
};
/* Time and Data to String conversion --------------------------------------- */
// Time and Data to String conversion ------------------------------------------
class CLogTimeDate
{
public:
@ -484,42 +485,41 @@ public:
};
/* Time and Data to String conversion --------------------------------------- */
// Logging ---------------------------------------------------------------------
class CLogging
{
public:
CLogging() : bDoLogging ( false ), pFile ( NULL ) {}
CLogging() : bDoLogging ( false ), File ( LOG_FILE_NAME ) {}
virtual ~CLogging()
{
if ( pFile != NULL )
if ( File.isOpen() )
{
fclose ( pFile );
File.close();
}
}
void Start()
{
// open file
pFile = fopen ( LOG_FILE_NAME, "a" );
if ( pFile != NULL )
if ( File.open ( QIODevice::Append ) )
{
bDoLogging = true;
}
}
void operator<< ( const QString & sNewStr )
void operator<< ( const QString& sNewStr )
{
if ( bDoLogging )
{
fprintf ( pFile, "%s\n", sNewStr.toStdString() );
fflush ( pFile );
// append new line in logging file
QTextStream out ( &File );
out << sNewStr << endl;
}
}
protected:
bool bDoLogging;
FILE* pFile;
bool bDoLogging;
QFile File;
};
#endif /* !defined ( UTIL_HOIH934256GEKJH98_3_43445KJIUHF1912__INCLUDED_ ) */

View file

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