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 @@ ...@@ -35,8 +35,10 @@
#include "math.h" #include "math.h"
#include "string.h" #include "string.h"
#include "audioDevice.h" #include "audioDevice.h"
#include "qstring.h" //#include "qstring.h"
#include <q3textstream.h> #include <QString>
//#include <q3textstream.h>
#include <QTextStream>
#define ONE_BASED (i+1) #define ONE_BASED (i+1)
...@@ -237,17 +239,19 @@ JackClient::JackClient (int nChans, int nFrames, bool output, bool input, AudioD ...@@ -237,17 +239,19 @@ JackClient::JackClient (int nChans, int nFrames, bool output, bool input, AudioD
for (int i = 0; i < nChans; i++) for (int i = 0; i < nChans; i++)
{ {
QString iName, oName; QString iName, oName;
QTextOStream (&iName) << "input" << ONE_BASED; //QTextOStream (&iName) << "input" << ONE_BASED;
QTextOStream (&oName) << "output" << ONE_BASED; //QTextOStream (&oName) << "output" << ONE_BASED;
QTextStream (&iName) << "input" << ONE_BASED;//QT4 Port****
QTextStream (&oName) << "output" << ONE_BASED;//QT4 Port****
if (output) if (output)
output_port[ONE_BASED] = output_port[ONE_BASED] =
jack_port_register (client, oName, jack_port_register (client, oName.toLatin1(),
JACK_DEFAULT_AUDIO_TYPE, JACK_DEFAULT_AUDIO_TYPE,
JackPortIsOutput, 0); JackPortIsOutput, 0);
if (input) if (input)
input_port[ONE_BASED] = input_port[ONE_BASED] =
jack_port_register (client, iName, jack_port_register (client, iName.toLatin1(),
JACK_DEFAULT_AUDIO_TYPE, JACK_DEFAULT_AUDIO_TYPE,
JackPortIsInput, 0); JackPortIsInput, 0);
} }
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
#include "qslider.h" #include "qslider.h"
#include "qcombobox.h" #include "qcombobox.h"
#include "qradiobutton.h" #include "qradiobutton.h"
#include "ThreadCommEvent.h" //#include "ThreadCommEvent.h"
#include <qlabel.h> #include <qlabel.h>
#include <qlayout.h> #include <qlayout.h>
...@@ -68,35 +68,35 @@ MainDialog::init(StreamBD *s) ...@@ -68,35 +68,35 @@ MainDialog::init(StreamBD *s)
//********************************************* //*********************************************
//Coment out to remove dependency of widget //Coment out to remove dependency of widget
QString tmp; QString tmp;
QTextOStream (&tmp) << "sampleRate " << s->args->sampleRate; QTextStream (&tmp) << "sampleRate " << s->args->sampleRate;
//sampleRateTextLabel->setText (tmp); tmp = ""; //sampleRateTextLabel->setText (tmp); tmp = "";
QTextOStream (&tmp) << "netHarpStrings " << s->args->netHarpStrings; QTextStream (&tmp) << "netHarpStrings " << s->args->netHarpStrings;
//netHarpStringsTextLabel->setText (tmp); tmp = ""; //netHarpStringsTextLabel->setText (tmp); tmp = "";
QTextOStream (&tmp) << "audioChannels " << s->args->audioChannels; QTextStream (&tmp) << "audioChannels " << s->args->audioChannels;
//audioChannelsTextLabel->setText (tmp); tmp = ""; //audioChannelsTextLabel->setText (tmp); tmp = "";
QTextOStream (&tmp) << "runFifo " << s->args->runFifo; QTextStream (&tmp) << "runFifo " << s->args->runFifo;
//runFifoTextLabel->setText (tmp); tmp = ""; //runFifoTextLabel->setText (tmp); tmp = "";
QTextOStream (&tmp) << "audioDeviceID " << s->args->audioDeviceID; QTextStream (&tmp) << "audioDeviceID " << s->args->audioDeviceID;
//audioDeviceIDTextLabel->setText (tmp); tmp = ""; //audioDeviceIDTextLabel->setText (tmp); tmp = "";
QTextOStream (&tmp) << "netInQInPackets " << s->args->networkInputQueueLengthInPackets; QTextStream (&tmp) << "netInQInPackets " << s->args->networkInputQueueLengthInPackets;
//netInQInPacketsTextLabel->setText (tmp); tmp = ""; //netInQInPacketsTextLabel->setText (tmp); tmp = "";
QTextOStream (&tmp) << "redundancy " << s->args->redundancy; QTextStream (&tmp) << "redundancy " << s->args->redundancy;
//redundancyTextLabel->setText (tmp); tmp = ""; //redundancyTextLabel->setText (tmp); tmp = "";
QTextOStream (&tmp) << "audioInQInAudioBufs " << s->args->audioInputQueueLengthInAudioBuffers; QTextStream (&tmp) << "audioInQInAudioBufs " << s->args->audioInputQueueLengthInAudioBuffers;
//audioInQInAudioBufsTextLabel->setText (tmp); tmp = ""; //audioInQInAudioBufsTextLabel->setText (tmp); tmp = "";
QTextOStream (&tmp) << "framesPerAudioBuffer " << s->args->framesPerAudioBuffer; QTextStream (&tmp) << "framesPerAudioBuffer " << s->args->framesPerAudioBuffer;
//framesPerAudioBufferTextLabel->setText (tmp); tmp = ""; //framesPerAudioBufferTextLabel->setText (tmp); tmp = "";
QTextOStream (&tmp) << "networkPortOffset " << s->args->networkPortOffset; QTextStream (&tmp) << "networkPortOffset " << s->args->networkPortOffset;
//networkPortOffsetTextLabel->setText (tmp); tmp = ""; //networkPortOffsetTextLabel->setText (tmp); tmp = "";
QTextOStream (&tmp) << "runMode " << s->args->runMode; QTextStream (&tmp) << "runMode " << s->args->runMode;
//runModeTextLabel->setText (tmp); tmp = ""; //runModeTextLabel->setText (tmp); tmp = "";
QTextOStream (&tmp) << "secondsBetweenPlucks " << s->args->secondsBetweenPlucks; QTextStream (&tmp) << "secondsBetweenPlucks " << s->args->secondsBetweenPlucks;
//secondsBetweenPlucksTextLabel->setText (tmp); tmp = ""; //secondsBetweenPlucksTextLabel->setText (tmp); tmp = "";
QTextOStream (&tmp) << "lowPassFilterCoeff " << s->args->lowPassFilterCoeff; QTextStream (&tmp) << "lowPassFilterCoeff " << s->args->lowPassFilterCoeff;
//lowPassFilterCoeffTextLabel->setText (tmp); tmp = ""; //lowPassFilterCoeffTextLabel->setText (tmp); tmp = "";
QTextOStream (&tmp) << "delayIncBtwnStrings " << s->args->delayIncrementBetweenStrings; QTextStream (&tmp) << "delayIncBtwnStrings " << s->args->delayIncrementBetweenStrings;
//delayIncBtwnStringsTextLabel->setText (tmp); tmp = ""; //delayIncBtwnStringsTextLabel->setText (tmp); tmp = "";
QTextOStream (&tmp) << "jack " << s->args->jack; QTextStream (&tmp) << "jack " << s->args->jack;
//jackTextLabel->setText (tmp); //jackTextLabel->setText (tmp);
//********************************************* //*********************************************
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
#ifndef _MAINDIALOG_H_ #ifndef _MAINDIALOG_H_
#define _MAINDIALOG_H_ #define _MAINDIALOG_H_
#include "q3ptrlist.h" //#include "q3ptrlist.h"
#include "qthread.h" #include "qthread.h"
#include <qstring.h> #include <qstring.h>
#include "qtimer.h" #include "qtimer.h"
......
...@@ -619,7 +619,7 @@ StreamBD::EstablishConnection (runModeT runMode, char *hostname, UDPOutput * net ...@@ -619,7 +619,7 @@ StreamBD::EstablishConnection (runModeT runMode, char *hostname, UDPOutput * net
/////FOLOW THIS TO FIND THE PROBLEM /////FOLOW THIS TO FIND THE PROBLEM
//**************JPC COMENTED OUT******************* //**************JPC COMENTED OUT*******************
cout << endl << "Connection received from: " << cout << endl << "Connection received from: " <<
netin->peer().toString().latin1() << endl; netin->peer().toString().toStdString() << endl;
//************************************************* //*************************************************
cout << "Requesting return connection...."; cout << "Requesting return connection....";
//netout->connect (netin->peer ()); //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) ...@@ -94,6 +94,7 @@ AudioInput::xfrFrom (void *buf)
} }
/*
void AudioInput::plotVal (double v) void AudioInput::plotVal (double v)
{ {
if(_rcvr!=NULL) if(_rcvr!=NULL)
...@@ -104,3 +105,4 @@ void AudioInput::plotVal (double v) ...@@ -104,3 +105,4 @@ void AudioInput::plotVal (double v)
QApplication::postEvent (_rcvr, e); // to app event loop QApplication::postEvent (_rcvr, e); // to app event loop
} }
} }
*/
...@@ -60,6 +60,6 @@ public: ...@@ -60,6 +60,6 @@ public:
int rcv (char *buf); int rcv (char *buf);
void run (); void run ();
void stop (); void stop ();
void plotVal (double v); //void plotVal (double v);
}; };
#endif #endif
...@@ -109,6 +109,7 @@ AudioOutput::stop () ...@@ -109,6 +109,7 @@ AudioOutput::stop ()
_running = false; _running = false;
} }
/*
void AudioOutput::plotVal (double v) void AudioOutput::plotVal (double v)
{ {
if(_rcvr!=NULL) if(_rcvr!=NULL)
...@@ -119,3 +120,4 @@ void AudioOutput::plotVal (double v) ...@@ -119,3 +120,4 @@ void AudioOutput::plotVal (double v)
QApplication::postEvent (_rcvr, e); // to app event loop QApplication::postEvent (_rcvr, e); // to app event loop
} }
} }
*/
...@@ -105,7 +105,7 @@ public: ...@@ -105,7 +105,7 @@ public:
*/ */
void stop (); void stop ();
void plotVal (double v); //void plotVal (double v);
}; };
/** NEWVERSION in other file */ /** NEWVERSION in other file */
......
...@@ -27,7 +27,7 @@ echo "qmake .pro built" ...@@ -27,7 +27,7 @@ echo "qmake .pro built"
qmake-qt4 -makefile -unix -o Makefile \ qmake-qt4 -makefile -unix -o Makefile \
"CONFIG+=qt debug thread warn_on" \ "CONFIG+=qt debug thread warn_on" \
"QMAKE_CXXFLAGS+=-Wno-deprecated -g -O2" \ "QMAKE_CXXFLAGS+=-Wno-deprecated -g -O2" \
"QT += network qt3support" \ "QT += network" \
"DEFINES+=__LINUX_ALSA__ APP_NAME=$APP_NAME_QUOTES" \ "DEFINES+=__LINUX_ALSA__ APP_NAME=$APP_NAME_QUOTES" \
"QMAKE_CLEAN+=$APP_NAME" \ "QMAKE_CLEAN+=$APP_NAME" \
"unix:LIBS+=-Xlinker -rpath $QTDIR/lib -ljack" \ "unix:LIBS+=-Xlinker -rpath $QTDIR/lib -ljack" \
...@@ -37,5 +37,6 @@ qmake-qt4 -makefile -unix -o Makefile \ ...@@ -37,5 +37,6 @@ qmake-qt4 -makefile -unix -o Makefile \
#INCLUDEPATH+=/usr/include/stk ../include" \ #INCLUDEPATH+=/usr/include/stk ../include" \
#"unix:LIBS+=-Xlinker -rpath $QTDIR/lib -lstk -lasound -ljack" \ #"unix:LIBS+=-Xlinker -rpath $QTDIR/lib -lstk -lasound -ljack" \
#"QT += network qt3support" \
echo "done" echo "done"
...@@ -68,7 +68,7 @@ IPv4Addr (char *namebuf) ...@@ -68,7 +68,7 @@ IPv4Addr (char *namebuf)
} }
#include <qapplication.h> #include <qapplication.h>
#include <q3textstream.h> //#include <q3textstream.h>
/**************************************************************************** /****************************************************************************
* MAIN * MAIN
***************************************************************************/ ***************************************************************************/
......
...@@ -36,11 +36,13 @@ ...@@ -36,11 +36,13 @@
#ifndef _PLUGIN_H #ifndef _PLUGIN_H
#define _PLUGIN_H #define _PLUGIN_H
#include <qthread.h> //#include <qthread.h>
#include <QThread>
// for plotting // for plotting
#include <sys/time.h> #include <sys/time.h>
#include "qapplication.h" //#include "qapplication.h"
#include "ThreadCommEvent.h" #include <QApplication>
//#include "ThreadCommEvent.h"
class Plugin:public QThread class Plugin:public QThread
...@@ -59,7 +61,7 @@ public: ...@@ -59,7 +61,7 @@ public:
}; };
QObject * _rcvr; QObject * _rcvr;
void setGUI(QObject * rcvr){_rcvr = rcvr;}; void setGUI(QObject * rcvr){_rcvr = rcvr;};
virtual void plotVal (double v) = 0; //virtual void plotVal (double v) = 0;
char *getName () char *getName ()
{ {
......
...@@ -37,7 +37,8 @@ ...@@ -37,7 +37,8 @@
#include <stdlib.h> #include <stdlib.h>
#include <time.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 #define debugMe FALSE
using namespace std; using namespace std;
...@@ -91,7 +92,8 @@ Stream::addInput (InputPlugin * newin) ...@@ -91,7 +92,8 @@ Stream::addInput (InputPlugin * newin)
newin->setWriteKey (ins.count ()); newin->setWriteKey (ins.count ());
APPEND (ins, newin); 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 (); addCircularBuffer ();
} }
...@@ -102,7 +104,8 @@ void ...@@ -102,7 +104,8 @@ void
Stream::addOutput (OutputPlugin * newout) Stream::addOutput (OutputPlugin * newout)
{ {
QSemaphore *tmp; 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. { // 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.) // add a lock for the first output (didn't need it when it was the only one.)
tmp = new QSemaphore (10); tmp = new QSemaphore (10);
...@@ -111,10 +114,12 @@ Stream::addOutput (OutputPlugin * newout) ...@@ -111,10 +114,12 @@ Stream::addOutput (OutputPlugin * newout)
APPEND (locks, tmp); APPEND (locks, tmp);
} }
newout->setReadKey (outs.count ()); //newout->setReadKey (outs.count ());
newout->setReadKey ( (outs.size() - outs.count(0)) );//QT4 port
APPEND (outs, newout); 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 (); addCircularBuffer ();
} }
...@@ -329,11 +334,17 @@ void ...@@ -329,11 +334,17 @@ void
Stream::startThreads () Stream::startThreads ()
{ {
// cache vector lengths for next run // cache vector lengths for next run
insCount = (int) ins.count (); //insCount = (int) ins.count ();
procsCount = (int) procs.count (); insCount = (int) (ins.size() - ins.count(0));//QT4 port
outsCount = (int) outs.count (); //procsCount = (int) procs.count ();
locksCount = (int) locks.count (); procsCount = (int) (procs.size() - procs.count(0));//QT4 port
bufsCount = (int) bufs.count (); //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 (); processesPerChan = procsCount / audioInfo->getNumChans ();
for (int i = 0; i < insCount; i++) for (int i = 0; i < insCount; i++)
...@@ -341,10 +352,12 @@ Stream::startThreads () ...@@ -341,10 +352,12 @@ Stream::startThreads ()
InputPlugin *ip = (InputPlugin *) ins[i]; InputPlugin *ip = (InputPlugin *) ins[i];
cout << "++++++++++++++++++++++" << endl; cout << "++++++++++++++++++++++" << endl;
if(!ip->dontRun) { if(!ip->dontRun) {
if (!ip->running ()) //if (!ip->running ())
if (!ip->isRunning())//QT4port-----------
ip->start (); ip->start ();
// with runMode == NETMIRROR ip needs to start earlier // 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-> cerr << "failed to start input plugin " << ip->
getName () << endl; getName () << endl;
...@@ -359,7 +372,8 @@ Stream::startThreads () ...@@ -359,7 +372,8 @@ Stream::startThreads ()
OutputPlugin *op = (OutputPlugin *) outs[i]; OutputPlugin *op = (OutputPlugin *) outs[i];
if(!op->dontRun) { if(!op->dontRun) {
op->start (); op->start ();
if (!op->running ()) //if (!op->running ())
if (!op->isRunning())//QT4port-----------
{ {
cerr << "failed to start output plugin " << op-> cerr << "failed to start output plugin " << op->
getName () << endl; getName () << endl;
...@@ -376,12 +390,14 @@ Stream::stopThreads () ...@@ -376,12 +390,14 @@ Stream::stopThreads ()
for (int i = 0; i < insCount; i++) for (int i = 0; i < insCount; i++)
{ {
InputPlugin *ip = ins[i]; InputPlugin *ip = ins[i];
if (ip->running ()) //if (ip->running ())
if (ip->isRunning())//QT4port-----------
{ {
ip->stop (); ip->stop ();
ip->wait (); ip->wait ();
delete ip; delete ip;
ins.remove (i); //ins.remove (i);
ins[i] = 0; //QT4 port
} }
} }
for (int i = 0; i < procsCount; i++) for (int i = 0; i < procsCount; i++)
...@@ -389,21 +405,24 @@ Stream::stopThreads () ...@@ -389,21 +405,24 @@ Stream::stopThreads ()
ProcessPlugin *pp = procs[i]; ProcessPlugin *pp = procs[i];
{ {
delete pp; delete pp;
procs.remove (i); //procs.remove (i);
procs[i] = 0; //QT4 port
} }
} }
for (int i = 0; i < outsCount; i++) for (int i = 0; i < outsCount; i++)
{ {
OutputPlugin *op = outs[i]; OutputPlugin *op = outs[i];
if (op->running ()) //if (op->running ())
if (op->isRunning())//QT4port-----------
{ {
cerr << i << " of " << outsCount << " STOP... " << cerr << i << " of " << outsCount << " STOP... " <<
endl; endl;
op->stop (); op->stop ();
op->wait (); op->wait ();
delete op; delete op;
outs.remove (i); //outs.remove (i);
outs[i] = 0; //QT4 port
cerr << " ... D, R " << op->getName () << endl; cerr << " ... D, R " << op->getName () << endl;
} }
} }
......
...@@ -41,7 +41,8 @@ ...@@ -41,7 +41,8 @@
#include "audioInfo.h" #include "audioInfo.h"
#include "networkInfo.h" #include "networkInfo.h"
#include "qthread.h" #include "qthread.h"
#include "q3ptrvector.h" //#include "q3ptrvector.h"
#include <QVector>
/** /**
* @brief Connects an InputPlugin to an OutputPlugin with * @brief Connects an InputPlugin to an OutputPlugin with
...@@ -58,15 +59,21 @@ class Stream ...@@ -58,15 +59,21 @@ class Stream
protected: protected:
// Vector inputs; // Vector inputs;
Q3PtrVector < InputPlugin > ins; //Q3PtrVector < InputPlugin > ins;
QVector < InputPlugin* > ins; //QT4 port
// Vector outputs; // Vector outputs;
Q3PtrVector < OutputPlugin > outs; //Q3PtrVector < OutputPlugin > outs;
QVector < OutputPlugin* > outs; //QT4 port
// Vector processes; // Vector processes;
Q3PtrVector < ProcessPlugin > procs; //Q3PtrVector < ProcessPlugin > procs;
QVector < ProcessPlugin* > procs; //QT4 port
// Vector circularBuffers; // Vector circularBuffers;
Q3PtrVector < CircularBuffer > bufs; //Q3PtrVector < CircularBuffer > bufs;
QVector < CircularBuffer* > bufs; //QT4 port
// Vector outputLocks; // Vector outputLocks;