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) ); //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()->muted = pNotify->bMuted;
osh->getEndpointHandlers().at(this->ep->getIndex())->getCallbackInfo()->mainVolume = pNotify->fMasterVolume; osh->getEndpointHandlers().at(this->ep->getIndex())->getCallbackInfo()->mainVolume = pNotify->fMasterVolume;
osh->getEndpointHandlers().at(this->ep->getIndex())->getCallbackInfo()->channels = pNotify->nChannels; osh->getEndpointHandlers().at(this->ep->getIndex())->getCallbackInfo()->channels = pNotify->nChannels;
UINT i = 0; UINT j = 0;
do { //todo: do while here caused stack corruption; sus
osh->getEndpointHandlers().at(this->ep->getIndex())->getCallbackInfo()->channelVolumes[i] = pNotify->afChannelVolumes[i]; while(j < pNotify->nChannels) {
} while(i++ < pNotify->nChannels); osh->getEndpointHandlers().at(this->ep->getIndex())->getCallbackInfo()->channelVolumes[j] = pNotify->afChannelVolumes[j];
j++;
}
return S_OK; return S_OK;
} }

View file

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

View file

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

View file

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

View file

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