Compare commits

...

2 commits

Author SHA1 Message Date
Albert Vaca Cintora
d618bac26c Fix really terrible code 2023-05-25 13:09:49 +02:00
Albert Vaca Cintora
4510762af5 Release all the things 2023-05-25 13:09:49 +02:00

View file

@ -227,6 +227,15 @@ SystemvolumePlugin::SystemvolumePlugin(QObject *parent, const QVariantList &args
SystemvolumePlugin::~SystemvolumePlugin()
{
if (valid) {
QSet<IAudioEndpointVolume*> endpoints;
for (auto &entry : sinkList.toStdMap()) {
endpoint->UnRegisterControlChangeNotify(entry.second);
endpoint->Release();
endpoints.insert(entry.first);
}
for (IAudioEndpointVolume* endpoint : endpoints) {
endpoint->Release();
}
deviceEnumerator->UnregisterEndpointNotificationCallback(deviceCallback);
deviceEnumerator->Release();
deviceEnumerator = nullptr;
@ -404,14 +413,12 @@ bool SystemvolumePlugin::receivePacket(const NetworkPacket &np)
} else {
QString name = np.get<QString>(QStringLiteral("name"));
if (sinkList.contains(name)) {
// unregister ControlChangeNotify before doing any changes to a sink
HRESULT unregisterSuccess = E_POINTER;
auto sinkListIterator = this->sinkList.find(name);
if (sinkListIterator != this->sinkList.end()) {
auto &sink = sinkListIterator.value();
if (!(sinkListIterator == this->sinkList.end())) {
unregisterSuccess = sink.first->UnregisterControlChangeNotify(sink.second);
}
// unregister ControlChangeNotify before doing any changes to a sink
HRESULT unregisterSuccess = sink.first->UnregisterControlChangeNotify(sink.second);
if (np.has(QStringLiteral("volume"))) {
float currentVolume;