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