almost captured, only to hotplug. such is life...

This commit is contained in:
Hane 2023-09-14 18:01:32 +02:00
commit 44ccde6ac8
6 changed files with 235 additions and 63 deletions

View file

@ -3,7 +3,6 @@ GUID NGuidToGUID(NGuid guid) {
msGuid.Data1 = guid.data1;
msGuid.Data2 = guid.data2;
msGuid.Data3 = guid.data3;
msGuid.Data1 = guid.data1;
for (int i = 0; i < 8; i++){
msGuid.Data4[i] = guid.data4[i];
//log_debugcpp("MSGUID DATA4 BYTE " << i << ": ");

View file

@ -39,30 +39,30 @@ HRESULT EndpointVolumeCallback::QueryInterface(REFIID riid, VOID **ppvInterface)
HRESULT EndpointVolumeCallback::OnNotify(PAUDIO_VOLUME_NOTIFICATION_DATA pNotify) {
if (pNotify == NULL) return E_INVALIDARG;
//delete osh->getEndpointHandlers().at(this->ep->getIndex())->getCallbackInfo()->caller;
//osh->getEndpointHandlers().at(this->ep->getIndex())->getCallbackInfo()->caller.freeData4();
//delete osh->getPlaybackEndpointHandlers().at(this->ep->getIndex())->getCallbackInfo()->caller;
//osh->getPlaybackEndpointHandlers().at(this->ep->getIndex())->getCallbackInfo()->caller.freeData4();
//Could've made a function or = override to hide this within Nguid, but back in cont = bad.
osh->getEndpointHandlers().at(this->ep->getIndex())->getCallbackInfo()->caller.data1 \
osh->getPlaybackEndpointHandlers().at(this->ep->getIndex())->getCallbackInfo()->caller.data1 \
= pNotify->guidEventContext.Data1;
osh->getEndpointHandlers().at(this->ep->getIndex())->getCallbackInfo()->caller.data2 \
osh->getPlaybackEndpointHandlers().at(this->ep->getIndex())->getCallbackInfo()->caller.data2 \
= pNotify->guidEventContext.Data2;
osh->getEndpointHandlers().at(this->ep->getIndex())->getCallbackInfo()->caller.data3 \
osh->getPlaybackEndpointHandlers().at(this->ep->getIndex())->getCallbackInfo()->caller.data3 \
= pNotify->guidEventContext.Data3;
for(int i = 0; i < 8 /* Data4 size */; i++){
osh->getEndpointHandlers().at(this->ep->getIndex())->getCallbackInfo()->caller.data4[i] = pNotify->guidEventContext.Data4[i];
osh->getPlaybackEndpointHandlers().at(this->ep->getIndex())->getCallbackInfo()->caller.data4[i] = pNotify->guidEventContext.Data4[i];
}
//memcpy(&osh->getEndpointHandlers().at(this->ep->getIndex())->getCallbackInfo()->caller, &pNotify->guidEventContext,sizeof(NGuid) );
//memcpy(&osh->getPlaybackEndpointHandlers().at(this->ep->getIndex())->getCallbackInfo()->caller, &pNotify->guidEventContext,sizeof(NGuid) );
osh->getEndpointHandlers().at(this->ep->getIndex())->getCallbackInfo()->muted = pNotify->bMuted;
osh->getEndpointHandlers().at(this->ep->getIndex())->getCallbackInfo()->mainVolume = pNotify->fMasterVolume;
osh->getEndpointHandlers().at(this->ep->getIndex())->getCallbackInfo()->channels = pNotify->nChannels;
osh->getPlaybackEndpointHandlers().at(this->ep->getIndex())->getCallbackInfo()->muted = pNotify->bMuted;
osh->getPlaybackEndpointHandlers().at(this->ep->getIndex())->getCallbackInfo()->mainVolume = pNotify->fMasterVolume;
osh->getPlaybackEndpointHandlers().at(this->ep->getIndex())->getCallbackInfo()->channels = pNotify->nChannels;
UINT j = 0;
//todo: do while here caused stack corruption; sus
while(j < pNotify->nChannels) {
osh->getEndpointHandlers().at(this->ep->getIndex())->getCallbackInfo()->channelVolumes[j] = pNotify->afChannelVolumes[j];
osh->getPlaybackEndpointHandlers().at(this->ep->getIndex())->getCallbackInfo()->channelVolumes[j] = pNotify->afChannelVolumes[j];
j++;
}
return S_OK;
@ -76,9 +76,10 @@ HRESULT EndpointVolumeCallback::OnNotify(PAUDIO_VOLUME_NOTIFICATION_DATA pNotify
*
*/
//todo: not on construct since it expects them to already exist; smells like refactor!
void EndpointSituationCallback::fill(IMMDeviceEnumerator *deviceEnumerator, std::vector<Endpoint*> playbackDevices){
void EndpointSituationCallback::fill(IMMDeviceEnumerator *deviceEnumerator, std::vector<Endpoint*> playbackDevices, std::vector<Endpoint*> captureDevices){
this->deviceEnumerator = deviceEnumerator;
this->playbackDevices = playbackDevices;
this->captureDevices = captureDevices;
}
ULONG EndpointSituationCallback::AddRef(){
@ -151,10 +152,14 @@ HRESULT EndpointSituationCallback::OnDeviceStateChanged(LPCWSTR pwstrDeviceId, D
osh->reviseEndpointShowing(endpointId, EndpointState::ENDPOINT_ACTIVE);
break;
case DEVICE_STATE_DISABLED:
case DEVICE_STATE_NOTPRESENT:
case DEVICE_STATE_UNPLUGGED:
osh->reviseEndpointShowing(endpointId, EndpointState::ENDPOINT_DISABLED);
break;
case DEVICE_STATE_NOTPRESENT:
osh->reviseEndpointShowing(endpointId, EndpointState::ENDPOINT_NOTPRESENT);
break;
case DEVICE_STATE_UNPLUGGED:
osh->reviseEndpointShowing(endpointId, EndpointState::ENDPOINT_UNPLUGGED);
break;
}
return S_OK;
@ -190,6 +195,11 @@ Endpoint::Endpoint(IMMDevice* ep, uint64_t idx){
reloadEndpointChannels();
/*
* if(FAILED(endpoint->Activate(__uuidof(IAudioMeterInformation),
* CLSCTX_ALL, NULL, (void**)&endpointPeakMeter))) { log_debugcpp("peakbros..."); }
*/
//todo:: atexit into exit Gather ID
LPWSTR tempString = nullptr;
if (FAILED(endpoint->GetId(&tempString))) {exit(-1);};
@ -206,6 +216,11 @@ Endpoint::Endpoint(IMMDevice* ep, uint64_t idx){
friendlyName = std::wstring(pv.pwszVal);
}
/*
* Endpoint::Endpoint(IMMDevice* endpoint) : Endpoint(endpoint, 0) {};
*/
void Endpoint::activateEndpointVolume() {
if (this->endpointVolume == nullptr)
if(FAILED(endpoint->Activate(IID_IAudioEndpointVolume, CLSCTX_ALL, NULL, (void**)&this->endpointVolume))) { log_debugcpp(std::string("no endpointVolume (IAudioEndpointVolume)")); };
@ -372,6 +387,33 @@ void Endpoint::removeRoles(Roles role){
this->endpointRoles = roles;
}
void Endpoint::setFlow() {
IMMEndpoint* flowGetter;
//this should be as simple as writing IID_IMMEndpoint, but it just won't find the macro, so I copied it. Sad.
GUID manual;
manual.Data1 = 0x1be09788;
manual.Data2 = 0x6894;
manual.Data3 = 0x4089;
manual.Data4[0] = 0x85;
manual.Data4[1] = 0x86;
manual.Data4[2] = 0x9a;
manual.Data4[3] = 0x2a;
manual.Data4[4] = 0x6c;
manual.Data4[5] = 0x26;
manual.Data4[6] = 0x5a;
manual.Data4[7] = 0xc5;
if(FAILED(this->endpoint->QueryInterface((const _GUID)manual, (void**)&flowGetter)))
{ log_debugcpp("no flow..."); }
EDataFlow MSflow;
HRESULT vafllar = flowGetter->GetDataFlow(&MSflow);
this->flow = (MSflow == EDataFlow::eRender ? Flows::FLOW_PLAYBACK : Flows::FLOW_CAPTURE);
flowGetter->Release();
}
Flows Endpoint::getFlow() {
return this->flow;
}
Endpoint::~Endpoint(){
log_debugcpp("murio endpoint-san uwu");
properties->Release();
@ -394,6 +436,7 @@ void Overseer::initCOMLibrary() {
GUID tempGuid;
if(FAILED(CoCreateGuid(&tempGuid))) { log_debugcpp("Failed to obtain GUID: " ); };
//todo: wtf? why is it working? floats are ptrs...
this->guid = GUIDToNGuid(&tempGuid);
//if(FAILED(CoCreateInstance(__uuidof(CPolicyConfigClient),
@ -403,28 +446,34 @@ void Overseer::initCOMLibrary() {
//TODO: Uninitialize COM
}
void Overseer::reloadEndpoints() {
void Overseer::reloadEndpoints(Flows flow) {
IMMDeviceCollection *deviceCollection;
unsigned int numEndpoints;
EDataFlow MSflow = (flow == Flows::FLOW_PLAYBACK ? EDataFlow::eRender : EDataFlow::eCapture);
// | DEVICE_STATE_DISABLED | DEVICE_STATE_NOTPRESENT | DEVICE_STATE_UNPLUGGED
// NOTPRESENT shows a lot of garbage, unnamed devices.
if(FAILED(deviceEnumerator->EnumAudioEndpoints(eRender, DEVICE_STATE_ACTIVE | DEVICE_STATE_DISABLED | DEVICE_STATE_NOTPRESENT | DEVICE_STATE_UNPLUGGED, &deviceCollection) ))
if(FAILED(deviceEnumerator->EnumAudioEndpoints(MSflow, DEVICE_STATE_ACTIVE | DEVICE_STATE_DISABLED | DEVICE_STATE_NOTPRESENT | DEVICE_STATE_UNPLUGGED, &deviceCollection) ))
{ log_debugcpp("si"); };
/*
* Counting them
*/
if(FAILED(deviceCollection->GetCount(&numPlaybackEndpoints))) { log_debugcpp("si");};
if(numPlaybackEndpoints == 0) { log_debugcpp("si"); };
if(FAILED(deviceCollection->GetCount(&numEndpoints))) { log_debugcpp("si");};
if(numEndpoints == 0) { log_debugcpp("si"); };
/*
* Retrieving actual endpoints and storing them on their own class
*/
IMMDevice *temp;
for (unsigned int i = 0; i < numPlaybackEndpoints; i++){
for (unsigned int i = 0; i < numEndpoints; i++){
if(deviceCollection->Item(i, &temp) != 0) { log_debugcpp("si"); };
Endpoint *endpoint = new Endpoint(temp, i);
endpoint->setFlow();
//endpoint->setIndex(i);
if (flow == Flows::FLOW_PLAYBACK)
this->playbackDevices.push_back(endpoint);
else
this->captureDevices.push_back(endpoint);
//TODO: le porblemx std::cout + "ola" + std::endl;
}
@ -447,20 +496,52 @@ void Overseer::reloadEndpoints() {
val = eCommunications;
break;
}
deviceEnumerator->GetDefaultAudioEndpoint(EDataFlow::eRender, val, &temp);
deviceEnumerator->GetDefaultAudioEndpoint(MSflow, val, &temp);
LPWSTR id = nullptr;
for (unsigned int j = 0; j < numPlaybackEndpoints; j++){
if (flow == Flows::FLOW_PLAYBACK) {
for (unsigned int j = 0; j < numEndpoints; j++) {
std::wstring eptId = playbackDevices.at(j)->getId();
temp->GetId(&id);
int comparison = CompareStringEx(LOCALE_NAME_USER_DEFAULT, 0, eptId.c_str(), -987, id, -987, NULL, NULL, 0);
if (comparison - 2 == 0) {
log_wdebugcpp(L"ola defaul de " + std::to_wstring(i) + L" es " + id);
log_wdebugcpp(L"ola defaul playback de "
+ std::to_wstring(i) + L" es " + id);
playbackDevices.at(j)->assignRoles((Roles)(1 << i));
}
//uint8_t debg = playbackDevices.at(j)->getRoles();
}
} else {
for (unsigned int j = 0; j < numEndpoints; j++){
std::wstring eptId = captureDevices.at(j)->getId();
temp->GetId(&id);
int comparison = CompareStringEx(LOCALE_NAME_USER_DEFAULT, 0, eptId.c_str(), -987, id, -987, NULL, NULL, 0);
if (comparison - 2 == 0) {
log_wdebugcpp(L"ola defaul capture de "
+ std::to_wstring(i) + L" es " + id);
captureDevices.at(j)->assignRoles((Roles)(1 << i));
}
}
}
}
}
Endpoint* Overseer::addEndpoint(std::wstring endpointId, /* out */Flows* flow = nullptr) {
IMMDevice* newep;
if(FAILED(deviceEnumerator->GetDevice((LPCWSTR)endpointId.c_str(), &newep)))
log_debugcpp("ay caramba con la hot metida.");
Endpoint *endpoint = new Endpoint(newep);
Flows getFlow = endpoint->getFlow();
if (getFlow == Flows::FLOW_PLAYBACK) {
endpoint->setIndex(osh->getPlaybackEndpointsCount());
this->playbackDevices.push_back(endpoint);
} else {
endpoint->setIndex(osh->getCaptureEndpointsCount());
this->captureDevices.push_back(endpoint);
}
if (flow != nullptr) *flow = getFlow;
return endpoint;
}
Overseer::Overseer() { //: epsc(deviceEnumerator, playbackDevices){
@ -469,8 +550,11 @@ Overseer::Overseer() { //: epsc(deviceEnumerator, playbackDevices){
initCOMLibrary();
//Obtaining playback endpoint collection on this point in time
reloadEndpoints();
this->epsc.fill(deviceEnumerator, playbackDevices);
reloadEndpoints(Flows::FLOW_PLAYBACK);
//reloadEndpoints(Flows::FLOW_CAPTURE);
//Registering for endpoint information callback
this->epsc.fill(deviceEnumerator, playbackDevices, captureDevices);
if(FAILED(deviceEnumerator->RegisterEndpointNotificationCallback(((IMMNotificationClient*)&epsc)))) { log_debugcpp("when no enchufas......"); }
}
@ -482,6 +566,10 @@ std::vector<Endpoint*> Overseer::getPlaybackEndpoints() {
return playbackDevices;
}
std::vector<Endpoint*> Overseer::getCaptureEndpoints() {
return captureDevices;
}
Overseer::~Overseer(){
log_debugcpp("cum");
deviceEnumerator->Release();

View file

@ -33,6 +33,8 @@ class Endpoint {
public:
Endpoint(IMMDevice* endpoint, uint64_t idx);
//todo: how to forward declare delegate constructors?
Endpoint(IMMDevice* endpoint) : Endpoint(endpoint, 0) {};
void reloadEndpointChannels();
uint64_t getIndex();
void setIndex(uint64_t idx);
@ -47,6 +49,8 @@ class Endpoint {
void setRoles(Roles role);
void assignRoles(Roles role);
void removeRoles(Roles role);
void setFlow();
Flows getFlow();
std::wstring getId();
std::wstring getName();
void setVolumeCallback(EndpointVolumeCallback *epc);
@ -58,6 +62,7 @@ class Endpoint {
uint32_t channelCount = 0;
IMMDevice* endpoint;
Flows flow;
IAudioEndpointVolume *endpointVolume = nullptr;
IPropertyStore *properties;
std::wstring friendlyName;
@ -65,6 +70,9 @@ class Endpoint {
unsigned long endpointState;
Roles endpointRoles = (Roles)0;
uint64_t idx;
/* Not implemented in llvm-mingw. Sad!
* IAudioMeterInformation *endpointPeakMeter = nullptr;
*/
};
class EndpointVolumeCallback : public IAudioEndpointVolumeCallback {
@ -95,11 +103,12 @@ class EndpointSituationCallback : public IMMNotificationClient {
HRESULT OnDeviceStateChanged(LPCWSTR pwstrDeviceId, DWORD dwNewState);
HRESULT OnPropertyValueChanged(LPCWSTR pwstrDeviceId, const PROPERTYKEY key);
void fill(IMMDeviceEnumerator *deviceEnumerator, std::vector<Endpoint*> playbackDevices);
void fill(IMMDeviceEnumerator *deviceEnumerator, std::vector<Endpoint*> playbackDevices, std::vector<Endpoint*> captureDevices);
private:
ULONG ref = 1;
IMMDeviceEnumerator *deviceEnumerator;
std::vector<Endpoint*> playbackDevices;
std::vector<Endpoint*> captureDevices;
};
class Overseer {
@ -107,7 +116,10 @@ class Overseer {
public:
Overseer();
std::vector<Endpoint*> getPlaybackEndpoints();
void reloadEndpoints();
std::vector<Endpoint*> getCaptureEndpoints();
void reloadEndpoints(Flows flow);
Endpoint* addEndpoint(std::wstring endpointId, /* out */ Flows* flow);
NGuid getGuid();
//void setEndpointStatusCallback();
//void setEndpointStatusCallback();
@ -121,11 +133,12 @@ class Overseer {
private:
NGuid guid;
unsigned int numPlaybackEndpoints;
IMMDeviceEnumerator *deviceEnumerator;
EndpointSituationCallback epsc;
//IPolicyConfig *policyConfig;
std::vector<Endpoint*> playbackDevices;
std::vector<Endpoint*> captureDevices;
void initCOMLibrary();
//IMMDeviceCollection *deviceCollection;
//int numCaptureEndpoints;

View file

@ -2,15 +2,28 @@
#include "contclasses.h"
//TODO: pragma once
EndpointHandler::EndpointHandler(uint64_t idx) {
EndpointHandler::EndpointHandler(uint64_t idx, Flows flow) {
//std::vector<Endpoint*> endpoints = osh->getPlaybackEndpoints().at(idx);
this->idx = idx;
this->ep = osh->getPlaybackEndpoints().at(idx);
this->flow = flow;
this->ep = (flow == Flows::FLOW_PLAYBACK ? osh->getPlaybackEndpoints().at(idx) : osh->getCaptureEndpoints().at(idx));
epc = new EndpointVolumeCallback(ep);
this->callbackInfo.caller = osh->getGuid();
//epName = ep->getName();
this->setBackEndpointVolumeCallbackInfoContent(this->getState());
osh->pushBackEndpointHandler(this, flow);
}
void OverseerHandler::pushBackEndpointHandler(EndpointHandler* eph, Flows flow) {
if (eph == nullptr) return;
if (flow = Flows::FLOW_PLAYBACK)
playbackEndpointHandlers.push_back(eph);
else
captureEndpointHandlers.push_back(eph);
return;
}
void EndpointHandler::setFrontVisibilityInfo(EndpointState state, uint64_t frontIdx){
@ -139,35 +152,79 @@ std::vector<Endpoint*> OverseerHandler::getPlaybackEndpoints() {
return this->os->getPlaybackEndpoints();
}
std::vector<EndpointHandler*> OverseerHandler::getEndpointHandlers(){
return endpointHandlers;
std::vector<Endpoint*> OverseerHandler::getCaptureEndpoints() {
return this->os->getCaptureEndpoints();
}
std::vector<EndpointHandler*> OverseerHandler::getPlaybackEndpointHandlers(){
return playbackEndpointHandlers;
}
std::vector<EndpointHandler*> OverseerHandler::getCaptureEndpointHandlers(){
return captureEndpointHandlers;
}
uint64_t OverseerHandler::getPlaybackEndpointsCount(){
return this->os->getPlaybackEndpoints().size();
}
uint64_t OverseerHandler::getCaptureEndpointsCount(){
return this->os->getCaptureEndpoints().size();
}
void OverseerHandler::reloadEndpointHandlers(){
//todo: add capture
//std::vector<EndpointHandler*>* ephs = new std::vector<EndpointHandler*>;
log_debugcpp(" VSize: " + std::to_string(this->getPlaybackEndpointsCount()));
log_debugcpp("Playback VSize: " + std::to_string(this->getPlaybackEndpointsCount()));
for(uint64_t i = 0; i < this->getPlaybackEndpointsCount(); i++){
log_debugcpp("Creating handler " + std::to_string(i));
log_debugcpp("Creating Playback handler " + std::to_string(i));
if(i < (this->endpointHandlers.size()) &&
this->endpointHandlers.at(i) != nullptr)
delete endpointHandlers.at(i);
EndpointHandler* ephexx = new EndpointHandler(i, Flows::FLOW_PLAYBACK);
//this->playbackEndpointHandlers.push_back(ephexx);
log_debugcpp("Created Playback handler " + std::to_string(i) + ", adding to vector. " + " VSize: " + std::to_string(this->playbackEndpointHandlers.size()));
EndpointHandler* eph = new EndpointHandler(i);
log_debugcpp("Created handler " + std::to_string(i) + ", adding to vector. " + " VSize: " + std::to_string(this->getPlaybackEndpointsCount()));
}
if (i >= this->endpointHandlers.size())
endpointHandlers.push_back(eph);
else endpointHandlers.at(i) = eph;
log_debugcpp("Capture VSize: " +
std::to_string(this->getCaptureEndpointsCount()));
for(uint64_t i = 0; i < this->getCaptureEndpointsCount(); i++){
log_debugcpp("Creating Capture handler " + std::to_string(i));
/*
* if(i < (this->captureEndpointHandlers.size()) &&
* this->captureEndpointHandlers.at(i) != nullptr)
* delete captureEndpointHandlers.at(i);
*/
EndpointHandler* ephoo = new EndpointHandler(i, Flows::FLOW_CAPTURE);
//this->captureEndpointHandlers.push_back(ephoo);
log_debugcpp("Created Capture handler " + std::to_string(i) + ", adding to vector. " + " VSize: " + std::to_string(this->captureEndpointHandlers.size()));
/*
* if (i >= this->captureEndpointHandlers.size())
* captureEndpointHandlers.push_back(eph);
* else captureEndpointHandlers.at(i) = eph;
*/
}
//setEndpointHandlers(ephs);
}
EndpointHandler* OverseerHandler::addEndpoint(std::wstring endpointId){
Flows flow;
Endpoint* newEp = this->os->addEndpoint(endpointId, &flow);
uint64_t ephIdx = (flow == Flows::FLOW_PLAYBACK ? this->getPlaybackEndpointsCount() : this->getCaptureEndpointsCount());
EndpointHandler* newEph = new EndpointHandler(ephIdx, flow);
// std::vector<EndpointHandler*> getPlaybackEndpointHandlers();
//std::vector<EndpointHandler*> getCaptureEndpointHandlers();
return newEph;
}
NGuid OverseerHandler::getGuid() {
return this->os->getGuid();
}
@ -182,13 +239,20 @@ void OverseerHandler::changeFrontDefaultsCallback(Roles role, std::wstring endpo
void OverseerHandler::reviseEndpointShowing(std::wstring endpointId, EndpointState state) {
EndpointHandler* eph = nullptr;
for (auto loopEph : this->endpointHandlers) {
for (auto loopEph : this->playbackEndpointHandlers) {
if (loopEph->getId() == endpointId) {
eph = loopEph;
break;
}
}
if (!eph) {
}
//todo: testing missing shiez. sowwy
//if(!eph) osh->
if(EndpointState::ENDPOINT_ACTIVE & state) {
this->addEndpointWidget(eph);
} else if (eph->getFrontVisibilityState() == EndpointState::ENDPOINT_ACTIVE){
@ -207,5 +271,5 @@ void OverseerHandler::setRemoveEndpointWidgetFunction(std::function<void(uint64_
void OverseerHandler::setEndpointHandlers(std::vector<EndpointHandler*> ephs){
this->endpointHandlers = ephs;
this->playbackEndpointHandlers = ephs;
}

View file

@ -62,7 +62,7 @@ struct BackEndpointVolumeCallbackInfo {
class EndpointHandler {
public:
EndpointHandler(uint64_t idx);
EndpointHandler(uint64_t idx, Flows flow);
void setBackEndpointVolumeCallbackInfoContent(uint8_t state);
//these two, currently unused. If I use them, I should feel bad.
@ -84,6 +84,7 @@ public:
uint64_t getFrontVisibilityIndex();
EndpointState getFrontVisibilityState();
Flows getFlow();
float getVolume(int channel);
bool getMute();
size_t getState();
@ -102,7 +103,7 @@ private:
uint64_t idx;
Endpoint *ep = nullptr;
EndpointVolumeCallback *epc = nullptr;
Flows flow;
BackEndpointVolumeCallbackInfo callbackInfo;
struct EndpointHandlerFrontVisibility {
EndpointState visibility = EndpointState::ENDPOINT_ALL;
@ -125,15 +126,21 @@ public:
void setAddEndpointWidgetFunction(std::function<void(EndpointHandler*)> addEndpointWidget);
void setEndpointHandlers(std::vector<EndpointHandler*> ephs);
std::vector<EndpointHandler*> getEndpointHandlers();
std::vector<EndpointHandler*> getPlaybackEndpointHandlers();
std::vector<EndpointHandler*> getCaptureEndpointHandlers();
std::vector<Endpoint*> getPlaybackEndpoints();
std::vector<Endpoint*> getCaptureEndpoints();
void pushBackEndpointHandler(EndpointHandler* eph, Flows flow);
uint64_t getPlaybackEndpointsCount();
uint64_t getCaptureEndpointsCount();
void reloadEndpointHandlers();
EndpointHandler* addEndpoint(std::wstring endpointId);
NGuid getGuid();
private:
Overseer *os;
std::vector<EndpointHandler*> endpointHandlers;
std::vector<EndpointHandler*> playbackEndpointHandlers;
std::vector<EndpointHandler*> captureEndpointHandlers;
std::function<void(Roles, std::wstring /* endpointid */)> changeFrontDefaults;
std::function<void(uint64_t /* epw id */)> removeEndpointWidget;
std::function<void(EndpointHandler*)> addEndpointWidget;

View file

@ -212,6 +212,7 @@ void MainWindow::removeEndpointWidget(EndpointWidgetEvent<uint64_t>* ev){
this->layout->removeWidget(ews.at(i));
uint64_t saisu = ews.size();
//delete ews.at(index);
delete ews.at(i);
while ((i + 1) < ews.size()) {
ews.at(i) = ews.at(i + 1);
ews.at(i)->setIndex(i);
@ -407,11 +408,11 @@ void MainWindow::trayIconActivated(QSystemTrayIcon::ActivationReason reason) {
void MainWindow::reloadEndpointWidgets() {
size_t i = 0;
for (size_t epwIndex = 0; i < (osh->getEndpointHandlers().size()); i++) {
if (osh->getEndpointHandlers().at(i)->getState() == EndpointState::ENDPOINT_ACTIVE){
for (size_t epwIndex = 0; i < (osh->getPlaybackEndpointHandlers().size()); i++) {
if (osh->getPlaybackEndpointHandlers().at(i)->getState() == EndpointState::ENDPOINT_ACTIVE){
log_debugcpp("EPWidget creation");
//osh->getEndpointHandlers().at(i)->getCallbackInfo()->caller = osh->getGuid();
EndpointWidget *epw = new EndpointWidget(epwIndex, osh->getEndpointHandlers().at(i), widget);
//osh->getPlaybackEndpointHandlers().at(i)->getCallbackInfo()->caller = osh->getGuid();
EndpointWidget *epw = new EndpointWidget(epwIndex, osh->getPlaybackEndpointHandlers().at(i), widget);
epwIndex++;
//alfinal estoes solopara inicializarlmao
ews.push_back(epw);