-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ActiveSpeakerObserver: fix memory leak and more improvements #942
Conversation
- When deleted, `ActiveSpeakerObserver` must iterate all entries in its `mapProducerSpeakers` and free them. This is because `ActiveSpeakerObserver::RemoveProducer()` **won't** be called for each existing `Producer` if the `ActiveSpeakerObserver` or its parent `Router` are directly closed. - If `AddProducer()` is called with an already paused `Producer`, consider it (because this can happen). - Code cleanup such as moving class `static` members to the top, initialize numeric members and so on. - Use `producerSpeaker` to name values in `this->mapProducerSpeakers` instead of naming them `rtpObserver`.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just few cosmetic changes requested 👍
@@ -308,10 +325,11 @@ namespace RTC | |||
dominantSpeaker->EvalActivityScores(); | |||
double newDominantC2 = C2; | |||
|
|||
for (const auto& it : this->mapProducerSpeaker) | |||
for (auto& kv : this->mapProducerSpeakers) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can't it be const
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is for consistency with the rest of the code. If we change this we should change it everywhere in tons of files.
@@ -351,10 +371,11 @@ namespace RTC | |||
{ | |||
MS_TRACE(); | |||
|
|||
for (const auto& it : this->mapProducerSpeaker) | |||
for (auto& kv : this->mapProducerSpeakers) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same, can't it be const
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same
Co-authored-by: José Luis Millán <jmillan@aliax.net>
In fact I'll do more changes.
|
🚨 When deleted,
ActiveSpeakerObserver
must iterate all entries in itsmapProducerSpeakers
and free them. This is becauseActiveSpeakerObserver::RemoveProducer()
won't be called for each existingProducer
if theActiveSpeakerObserver
or its parentRouter
are directly closed. So fix a memory leak here.Make
mapProducerSpeakers
contain pointers toProducerSpeaker
as done everywhere else.If
AddProducer()
is called with an already pausedProducer
, consider it (because this can happen).Code cleanup such as moving class
static
members to the top, initialize numeric members, makeProducerSpeaker
be a class instead of a struct, useproducerSpeaker
to name values inthis->mapProducerSpeakers
instead of naming themrtpObserver
, etc.