fix: sessionmanager life expired under my feet
This commit is contained in:
parent
9f7e7e30e2
commit
2a1b30e166
6 changed files with 58 additions and 22 deletions
|
|
@ -351,16 +351,12 @@ Endpoint::Endpoint(IMMDevice* ep, IPolicyConfig7* policyConfig, uint64_t idx){
|
|||
endpoint->OpenPropertyStore(STGM_READ, &properties);
|
||||
this->updateName();
|
||||
this->setFlow();
|
||||
if (this->flow == Flows::FLOW_PLAYBACK) {
|
||||
activateEndpointSessions();
|
||||
log_debugcpp("plays back");
|
||||
}
|
||||
}
|
||||
|
||||
void Endpoint::updateName() {
|
||||
PROPVARIANT pv;
|
||||
#define store_name(key, propvariant, wstr) do { \
|
||||
properties->GetValue(key , &propvariant); \
|
||||
properties->GetValue(key, &propvariant); \
|
||||
if (pv.pwszVal == nullptr) wstr = L"Unnamed Not Present Endpoint"; \
|
||||
else wstr = std::wstring(pv.pwszVal); \
|
||||
} while (0)
|
||||
|
|
@ -373,8 +369,16 @@ void Endpoint::updateName() {
|
|||
}
|
||||
|
||||
void Endpoint::activateEndpointSessions() {
|
||||
//sessionManager;
|
||||
if (FAILED(endpoint->Activate(__uuidof(IAudioSessionManager2), CLSCTX_ALL, NULL, (void**) &sessionManager))) { log_wdebugcpp(L"sesionbros..."); return; }
|
||||
if (this->flow != Flows::FLOW_PLAYBACK) {
|
||||
log_debugcpp("recording. No seshes for u :(");
|
||||
return;
|
||||
}
|
||||
|
||||
if (FAILED(endpoint->Activate(__uuidof(IAudioSessionManager2),
|
||||
CLSCTX_ALL, NULL, (void**) &sessionManager))) {
|
||||
log_debugcpp("Couldn't open session manager2, huh");
|
||||
return;
|
||||
}
|
||||
|
||||
IAudioSessionEnumerator* sessionEnumerator = nullptr;
|
||||
if (FAILED(sessionManager->GetSessionEnumerator(&sessionEnumerator))) { log_wdebugcpp(L"sesEnumeratorBros..."); return; }
|
||||
|
|
@ -382,7 +386,7 @@ void Endpoint::activateEndpointSessions() {
|
|||
endpointSessions.resize(1, nullptr);
|
||||
int sessionCount;
|
||||
sessionEnumerator->GetCount(&sessionCount);
|
||||
for (int i = 0; i < sessionCount; i++) {
|
||||
for (int i = 0; i < sessionCount; i++) {
|
||||
IAudioSessionControl* sessionControlTmp;
|
||||
sessionEnumerator->GetSession(i, (IAudioSessionControl**)&sessionControlTmp);
|
||||
/*todo: borrar when donezo
|
||||
|
|
@ -390,7 +394,7 @@ void Endpoint::activateEndpointSessions() {
|
|||
* IAudioMeterInformation* ttmp = (IAudioMeterInformation*)sessionControlTmp;
|
||||
* ttmp->GetPeakValue(&test2);
|
||||
*/
|
||||
//todo:: asegurar lo del dynamic_cast
|
||||
|
||||
IAudioSessionControl2* sessionControl;
|
||||
sessionControlTmp->QueryInterface(__uuidof(IAudioSessionControl2), (void**)&sessionControl);
|
||||
sessionControl->AddRef();
|
||||
|
|
@ -593,12 +597,22 @@ void Endpoint::unregisterNewSessionNotification(EndpointNewSessionCallback* ensc
|
|||
sessionManager->UnregisterSessionNotification(ensc);
|
||||
}
|
||||
|
||||
void Endpoint::deleteSessions() {
|
||||
for (auto session : endpointSessions) {
|
||||
delete session;
|
||||
}
|
||||
endpointSessions.resize(0);
|
||||
}
|
||||
|
||||
Endpoint::~Endpoint(){
|
||||
log_wdebugcpp(L"murio endpoint-san uwu");
|
||||
properties->Release();
|
||||
endpointVolume->Release();
|
||||
endpoint->Release();
|
||||
sessionManager->Release();
|
||||
for (auto session : endpointSessions) {
|
||||
delete session;
|
||||
}
|
||||
}
|
||||
|
||||
void Overseer::initCOMLibrary() {
|
||||
|
|
|
|||
|
|
@ -80,19 +80,19 @@ class Endpoint {
|
|||
void addSession(Session* session);
|
||||
void registerNewSessionNotification(EndpointNewSessionCallback* ensc);
|
||||
void unregisterNewSessionNotification(EndpointNewSessionCallback* ensc);
|
||||
|
||||
void deleteSessions();
|
||||
void activateEndpointSessions();
|
||||
~Endpoint();
|
||||
|
||||
private:
|
||||
void inline activateEndpointVolume();
|
||||
void inline activateEndpointSessions();
|
||||
|
||||
std::vector<Session*> endpointSessions;
|
||||
uint32_t channelCount = 0;
|
||||
IMMDevice *endpoint;
|
||||
IAudioClient *audioClient;
|
||||
int64_t defTime, minTime;
|
||||
IAudioSessionManager2 *sessionManager;
|
||||
IAudioSessionManager2 *sessionManager = nullptr;
|
||||
Flows flow;
|
||||
IAudioEndpointVolume *endpointVolume = nullptr;
|
||||
IPropertyStore *properties;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -74,6 +74,8 @@ public:
|
|||
void setRemoveSessionWidgetFunction(std::function<void(SessionHandler*)> removeSessionWidget);
|
||||
void sendSessionToFront(SessionHandler* sh);
|
||||
void removeSessionFromFront(SessionHandler* sh);
|
||||
void deleteSessions();
|
||||
void createSessionHandlers();
|
||||
|
||||
~EndpointHandler();
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -531,6 +531,7 @@ EndpointWidget::EndpointWidget(EndpointHandler* eph, QWidget *parent, uint64_t i
|
|||
this->idx = idx;
|
||||
this->eph = eph;
|
||||
|
||||
eph->createSessionHandlers();
|
||||
//todo: sussy
|
||||
this->eph->setState(EndpointState::ENDPOINT_ACTIVE, idx);
|
||||
this->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
|
||||
|
|
@ -749,6 +750,10 @@ EndpointWidget::~EndpointWidget() {
|
|||
timer->stop();
|
||||
delete timer;
|
||||
this->eph->setFrontVisibilityInfo(EndpointState::ENDPOINT_ALL, INT_MAX);
|
||||
this->eph->deleteSessions();
|
||||
for(auto sw : sessionWidgets) {
|
||||
delete sw;
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::customEvent(QEvent* ev) {
|
||||
|
|
@ -894,6 +899,8 @@ void EndpointWidget::updateMainVolume(int newValue){
|
|||
*/
|
||||
|
||||
void EndpointWidget::updateChannelsVisibility() {
|
||||
if (!cw) return;
|
||||
|
||||
char* const channelSettings = set->getValue("show_channels");
|
||||
if(channelSettings && !(strcmp(channelSettings, "true"))){
|
||||
cw->setVisible(true);
|
||||
|
|
|
|||
|
|
@ -149,7 +149,7 @@ private:
|
|||
size_t defaultRolesVectorSize = 4;
|
||||
QTimer* timer = nullptr;
|
||||
uint64_t idx;
|
||||
ChannelWidget* cw;
|
||||
ChannelWidget* cw = nullptr;
|
||||
std::vector<SessionWidget*> sessionWidgets;
|
||||
QSize minimum;
|
||||
//std::vector<EndpointHandler*> *ephs;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue