mirror of
https://github.com/JulianGro/overte.git
synced 2025-07-10 15:17:38 +02:00
fix for sticking windows audio-mixer
This commit is contained in:
parent
f45c2a3e56
commit
81460e48f4
3 changed files with 17 additions and 12 deletions
|
@ -66,6 +66,9 @@ AssignmentClient::AssignmentClient(Assignment::Type requestAssignmentType, QStri
|
||||||
// set the logging target to the the CHILD_TARGET_NAME
|
// set the logging target to the the CHILD_TARGET_NAME
|
||||||
LogHandler::getInstance().setTargetName(ASSIGNMENT_CLIENT_TARGET_NAME);
|
LogHandler::getInstance().setTargetName(ASSIGNMENT_CLIENT_TARGET_NAME);
|
||||||
|
|
||||||
|
// make sure we output process IDs for a child AC otherwise it's insane to parse
|
||||||
|
LogHandler::getInstance().setShouldOutputPID(true);
|
||||||
|
|
||||||
// setup our _requestAssignment member variable from the passed arguments
|
// setup our _requestAssignment member variable from the passed arguments
|
||||||
_requestAssignment = Assignment(Assignment::RequestCommand, requestAssignmentType, assignmentPool);
|
_requestAssignment = Assignment(Assignment::RequestCommand, requestAssignmentType, assignmentPool);
|
||||||
|
|
||||||
|
|
|
@ -39,9 +39,9 @@ AssignmentClientMonitor::AssignmentClientMonitor(const unsigned int numAssignmen
|
||||||
_walletUUID(walletUUID),
|
_walletUUID(walletUUID),
|
||||||
_assignmentServerHostname(assignmentServerHostname),
|
_assignmentServerHostname(assignmentServerHostname),
|
||||||
_assignmentServerPort(assignmentServerPort)
|
_assignmentServerPort(assignmentServerPort)
|
||||||
{
|
{
|
||||||
qDebug() << "_requestAssignmentType =" << _requestAssignmentType;
|
qDebug() << "_requestAssignmentType =" << _requestAssignmentType;
|
||||||
|
|
||||||
// start the Logging class with the parent's target name
|
// start the Logging class with the parent's target name
|
||||||
LogHandler::getInstance().setTargetName(ASSIGNMENT_CLIENT_MONITOR_TARGET_NAME);
|
LogHandler::getInstance().setTargetName(ASSIGNMENT_CLIENT_MONITOR_TARGET_NAME);
|
||||||
|
|
||||||
|
@ -77,13 +77,13 @@ void AssignmentClientMonitor::simultaneousWaitOnChildren(int waitMsecs) {
|
||||||
while(_childProcesses.size() > 0 && !waitTimer.hasExpired(waitMsecs)) {
|
while(_childProcesses.size() > 0 && !waitTimer.hasExpired(waitMsecs)) {
|
||||||
// continue processing events so we can handle a process finishing up
|
// continue processing events so we can handle a process finishing up
|
||||||
QCoreApplication::processEvents();
|
QCoreApplication::processEvents();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AssignmentClientMonitor::childProcessFinished() {
|
void AssignmentClientMonitor::childProcessFinished() {
|
||||||
QProcess* childProcess = qobject_cast<QProcess*>(sender());
|
QProcess* childProcess = qobject_cast<QProcess*>(sender());
|
||||||
qint64 processID = _childProcesses.key(childProcess);
|
qint64 processID = _childProcesses.key(childProcess);
|
||||||
|
|
||||||
if (processID > 0) {
|
if (processID > 0) {
|
||||||
qDebug() << "Child process" << processID << "has finished. Removing from internal map.";
|
qDebug() << "Child process" << processID << "has finished. Removing from internal map.";
|
||||||
_childProcesses.remove(processID);
|
_childProcesses.remove(processID);
|
||||||
|
@ -98,17 +98,17 @@ void AssignmentClientMonitor::stopChildProcesses() {
|
||||||
qDebug() << "Attempting to terminate child process" << childProcess->processId();
|
qDebug() << "Attempting to terminate child process" << childProcess->processId();
|
||||||
childProcess->terminate();
|
childProcess->terminate();
|
||||||
}
|
}
|
||||||
|
|
||||||
simultaneousWaitOnChildren(WAIT_FOR_CHILD_MSECS);
|
simultaneousWaitOnChildren(WAIT_FOR_CHILD_MSECS);
|
||||||
|
|
||||||
if (_childProcesses.size() > 0) {
|
if (_childProcesses.size() > 0) {
|
||||||
// ask even more firmly
|
// ask even more firmly
|
||||||
foreach(QProcess* childProcess, _childProcesses) {
|
foreach(QProcess* childProcess, _childProcesses) {
|
||||||
qDebug() << "Attempting to kill child process" << childProcess->processId();
|
qDebug() << "Attempting to kill child process" << childProcess->processId();
|
||||||
childProcess->kill();
|
childProcess->kill();
|
||||||
}
|
}
|
||||||
|
|
||||||
simultaneousWaitOnChildren(WAIT_FOR_CHILD_MSECS);
|
simultaneousWaitOnChildren(WAIT_FOR_CHILD_MSECS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ void AssignmentClientMonitor::aboutToQuit() {
|
||||||
void AssignmentClientMonitor::spawnChildClient() {
|
void AssignmentClientMonitor::spawnChildClient() {
|
||||||
QProcess* assignmentClient = new QProcess(this);
|
QProcess* assignmentClient = new QProcess(this);
|
||||||
|
|
||||||
|
|
||||||
// unparse the parts of the command-line that the child cares about
|
// unparse the parts of the command-line that the child cares about
|
||||||
QStringList _childArguments;
|
QStringList _childArguments;
|
||||||
if (_assignmentPool != "") {
|
if (_assignmentPool != "") {
|
||||||
|
@ -153,7 +153,7 @@ void AssignmentClientMonitor::spawnChildClient() {
|
||||||
|
|
||||||
// make sure that the output from the child process appears in our output
|
// make sure that the output from the child process appears in our output
|
||||||
assignmentClient->setProcessChannelMode(QProcess::ForwardedChannels);
|
assignmentClient->setProcessChannelMode(QProcess::ForwardedChannels);
|
||||||
|
|
||||||
assignmentClient->start(QCoreApplication::applicationFilePath(), _childArguments);
|
assignmentClient->start(QCoreApplication::applicationFilePath(), _childArguments);
|
||||||
|
|
||||||
// make sure we hear that this process has finished when it does
|
// make sure we hear that this process has finished when it does
|
||||||
|
@ -194,7 +194,7 @@ void AssignmentClientMonitor::checkSpares() {
|
||||||
qDebug() << "asking child" << aSpareId << "to exit.";
|
qDebug() << "asking child" << aSpareId << "to exit.";
|
||||||
SharedNodePointer childNode = nodeList->nodeWithUUID(aSpareId);
|
SharedNodePointer childNode = nodeList->nodeWithUUID(aSpareId);
|
||||||
childNode->activateLocalSocket();
|
childNode->activateLocalSocket();
|
||||||
|
|
||||||
QByteArray diePacket = nodeList->byteArrayWithPopulatedHeader(PacketTypeStopNode);
|
QByteArray diePacket = nodeList->byteArrayWithPopulatedHeader(PacketTypeStopNode);
|
||||||
nodeList->writeUnverifiedDatagram(diePacket, childNode);
|
nodeList->writeUnverifiedDatagram(diePacket, childNode);
|
||||||
}
|
}
|
||||||
|
@ -239,7 +239,7 @@ void AssignmentClientMonitor::readPendingDatagrams() {
|
||||||
// update our records about how to reach this child
|
// update our records about how to reach this child
|
||||||
matchingNode->setLocalSocket(senderSockAddr);
|
matchingNode->setLocalSocket(senderSockAddr);
|
||||||
|
|
||||||
QVariantMap packetVariantMap =
|
QVariantMap packetVariantMap =
|
||||||
JSONBreakableMarshal::fromStringBuffer(receivedPacket.mid(numBytesForPacketHeader(receivedPacket)));
|
JSONBreakableMarshal::fromStringBuffer(receivedPacket.mid(numBytesForPacketHeader(receivedPacket)));
|
||||||
QJsonObject unpackedStatsJSON = QJsonObject::fromVariantMap(packetVariantMap);
|
QJsonObject unpackedStatsJSON = QJsonObject::fromVariantMap(packetVariantMap);
|
||||||
|
|
||||||
|
|
|
@ -850,7 +850,9 @@ void AudioMixer::run() {
|
||||||
|
|
||||||
++_numStatFrames;
|
++_numStatFrames;
|
||||||
|
|
||||||
|
// since we're a while loop we need to help Qt's event processing
|
||||||
QCoreApplication::processEvents();
|
QCoreApplication::processEvents();
|
||||||
|
QCoreApplication::sendPostedEvents(this, 0);
|
||||||
|
|
||||||
if (_isFinished) {
|
if (_isFinished) {
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue