fix: sessionmanager life expired under my feet

This commit is contained in:
Hane 2024-12-17 00:01:02 +01:00
commit 2a1b30e166
6 changed files with 58 additions and 22 deletions

View file

@ -30,19 +30,10 @@ EndpointHandler::EndpointHandler(uint64_t idx, Flows flow) {
this->ep = (flow == Flows::FLOW_PLAYBACK ? osh->getPlaybackEndpoints().at(idx) : osh->getCaptureEndpoints().at(idx));
epc = new EndpointVolumeCallback(ep);
ensc = new EndpointNewSessionCallback(this);
this->callbackInfo.caller = osh->getGuid();
ep->registerNewSessionNotification(ensc);
//epName = ep->getName();
this->setBackEndpointVolumeCallbackInfoContent(this->getState());
osh->pushBackEndpointHandler(this, flow);
if (this->flow == Flows::FLOW_PLAYBACK) {
for (int i = 0; i < this->getSessionCount(); i++) {
SessionHandler* sessionHandler = new SessionHandler(this, this->getSessions().at(i),i);
sessionHandlers.push_back(sessionHandler);
}
}
}
void OverseerHandler::pushBackEndpointHandler(EndpointHandler* eph, Flows flow) {
@ -215,6 +206,28 @@ void EndpointHandler::removeSessionFromFront(SessionHandler* sh) {
this->removeSessionWidget(sh);
}
void EndpointHandler::deleteSessions() {
ep->unregisterNewSessionNotification(ensc);
ensc->Release();
for (auto sh : sessionHandlers) {
delete sh;
}
sessionHandlers.resize(0);
ep->deleteSessions();
}
void EndpointHandler::createSessionHandlers() {
ep->activateEndpointSessions();
ensc = new EndpointNewSessionCallback(this);
ep->registerNewSessionNotification(ensc);
if (this->flow == Flows::FLOW_PLAYBACK) {
for (int i = 0; i < this->getSessionCount(); i++) {
SessionHandler* sessionHandler = new SessionHandler(this, this->getSessions().at(i),i);
sessionHandlers.push_back(sessionHandler);
}
}
}
EndpointHandler::~EndpointHandler() {
ep->removeVolumeCallback(epc);
ep->unregisterNewSessionNotification(ensc);