Fixed sigsev on PD restart.

Fixed pan bug on pd patch
This commit is contained in:
Santi Noreña 2014-07-16 18:24:51 +02:00
parent 5cfd9f7a10
commit a45234bc68
2 changed files with 57 additions and 57 deletions

View file

@ -26,19 +26,6 @@ AudioMotor::AudioMotor(QObject *parent) :
m_gui(true)
{
qsrand(qrand());
qDebug() << "Init MotorAudio";
}
AudioMotor::~AudioMotor()
{
close();
}
/** Init the engine
*/
bool AudioMotor::init()
{
/* Sets the socket an connections for the comunication with PD
QFile socket(SOCKET);
if (socket.exists())
@ -70,7 +57,19 @@ bool AudioMotor::init()
connect(m_pd_audio, SIGNAL(readyReadStandardError()), this, SLOT(stdout()));
connect(m_pd_audio, SIGNAL(finished(int)), this, SLOT(restartAudio()));
qDebug() << "Init MotorAudio";
}
AudioMotor::~AudioMotor()
{
close();
}
/** Init the engine
*/
bool AudioMotor::init()
{
QString arguments;
// arguments.append("./puredata/pd -alsa -channels 2 -audiodev 1 -stderr -nostdpath -path ./puredata/externals/ -open ./puredata/lms-audio.pd ");
arguments.append("./puredata/pd -channels 2 -stderr -nostdpath -path ./puredata/externals/ -open ./puredata/lms-audio.pd ");
@ -95,27 +94,27 @@ bool AudioMotor::init()
*/
bool AudioMotor::close()
{
disconnect(m_pd_audio, SIGNAL(readyReadStandardError()), this, SLOT(stdout()));
// disconnect(m_pd_audio, SIGNAL(readyReadStandardError()), this, SLOT(stdout()));
disconnect(m_pd_audio, SIGNAL(finished(int)), this, SLOT(restartAudio()));
m_pd_audio->terminate();
m_pd_audio->waitForFinished(1000);
delete m_pd_audio;
m_pd_audio = NULL;
// m_pd_audio->terminate();
m_pd_audio->waitForFinished(3000);
// delete m_pd_audio;
// m_pd_audio = NULL;
if (m_writePD != NULL)
{
disconnect(m_writePD, SIGNAL(connected()),this, SLOT(newConexion()));
m_writePD->close();
delete m_writePD;
m_writePD = NULL;
// delete m_writePD;
// m_writePD = NULL;
}
if (m_readPD != NULL)
/* if (m_readPD != NULL)
{
disconnect(m_readPD, SIGNAL(newConnection()),this, SLOT(newPeer()));
m_readPD->close();
delete m_readPD;
m_readPD = NULL;
}
/*
QFile socket(SOCKET);
if (socket.exists())
{
@ -313,8 +312,10 @@ void AudioMotor::parse(QString message)
emit toTerminal("AudioMotor::newMessage() Loadbang from PD Audio received");
// Conectamos a Pure Data para escribir
m_writePD->connectToHost(QHostAddress::LocalHost, SOCKET, QIODevice::WriteOnly);
if (m_writePD->waitForConnected(30000))
if (m_writePD->waitForConnected(30000)) {
emit loadbang();
connect(m_pd_audio, SIGNAL(finished(int)), this, SLOT(restartAudio()));
}
break;
case 9:
if (list.at(i).at(2).digitValue() == 0) {