From ccc664a0841f43d0ec9edad36b38c6449c345063 Mon Sep 17 00:00:00 2001 From: Volker Fischer Date: Sat, 26 Jan 2008 14:55:38 +0000 Subject: [PATCH] some file writing issues, some other fixes --- src/client.cpp | 2 +- src/llconserverdlg.cpp | 6 +++--- src/protocol.cpp | 4 ++-- src/util.cpp | 34 ++++++++++++++++++------------- src/util.h | 46 +++++++++++++++++++++--------------------- windows/sound.h | 4 ++-- 6 files changed, 51 insertions(+), 45 deletions(-) diff --git a/src/client.cpp b/src/client.cpp index 1e86ad44..057cad8b 100755 --- a/src/client.cpp +++ b/src/client.cpp @@ -210,7 +210,7 @@ void CClient::run() // TEST -Sleep(300); +//Sleep(300); // copy data from one stereo buffer in two separate buffers diff --git a/src/llconserverdlg.cpp b/src/llconserverdlg.cpp index 40e294f2..8cdd80e6 100755 --- a/src/llconserverdlg.cpp +++ b/src/llconserverdlg.cpp @@ -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 ); } diff --git a/src/protocol.cpp b/src/protocol.cpp index 75201a38..80a2508d 100755 --- a/src/protocol.cpp +++ b/src/protocol.cpp @@ -703,7 +703,7 @@ uint32_t CProtocol::GetValFromStream ( const CVector& vecIn, */ // 4 bytes maximum since we return uint32 Q_ASSERT ( ( iNumOfBytes > 0 ) && ( iNumOfBytes <= 4 ) ); - Q_ASSERT ( vecIn.Size() >= iPos + iNumOfBytes ); + Q_ASSERT ( static_cast ( vecIn.Size() ) >= iPos + iNumOfBytes ); uint32_t iRet = 0; for ( unsigned int i = 0; i < iNumOfBytes; i++ ) @@ -782,7 +782,7 @@ void CProtocol::PutValOnStream ( CVector& vecIn, */ // 4 bytes maximum since we use uint32 Q_ASSERT ( ( iNumOfBytes > 0 ) && ( iNumOfBytes <= 4 ) ); - Q_ASSERT ( vecIn.Size() >= iPos + iNumOfBytes ); + Q_ASSERT ( static_cast ( vecIn.Size() ) >= iPos + iNumOfBytes ); for ( unsigned int i = 0; i < iNumOfBytes; i++ ) { diff --git a/src/util.cpp b/src/util.cpp index 5914f9b1..cc8dd8aa 100755 --- a/src/util.cpp +++ b/src/util.cpp @@ -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& 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 ); } diff --git a/src/util.h b/src/util.h index a91b8971..80b79b67 100755 --- a/src/util.h +++ b/src/util.h @@ -31,6 +31,7 @@ #include #include #include +#include #include #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 CMovingAv : public CVector public: CMovingAv() : CVector(), iCurIdx ( 0 ), iNorm ( 0 ), tCurAvResult ( TData ( 0 ) ) {} - CMovingAv ( const int iNeSi ) : CVector ( iNeSi ), iCurIdx ( 0 ), iNorm ( 0 ), - tCurAvResult ( TData ( 0 ) ) {} + CMovingAv ( const int iNeSi ) : CVector ( iNeSi ), iCurIdx ( 0 ), + iNorm ( 0 ), tCurAvResult ( TData ( 0 ) ) {} CMovingAv ( const int iNeSi, const TData tInVa ) : CVector ( iNeSi, tInVa ), iCurIdx ( 0 ), iNorm ( 0 ), tCurAvResult ( TData ( 0 ) ) {} @@ -313,7 +314,7 @@ template void CMovingAv::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_ ) */ diff --git a/windows/sound.h b/windows/sound.h index 0863d08c..3a248ffa 100755 --- a/windows/sound.h +++ b/windows/sound.h @@ -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