Commit 0185410d authored by jcaceres's avatar jcaceres
Browse files

add qt3 branch

parent 8a5575f0
......@@ -3,9 +3,6 @@
#ifndef THREADCOMMEVENT_H
#define THREADCOMMEVENT_H
#include "qobject.h"
//Added by qt3to4:
#include <QEvent>
#include <QCustomEvent>
class ThreadCommEvent:public QCustomEvent
{
......
......@@ -60,7 +60,7 @@ mode (mode)
case RECORD:
if (jack)
jdevice =
new JackClient ("jacktrip",//APP_NAME, //*JPC Hack, need to fix later
new JackClient (APP_NAME,
audioInfo->
getNumChans (),
audioInfo->
......@@ -85,7 +85,7 @@ mode (mode)
case PLAYBACK:
if (jack)
jdevice =
new JackClient ("jacktrip",//APP_NAME, //*JPC Hack, need to fix later
new JackClient (APP_NAME,
audioInfo->
getNumChans (),
audioInfo->
......@@ -106,7 +106,7 @@ mode (mode)
case DUPLEX:
if (jack)
jdevice =
new JackClient ("jacktrip",//APP_NAME, //*JPC Hack, need to fix later
new JackClient (APP_NAME,
audioInfo->
getNumChans (),
audioInfo->
......@@ -172,8 +172,7 @@ mode (mode)
{
readLock = new QSemaphore (1);
writeLock = new QSemaphore (1);
//(*writeLock)++; // lock out write, to start with read
(*writeLock).acquire(); //****JPC qt4 porting******
(*writeLock)++; // lock out write, to start with read
}
if (jack)
......@@ -241,8 +240,7 @@ AudioDevice::bufferPtrs (void *jib, void *job)
void
AudioDevice::unlockRead ()
{
//(*readLock)--; // so audio input thread will unblock when stopped
(*readLock).release();//****JPC qt4 porting******
(*readLock)--; // so audio input thread will unblock when stopped
}
void
......@@ -254,11 +252,9 @@ AudioDevice::readBuffer (void *to)
cerr << "ERROR: AudioDevice::readBuffer called on device in PLAYBACK mode!" << endl;
}
//(*readLock)++;
(*readLock).acquire();//****JPC qt4 porting******
(*readLock)++;
memcpy (to, buffer, bytesPerBuffer);
//(*writeLock)--;
(*writeLock).release();//****JPC qt4 porting******
(*writeLock)--;
}
......@@ -272,12 +268,10 @@ AudioDevice::writeBuffer (void *from)
if (harp == false)
{
//(*writeLock)++;
(*writeLock).acquire();//****JPC qt4 porting******
(*writeLock)++;
memcpy (buffer, from, bytesPerBuffer);
tick (); // calls tickstream, blocks
//(*readLock)--;
(*readLock).release();//****JPC qt4 porting******
(*readLock)--;
}
else
......
......@@ -19,10 +19,6 @@
#include "JackClient.h"
#include "qthread.h"
#include "StreamBD.h"
//#include <qwaitcondition.h>
#include <QWaitCondition>
#include <QSemaphore>
/**
* @brief Interfaces with an RtAudio sound device.
*/
......
......@@ -41,7 +41,6 @@ maxSeq (maxSeq)
prepareReaderWriter ();
dataLock = new QSemaphore (1);
//cout << (*dataLock).available() << endl;
secondTry = false;
}
......@@ -94,8 +93,7 @@ CircularBuffer::write (const void *writeChunk)
this->overflowReset ();
}
if (blockOnEmpty)
//(*readSemaphore)--;
(*readSemaphore).release();//****JPC qt4 porting******
(*readSemaphore)--;
return chunkSize;
}
......@@ -104,8 +102,7 @@ CircularBuffer::writeRedundant (const void *writeChunk, int z, int seq)
{
// if (isFull () == false)
{
//(*dataLock)++;
(*dataLock).acquire();//****JPC qt4 porting******
(*dataLock)++;
int tmpPosition = writePosition - z;
if (tmpPosition < 0)
{
......@@ -127,13 +124,10 @@ CircularBuffer::writeRedundant (const void *writeChunk, int z, int seq)
// cout << "seq " << seq <<"\t";
if (z == 0)
writePosition = ++writePosition % numBufChunks;
//(*dataLock)--;
(*dataLock).release();//****JPC qt4 porting******
}
if (blockOnEmpty) {
//(*readSemaphore)--;
(*readSemaphore).release();//****JPC qt4 porting******
(*dataLock)--;
}
if (blockOnEmpty)
(*readSemaphore)--;
// return chunkSize;
return writePosition;
}
......@@ -143,8 +137,7 @@ CircularBuffer::read (void *readChunk)
{
if (blockOnEmpty)
{
//(*readSemaphore)++;
(*readSemaphore).acquire();//****JPC qt4 porting******
(*readSemaphore)++;
if (isEmpty () == false)
......@@ -165,8 +158,7 @@ CircularBuffer::read (void *readChunk)
{ // not blockOnEmpty
if (lastSeq == -1)
lastSeq = 0;
//(*dataLock)++;
(*dataLock).acquire();//****JPC qt4 porting******
(*dataLock)++;
int nextSeq = (lastSeq + 1) % maxSeq;
int i = 0;
int lag = -maxSeq;
......@@ -196,8 +188,7 @@ CircularBuffer::read (void *readChunk)
memcpy (readChunk,
(void *) ((char *) cbBuffer +
bestReadPosition * chunkSize), chunkSize);
//(*dataLock)--;
(*dataLock).release();//****JPC qt4 porting******
(*dataLock)--;
}
if (blockOnEmpty)
return chunkSize;
......@@ -208,20 +199,17 @@ CircularBuffer::read (void *readChunk)
/** Full if writer is one circular position behind the reader. */
bool CircularBuffer::isFull ()
{
//(*dataLock)++;
(*dataLock).acquire();//****JPC qt4 porting******
(*dataLock)++;
// cerr << "(" << writePosition << "," << readPosition << ") ";
// cerr << ((readPosition + numChunks - writePosition) % numChunks) << endl;
if (writePosition == (readPosition + numBufChunks - 1) % numBufChunks)
{
//(*dataLock)--;
(*dataLock).release();//****JPC qt4 porting******
(*dataLock)--;
return true;
}
else
{
//(*dataLock)--;
(*dataLock).release();//****JPC qt4 porting******
(*dataLock)--;
return false;
}
}
......@@ -230,18 +218,15 @@ bool CircularBuffer::isFull ()
/** Empty if writer is equal to reader */
bool CircularBuffer::isEmpty ()
{
//(*dataLock)++;
(*dataLock).acquire();//****JPC qt4 porting******
(*dataLock)++;
if (writePosition == readPosition)
{
//(*dataLock)--;
(*dataLock).release();//****JPC qt4 porting******
(*dataLock)--;
return true;
}
else
{
//(*dataLock)--;
(*dataLock).release();//****JPC qt4 porting******
(*dataLock)--;
return false;
}
}
......@@ -250,8 +235,7 @@ void
CircularBuffer::prepareReaderWriter ()
{
readSemaphore = new QSemaphore (1);
//(*readSemaphore)++;
(*readSemaphore).acquire();//****JPC qt4 porting******
(*readSemaphore)++;
fillChunksWithZeros (0, numBufChunks / 2 - 1);
}
......@@ -265,10 +249,8 @@ CircularBuffer::fillChunksWithZeros (int from, int to)
{
memset (((char *) cbBuffer + writePosition * chunkSize), 0,
chunkSize);
if (blockOnEmpty) {
//(*readSemaphore)--;
(*readSemaphore).release();//****JPC qt4 porting******
}
if (blockOnEmpty)
(*readSemaphore)--;
}
writePosition = writePosition % numBufChunks;
readPosition = from;
......@@ -281,12 +263,10 @@ CircularBuffer::underrunReset ()
cerr << "----output- underflow!!" << endl;
else
cerr << "-input--- underflow!!" << endl;
//(*dataLock)++;
(*dataLock).acquire();//****JPC qt4 porting******
(*dataLock)++;
delete readSemaphore;
prepareReaderWriter ();
//(*dataLock)--;
(*dataLock).release();//****JPC qt4 porting******
(*dataLock)--;
}
void
......@@ -297,9 +277,7 @@ CircularBuffer::overflowReset ()
else
cerr << "-input--- Overflow!" << endl;
//(*dataLock)++;
(*dataLock).acquire();//****JPC qt4 porting******
(*dataLock)++;
readPosition = (writePosition + (numBufChunks / 2)) % numBufChunks;
//(*dataLock)--;
(*dataLock).release();//****JPC qt4 porting******
(*dataLock)--;
}
......@@ -3,8 +3,7 @@
#define INCLUDED_CIRCULARBUFFER
#include <qthread.h>
//#include <qsemaphore.h>//***JPC Port to qt4*****************
#include <QSemaphore>
/**
* @brief Provides a circular buffer that can be written to and read
* from asynchronously.
......
......@@ -13,21 +13,19 @@ APP_NAME_QUOTES=\\\"$APP_NAME\\\"
#rm -r obj
#rm -r moc
rm $APP_NAME.pro
rm Makefile
#rm $APP_NAME.pro
#echo "progen"
#qmake -project -o $APP_NAME.pro ui/ ../include/
qmake-qt4 -project -o $APP_NAME.pro
qmake -project -o $APP_NAME.pro
echo "qmake .pro built"
#Create Makefile
qmake-qt4 -makefile -unix -o Makefile \
qmake -makefile -unix -o Makefile \
"CONFIG+=qt thread warn_on debug" \
"QMAKE_CXXFLAGS+=-Wno-deprecated -g -O2" \
"QT += network qt3support" \
"QMAKE_CXXFLAGS+=-Wno-deprecated -pg -g" \
"INCLUDEPATH+=/usr/include/stk ../include" \
"DEFINES+=__LINUX_ALSA__ APP_NAME=$APP_NAME_QUOTES" \
"QMAKE_CLEAN+=$APP_NAME" \
......
......@@ -35,7 +35,7 @@ IPv4Addr (char *namebuf)
}
#include <qapplication.h>
#include <q3textstream.h>
#include <qtextstream.h>
/****************************************************************************
* MAIN
***************************************************************************/
......@@ -51,8 +51,8 @@ main (int argc, char **argv)
if (s.ParseCommandLine (argc, argv) == 0)
return 0;
MainDialog m;
//a.setMainWidget (&m);
//if (s.args->gui) m.show ();
a.setMainWidget (&m);
if (s.args->gui) m.show ();
m.init (&s);
a.processEvents ();
return a.exec ();
......
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