fixed stack corruption after refactor?

This commit is contained in:
Hane 2023-09-11 20:37:33 +02:00
commit 6d2f981d35
5 changed files with 18 additions and 14 deletions

View file

@ -54,15 +54,17 @@ HRESULT EndpointVolumeCallback::OnNotify(PAUDIO_VOLUME_NOTIFICATION_DATA pNotify
//memcpy(&osh->getEndpointHandlers().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;
UINT i = 0;
do {
osh->getEndpointHandlers().at(this->ep->getIndex())->getCallbackInfo()->channelVolumes[i] = pNotify->afChannelVolumes[i];
} while(i++ < 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];
j++;
}
return S_OK;
}

View file

@ -139,7 +139,6 @@ std::vector<Endpoint*> OverseerHandler::getPlaybackEndpoints() {
return this->os->getPlaybackEndpoints();
}
std::vector<EndpointHandler*> OverseerHandler::getEndpointHandlers(){
return endpointHandlers;
}
@ -189,14 +188,13 @@ void OverseerHandler::reviseEndpointShowing(std::wstring endpointId, EndpointSta
break;
}
}
//todo:
if(EndpointState::ENDPOINT_ACTIVE & state) {
this->addEndpointWidget(eph);
} else if (eph->getFrontVisibilityState() == EndpointState::ENDPOINT_ACTIVE){
this->removeEndpointWidget(eph->getFrontVisibilityIndex());
}
return;
//this->reviseEndpointShowing(endpointId, role);
}
void OverseerHandler::setAddEndpointWidgetFunction(std::function<void(EndpointHandler*)> addEndpointWidget){

View file

@ -35,6 +35,7 @@ enum Roles {
};
struct NGuid {
//todo: still leaking?
uint32_t data1;
uint16_t data2;
uint16_t data3;

View file

@ -187,6 +187,8 @@ EndpointWidget::EndpointWidget(uint64_t idx, EndpointHandler* eph, QWidget *pare
}
EndpointWidget::~EndpointWidget() {
timer->stop();
delete timer;
this->eph->setFrontVisibilityInfo(EndpointState::ENDPOINT_ALL, INT_MAX);
}
@ -211,7 +213,7 @@ void MainWindow::removeEndpointWidget(EndpointWidgetEvent<uint64_t>* ev){
//delete ews.at(index);
while ((i + 1) < ews.size()) {
ews.at(i) = ews.at(i + 1);
ews.at(i)->updateEndpointHandlerFrontIndex(i);
ews.at(i)->updateFrontIndex(i);
i++;
}
ews.pop_back();
@ -270,7 +272,8 @@ EndpointHandler* EndpointWidget::getEndpointHandler(){
return this->eph;
}
void EndpointWidget::updateEndpointHandlerFrontIndex(uint64_t index){
void EndpointWidget::updateFrontIndex(uint64_t index){
this->idx = index;
this->eph->setFrontVisibilityInfo(EndpointState::ENDPOINT_ACTIVE, index);
}

View file

@ -92,7 +92,7 @@ public:
EndpointWidget(uint64_t idx, EndpointHandler* eph, QWidget *parent = nullptr);
EndpointHandler* getEndpointHandler();
void updateEndpointHandlerFrontIndex(uint64_t index);
void updateFrontIndex(uint64_t index);
void setIndex(uint64_t idx);
uint64_t getIndex();