Commit f75b9b37 authored by jcacerec's avatar jcacerec
Browse files

Server cleaned up and working fine, need to add oncfiguration variables

parent f982a931
......@@ -4,6 +4,8 @@
- (fixed) Improved exceptions handling
- (added) Meta-server
- (added) Basic Karplus-Strong model added
- (dropped) Dropped support for PPC Mac OS X, now only supports
Intel Mac OS X machines and Linux
---
1.0.2 Alpha
......
......@@ -222,21 +222,20 @@ public slots:
/// \brief Slot to stop all the processes and threads
void slotStopProcesses()
{
std::cout << "----------- STOPING JACKTRIP --------------" << std::endl;
std::cout << "Stopping JackTrip..." << std::endl;
stop();
};
/** \brief This slot emit the signal signalProcessesStopped()
/** \brief This slot emits in turn the signal signalNoUdpPacketsForSeconds
* when UDP is waited for more than 30 seconds.
*
* It is used to remove the thread from the server.
*/
void slotUdpWatingTooLong(int wait_msec)
{
int wait_time = 1000; // msec
int wait_time = 30000; // msec
if ( !(wait_msec%wait_time) ) {
std::cerr << "UDP WAITED MORE THAN 30 seconds." << std::endl;
//emit signalProcessesStopped();
emit signalNoUdpPacketsForSeconds();
}
}
......@@ -245,9 +244,10 @@ public slots:
signals:
/// \brieg Signal emitted when all the processes and threads are stopped
void signalProcessesStopped();
/// \brieg Signal emitted when no UDP Packets have been received for a while
void signalNoUdpPacketsForSeconds();
private:
/// \brief Set the JackAudioInteface object
......
......@@ -63,7 +63,7 @@ void JackTripThread::run()
//QThread::sleep(1);
jacktrip.start();
netks.play();
//netks.play();
jacktrip.wait();
......
......@@ -42,7 +42,6 @@
#include <QMutexLocker>
#include "JackTripWorker.h"
#include "JackTripWorkerMessages.h"
#include "JackTrip.h"
#include "UdpMasterListener.h"
#include "NetKS.h"
......@@ -110,64 +109,47 @@ void JackTripWorker::run()
// Try catching any exceptions that come from JackTrip
try
{
// Local event loop. this is necesary because QRunnables don't have their own as QThreads
QEventLoop event_loop;
// Create and setup JackTrip Object
JackTrip jacktrip(JackTrip::CLIENT, JackTrip::UDP, mNumChans, 2);
jacktrip.setPeerAddress( mClientAddress.toString().toLatin1().data() );
jacktrip.setLocalPorts(mServerPort);
jacktrip.setPeerPorts(mClientPort-1);
NetKS netks;
jacktrip.appendProcessPlugin(&netks);
// Create and setup signals and slots connections
//JackTripWorkerMessages JTWMessages;
//QObject::connect(&jacktrip, SIGNAL(signalProcessesStopped()),
// &JTWMessages, SLOT(slotTest()), Qt::QueuedConnection);
//QObject::connect(&jacktrip, SIGNAL(signalNoUdpPacketsForSeconds()),
// &JTWMessages, SLOT(slotTest()), Qt::QueuedConnection);
// Connect signals and slots
// -------------------------
QObject::connect(&jacktrip, SIGNAL(signalNoUdpPacketsForSeconds()),
&jacktrip, SLOT(slotStopProcesses()), Qt::QueuedConnection);
// Start Threads and event loop
jacktrip.start();
QEventLoop event_loop;
QObject::connect(&jacktrip, SIGNAL(signalNoUdpPacketsForSeconds()),
&event_loop, SLOT(quit()),
Qt::QueuedConnection);
//QObject::connect(&JTWMessages, SIGNAL(signalStopEventLoop()),
// &event_loop, SLOT(quit()), Qt::QueuedConnection);
// Connection to terminate the local eventloop when jacktrip is done
QObject::connect(&jacktrip, SIGNAL(signalProcessesStopped()),
&event_loop, SLOT(quit()),
Qt::QueuedConnection);
&event_loop, SLOT(quit()), Qt::QueuedConnection);
// Karplus Strong String
NetKS netks;
jacktrip.appendProcessPlugin(&netks);
// Play the String
QTimer timer;
QObject::connect(&timer, SIGNAL(timeout()), &netks, SLOT(exciteString()),
Qt::QueuedConnection);
timer.start(300);
// Start Threads and event loop
jacktrip.start();
{ // Thread is already spawning, so release the lock
QMutexLocker locker(&mMutex);
mSpawning = false;
}
event_loop.exec(); // Excecution will block here until exit() the QEventLoop
//--------------------------------------------------------------------------
// wait for jacktrip to be done before exiting the Worker Thread
jacktrip.wait();
}
catch ( const std::exception & e )
{
......@@ -175,18 +157,14 @@ void JackTripWorker::run()
std::cerr << e.what() << endl;
std::cerr << gPrintSeparator << endl;
}
mUdpMasterListener->releasePort(mID);
{ // Thread is already spawning, so release the lock
{
// Thread is already spawning, so release the lock
QMutexLocker locker(&mMutex);
mSpawning = false;
}
/*
QObject::connect(jacktrip, SIGNAL(JackTripStopped()),
udpmasterlistener, SLOT(setValue(int)));
*/
cout << "JackTrip ID = " << mID << " released from the THREAD POOL" << endl;
cout << gPrintSeparator << endl;
}
......
......@@ -45,13 +45,17 @@
#include "ProcessPlugin.h"
/** \brief A simple (basic) network Karplus Strong.
*
* This plugin creates a one channel network karplus strong.
*/
class NetKS : public ProcessPlugin
{
Q_OBJECT;
public:
/*
void play()
{
std::cout << "********** PALYING ***********************************" << std::endl;
......@@ -59,19 +63,17 @@ public:
QObject::connect(timer, SIGNAL(timeout()), this, SLOT(exciteString()));
timer->start(300);
}
//signals:
//void playString();
*/
private slots:
/// \brief Stlot to excite (play) the string
void exciteString()
{
std::cout << "========= EXTICING STRING ===========" << std::endl;
fbutton0 = 1.0;
//std::cout << fbutton0 << std::endl;
usleep(280000);
usleep(280000); /// \todo Define this number based on the sampling rate and buffer size
fbutton0 = 0.0;
//std::cout << fbutton0 << std::endl;
}
......
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