session baby steps

This commit is contained in:
Hane 2023-09-18 23:37:06 +02:00
commit 6d88697811
14 changed files with 393 additions and 87 deletions

View file

@ -207,7 +207,7 @@ Endpoint::Endpoint(IMMDevice* ep, uint64_t idx){
reloadEndpointChannels();
/*
/* todo: check header
* if(FAILED(endpoint->Activate(__uuidof(IAudioMeterInformation),
* CLSCTX_ALL, NULL, (void**)&endpointPeakMeter))) { log_debugcpp("peakbros..."); }
*/
@ -228,12 +228,37 @@ Endpoint::Endpoint(IMMDevice* ep, uint64_t idx){
friendlyName = std::wstring(pv.pwszVal);
this->setFlow();
if (this->endpointState == EndpointState::ENDPOINT_ACTIVE && this->flow == Flows::FLOW_PLAYBACK) {
activateEndpointSessions();
}
}
/*
* Endpoint::Endpoint(IMMDevice* endpoint) : Endpoint(endpoint, 0) {};
*/
void Endpoint::activateEndpointSessions() {
//sessionManager;
if (FAILED(endpoint->Activate(__uuidof(IAudioSessionManager2), CLSCTX_ALL, NULL, (void**) &sessionManager))) { log_wdebugcpp(L"sesionbros..."); return; }
IAudioSessionEnumerator* sessionEnumerator = nullptr;
if (FAILED(sessionManager->GetSessionEnumerator(&sessionEnumerator))) { log_wdebugcpp(L"sesEnumeratorBros..."); return; }
int sessionCount;
sessionEnumerator->GetCount(&sessionCount);
for (int i = 0; i < sessionCount; i++) {
IAudioSessionControl* sessionControlTmp;
sessionEnumerator->GetSession(i, (IAudioSessionControl**)&sessionControlTmp);
//todo:: asegurar lo del dynamic_cast
IAudioSessionControl2* sessionControl;
sessionControlTmp->QueryInterface(__uuidof(IAudioSessionControl2), (void**)&sessionControl);
sessionControl->AddRef();
sessionControlTmp->Release();
Session* session = new Session(this, sessionControl, (size_t)i);
endpointSessions.push_back(session);
}
sessionEnumerator->Release();
}
void Endpoint::activateEndpointVolume() {
//bool extraThread = false;
@ -444,11 +469,21 @@ Flows Endpoint::getFlow() {
return this->flow;
}
/* sessions */
std::vector<Session*> Endpoint::getSessions() {
return endpointSessions;
}
size_t Endpoint::getSessionCount() {
return endpointSessions.size();
}
Endpoint::~Endpoint(){
log_debugcpp("murio endpoint-san uwu");
log_wdebugcpp(L"murio endpoint-san uwu");
properties->Release();
endpointVolume->Release();
endpoint->Release();
sessionManager->Release();
}
void Overseer::initCOMLibrary() {