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
|
|
@ -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