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
|
|
@ -38,34 +38,46 @@ HRESULT EndpointCallback::QueryInterface(REFIID riid, VOID **ppvInterface) {
|
||||||
|
|
||||||
HRESULT EndpointCallback::OnNotify(PAUDIO_VOLUME_NOTIFICATION_DATA pNotify) {
|
HRESULT EndpointCallback::OnNotify(PAUDIO_VOLUME_NOTIFICATION_DATA pNotify) {
|
||||||
if (pNotify == NULL) return E_INVALIDARG;
|
if (pNotify == NULL) return E_INVALIDARG;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* float extraChannelVol[pNotify->nChannels];
|
||||||
|
* for (UINT i = 0; i < pNotify->nChannels; i++){
|
||||||
|
* AUDIO_VOLUME_NOTIFICATION_DATA eventData = *pNotify;
|
||||||
|
* extraChannelVol[i] = pNotify->afChannelVolumes[i];
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
|
||||||
float extraChannelVol[pNotify->nChannels];
|
// osh->callbackInfo[this->ep->getIndex()]->caller = (NGuid)pNotify->guidEventContext;
|
||||||
bool multiChannel = false;
|
memcpy(osh->callbackInfo[this->ep->getIndex()]->caller, &pNotify->guidEventContext,sizeof(NGuid) );
|
||||||
AUDIO_VOLUME_NOTIFICATION_DATA eventData = *pNotify;
|
|
||||||
if(pNotify->nChannels > 1) {
|
|
||||||
multiChannel = true;
|
|
||||||
for (UINT i = 0; i < pNotify->nChannels; i++){
|
|
||||||
extraChannelVol[i] = pNotify->afChannelVolumes[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
NGuid* guid = osh->getGuid();
|
|
||||||
|
|
||||||
if (memcmp(guid, &eventData, sizeof(*guid)) == 0) {
|
|
||||||
log_debugcpp("Onnanokotify says You Shall Not Update Thy Interface.");
|
|
||||||
} else {
|
|
||||||
log_debugcpp("Onnanokotify says Stored: " << guid->data1);
|
|
||||||
log_debugcpp("Onnanokotify says Grace of God: " << eventData.guidEventContext.Data1);
|
|
||||||
osh->updateMuteCallback(this->ep->getIndex(), eventData.bMuted);
|
|
||||||
osh->updateVolumeCallback(this->ep->getIndex(), AudioChannel::CHANNEL_MAIN ,eventData.fMasterVolume);
|
|
||||||
log_debugcpp("Onnanokotify says Reported Channel Qty: " << eventData.nChannels);
|
|
||||||
|
|
||||||
if(multiChannel)
|
osh->callbackInfo[this->ep->getIndex()]->muted = pNotify->bMuted;
|
||||||
for(UINT i = 0; i < eventData.nChannels; i++) {
|
osh->callbackInfo[this->ep->getIndex()]->mainVolume = pNotify->fMasterVolume;
|
||||||
osh->updateVolumeCallback(this->ep->getIndex(), (uint32_t)i, extraChannelVol[i]);
|
osh->callbackInfo[this->ep->getIndex()]->channels = pNotify->nChannels;
|
||||||
}
|
|
||||||
else
|
UINT i = 0;
|
||||||
osh->updateVolumeCallback(this->ep->getIndex(), (uint32_t)0, pNotify->afChannelVolumes[0]);
|
do {
|
||||||
}
|
osh->callbackInfo[this->ep->getIndex()]->channelVolumes[i] = pNotify->afChannelVolumes[i];
|
||||||
|
} while(i++ < pNotify->nChannels);
|
||||||
|
|
||||||
|
//osh->receiveBackEndpointCallback(this->ep->getIndex());
|
||||||
|
|
||||||
|
/* NGuid* guid = osh->getGuid();
|
||||||
|
* //AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
||||||
|
* if (memcmp(guid, &eventData.guidEventContext, sizeof(*guid)) == 0) {
|
||||||
|
* //log_debugcpp("Onnanokotify says You Shall Not Update Thy Interface.");
|
||||||
|
* } else {
|
||||||
|
* //log_debugcpp("Onnanokotify says Stored: " << guid->data1);
|
||||||
|
* //log_debugcpp("Onnanokotify says Grace of God: " << eventData.guidEventContext.Data1);
|
||||||
|
* osh->updateMuteCallback(this->ep->getIndex(), eventData.bMuted);
|
||||||
|
* osh->updateVolumeCallback(this->ep->getIndex(), AudioChannel::CHANNEL_MAIN ,eventData.fMasterVolume);
|
||||||
|
* //log_debugcpp("Onnanokotify says Reported Channel Qty: " << eventData.nChannels);
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* for(UINT i = 0; i < eventData.nChannels; i++) {
|
||||||
|
* osh->updateVolumeCallback(this->ep->getIndex(), (uint32_t)i, extraChannelVol[i]);
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
@ -118,9 +130,10 @@ uint32_t Endpoint::getChannelCount(){
|
||||||
bool Endpoint::getMute(){
|
bool Endpoint::getMute(){
|
||||||
BOOL mut;
|
BOOL mut;
|
||||||
if(FAILED(endpointVolume->GetMute(&mut))) { log_debugcpp("si"); }
|
if(FAILED(endpointVolume->GetMute(&mut))) { log_debugcpp("si"); }
|
||||||
log_debugcpp("back BOOL is " << mut);
|
//TODO: mutex test
|
||||||
|
//log_debugcpp("back BOOL is " << mut);
|
||||||
bool mute = (bool)mut;
|
bool mute = (bool)mut;
|
||||||
log_debugcpp("translate to bool " << mute);
|
//log_debugcpp("translate to bool " << mute);
|
||||||
return mute;
|
return mute;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -140,12 +153,14 @@ bool Endpoint::getMute(){
|
||||||
|
|
||||||
|
|
||||||
void Endpoint::setVolume(NGuid* guid, int channel, float volume) {
|
void Endpoint::setVolume(NGuid* guid, int channel, float volume) {
|
||||||
|
//TODO: mutex test
|
||||||
GUID tempMsGuid = NGuidToGUID(guid);
|
GUID tempMsGuid = NGuidToGUID(guid);
|
||||||
if (channel == AudioChannel::CHANNEL_MAIN) {
|
if (channel == AudioChannel::CHANNEL_MAIN) {
|
||||||
if(FAILED(endpointVolume->SetMasterVolumeLevelScalar(volume, &tempMsGuid))) { log_debugcpp("MASTER VOLUME FAILED"); };
|
if(FAILED(endpointVolume->SetMasterVolumeLevelScalar(volume, &tempMsGuid))) { //log_debugcpp("MASTER VOLUME FAILED");
|
||||||
|
};
|
||||||
} else {
|
} else {
|
||||||
log_debugcpp("Windows: Channel being updated: " << channel);
|
//log_debugcpp("Windows: Channel being updated: " << channel);
|
||||||
if(FAILED(endpointVolume->SetChannelVolumeLevelScalar(channel, volume, &tempMsGuid))) { log_debugcpp("CHANNEL "<< channel <<" VOLUME FAILED"); };
|
if(FAILED(endpointVolume->SetChannelVolumeLevelScalar(channel, volume, &tempMsGuid))) { /* log_debugcpp("CHANNEL "<< channel <<" VOLUME FAILED"); */ };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,8 @@ void EndpointHandler::setVolume(NGuid* guid, int channel, int value){
|
||||||
|
|
||||||
void EndpointHandler::setMute(NGuid* guid, bool muted){
|
void EndpointHandler::setMute(NGuid* guid, bool muted){
|
||||||
//Qt momento, de ahi el param?
|
//Qt momento, de ahi el param?
|
||||||
log_debugcpp("kinda handling the muting tbh");
|
//TODO: mutex test
|
||||||
|
//log_debugcpp("kinda handling the muting tbh");
|
||||||
ep->setMute(guid, muted);
|
ep->setMute(guid, muted);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -108,9 +109,11 @@ void OverseerHandler::setFrontMuteCallback(std::function<void(uint64_t, bool)> f
|
||||||
this->updateFrontMuteCallback = f;
|
this->updateFrontMuteCallback = f;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OverseerHandler::updateMuteCallback(uint64_t idx, bool muted){
|
/*
|
||||||
updateFrontMuteCallback(idx, muted);
|
* void OverseerHandler::updateMuteCallback(uint64_t idx, bool muted){
|
||||||
}
|
* updateFrontMuteCallback(idx, muted);
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* void OverseerHandler::updateMainVolumeCallback(uint64_t idx, float newVal){
|
* void OverseerHandler::updateMainVolumeCallback(uint64_t idx, float newVal){
|
||||||
|
|
@ -118,21 +121,32 @@ void OverseerHandler::updateMuteCallback(uint64_t idx, bool muted){
|
||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void OverseerHandler::updateVolumeCallback(uint64_t idx, uint32_t channel, float newVal){
|
/*
|
||||||
if (channel == (uint32_t)AudioChannel::CHANNEL_MAIN) {
|
* void OverseerHandler::updateVolumeCallback(uint64_t idx, uint32_t channel, float newVal){
|
||||||
log_debugcpp("mainvolcallback float: " << newVal);
|
* if (channel == (uint32_t)AudioChannel::CHANNEL_MAIN) {
|
||||||
updateFrontVolumeCallback(idx, AudioChannel::CHANNEL_MAIN, newVal);
|
* //TODO: mutex test
|
||||||
return;
|
* //log_debugcpp("mainvolcallback float: " << newVal);
|
||||||
}
|
* updateFrontVolumeCallback(idx, AudioChannel::CHANNEL_MAIN, newVal);
|
||||||
|
* return;
|
||||||
|
* }
|
||||||
// convert channel to bitmask
|
*
|
||||||
uint32_t i = 0;
|
*
|
||||||
while (i < channel)
|
* // convert channel to bitmask
|
||||||
i++;
|
* uint32_t i = 0;
|
||||||
uint32_t mask = (1 << i);
|
* while (i < channel)
|
||||||
|
* i++;
|
||||||
|
* uint32_t mask = (1 << i);
|
||||||
|
* //TODO: Mutex test
|
||||||
|
* //log_debugcpp("Back->Cont Channel: " << mask << " volcallback float: " << newVal);
|
||||||
|
*
|
||||||
|
* updateFrontVolumeCallback(idx, mask, newVal);
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
|
||||||
log_debugcpp("Back->Cont Channel: " << mask << " volcallback float: " << newVal);
|
/*
|
||||||
|
* void OverseerHandler::receiveBackEndpointCallback(uint64_t index) {
|
||||||
updateFrontVolumeCallback(idx, mask, newVal);
|
* if (memcmp(os.getGuid(), callbackInfo.caller, sizeof(*guid)) != 0)
|
||||||
}
|
* updateFrontCallback(uint64_t index, &callbackInfo);
|
||||||
|
*
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
|
|
||||||
|
|
@ -20,10 +20,18 @@ enum AudioChannel {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct NGuid {
|
struct NGuid {
|
||||||
uint32_t data1;
|
uint32_t data1;
|
||||||
uint16_t data2;
|
uint16_t data2;
|
||||||
uint16_t data3;
|
uint16_t data3;
|
||||||
unsigned char data4[8];
|
unsigned char data4[8];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct BackEndpointCallbackInfo {
|
||||||
|
NGuid* caller = new NGuid();
|
||||||
|
bool muted;
|
||||||
|
float mainVolume;
|
||||||
|
size_t channels;
|
||||||
|
float* channelVolumes = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
class EndpointHandler {
|
class EndpointHandler {
|
||||||
|
|
@ -69,15 +77,20 @@ public:
|
||||||
uint64_t getPlaybackEndpointsCount();
|
uint64_t getPlaybackEndpointsCount();
|
||||||
void reloadEndpointHandlers();
|
void reloadEndpointHandlers();
|
||||||
NGuid* getGuid();
|
NGuid* getGuid();
|
||||||
void updateMuteCallback(uint64_t idx, bool muted);
|
|
||||||
void setFrontMuteCallback(std::function<void(uint64_t, bool)> f);
|
void setFrontMuteCallback(std::function<void(uint64_t, bool)> f);
|
||||||
void setFrontVolumeCallback(std::function<void(uint64_t, uint32_t, float)> f);
|
void setFrontVolumeCallback(std::function<void(uint64_t, uint32_t, float)> f);
|
||||||
//void updateMainVolumeCallback(uint64_t idx, float newVal);
|
void setUpdateFrontCallback(std::function<void(uint64_t, BackEndpointCallbackInfo*)> f);
|
||||||
void updateVolumeCallback(uint64_t idx, uint32_t channel, float newVal);
|
//TODO: A EPH
|
||||||
|
BackEndpointCallbackInfo** callbackInfo = nullptr;
|
||||||
|
int callbackInfoSize = 0;
|
||||||
|
/* void updateMuteCallback(uint64_t idx, bool muted); */
|
||||||
|
/* void updateVolumeCallback(uint64_t idx, uint32_t channel, float newVal); */
|
||||||
|
//void receiveBackEndpointCallback(uint64_t index);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static Overseer os;
|
static Overseer os;
|
||||||
std::vector<EndpointHandler*> endpointHandlers;
|
std::vector<EndpointHandler*> endpointHandlers;
|
||||||
|
|
||||||
std::function<void(uint64_t /* device */, uint32_t /* channel */, float /* value */)> updateFrontVolumeCallback;
|
std::function<void(uint64_t /* device */, uint32_t /* channel */, float /* value */)> updateFrontVolumeCallback;
|
||||||
std::function<void(uint64_t /* device */, bool /* mute */)> updateFrontMuteCallback;
|
std::function<void(uint64_t /* device */, bool /* mute */)> updateFrontMuteCallback;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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;
|
this->eph = eph;
|
||||||
layout = new QGridLayout();
|
layout = new QGridLayout();
|
||||||
this->setLayout(layout);
|
this->setLayout(layout);
|
||||||
|
|
@ -34,9 +35,13 @@ EndpointWidget::EndpointWidget(EndpointHandler* eph, QWidget *parent) : QWidget(
|
||||||
mainSlider->setSingleStep(1);
|
mainSlider->setSingleStep(1);
|
||||||
mainSlider->setRange(0,100);
|
mainSlider->setRange(0,100);
|
||||||
|
|
||||||
|
//TODO: APARTE
|
||||||
|
osh->callbackInfo[idx]->muted = eph->getMute();
|
||||||
muteButton->setCheckState((eph->getMute() == false ? Qt::Unchecked : Qt::Checked));
|
muteButton->setCheckState((eph->getMute() == false ? Qt::Unchecked : Qt::Checked));
|
||||||
muteButton->setText(eph->getMute() ? STRING_UNMUTE : STRING_MUTE);
|
muteButton->setText(eph->getMute() ? STRING_UNMUTE : STRING_MUTE);
|
||||||
float volume = eph->getVolume(ENDPOINT_MASTER_VOLUME) * 100;
|
float volume = eph->getVolume(ENDPOINT_MASTER_VOLUME) * 100;
|
||||||
|
//TODO: APARTE
|
||||||
|
osh->callbackInfo[idx]->mainVolume = eph->getVolume(ENDPOINT_MASTER_VOLUME);
|
||||||
mainSlider->setValue((int)volume);
|
mainSlider->setValue((int)volume);
|
||||||
log_debugcpp("ENDPOINT SET WITH VOLUME " << volume);
|
log_debugcpp("ENDPOINT SET WITH VOLUME " << volume);
|
||||||
|
|
||||||
|
|
@ -46,15 +51,24 @@ EndpointWidget::EndpointWidget(EndpointHandler* eph, QWidget *parent) : QWidget(
|
||||||
mainMuteLayout->addWidget(muteButton, 0, 1);
|
mainMuteLayout->addWidget(muteButton, 0, 1);
|
||||||
layout->addWidget(mainSlider, 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++){
|
for(uint32_t i = 0; i < eph->getChannelCount(); i++){
|
||||||
QSlider* tmp = new QSlider(Qt::Horizontal);
|
QSlider* tmp = new QSlider(Qt::Horizontal);
|
||||||
QLabel* tmpLb = new QLabel("");
|
QLabel* tmpLb = new QLabel("");
|
||||||
tmp->setTickInterval(5);
|
tmp->setTickInterval(5);
|
||||||
tmp->setSingleStep(1);
|
tmp->setSingleStep(1);
|
||||||
tmp->setRange(0,100);
|
tmp->setRange(0,100);
|
||||||
|
//TODO: Aparte
|
||||||
|
osh->callbackInfo[idx]->channelVolumes[i] = eph->getVolume(i);
|
||||||
volume = eph->getVolume(i) * 100;
|
volume = eph->getVolume(i) * 100;
|
||||||
tmp->setValue((int) volume);
|
tmp->setValue((int) volume);
|
||||||
tmpLb->setText(QString::number(volume));
|
tmpLb->setText(QString::number(volume));
|
||||||
|
|
@ -63,8 +77,22 @@ EndpointWidget::EndpointWidget(EndpointHandler* eph, QWidget *parent) : QWidget(
|
||||||
layout->addWidget(tmp, 1, i);
|
layout->addWidget(tmp, 1, i);
|
||||||
layout->addWidget(tmpLb, 2, 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
|
//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, 0);
|
||||||
layout->addItem(new QSpacerItem(1, 1, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding), 3, 1);
|
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){
|
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.
|
//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->blockSignals(true);
|
||||||
//this->muteButton->blockSignals(true);
|
this->muteButton->blockSignals(true);
|
||||||
|
|
||||||
//this->eph->setMute(osh->getGuid(), muted);
|
//this->eph->setMute(osh->getGuid(), muted);
|
||||||
this->muteButton->setChecked(muted);
|
this->muteButton->setChecked(muted);
|
||||||
this->muteButton->setText(this->eph->getMute() ? STRING_UNMUTE : STRING_MUTE);
|
this->muteButton->setText(this->eph->getMute() ? STRING_UNMUTE : STRING_MUTE);
|
||||||
//this->muteButton->blockSignals(false);
|
this->muteButton->blockSignals(false);
|
||||||
//this->blockSignals(false);
|
//this->blockSignals(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -94,7 +123,8 @@ void EndpointWidget::updateMute(int checked){
|
||||||
}
|
}
|
||||||
|
|
||||||
void EndpointWidget::updateMainVolume(int newValue){
|
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);
|
this->eph->setVolume(osh->getGuid(), ENDPOINT_MASTER_VOLUME, newValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -102,16 +132,19 @@ void EndpointWidget::updateVolume(uint32_t channel, float newValue){
|
||||||
//this->blockSignals(true);
|
//this->blockSignals(true);
|
||||||
int newVal = newValue * 100;
|
int newVal = newValue * 100;
|
||||||
if (channel == (uint32_t)AudioChannel::CHANNEL_MAIN) {
|
if (channel == (uint32_t)AudioChannel::CHANNEL_MAIN) {
|
||||||
log_debugcpp("mainvolcallback int: " << newVal);
|
//TODO: mutex test
|
||||||
|
//log_debugcpp("mainvolcallback int: " << newVal);
|
||||||
//this->mainSlider->blockSignals(true);
|
//this->mainSlider->blockSignals(true);
|
||||||
|
|
||||||
if(this->mainSlider->value() != newVal) {
|
if(this->mainSlider->value() != newVal) {
|
||||||
|
this->mainSlider->blockSignals(true);
|
||||||
this->mainSlider->setValue(newVal);
|
this->mainSlider->setValue(newVal);
|
||||||
|
this->mainSlider->blockSignals(false);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
//TODO: mutex test
|
||||||
log_debugcpp("Cont->Front Channel:: " << channel << " volcallback int: " << newVal);
|
//log_debugcpp("Cont->Front Channel:: " << channel << " volcallback int: " << newVal);
|
||||||
|
|
||||||
for (size_t i = 0; i < sizeof(uint32_t) * 8 && i < channelSliders.size(); ++i) {
|
for (size_t i = 0; i < sizeof(uint32_t) * 8 && i < channelSliders.size(); ++i) {
|
||||||
if (((channel >> i) & 1) && this->channelSliders.at(i)->value() != newVal) {
|
if (((channel >> i) & 1) && this->channelSliders.at(i)->value() != newVal) {
|
||||||
|
|
@ -162,23 +195,35 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::reloadEndpointWidgets() {
|
void MainWindow::reloadEndpointWidgets() {
|
||||||
unsigned int i = 0;
|
size_t i = 0;
|
||||||
for (; i < (osh->getEndpointHandlers().size()); i++) {
|
for (; i < (osh->getEndpointHandlers().size()); i++) {
|
||||||
log_debugcpp("EPWidget creation");
|
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);
|
ews.push_back(epw);
|
||||||
layout->addWidget(epw, i, 0);
|
layout->addWidget(epw, i, 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
layout->addItem(new QSpacerItem(1, 1, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding), 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) {
|
osh->setFrontVolumeCallback([this](uint64_t device, uint32_t channel, float value) {
|
||||||
if (device < ews.size())
|
if (device < ews.size())
|
||||||
ews[device]->updateVolume(channel, value);
|
ews.at(device)->updateVolume(channel, value);
|
||||||
});
|
});
|
||||||
osh->setFrontMuteCallback([this](uint64_t device, bool muted) {
|
osh->setFrontMuteCallback([this](uint64_t device, bool muted) {
|
||||||
if (device < ews.size())
|
if (device < ews.size())
|
||||||
ews[device]->updateMute(muted);
|
ews.at(device)->updateMute(muted);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@
|
||||||
#include <QGridLayout>
|
#include <QGridLayout>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
|
#include <QTimer>
|
||||||
/*
|
/*
|
||||||
* #else
|
* #else
|
||||||
* class QSlider;
|
* class QSlider;
|
||||||
|
|
@ -53,7 +54,7 @@ class EndpointWidget : public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
EndpointWidget(EndpointHandler* eph, QWidget *parent = nullptr);
|
EndpointWidget(uint64_t idx, EndpointHandler* eph, QWidget *parent = nullptr);
|
||||||
//TODO: get();
|
//TODO: get();
|
||||||
EndpointHandler* eph;
|
EndpointHandler* eph;
|
||||||
void setIndex(uint64_t idx);
|
void setIndex(uint64_t idx);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue