Fix deletion
This commit is contained in:
parent
e326eabbf8
commit
4f240b128b
3 changed files with 187 additions and 34 deletions
|
|
@ -472,14 +472,19 @@ void PipeWireController::ensureNodeMeter(uint32_t nodeId, const QString &targetN
|
|||
|
||||
void PipeWireController::removeNodeMeter(uint32_t nodeId)
|
||||
{
|
||||
QMutexLocker lock(&m_meterMutex);
|
||||
if (!m_nodeMeters.contains(nodeId)) {
|
||||
return;
|
||||
NodeMeter *meter = nullptr;
|
||||
{
|
||||
QMutexLocker lock(&m_meterMutex);
|
||||
if (!m_nodeMeters.contains(nodeId)) {
|
||||
return;
|
||||
}
|
||||
meter = m_nodeMeters.take(nodeId);
|
||||
}
|
||||
|
||||
NodeMeter *meter = m_nodeMeters.take(nodeId);
|
||||
if (meter && meter->stream) {
|
||||
lock();
|
||||
pw_stream_destroy(meter->stream);
|
||||
unlock();
|
||||
}
|
||||
delete meter;
|
||||
}
|
||||
|
|
@ -494,6 +499,19 @@ uint32_t PipeWireController::createLink(uint32_t outputNodeId, uint32_t outputPo
|
|||
qWarning() << "Cannot create link: not connected to PipeWire";
|
||||
return 0;
|
||||
}
|
||||
|
||||
{
|
||||
QMutexLocker lock(&m_nodesMutex);
|
||||
for (auto it = m_links.cbegin(); it != m_links.cend(); ++it) {
|
||||
const LinkInfo &link = it.value();
|
||||
if (link.outputNodeId == outputNodeId &&
|
||||
link.outputPortId == outputPortId &&
|
||||
link.inputNodeId == inputNodeId &&
|
||||
link.inputPortId == inputPortId) {
|
||||
return link.id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lock();
|
||||
|
||||
|
|
@ -591,15 +609,21 @@ bool PipeWireController::destroyLink(uint32_t linkId)
|
|||
|
||||
unlock();
|
||||
|
||||
{
|
||||
QMutexLocker lock(&m_nodesMutex);
|
||||
m_links.remove(linkId);
|
||||
QElapsedTimer timer;
|
||||
timer.start();
|
||||
while (timer.elapsed() < 2000) {
|
||||
{
|
||||
QMutexLocker lock(&m_nodesMutex);
|
||||
if (!m_links.contains(linkId)) {
|
||||
qInfo() << "Link destroyed:" << linkId;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
QThread::msleep(10);
|
||||
}
|
||||
|
||||
emit linkRemoved(linkId);
|
||||
|
||||
qInfo() << "Link destroyed:" << linkId;
|
||||
return true;
|
||||
|
||||
qWarning() << "Link destroy requested but ID still present" << linkId;
|
||||
return false;
|
||||
}
|
||||
|
||||
QString PipeWireController::dumpGraph() const
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue