wip: setenabled crash to fix
This commit is contained in:
parent
1a4692533d
commit
f620a0575d
6 changed files with 111 additions and 17 deletions
|
|
@ -125,21 +125,17 @@ HRESULT EndpointSituationCallback::OnDefaultDeviceChanged(EDataFlow flow, ERole
|
|||
nRole = Roles::ROLE_COMMUNICATIONS;
|
||||
break;
|
||||
}
|
||||
|
||||
osh
|
||||
std::wstring wstringEndpointId = pwstrDeviceId;
|
||||
osh->changeFrontDefaultsCallback(nRole, wstringEndpointId);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT EndpointSituationCallback::OnDeviceAdded(LPCWSTR pwstrDeviceId) {
|
||||
|
||||
printf(" -->Added device\n");
|
||||
return S_OK;
|
||||
};
|
||||
|
||||
HRESULT EndpointSituationCallback::OnDeviceRemoved(LPCWSTR pwstrDeviceId) {
|
||||
|
||||
printf(" -->Removed device\n");
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
|
@ -331,11 +327,15 @@ void Endpoint::setRoles(Roles role){
|
|||
}
|
||||
|
||||
void Endpoint::assignRoles(uint8_t role){
|
||||
//todo: operador virtuoso
|
||||
uint8_t roles = endpointRoles | role;
|
||||
this->endpointRoles = roles;
|
||||
}
|
||||
|
||||
void Endpoint::removeRoles(uint8_t role){
|
||||
uint8_t roles = endpointRoles ^ role;
|
||||
this->endpointRoles = roles;
|
||||
}
|
||||
|
||||
Endpoint::~Endpoint(){
|
||||
log_debugcpp("murio endpoint-san uwu");
|
||||
properties->Release();
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ class Endpoint {
|
|||
uint8_t getRoles();
|
||||
void setRoles(Roles role);
|
||||
void assignRoles(uint8_t role);
|
||||
void removeRoles(uint8_t role);
|
||||
std::wstring getId();
|
||||
std::wstring getName();
|
||||
void setVolumeCallback(EndpointVolumeCallback *epc);
|
||||
|
|
|
|||
|
|
@ -17,6 +17,16 @@ EndpointHandler::EndpointHandler(uint64_t idx) {
|
|||
}
|
||||
}
|
||||
|
||||
/* these two, currently unused. If I use them, I should feel bad.
|
||||
* Endpoint* EndpointHandler::getEndpoint() {
|
||||
* return this->ep;
|
||||
* }
|
||||
*
|
||||
* EndpointVolumeCallback* EndpointHandler::getEndpointVolumeCallback() {
|
||||
* return this->epc;
|
||||
* }
|
||||
*/
|
||||
|
||||
BackEndpointVolumeCallbackInfo* EndpointHandler::getCallbackInfo(){
|
||||
return &this->callbackInfo;
|
||||
}
|
||||
|
|
@ -50,6 +60,10 @@ std::wstring EndpointHandler::getName(){
|
|||
return ep->getName();
|
||||
}
|
||||
|
||||
std::wstring EndpointHandler::getId(){
|
||||
return ep->getId();
|
||||
}
|
||||
|
||||
float EndpointHandler::getVolume(int channel){
|
||||
return ep->getVolume(channel);
|
||||
}
|
||||
|
|
@ -74,6 +88,14 @@ void EndpointHandler::setRoles(Roles newRole){
|
|||
ep->setRoles(newRole);
|
||||
}
|
||||
|
||||
void EndpointHandler::assignRoles(Roles newRole){
|
||||
ep->assignRoles((uint8_t)newRole);
|
||||
}
|
||||
|
||||
void EndpointHandler::removeRoles(Roles newRole){
|
||||
ep->removeRoles((uint8_t)newRole);
|
||||
}
|
||||
|
||||
EndpointHandler::~EndpointHandler() {
|
||||
ep->removeVolumeCallback(epc);
|
||||
epc->Release();
|
||||
|
|
@ -122,10 +144,14 @@ NGuid OverseerHandler::getGuid() {
|
|||
return this->os->getGuid();
|
||||
}
|
||||
|
||||
void setChangeFrontDefaultsFunction(std::function<void(Roles, wchar* endpointId)> changeFrontDefaults){
|
||||
void OverseerHandler::setChangeFrontDefaultsFunction(std::function<void(Roles, std::wstring)> changeFrontDefaults){
|
||||
this->changeFrontDefaults = changeFrontDefaults;
|
||||
}
|
||||
|
||||
void OverseerHandler::changeFrontDefaultsCallback(Roles role, std::wstring endpointId) {
|
||||
this->changeFrontDefaults(role, endpointId);
|
||||
}
|
||||
|
||||
void OverseerHandler::setEndpointHandlers(std::vector<EndpointHandler*> ephs){
|
||||
this->endpointHandlers = ephs;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,11 +62,11 @@ class EndpointHandler {
|
|||
|
||||
public:
|
||||
EndpointHandler(uint64_t idx);
|
||||
//TODO: get();
|
||||
Endpoint *ep = nullptr;
|
||||
EndpointVolumeCallback *epc = nullptr;
|
||||
//std::wstring epName;
|
||||
//these two, currently unused. If I use them, I should feel bad.
|
||||
//EndpointVolumeCallback* getEndpointVolumeCallback();
|
||||
//Endpoint* getEndpoint();
|
||||
|
||||
//std::wstring epName;
|
||||
BackEndpointVolumeCallbackInfo* getCallbackInfo();
|
||||
uint32_t getChannelCount();
|
||||
|
||||
|
|
@ -75,11 +75,15 @@ public:
|
|||
void setVolume(int channel, float volume);
|
||||
|
||||
std::wstring getName();
|
||||
std::wstring getId();
|
||||
|
||||
float getVolume(int channel);
|
||||
bool getMute();
|
||||
uint8_t getState();
|
||||
uint8_t getRoles();
|
||||
void setRoles(Roles newRole);
|
||||
void assignRoles(Roles newRole);
|
||||
void removeRoles(Roles newRole);
|
||||
|
||||
void setVolume(NGuid guid, int channel, int value);
|
||||
void setMute(NGuid guid, bool muted);
|
||||
|
|
@ -88,6 +92,8 @@ public:
|
|||
~EndpointHandler();
|
||||
private:
|
||||
uint64_t idx;
|
||||
Endpoint *ep = nullptr;
|
||||
EndpointVolumeCallback *epc = nullptr;
|
||||
BackEndpointVolumeCallbackInfo callbackInfo;
|
||||
//QSlider *slidy;
|
||||
};
|
||||
|
|
@ -97,7 +103,9 @@ class OverseerHandler {
|
|||
|
||||
public:
|
||||
OverseerHandler();
|
||||
void setChangeFrontDefaultsFunction(std::function<void(Roles, wchar* endpointId)> changeFrontDefaults);
|
||||
void setChangeFrontDefaultsFunction(std::function<void(Roles, std::wstring)> changeFrontDefaults);
|
||||
void changeFrontDefaultsCallback(Roles role, std::wstring endpointId);
|
||||
|
||||
void setEndpointHandlers(std::vector<EndpointHandler*> ephs);
|
||||
std::vector<EndpointHandler*> getEndpointHandlers();
|
||||
std::vector<Endpoint*> getPlaybackEndpoints();
|
||||
|
|
@ -108,7 +116,8 @@ public:
|
|||
private:
|
||||
Overseer *os;
|
||||
std::vector<EndpointHandler*> endpointHandlers;
|
||||
std::function<void(Roles, wchar* endpointId)> changeFrontDefaults;
|
||||
std::function<void(Roles, std::wstring)> changeFrontDefaults;
|
||||
|
||||
//std::function<void(uint64_t /* device */, uint32_t /* channel */, float /* value */)> updateFrontVolumeCallback;
|
||||
//std::function<void(uint64_t /* device */, bool /* mute */)> updateFrontMuteCallback;
|
||||
|
||||
|
|
|
|||
|
|
@ -192,6 +192,10 @@ void EndpointWidget::updateMainVolume(int newValue){
|
|||
* }
|
||||
*/
|
||||
|
||||
EndpointHandler* EndpointWidget::getEndpointHandler(){
|
||||
return this->eph;
|
||||
}
|
||||
|
||||
void EndpointWidget::setIndex(uint64_t idx){
|
||||
this->idx = idx;
|
||||
}
|
||||
|
|
@ -228,8 +232,61 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
|
|||
trayIcon->show();
|
||||
trayIcon->setToolTip(STRING_TITLE);
|
||||
trayIcon->setContextMenu(trayIconMenu);
|
||||
//todo: ayo...
|
||||
QString as = trayIcon->toolTip();
|
||||
connect(trayIcon, &QSystemTrayIcon::activated, this, &MainWindow::trayIconActivated);
|
||||
|
||||
|
||||
osh->setChangeFrontDefaultsFunction([this](Roles role, std::wstring endpointId) {
|
||||
|
||||
for (auto epw : this->ews) {
|
||||
if (epw->getEndpointHandler()->getId() == endpointId) {
|
||||
//not necessary to keep endpointState flags up to date right now, but updating it will allow for later config files / profiles
|
||||
epw->defaultRolesCheckBoxes.at(role)->blockSignals(true);
|
||||
epw->getEndpointHandler()->assignRoles(role);
|
||||
epw->defaultRolesCheckBoxes.at(role)->setCheckState(Qt::Checked);
|
||||
//epw->defaultRolesCheckBoxes.at(role)->setDisabled(true);
|
||||
epw->defaultRolesCheckBoxes.at(role)->blockSignals(false);
|
||||
|
||||
if (epw->getEndpointHandler()->getRoles() == Roles::ROLE_ALL) {
|
||||
epw->defaultRolesCheckBoxes.at(Roles::ROLE_ALL)->blockSignals(true);
|
||||
epw->defaultRolesCheckBoxes.at(Roles::ROLE_ALL)->setCheckState(Qt::Checked);
|
||||
//epw->defaultRolesCheckBoxes.at(Roles::ROLE_ALL)->setDisabled(true);
|
||||
epw->defaultRolesCheckBoxes.at(Roles::ROLE_ALL)->blockSignals(false);
|
||||
}
|
||||
|
||||
/*
|
||||
* switch (role) {
|
||||
* case Roles::ROLE_CONSOLE:
|
||||
* epw->getEndpointHandler()->assignRoles(role);
|
||||
* break;
|
||||
* case Roles::ROLE_MULTIMEDIA:
|
||||
* break;
|
||||
* case Roles::ROLE_COMMUNICATIONS:
|
||||
* break;
|
||||
*
|
||||
* }
|
||||
*/
|
||||
} else {
|
||||
if (epw->getEndpointHandler()->getRoles() & role) {
|
||||
epw->defaultRolesCheckBoxes.at(role)->blockSignals(true);
|
||||
epw->getEndpointHandler()->removeRoles(role);
|
||||
epw->defaultRolesCheckBoxes.at(role)->setCheckState(Qt::Unchecked);
|
||||
//epw->defaultRolesCheckBoxes.at(role)->setDisabled(false);
|
||||
epw->defaultRolesCheckBoxes.at(role)->blockSignals(false);
|
||||
|
||||
if (!epw->defaultRolesCheckBoxes.at(Roles::ROLE_ALL)->isEnabled()) {
|
||||
epw->defaultRolesCheckBoxes.at(Roles::ROLE_ALL)->blockSignals(true);
|
||||
//epw->defaultRolesCheckBoxes.at(Roles::ROLE_ALL)->setDisabled(false);
|
||||
epw->defaultRolesCheckBoxes.at(Roles::ROLE_ALL)->setCheckState(Qt::Unchecked);
|
||||
epw->defaultRolesCheckBoxes.at(Roles::ROLE_ALL)->blockSignals(false);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void MainWindow::closeEvent(QCloseEvent *event) {
|
||||
|
|
|
|||
|
|
@ -62,8 +62,8 @@ class EndpointWidget : public QWidget {
|
|||
|
||||
public:
|
||||
EndpointWidget(uint64_t idx, EndpointHandler* eph, QWidget *parent = nullptr);
|
||||
//TODO: get();
|
||||
EndpointHandler* eph;
|
||||
|
||||
EndpointHandler* getEndpointHandler();
|
||||
void setIndex(uint64_t idx);
|
||||
uint64_t getIndex();
|
||||
|
||||
|
|
@ -90,6 +90,7 @@ public slots:
|
|||
void updateMute(int checked);
|
||||
|
||||
private:
|
||||
EndpointHandler* eph;
|
||||
size_t defaultRolesVectorSize = 4;
|
||||
QTimer* timer = nullptr;
|
||||
uint64_t idx;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue