polling data source vector'd and moved to eph
This commit is contained in:
parent
8e9de6a771
commit
8c1cea2da9
4 changed files with 41 additions and 53 deletions
|
|
@ -39,14 +39,18 @@ HRESULT EndpointCallback::QueryInterface(REFIID riid, VOID **ppvInterface) {
|
|||
HRESULT EndpointCallback::OnNotify(PAUDIO_VOLUME_NOTIFICATION_DATA pNotify) {
|
||||
if (pNotify == NULL) return E_INVALIDARG;
|
||||
|
||||
memcpy(osh->callbackInfo[this->ep->getIndex()]->caller, &pNotify->guidEventContext,sizeof(NGuid) );
|
||||
osh->callbackInfo[this->ep->getIndex()]->muted = pNotify->bMuted;
|
||||
osh->callbackInfo[this->ep->getIndex()]->mainVolume = pNotify->fMasterVolume;
|
||||
osh->callbackInfo[this->ep->getIndex()]->channels = pNotify->nChannels;
|
||||
//TODO: MEMORY LEAK. FREE DATA4 FROM NGUID.
|
||||
//TODO: el default = objcopy frees?
|
||||
//delete osh->getEndpointHandlers().at(this->ep->getIndex())->getCallbackInfo()->caller;
|
||||
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->callbackInfo[this->ep->getIndex()]->channelVolumes[i] = pNotify->afChannelVolumes[i];
|
||||
osh->getEndpointHandlers().at(this->ep->getIndex())->getCallbackInfo()->channelVolumes[i] = pNotify->afChannelVolumes[i];
|
||||
} while(i++ < pNotify->nChannels);
|
||||
|
||||
return S_OK;
|
||||
|
|
|
|||
|
|
@ -11,6 +11,17 @@ EndpointHandler::EndpointHandler(uint64_t idx) {
|
|||
epc = new EndpointCallback(ep);
|
||||
//epName = ep->getName();
|
||||
ep->setCallback(epc);
|
||||
callbackInfo.muted = this->getMute();
|
||||
callbackInfo.mainVolume = this->getVolume(AudioChannel::CHANNEL_MAIN);
|
||||
callbackInfo.channels = this->getChannelCount();
|
||||
callbackInfo.channelVolumes.resize(this->callbackInfo.channels);
|
||||
for(uint32_t i = 0; i < this->getChannelCount(); i++){
|
||||
callbackInfo.channelVolumes[i] = this->getVolume(i);
|
||||
}
|
||||
}
|
||||
|
||||
BackEndpointCallbackInfo* EndpointHandler::getCallbackInfo(){
|
||||
return &this->callbackInfo;
|
||||
}
|
||||
|
||||
uint32_t EndpointHandler::getChannelCount(){
|
||||
|
|
|
|||
|
|
@ -1,12 +1,6 @@
|
|||
#pragma once
|
||||
#define invoke_mem_fn(object,ptrToMember) ((object).*(ptrToMember))
|
||||
#define pinvoke_mem_fn(object,ptrToMember) ((object)->*(ptrToMember))
|
||||
|
||||
/* #ifndef QTBLESSED */
|
||||
/* //#define Q_OBJECT */
|
||||
/* class QWidget{}; */
|
||||
/* class QMainWindow{}; */
|
||||
/* #endif */
|
||||
//#define invoke_mem_fn(object,ptrToMember) ((object).*(ptrToMember))
|
||||
//#define pinvoke_mem_fn(object,ptrToMember) ((object)->*(ptrToMember))
|
||||
|
||||
class EndpointWidget;
|
||||
class Endpoint;
|
||||
|
|
@ -31,7 +25,7 @@ struct BackEndpointCallbackInfo {
|
|||
bool muted;
|
||||
float mainVolume;
|
||||
size_t channels;
|
||||
float* channelVolumes = nullptr;
|
||||
std::vector<float> channelVolumes;
|
||||
};
|
||||
|
||||
class EndpointHandler {
|
||||
|
|
@ -43,6 +37,7 @@ public:
|
|||
EndpointCallback *epc = nullptr;
|
||||
//std::wstring epName;
|
||||
|
||||
BackEndpointCallbackInfo* getCallbackInfo();
|
||||
uint32_t getChannelCount();
|
||||
|
||||
void setIndex(uint64_t idx);
|
||||
|
|
@ -59,11 +54,8 @@ public:
|
|||
~EndpointHandler();
|
||||
private:
|
||||
uint64_t idx;
|
||||
BackEndpointCallbackInfo callbackInfo;
|
||||
//QSlider *slidy;
|
||||
|
||||
//signals:
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -78,10 +70,6 @@ public:
|
|||
void reloadEndpointHandlers();
|
||||
NGuid* getGuid();
|
||||
|
||||
//TODO: A EPH
|
||||
BackEndpointCallbackInfo** callbackInfo = nullptr;
|
||||
int callbackInfoSize = 0;
|
||||
|
||||
private:
|
||||
static Overseer os;
|
||||
std::vector<EndpointHandler*> endpointHandlers;
|
||||
|
|
|
|||
|
|
@ -35,13 +35,9 @@ EndpointWidget::EndpointWidget(uint64_t idx, EndpointHandler* eph, QWidget *pare
|
|||
mainSlider->setSingleStep(1);
|
||||
mainSlider->setRange(0,100);
|
||||
|
||||
//TODO: APARTE
|
||||
osh->callbackInfo[idx]->muted = eph->getMute();
|
||||
muteButton->setCheckState((eph->getMute() == false ? Qt::Unchecked : Qt::Checked));
|
||||
muteButton->setText(eph->getMute() ? STRING_UNMUTE : STRING_MUTE);
|
||||
float volume = eph->getVolume(AudioChannel::CHANNEL_MAIN) * 100;
|
||||
//TODO: APARTE
|
||||
osh->callbackInfo[idx]->mainVolume = eph->getVolume(AudioChannel::CHANNEL_MAIN);
|
||||
mainSlider->setValue((int)volume);
|
||||
log_debugcpp("ENDPOINT SET WITH VOLUME " << volume);
|
||||
|
||||
|
|
@ -55,9 +51,6 @@ EndpointWidget::EndpointWidget(uint64_t idx, EndpointHandler* eph, QWidget *pare
|
|||
connect<void(QSlider::*)(int), void(EndpointWidget::*)(int)>(mainSlider, &QSlider::valueChanged, this,&EndpointWidget::updateMainVolume);
|
||||
connect<void(QCheckBox::*)(int), void(EndpointWidget::*)(int)>(muteButton, &QCheckBox::stateChanged, this, (&EndpointWidget::updateMute));
|
||||
|
||||
//TODO: APARTE
|
||||
osh->callbackInfo[idx]->channels = eph->getChannelCount();
|
||||
osh->callbackInfo[idx]->channelVolumes = (float*)calloc(osh->callbackInfo[idx]->channels, sizeof(float));
|
||||
|
||||
for(uint32_t i = 0; i < eph->getChannelCount(); i++){
|
||||
QSlider* tmp = new QSlider(Qt::Horizontal);
|
||||
|
|
@ -65,8 +58,7 @@ EndpointWidget::EndpointWidget(uint64_t idx, EndpointHandler* eph, QWidget *pare
|
|||
tmp->setTickInterval(5);
|
||||
tmp->setSingleStep(1);
|
||||
tmp->setRange(0,100);
|
||||
//TODO: Aparte
|
||||
osh->callbackInfo[idx]->channelVolumes[i] = eph->getVolume(i);
|
||||
|
||||
volume = eph->getVolume(i) * 100;
|
||||
tmp->setValue((int) volume);
|
||||
tmpLb->setText(QString::number(volume));
|
||||
|
|
@ -84,22 +76,25 @@ EndpointWidget::EndpointWidget(uint64_t idx, EndpointHandler* eph, QWidget *pare
|
|||
|
||||
//Polling time
|
||||
timer = new QTimer(this);
|
||||
connect(timer, &QTimer::timeout, [this, idx](){
|
||||
//if (memcmp(osh->callbackInfo[idx]->caller, osh->getGuid(), sizeof(NGuid)) == 0) return;
|
||||
connect(timer, &QTimer::timeout, [this, eph](){
|
||||
//if (memcmp(osh->callbackInfo[idx]->caller, osh->getGuid(), sizeof(NGuid)) == 0) return; CHECK IF THIS PROGRAM GENERATED THE FUNSIES IS NO LONGER IN USE FOR NOW.
|
||||
const float roundingFactor = 0.005;
|
||||
mainSlider->blockSignals(true);
|
||||
muteButton->blockSignals(true);
|
||||
mainSlider->setValue((int)((osh->callbackInfo[idx]->mainVolume + roundingFactor) * 100));
|
||||
muteButton->setCheckState((osh->callbackInfo[idx]->muted == false ? Qt::Unchecked : Qt::Checked));
|
||||
muteButton->setText(osh->callbackInfo[idx]->muted ? STRING_UNMUTE : STRING_MUTE);
|
||||
for(uint32_t i = 0; i < osh->callbackInfo[idx]->channels; i++){
|
||||
mainSlider->setValue((int)((eph->getCallbackInfo()->mainVolume + roundingFactor) * 100));
|
||||
muteButton->setCheckState((eph->getCallbackInfo()->muted == false ? Qt::Unchecked : Qt::Checked));
|
||||
muteButton->setText(eph->getCallbackInfo()->muted ? STRING_UNMUTE : STRING_MUTE);
|
||||
for(uint32_t i = 0; i < eph->getCallbackInfo()->channels; i++){
|
||||
this->channelSliders.at(i)->blockSignals(true);
|
||||
this->channelSliders.at(i)->setValue((int)((osh->callbackInfo[idx]->channelVolumes[i] + roundingFactor) * 100));
|
||||
this->channelLabels.at(i)->setText(QString::number((int)((osh->callbackInfo[idx]->channelVolumes[i] + roundingFactor) * 100)));
|
||||
this->channelSliders.at(i)->setValue((int)((eph->getCallbackInfo()->channelVolumes[i] + roundingFactor) * 100));
|
||||
this->channelLabels.at(i)->setText(QString::number((int)((eph->getCallbackInfo()->channelVolumes[i] + roundingFactor) * 100)));
|
||||
this->channelSliders.at(i)->blockSignals(false);
|
||||
}
|
||||
//memcpy(osh->callbackInfo[idx]->caller, osh->getGuid(), sizeof(NGuid));
|
||||
*osh->callbackInfo[idx]->caller = *osh->getGuid();
|
||||
|
||||
//TODO: el default = objcopy frees?
|
||||
//delete eph->getCallbackInfo()->caller;
|
||||
*eph->getCallbackInfo()->caller = *osh->getGuid();
|
||||
mainSlider->blockSignals(false);
|
||||
muteButton->blockSignals(false);
|
||||
});
|
||||
|
|
@ -193,17 +188,7 @@ void MainWindow::reloadEndpointWidgets() {
|
|||
size_t i = 0;
|
||||
for (; i < (osh->getEndpointHandlers().size()); i++) {
|
||||
log_debugcpp("EPWidget creation");
|
||||
//TODO: APARTE
|
||||
if(i >= osh->callbackInfoSize) {
|
||||
BackEndpointCallbackInfo** temp = (BackEndpointCallbackInfo**)calloc((i + 1), sizeof(BackEndpointCallbackInfo));
|
||||
memcpy(temp,osh->callbackInfo, i * sizeof(sizeof(BackEndpointCallbackInfo)));
|
||||
free(osh->callbackInfo);
|
||||
osh->callbackInfo = temp;
|
||||
osh->callbackInfo[i] = new BackEndpointCallbackInfo();
|
||||
osh->callbackInfoSize++;
|
||||
}
|
||||
memcpy(osh->callbackInfo[i]->caller, osh->getGuid(),sizeof(NGuid) );
|
||||
|
||||
*osh->getEndpointHandlers().at(i)->getCallbackInfo()->caller = *osh->getGuid();
|
||||
EndpointWidget *epw = new EndpointWidget(i, osh->getEndpointHandlers().at(i), widget);
|
||||
//TODO: ALWAYS PUSH BACK??? PSZ CHANGE DIS WHEN IMPLEMENTING DYN ENDPOINT DET
|
||||
ews.push_back(epw);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue