Commit a9c1bac4 authored by jcaceres's avatar jcaceres
Browse files

Merge with trunk and fix udp classes for full compatibility with qt4

parent 6d6d9580
......@@ -35,8 +35,10 @@
#include "math.h"
#include "string.h"
#include "audioDevice.h"
#include "qstring.h"
#include <q3textstream.h>
//#include "qstring.h"
#include <QString>
//#include <q3textstream.h>
#include <QTextStream>
#define ONE_BASED (i+1)
......@@ -237,17 +239,19 @@ JackClient::JackClient (int nChans, int nFrames, bool output, bool input, AudioD
for (int i = 0; i < nChans; i++)
{
QString iName, oName;
QTextOStream (&iName) << "input" << ONE_BASED;
QTextOStream (&oName) << "output" << ONE_BASED;
//QTextOStream (&iName) << "input" << ONE_BASED;
//QTextOStream (&oName) << "output" << ONE_BASED;
QTextStream (&iName) << "input" << ONE_BASED;//QT4 Port****
QTextStream (&oName) << "output" << ONE_BASED;//QT4 Port****
if (output)
output_port[ONE_BASED] =
jack_port_register (client, oName,
jack_port_register (client, oName.toLatin1(),
JACK_DEFAULT_AUDIO_TYPE,
JackPortIsOutput, 0);
if (input)
input_port[ONE_BASED] =
jack_port_register (client, iName,
jack_port_register (client, iName.toLatin1(),
JACK_DEFAULT_AUDIO_TYPE,
JackPortIsInput, 0);
}
......
......@@ -36,7 +36,7 @@
#include "qslider.h"
#include "qcombobox.h"
#include "qradiobutton.h"
#include "ThreadCommEvent.h"
//#include "ThreadCommEvent.h"
#include <qlabel.h>
#include <qlayout.h>
......@@ -68,35 +68,35 @@ MainDialog::init(StreamBD *s)
//*********************************************
//Coment out to remove dependency of widget
QString tmp;
QTextOStream (&tmp) << "sampleRate " << s->args->sampleRate;
QTextStream (&tmp) << "sampleRate " << s->args->sampleRate;
//sampleRateTextLabel->setText (tmp); tmp = "";
QTextOStream (&tmp) << "netHarpStrings " << s->args->netHarpStrings;
QTextStream (&tmp) << "netHarpStrings " << s->args->netHarpStrings;
//netHarpStringsTextLabel->setText (tmp); tmp = "";
QTextOStream (&tmp) << "audioChannels " << s->args->audioChannels;
QTextStream (&tmp) << "audioChannels " << s->args->audioChannels;
//audioChannelsTextLabel->setText (tmp); tmp = "";
QTextOStream (&tmp) << "runFifo " << s->args->runFifo;
QTextStream (&tmp) << "runFifo " << s->args->runFifo;
//runFifoTextLabel->setText (tmp); tmp = "";
QTextOStream (&tmp) << "audioDeviceID " << s->args->audioDeviceID;
QTextStream (&tmp) << "audioDeviceID " << s->args->audioDeviceID;
//audioDeviceIDTextLabel->setText (tmp); tmp = "";
QTextOStream (&tmp) << "netInQInPackets " << s->args->networkInputQueueLengthInPackets;
QTextStream (&tmp) << "netInQInPackets " << s->args->networkInputQueueLengthInPackets;
//netInQInPacketsTextLabel->setText (tmp); tmp = "";
QTextOStream (&tmp) << "redundancy " << s->args->redundancy;
QTextStream (&tmp) << "redundancy " << s->args->redundancy;
//redundancyTextLabel->setText (tmp); tmp = "";
QTextOStream (&tmp) << "audioInQInAudioBufs " << s->args->audioInputQueueLengthInAudioBuffers;
QTextStream (&tmp) << "audioInQInAudioBufs " << s->args->audioInputQueueLengthInAudioBuffers;
//audioInQInAudioBufsTextLabel->setText (tmp); tmp = "";
QTextOStream (&tmp) << "framesPerAudioBuffer " << s->args->framesPerAudioBuffer;
QTextStream (&tmp) << "framesPerAudioBuffer " << s->args->framesPerAudioBuffer;
//framesPerAudioBufferTextLabel->setText (tmp); tmp = "";
QTextOStream (&tmp) << "networkPortOffset " << s->args->networkPortOffset;
QTextStream (&tmp) << "networkPortOffset " << s->args->networkPortOffset;
//networkPortOffsetTextLabel->setText (tmp); tmp = "";
QTextOStream (&tmp) << "runMode " << s->args->runMode;
QTextStream (&tmp) << "runMode " << s->args->runMode;
//runModeTextLabel->setText (tmp); tmp = "";
QTextOStream (&tmp) << "secondsBetweenPlucks " << s->args->secondsBetweenPlucks;
QTextStream (&tmp) << "secondsBetweenPlucks " << s->args->secondsBetweenPlucks;
//secondsBetweenPlucksTextLabel->setText (tmp); tmp = "";
QTextOStream (&tmp) << "lowPassFilterCoeff " << s->args->lowPassFilterCoeff;
QTextStream (&tmp) << "lowPassFilterCoeff " << s->args->lowPassFilterCoeff;
//lowPassFilterCoeffTextLabel->setText (tmp); tmp = "";
QTextOStream (&tmp) << "delayIncBtwnStrings " << s->args->delayIncrementBetweenStrings;
QTextStream (&tmp) << "delayIncBtwnStrings " << s->args->delayIncrementBetweenStrings;
//delayIncBtwnStringsTextLabel->setText (tmp); tmp = "";
QTextOStream (&tmp) << "jack " << s->args->jack;
QTextStream (&tmp) << "jack " << s->args->jack;
//jackTextLabel->setText (tmp);
//*********************************************
......
......@@ -33,7 +33,7 @@
#ifndef _MAINDIALOG_H_
#define _MAINDIALOG_H_
#include "q3ptrlist.h"
//#include "q3ptrlist.h"
#include "qthread.h"
#include <qstring.h>
#include "qtimer.h"
......
......@@ -619,7 +619,7 @@ StreamBD::EstablishConnection (runModeT runMode, char *hostname, UDPOutput * net
/////FOLOW THIS TO FIND THE PROBLEM
//**************JPC COMENTED OUT*******************
cout << endl << "Connection received from: " <<
netin->peer().toString().latin1() << endl;
netin->peer().toString().toStdString() << endl;
//*************************************************
cout << "Requesting return connection....";
//netout->connect (netin->peer ());
......
/*
JackTrip: A Multimachine System for High-Quality Audio
Network Performance over the Internet
Copyright (c) 2008 Chris Chafe, Juan-Pablo Caceres,
SoundWIRE group at CCRMA.
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
*/
/*
* ThreadCommEvent.h
*
* The custom event class
*/
#ifndef THREADCOMMEVENT_H
#define THREADCOMMEVENT_H
#include "qobject.h"
//Added by qt3to4:
#include <QEvent>
#include <QCustomEvent>
class ThreadCommEvent:public QCustomEvent
{
public:
ThreadCommEvent (double val0, double val1,
double val2):QCustomEvent (QEvent::User + 117),
_val0 (val0), _val1 (val1), _val2 (val2)
{
};
double val0 () const
{
return _val0;
};
double val1 () const
{
return _val1;
};
double val2 () const
{
return _val2;
};
private:
double _val0;
double _val1;
double _val2;
};
class ReverbCommEvent:public QCustomEvent
{
public:
ReverbCommEvent (double val0, double val1,
double val2):QCustomEvent (QEvent::User + 118),
_val0 (val0), _val1 (val1), _val2 (val2)
{
};
double val0 () const
{
return _val0;
};
double val1 () const
{
return _val1;
};
double val2 () const
{
return _val2;
};
private:
double _val0;
double _val1;
double _val2;
};
#endif // THREADCOMMEVENT_H
......@@ -94,6 +94,7 @@ AudioInput::xfrFrom (void *buf)
}
/*
void AudioInput::plotVal (double v)
{
if(_rcvr!=NULL)
......@@ -104,3 +105,4 @@ void AudioInput::plotVal (double v)
QApplication::postEvent (_rcvr, e); // to app event loop
}
}
*/
......@@ -60,6 +60,6 @@ public:
int rcv (char *buf);
void run ();
void stop ();
void plotVal (double v);
//void plotVal (double v);
};
#endif
......@@ -109,6 +109,7 @@ AudioOutput::stop ()
_running = false;
}
/*
void AudioOutput::plotVal (double v)
{
if(_rcvr!=NULL)
......@@ -119,3 +120,4 @@ void AudioOutput::plotVal (double v)
QApplication::postEvent (_rcvr, e); // to app event loop
}
}
*/
......@@ -105,7 +105,7 @@ public:
*/
void stop ();
void plotVal (double v);
//void plotVal (double v);
};
/** NEWVERSION in other file */
......
......@@ -27,7 +27,7 @@ echo "qmake .pro built"
qmake-qt4 -makefile -unix -o Makefile \
"CONFIG+=qt debug thread warn_on" \
"QMAKE_CXXFLAGS+=-Wno-deprecated -g -O2" \
"QT += network qt3support" \
"QT += network" \
"DEFINES+=__LINUX_ALSA__ APP_NAME=$APP_NAME_QUOTES" \
"QMAKE_CLEAN+=$APP_NAME" \
"unix:LIBS+=-Xlinker -rpath $QTDIR/lib -ljack" \
......@@ -37,5 +37,6 @@ qmake-qt4 -makefile -unix -o Makefile \
#INCLUDEPATH+=/usr/include/stk ../include" \
#"unix:LIBS+=-Xlinker -rpath $QTDIR/lib -lstk -lasound -ljack" \
#"QT += network qt3support" \
echo "done"
......@@ -68,7 +68,7 @@ IPv4Addr (char *namebuf)
}
#include <qapplication.h>
#include <q3textstream.h>
//#include <q3textstream.h>
/****************************************************************************
* MAIN
***************************************************************************/
......
......@@ -36,11 +36,13 @@
#ifndef _PLUGIN_H
#define _PLUGIN_H
#include <qthread.h>
//#include <qthread.h>
#include <QThread>
// for plotting
#include <sys/time.h>
#include "qapplication.h"
#include "ThreadCommEvent.h"
//#include "qapplication.h"
#include <QApplication>
//#include "ThreadCommEvent.h"
class Plugin:public QThread
......@@ -59,7 +61,7 @@ public:
};
QObject * _rcvr;
void setGUI(QObject * rcvr){_rcvr = rcvr;};
virtual void plotVal (double v) = 0;
//virtual void plotVal (double v) = 0;
char *getName ()
{
......
......@@ -37,7 +37,8 @@
#include <stdlib.h>
#include <time.h>
#define APPEND(x,y) x.resize(x.count()+1); x.insert (x.count(), y)
//#define APPEND(x,y) x.resize(x.count()+1); x.insert (x.count(), y)
#define APPEND(x,y) x.resize( (x.size()-x.count(0)) + 1); x.insert ( (x.size()-x.count(0)), y)//QT4 port
#define debugMe FALSE
using namespace std;
......@@ -91,7 +92,8 @@ Stream::addInput (InputPlugin * newin)
newin->setWriteKey (ins.count ());
APPEND (ins, newin);
if (ins.count () > bufs.count ())
//if (ins.count () > bufs.count ())
if ( (ins.size() - ins.count(0)) > (bufs.count() - bufs.count(0)))//QT4 port
{
addCircularBuffer ();
}
......@@ -102,7 +104,8 @@ void
Stream::addOutput (OutputPlugin * newout)
{
QSemaphore *tmp;
if (outs.count () == 1)
//if (outs.count () == 1)
if ( (outs.size() - outs.count(0)) == 1 ) //QT4 port
{ // We are going to need output synchronization locking.
// add a lock for the first output (didn't need it when it was the only one.)
tmp = new QSemaphore (10);
......@@ -111,10 +114,12 @@ Stream::addOutput (OutputPlugin * newout)
APPEND (locks, tmp);
}
newout->setReadKey (outs.count ());
//newout->setReadKey (outs.count ());
newout->setReadKey ( (outs.size() - outs.count(0)) );//QT4 port
APPEND (outs, newout);
if (outs.count () > bufs.count ())
//if (outs.count () > bufs.count ())
if ( (outs.size() - outs.count(0)) > (bufs.count() - bufs.count(0)) )
{
addCircularBuffer ();
}
......@@ -329,11 +334,17 @@ void
Stream::startThreads ()
{
// cache vector lengths for next run
insCount = (int) ins.count ();
procsCount = (int) procs.count ();
outsCount = (int) outs.count ();
locksCount = (int) locks.count ();
bufsCount = (int) bufs.count ();
//insCount = (int) ins.count ();
insCount = (int) (ins.size() - ins.count(0));//QT4 port
//procsCount = (int) procs.count ();
procsCount = (int) (procs.size() - procs.count(0));//QT4 port
//outsCount = (int) outs.count ();
outsCount = (int) (outs.size() - outs.count(0));//QT4 port
//locksCount = (int) locks.count ();
locksCount = (int) (locks.size() - locks.count(0));//QT4 port
//bufsCount = (int) bufs.count ();
bufsCount = (int) (locks.size() - locks.count(0));//QT4 port
processesPerChan = procsCount / audioInfo->getNumChans ();
for (int i = 0; i < insCount; i++)
......@@ -341,10 +352,12 @@ Stream::startThreads ()
InputPlugin *ip = (InputPlugin *) ins[i];
cout << "++++++++++++++++++++++" << endl;
if(!ip->dontRun) {
if (!ip->running ())
//if (!ip->running ())
if (!ip->isRunning())//QT4port-----------
ip->start ();
// with runMode == NETMIRROR ip needs to start earlier
if (!ip->running ())
//if (!ip->running ())
if (!ip->isRunning())//QT4port-----------
{
cerr << "failed to start input plugin " << ip->
getName () << endl;
......@@ -359,7 +372,8 @@ Stream::startThreads ()
OutputPlugin *op = (OutputPlugin *) outs[i];
if(!op->dontRun) {
op->start ();
if (!op->running ())
//if (!op->running ())
if (!op->isRunning())//QT4port-----------
{
cerr << "failed to start output plugin " << op->
getName () << endl;
......@@ -376,12 +390,14 @@ Stream::stopThreads ()
for (int i = 0; i < insCount; i++)
{
InputPlugin *ip = ins[i];
if (ip->running ())
//if (ip->running ())
if (ip->isRunning())//QT4port-----------
{
ip->stop ();
ip->wait ();
delete ip;
ins.remove (i);
//ins.remove (i);
ins[i] = 0; //QT4 port
}
}
for (int i = 0; i < procsCount; i++)
......@@ -389,21 +405,24 @@ Stream::stopThreads ()
ProcessPlugin *pp = procs[i];
{
delete pp;
procs.remove (i);
//procs.remove (i);
procs[i] = 0; //QT4 port
}
}
for (int i = 0; i < outsCount; i++)
{
OutputPlugin *op = outs[i];
if (op->running ())
//if (op->running ())
if (op->isRunning())//QT4port-----------
{
cerr << i << " of " << outsCount << " STOP... " <<
endl;
op->stop ();
op->wait ();
delete op;
outs.remove (i);
//outs.remove (i);
outs[i] = 0; //QT4 port
cerr << " ... D, R " << op->getName () << endl;
}
}
......
......@@ -41,7 +41,8 @@
#include "audioInfo.h"
#include "networkInfo.h"
#include "qthread.h"
#include "q3ptrvector.h"
//#include "q3ptrvector.h"
#include <QVector>
/**
* @brief Connects an InputPlugin to an OutputPlugin with
......@@ -58,15 +59,21 @@ class Stream
protected:
// Vector inputs;
Q3PtrVector < InputPlugin > ins;
//Q3PtrVector < InputPlugin > ins;
QVector < InputPlugin* > ins; //QT4 port
// Vector outputs;
Q3PtrVector < OutputPlugin > outs;
//Q3PtrVector < OutputPlugin > outs;
QVector < OutputPlugin* > outs; //QT4 port
// Vector processes;
Q3PtrVector < ProcessPlugin > procs;
//Q3PtrVector < ProcessPlugin > procs;
QVector < ProcessPlugin* > procs; //QT4 port
// Vector circularBuffers;
Q3PtrVector < CircularBuffer > bufs;
//Q3PtrVector < CircularBuffer > bufs;
QVector < CircularBuffer* > bufs; //QT4 port
// Vector outputLocks;
Q3PtrVector < QSemaphore >locks;
//Q3PtrVector < QSemaphore >locks;
QVector < QSemaphore* >locks; //QT4 port
int insCount;
int procsCount;
int outsCount;
......
......@@ -215,7 +215,7 @@ UDPInput::run ()
exit ();
}
cout <<"Local Host Name: " << QString(QHostInfo::localHostName ()).latin1() << endl;//***JPC Port to qt4*****************
cout <<"Local Host Name: " << QString(QHostInfo::localHostName ()).toStdString() << endl;//***JPC Port to qt4*****************
//cout << "Rx buff = " << sock->receiveBufferSize () << endl;//***JPC Port to qt4*****************
QHostAddress *ha = new QHostAddress ();//***JPC Port to qt4*****************
QString *s = IPv4Addr (localhostbuf); // dotted integer from name//***JPC Port to qt4*****************
......@@ -333,6 +333,7 @@ UDPInput::run ()
//-------------------------------------------------------------------------------
//-------------------------------------------------------------------------------
/*
void UDPInput::plotVal (double v)
{
if(_rcvr!=NULL)
......@@ -341,6 +342,7 @@ void UDPInput::plotVal (double v)
QApplication::postEvent (_rcvr, e); // to app event loop
}
}
*/
//-------------------------------------------------------------------------------
......@@ -359,7 +361,7 @@ bool UDPInput::hasPeer ()
QHostAddress UDPInput::peer ()
{
sock->readDatagram (packetData, wholeSize, peerAddress);//***JPC Port to qt4*****************
cout << (*peerAddress).toString().latin1() << endl;
cout << (*peerAddress).toString().toStdString() << endl;
//cout << sock->state() << endl;
//cout << sock->peerName().latin1() << endl;
//return sock->peerAddress ();
......
......@@ -82,7 +82,7 @@ public:
int bpp;
int wholeSize;
int numRedundantBuffers;
void plotVal (double v);
//void plotVal (double v);
};
......
......@@ -108,7 +108,7 @@ UDPOutput::connect (QHostAddress remote)
//sock->connect (remote, netInfo->getInPort ()); //***JPC Port to qt4*****************
sock->connectToHost (remote, netInfo->getInPort ()); //***JPC Port to qt4*****************
cout << "Connecting to " << remote.toString().latin1() << ":" << netInfo->
cout << "Connecting to " << remote.toString().toStdString() << ":" << netInfo->
getInPort () << endl;
return 0;
......@@ -287,7 +287,7 @@ UDPOutput::run ()
perror ("Send");
//**************JPC COMENTED OUT*******************
cout << "error sending to " << sock->peerAddress ().
toString ().latin1() << endl;
toString ().toStdString() << endl;
//*************************************************
return;
}
......@@ -327,6 +327,7 @@ UDPOutput::stop ()
/*! \brief
*/
//---------------------------------------------------------------------------------------------
/*
void UDPOutput::plotVal (double v)
{
if(_rcvr!=NULL)
......@@ -335,4 +336,4 @@ void UDPOutput::plotVal (double v)
QApplication::postEvent (_rcvr, e); // to app event loop
}
}
*/
......@@ -78,7 +78,7 @@ public:
void stop ();
int bpp;
int wholeSize;
void plotVal (double v);
//void plotVal (double v);
int setPeerAddress (QHostAddress remote);
};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment