back to front now works without hangs?
This commit is contained in:
parent
966cf91a23
commit
d1f0bcaf26
5 changed files with 166 additions and 78 deletions
|
|
@ -16,7 +16,8 @@
|
|||
* }
|
||||
*/
|
||||
|
||||
EndpointWidget::EndpointWidget(EndpointHandler* eph, QWidget *parent) : QWidget(parent){
|
||||
EndpointWidget::EndpointWidget(uint64_t idx, EndpointHandler* eph, QWidget *parent) : QWidget(parent){
|
||||
this->idx = idx;
|
||||
this->eph = eph;
|
||||
layout = new QGridLayout();
|
||||
this->setLayout(layout);
|
||||
|
|
@ -34,9 +35,13 @@ EndpointWidget::EndpointWidget(EndpointHandler* eph, QWidget *parent) : QWidget(
|
|||
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(ENDPOINT_MASTER_VOLUME) * 100;
|
||||
//TODO: APARTE
|
||||
osh->callbackInfo[idx]->mainVolume = eph->getVolume(ENDPOINT_MASTER_VOLUME);
|
||||
mainSlider->setValue((int)volume);
|
||||
log_debugcpp("ENDPOINT SET WITH VOLUME " << volume);
|
||||
|
||||
|
|
@ -46,15 +51,24 @@ EndpointWidget::EndpointWidget(EndpointHandler* eph, QWidget *parent) : QWidget(
|
|||
mainMuteLayout->addWidget(muteButton, 0, 1);
|
||||
layout->addWidget(mainSlider, 0, 1);
|
||||
|
||||
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));
|
||||
|
||||
/*
|
||||
* 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);
|
||||
QLabel* tmpLb = new QLabel("");
|
||||
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));
|
||||
|
|
@ -63,8 +77,22 @@ EndpointWidget::EndpointWidget(EndpointHandler* eph, QWidget *parent) : QWidget(
|
|||
layout->addWidget(tmp, 1, i);
|
||||
layout->addWidget(tmpLb, 2, i);
|
||||
//TODO: check if there's a need to prevent deadlocks; probably this will eventually turn into its own func
|
||||
connect(tmp, &QSlider::valueChanged, [this, i](int newValue){ this->eph->setVolume(osh->getGuid(), i, newValue); this->channelLabels.at(i)->setText(QString::number(newValue)); });
|
||||
/*
|
||||
* connect(tmp, &QSlider::valueChanged, [this, i](int newValue){ this->eph->setVolume(osh->getGuid(), i, newValue); this->channelLabels.at(i)->setText(QString::number(newValue)); });
|
||||
*/
|
||||
}
|
||||
|
||||
QTimer *timer = new QTimer(this);
|
||||
connect(timer, &QTimer::timeout, [this, idx](){
|
||||
mainSlider->setValue((int)(osh->callbackInfo[idx]->mainVolume * 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++){
|
||||
this->channelSliders.at(i)->setValue((int)(osh->callbackInfo[idx]->channelVolumes[i] * 100));
|
||||
this->channelLabels.at(i)->setText(QString::number((int)(osh->callbackInfo[idx]->channelVolumes[i] * 100)));
|
||||
}
|
||||
});
|
||||
timer->start(10);
|
||||
|
||||
layout->addItem(new QSpacerItem(1, 1, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding), 3, 0);
|
||||
layout->addItem(new QSpacerItem(1, 1, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding), 3, 1);
|
||||
|
|
@ -72,15 +100,16 @@ EndpointWidget::EndpointWidget(EndpointHandler* eph, QWidget *parent) : QWidget(
|
|||
}
|
||||
|
||||
void EndpointWidget::updateMute(bool muted){
|
||||
log_debugcpp("cliqui callboqui cloqui");
|
||||
//TODO: mutex test
|
||||
//log_debugcpp("cliqui callboqui cloqui");
|
||||
//TIP: Blocksignals here to diagnose slider visuals locking when playing DJ with external volume bar. Functionality is restored when mute checkbox is clicked.
|
||||
//this->blockSignals(true);
|
||||
//this->muteButton->blockSignals(true);
|
||||
this->muteButton->blockSignals(true);
|
||||
|
||||
//this->eph->setMute(osh->getGuid(), muted);
|
||||
this->muteButton->setChecked(muted);
|
||||
this->muteButton->setText(this->eph->getMute() ? STRING_UNMUTE : STRING_MUTE);
|
||||
//this->muteButton->blockSignals(false);
|
||||
this->muteButton->blockSignals(false);
|
||||
//this->blockSignals(false);
|
||||
}
|
||||
|
||||
|
|
@ -94,7 +123,8 @@ void EndpointWidget::updateMute(int checked){
|
|||
}
|
||||
|
||||
void EndpointWidget::updateMainVolume(int newValue){
|
||||
log_debugcpp("updateMainVolume slot.");
|
||||
//TODO: mutex test
|
||||
//log_debugcpp("updateMainVolume slot.");
|
||||
this->eph->setVolume(osh->getGuid(), ENDPOINT_MASTER_VOLUME, newValue);
|
||||
}
|
||||
|
||||
|
|
@ -102,16 +132,19 @@ void EndpointWidget::updateVolume(uint32_t channel, float newValue){
|
|||
//this->blockSignals(true);
|
||||
int newVal = newValue * 100;
|
||||
if (channel == (uint32_t)AudioChannel::CHANNEL_MAIN) {
|
||||
log_debugcpp("mainvolcallback int: " << newVal);
|
||||
//TODO: mutex test
|
||||
//log_debugcpp("mainvolcallback int: " << newVal);
|
||||
//this->mainSlider->blockSignals(true);
|
||||
|
||||
if(this->mainSlider->value() != newVal) {
|
||||
this->mainSlider->blockSignals(true);
|
||||
this->mainSlider->setValue(newVal);
|
||||
this->mainSlider->blockSignals(false);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
log_debugcpp("Cont->Front Channel:: " << channel << " volcallback int: " << newVal);
|
||||
//TODO: mutex test
|
||||
//log_debugcpp("Cont->Front Channel:: " << channel << " volcallback int: " << newVal);
|
||||
|
||||
for (size_t i = 0; i < sizeof(uint32_t) * 8 && i < channelSliders.size(); ++i) {
|
||||
if (((channel >> i) & 1) && this->channelSliders.at(i)->value() != newVal) {
|
||||
|
|
@ -162,23 +195,35 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
|
|||
}
|
||||
|
||||
void MainWindow::reloadEndpointWidgets() {
|
||||
unsigned int i = 0;
|
||||
size_t i = 0;
|
||||
for (; i < (osh->getEndpointHandlers().size()); i++) {
|
||||
log_debugcpp("EPWidget creation");
|
||||
EndpointWidget *epw = new EndpointWidget(osh->getEndpointHandlers().at(i), widget);
|
||||
//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) );
|
||||
|
||||
EndpointWidget *epw = new EndpointWidget(i, osh->getEndpointHandlers().at(i), widget);
|
||||
ews.push_back(epw);
|
||||
layout->addWidget(epw, i, 0);
|
||||
|
||||
}
|
||||
|
||||
layout->addItem(new QSpacerItem(1, 1, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding), i, 0);
|
||||
|
||||
osh->setFrontVolumeCallback([this](uint64_t device, uint32_t channel, float value) {
|
||||
if (device < ews.size())
|
||||
ews[device]->updateVolume(channel, value);
|
||||
if (device < ews.size())
|
||||
ews.at(device)->updateVolume(channel, value);
|
||||
});
|
||||
osh->setFrontMuteCallback([this](uint64_t device, bool muted) {
|
||||
if (device < ews.size())
|
||||
ews[device]->updateMute(muted);
|
||||
ews.at(device)->updateMute(muted);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue