Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Network
KDE Connect
Commits
d37f4061
Commit
d37f4061
authored
Jun 20, 2021
by
Piyush Aggarwal
🎮
Browse files
systemvolumeplugin_win: fix a desktop memory leak that occurs when sink list is open on Android app
parent
8cd17dbe
Pipeline
#66773
passed with stage
in 7 minutes and 37 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
plugins/systemvolume/systemvolumeplugin-win.cpp
View file @
d37f4061
...
...
@@ -413,17 +413,54 @@ bool SystemvolumePlugin::receivePacket(const NetworkPacket &np)
if
(
sinkList
.
contains
(
name
))
{
// unregister ControlChangeNotify before doing any changes to a sink
HRESULT
unregisterSuccess
=
E_POINTER
;
auto
sinkListIterator
=
this
->
sinkList
.
find
(
name
);
auto
&
sink
=
sinkListIterator
.
value
();
if
(
!
(
sinkListIterator
==
this
->
sinkList
.
end
()))
{
unregisterSuccess
=
sink
.
first
->
UnregisterControlChangeNotify
(
sink
.
second
);
}
if
(
np
.
has
(
QStringLiteral
(
"volume"
)))
{
sinkList
[
name
].
first
->
SetMasterVolumeLevelScalar
((
float
)
np
.
get
<
int
>
(
QStringLiteral
(
"volume"
))
/
100
,
NULL
);
float
currentVolume
;
sink
.
first
->
GetMasterVolumeLevelScalar
(
&
currentVolume
);
float
requestedVolume
=
(
float
)
np
.
get
<
int
>
(
QStringLiteral
(
"volume"
),
100
)
/
100
;
if
(
currentVolume
!=
requestedVolume
)
{
sinkList
[
name
].
first
->
SetMasterVolumeLevelScalar
(
requestedVolume
,
NULL
);
}
}
if
(
np
.
has
(
QStringLiteral
(
"muted"
)))
{
sinkList
[
name
].
first
->
SetMute
(
np
.
get
<
bool
>
(
QStringLiteral
(
"muted"
)),
NULL
);
BOOL
currentMuteStatus
;
sink
.
first
->
GetMute
(
&
currentMuteStatus
);
BOOL
requestedMuteStatus
=
np
.
get
<
bool
>
(
QStringLiteral
(
"muted"
),
false
);
if
(
currentMuteStatus
!=
requestedMuteStatus
)
{
sinkList
[
name
].
first
->
SetMute
(
requestedMuteStatus
,
NULL
);
}
}
if
(
np
.
has
(
QStringLiteral
(
"enabled"
)))
{
setDefaultAudioPlaybackDevice
(
name
,
np
.
get
<
bool
>
(
QStringLiteral
(
"enabled"
)));
// get the current default device ID
IMMDevice
*
defaultDevice
=
nullptr
;
deviceEnumerator
->
GetDefaultAudioEndpoint
(
eRender
,
eMultimedia
,
&
defaultDevice
);
LPWSTR
defaultId
=
NULL
;
defaultDevice
->
GetId
(
&
defaultId
);
defaultDevice
->
Release
();
// get current sink's device ID
QString
qDefaultId
=
QString
::
fromWCharArray
(
defaultId
);
QString
currentDeviceId
=
idToNameMap
.
key
(
name
);
if
((
bool
)
qDefaultId
.
compare
(
currentDeviceId
))
{
setDefaultAudioPlaybackDevice
(
name
,
np
.
get
<
bool
>
(
QStringLiteral
(
"enabled"
)));
}
}
// re-register ControlChangeNotify in case we unregistered it
if
(
unregisterSuccess
==
S_OK
)
{
sink
.
first
->
RegisterControlChangeNotify
(
sink
.
second
);
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment