Remove frontend header from contclasses
This commit is contained in:
parent
81f6cb32c8
commit
5bb37eb9fd
5 changed files with 57 additions and 43 deletions
|
|
@ -55,7 +55,6 @@ HRESULT EndpointCallback::OnNotify(PAUDIO_VOLUME_NOTIFICATION_DATA pNotify) {
|
|||
} else {
|
||||
log_debugcpp("Onnanokotify says Stored: " << guid->data1);
|
||||
log_debugcpp("Onnanokotify says Grace of God: " << eventData.guidEventContext.Data1);
|
||||
osh->toggleFrontEvents(this->ep->getIndex(), true);
|
||||
osh->updateMuteCallback(this->ep->getIndex(), eventData.bMuted);
|
||||
osh->updateMainVolumeCallback(this->ep->getIndex(), eventData.fMasterVolume);
|
||||
log_debugcpp("Onnanokotify says Reported Channel Qty: " << eventData.nChannels);
|
||||
|
|
@ -66,7 +65,6 @@ HRESULT EndpointCallback::OnNotify(PAUDIO_VOLUME_NOTIFICATION_DATA pNotify) {
|
|||
}
|
||||
else
|
||||
osh->updateChannelVolumeCallback(this->ep->getIndex(), (uint32_t)0, pNotify->afChannelVolumes[0]);
|
||||
osh->toggleFrontEvents(this->ep->getIndex(), false);
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
#include "backlasses.h"
|
||||
#include "qtclasses.h"
|
||||
#include "contclasses.h"
|
||||
//TODO: pragma once
|
||||
|
||||
|
|
@ -64,12 +63,6 @@ std::vector<Endpoint*> OverseerHandler::getPlaybackEndpoints() {
|
|||
return this->os.getPlaybackEndpoints();
|
||||
}
|
||||
|
||||
/*
|
||||
* Overseer* OverseerHandler::getOverseer(){
|
||||
* return &os;
|
||||
* }
|
||||
*/
|
||||
|
||||
|
||||
std::vector<EndpointHandler*> OverseerHandler::getEndpointHandlers(){
|
||||
return endpointHandlers;
|
||||
|
|
@ -114,32 +107,29 @@ void OverseerHandler::setEndpointWidgets(std::vector<EndpointWidget*> ews){
|
|||
}
|
||||
|
||||
void OverseerHandler::updateMuteCallback(uint64_t idx, bool muted){
|
||||
epwMuteFunc f = &EndpointWidget::updateMute;
|
||||
pinvoke_mem_fn(endpointWidgets.at(idx),f)(muted);
|
||||
//std::invoke(f, endpointWidgets.at(idx), muted);
|
||||
updateFrontMuteCallback(idx, muted);
|
||||
}
|
||||
|
||||
void OverseerHandler::updateMainVolumeCallback(uint64_t idx, float newVal){
|
||||
//int translatedNewVal = newVal * 100;
|
||||
log_debugcpp("mainvolcallback float: " << newVal);
|
||||
epwMainVolumeFunc f = &EndpointWidget::updateMainVolume;
|
||||
pinvoke_mem_fn(endpointWidgets.at(idx),f)(newVal);
|
||||
//std::invoke(f, endpointWidgets.at(idx), newVal);
|
||||
updateFrontVolumeCallback(idx, AudioChannel::CHANNEL_MAIN, newVal);
|
||||
}
|
||||
|
||||
void OverseerHandler::setFrontVolumeCallback(std::function<void(uint64_t, uint32_t, float)> f) {
|
||||
this->updateFrontVolumeCallback = f;
|
||||
}
|
||||
|
||||
void OverseerHandler::setFrontMuteCallback(std::function<void(uint64_t, bool)> f) {
|
||||
this->updateFrontMuteCallback = f;
|
||||
}
|
||||
|
||||
void OverseerHandler::updateChannelVolumeCallback(uint64_t idx, uint32_t channel, float newVal){
|
||||
//int translatedNewVal = newVal * 100;
|
||||
log_debugcpp("channel: " << channel << " volcallback float: " << newVal);
|
||||
|
||||
log_debugcpp("chanel: " << channel << " volcallback float: " << newVal);
|
||||
epwChannelVolumeFunc f = &EndpointWidget::updateChannelVolume;
|
||||
//std::invoke(f, endpointWidgets.at(idx), channel, newVal);
|
||||
pinvoke_mem_fn(endpointWidgets.at(idx),f)(channel, newVal);
|
||||
//TODO: Soy retrasado
|
||||
//endpointWidgets.at(idx)->updateChannelVolume(channel, newVal);
|
||||
}
|
||||
|
||||
void OverseerHandler::toggleFrontEvents(uint64_t idx, bool active) {
|
||||
epwToggleFrontFunc f = &EndpointWidget::toggleFrontEvents;
|
||||
pinvoke_mem_fn(endpointWidgets.at(idx),f)(active);
|
||||
//std::invoke(f, , active);
|
||||
// convert channel to bitmask
|
||||
int i = 0;
|
||||
while (i++);
|
||||
uint32_t mask = (1 << i);
|
||||
|
||||
updateFrontVolumeCallback(idx, mask, newVal);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,11 +9,16 @@
|
|||
/* #endif */
|
||||
|
||||
class EndpointWidget;
|
||||
|
||||
class Endpoint;
|
||||
class EndpointCallback;
|
||||
class Overseer;
|
||||
|
||||
enum AudioChannel {
|
||||
CHANNEL_LEFT = (1 << 0),
|
||||
CHANNEL_RIGHT = (1 << 1),
|
||||
CHANNEL_MAIN = ~0,
|
||||
};
|
||||
|
||||
struct NGuid {
|
||||
uint32_t data1;
|
||||
uint16_t data2;
|
||||
|
|
@ -66,14 +71,15 @@ public:
|
|||
void reloadEndpointHandlers();
|
||||
NGuid* getGuid();
|
||||
void updateMuteCallback(uint64_t idx, bool muted);
|
||||
void setFrontMuteCallback(std::function<void(uint64_t, bool)> f);
|
||||
void setFrontVolumeCallback(std::function<void(uint64_t, uint32_t, float)> f);
|
||||
void updateMainVolumeCallback(uint64_t idx, float newVal);
|
||||
void updateChannelVolumeCallback(uint64_t idx, uint32_t channel, float newVal);
|
||||
void toggleFrontEvents(uint64_t idx, bool active);
|
||||
//void parseExternalEndpointCallback(EndpointCallback *epc, PAUDIO_VOLUME_NOTIFICATION_DATA pNotify);
|
||||
//static Overseer* getOverseer();
|
||||
|
||||
private:
|
||||
static Overseer os;
|
||||
std::vector<EndpointHandler*> endpointHandlers;
|
||||
std::vector<EndpointWidget*> endpointWidgets;
|
||||
std::vector<EndpointWidget*> endpointWidgets;
|
||||
std::function<void(uint64_t /* device */, uint32_t /* channel */, float /* value */)> updateFrontVolumeCallback = {};
|
||||
std::function<void(uint64_t /* device */, bool /* mute */)> updateFrontMuteCallback = {};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -74,11 +74,11 @@ EndpointWidget::EndpointWidget(EndpointHandler* eph, QWidget *parent) : QWidget(
|
|||
void EndpointWidget::updateMute(bool muted){
|
||||
log_debugcpp("cliqui callboqui cloqui");
|
||||
//TODO: Here to diagnose slider visuals locking when playing DJ with external volume bar. Functionality is restored when mute checkbox is clicked.
|
||||
//this->muteButton->blockSignals(true);
|
||||
this->muteButton->blockSignals(true);
|
||||
//this->eph->setMute(osh->getGuid(), muted);
|
||||
this->muteButton->setChecked(eph->getMute() ? true : false);
|
||||
this->muteButton->setChecked(muted);
|
||||
this->muteButton->setText(this->eph->getMute() ? STRING_UNMUTE : STRING_MUTE);
|
||||
//this->muteButton->blockSignals(false);
|
||||
this->muteButton->blockSignals(false);
|
||||
}
|
||||
|
||||
void EndpointWidget::updateMute(int checked){
|
||||
|
|
@ -107,14 +107,23 @@ void EndpointWidget::updateMainVolume(float newValue){
|
|||
}
|
||||
|
||||
void EndpointWidget::updateChannelVolume(uint32_t channel, float newValue){
|
||||
int newVal = newValue * 100;
|
||||
log_debugcpp("chanel: " << channel << " volcallback int: " << newVal);
|
||||
//TODO: Above
|
||||
//this->channelSliders.at(channel)->blockSignals(true);
|
||||
if(this->channelSliders.at(channel)->value() != newVal) {
|
||||
this->channelSliders.at(channel)->setValue(newVal);
|
||||
this->channelLabels.at(channel)->setText(QString::number((int)(newValue * 100)));
|
||||
this->blockSignals(true);
|
||||
if (channel == (uint32_t)AudioChannel::CHANNEL_MAIN) {
|
||||
updateMainVolume(newValue);
|
||||
} else {
|
||||
int newVal = newValue * 100;
|
||||
log_debugcpp("chanel: " << channel << " volcallback int: " << newVal);
|
||||
//TODO: Above
|
||||
//this->channelSliders.at(channel)->blockSignals(true);
|
||||
|
||||
for (size_t i = 0; i < sizeof(uint32_t) * 8; ++i) {
|
||||
if ((channel << i & 1) && this->channelSliders.at(channel)->value() != newVal) {
|
||||
this->channelSliders.at(channel)->setValue(newVal);
|
||||
this->channelLabels.at(channel)->setText(QString::number((int)(newValue * 100)));
|
||||
}
|
||||
}
|
||||
}
|
||||
this->blockSignals(false);
|
||||
//this->channelSliders.at(channel)->blockSignals(false);
|
||||
}
|
||||
|
||||
|
|
@ -160,8 +169,18 @@ void MainWindow::reloadEndpointWidgets() {
|
|||
}
|
||||
osh->setEndpointWidgets(ews);
|
||||
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]->updateChannelVolume(channel, value);
|
||||
});
|
||||
osh->setFrontMuteCallback([this](uint64_t device, bool muted) {
|
||||
if (device < ews.size())
|
||||
ews[device]->updateMute(muted);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
//#include "qtclosemwh.h"
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -103,6 +103,7 @@ class MainWindow : public QMainWindow {
|
|||
public:
|
||||
MainWindow(QWidget *parent = nullptr);
|
||||
void reloadEndpointWidgets();
|
||||
|
||||
//TODO: destroy/empty existing EndpointWidgets
|
||||
//void setEndpointHandlers(std::vector<EndpointHandler*> *ephs);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue