slight code cleanup
This commit is contained in:
parent
2e76621616
commit
b3c663046f
3 changed files with 26 additions and 58 deletions
|
|
@ -140,12 +140,6 @@ HRESULT EndpointVolumeCallback::OnNotify(PAUDIO_VOLUME_NOTIFICATION_DATA pNotify
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
//todo: not on construct since it expects them to already exist; smells like refactor!
|
|
||||||
void EndpointSituationCallback::fill(IMMDeviceEnumerator *deviceEnumerator, std::vector<Endpoint*> playbackDevices, std::vector<Endpoint*> captureDevices){
|
|
||||||
this->deviceEnumerator = deviceEnumerator;
|
|
||||||
this->playbackDevices = playbackDevices;
|
|
||||||
this->captureDevices = captureDevices;
|
|
||||||
}
|
|
||||||
|
|
||||||
ULONG EndpointSituationCallback::AddRef(){
|
ULONG EndpointSituationCallback::AddRef(){
|
||||||
return InterlockedIncrement(&ref);
|
return InterlockedIncrement(&ref);
|
||||||
|
|
@ -685,7 +679,8 @@ Overseer::Overseer() { //: epsc(deviceEnumerator, playbackDevices){
|
||||||
//reloadEndpoints(Flows::FLOW_CAPTURE);
|
//reloadEndpoints(Flows::FLOW_CAPTURE);
|
||||||
|
|
||||||
//Registering for endpoint information callback
|
//Registering for endpoint information callback
|
||||||
this->epsc.fill(deviceEnumerator, playbackDevices, captureDevices);
|
//this->epsc.fill(deviceEnumerator, playbackDevices, captureDevices);
|
||||||
|
//this->epsc.fill(deviceEnumerator);
|
||||||
if(FAILED(deviceEnumerator->RegisterEndpointNotificationCallback(((IMMNotificationClient*)&epsc)))) { log_debugcpp("when no enchufas......"); }
|
if(FAILED(deviceEnumerator->RegisterEndpointNotificationCallback(((IMMNotificationClient*)&epsc)))) { log_debugcpp("when no enchufas......"); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,9 +11,9 @@ class Session;
|
||||||
class Endpoint {
|
class Endpoint {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Endpoint(IMMDevice* endpoint, uint64_t idx);
|
Endpoint(IMMDevice* endpoint, uint64_t idx = 0);
|
||||||
//todo: how to forward declare delegate constructors?
|
//todo: how to forward declare delegate constructors?
|
||||||
Endpoint(IMMDevice* endpoint) : Endpoint(endpoint, 0) {};
|
//Endpoint(IMMDevice* endpoint) : Endpoint(endpoint, 0) {};
|
||||||
void reloadEndpointChannels();
|
void reloadEndpointChannels();
|
||||||
uint64_t getIndex();
|
uint64_t getIndex();
|
||||||
void setIndex(uint64_t idx);
|
void setIndex(uint64_t idx);
|
||||||
|
|
@ -84,7 +84,7 @@ class EndpointVolumeCallback : public IAudioEndpointVolumeCallback {
|
||||||
|
|
||||||
class EndpointSituationCallback : public IMMNotificationClient {
|
class EndpointSituationCallback : public IMMNotificationClient {
|
||||||
public:
|
public:
|
||||||
//EndpointSituationCallback(IMMDeviceEnumerator *deviceEnumerator, std::vector<Endpoint*> playbackDevices);
|
//EndpointSituationCallback(IMMDeviceEnumerator *deviceEnumerator, std::vector<Endpoint*> playbackDevices, std::vector<Endpoint*> captureDevices);
|
||||||
ULONG AddRef();
|
ULONG AddRef();
|
||||||
ULONG Release();
|
ULONG Release();
|
||||||
HRESULT QueryInterface(REFIID riid, VOID **ppvInterface);
|
HRESULT QueryInterface(REFIID riid, VOID **ppvInterface);
|
||||||
|
|
@ -94,12 +94,11 @@ class EndpointSituationCallback : public IMMNotificationClient {
|
||||||
HRESULT OnDeviceStateChanged(LPCWSTR pwstrDeviceId, DWORD dwNewState);
|
HRESULT OnDeviceStateChanged(LPCWSTR pwstrDeviceId, DWORD dwNewState);
|
||||||
HRESULT OnPropertyValueChanged(LPCWSTR pwstrDeviceId, const PROPERTYKEY key);
|
HRESULT OnPropertyValueChanged(LPCWSTR pwstrDeviceId, const PROPERTYKEY key);
|
||||||
|
|
||||||
void fill(IMMDeviceEnumerator *deviceEnumerator, std::vector<Endpoint*> playbackDevices, std::vector<Endpoint*> captureDevices);
|
|
||||||
private:
|
private:
|
||||||
ULONG ref = 1;
|
ULONG ref = 1;
|
||||||
IMMDeviceEnumerator *deviceEnumerator;
|
//IMMDeviceEnumerator *deviceEnumerator;
|
||||||
std::vector<Endpoint*> playbackDevices;
|
//std::vector<Endpoint*> playbackDevices;
|
||||||
std::vector<Endpoint*> captureDevices;
|
//std::vector<Endpoint*> captureDevices;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Overseer {
|
class Overseer {
|
||||||
|
|
|
||||||
|
|
@ -285,7 +285,6 @@ EndpointWidget::EndpointWidget(uint64_t idx, EndpointHandler* eph, QWidget *pare
|
||||||
mainVolumeLabel->setText(QString::number(volume));
|
mainVolumeLabel->setText(QString::number(volume));
|
||||||
log_debugcpp("ENDPOINT SET WITH VOLUME " + std::to_string(volume));
|
log_debugcpp("ENDPOINT SET WITH VOLUME " + std::to_string(volume));
|
||||||
|
|
||||||
//tip: would need to be new widget with layout in it
|
|
||||||
//mainMuteLayout = new QGridLayout();
|
//mainMuteLayout = new QGridLayout();
|
||||||
widgetLayout->addWidget(mainLabel, row, 0, 1, 3, Qt::AlignLeft | Qt::AlignVCenter);
|
widgetLayout->addWidget(mainLabel, row, 0, 1, 3, Qt::AlignLeft | Qt::AlignVCenter);
|
||||||
widgetLayout->addWidget(muteButton, row, 2, Qt::AlignRight | Qt::AlignVCenter);
|
widgetLayout->addWidget(muteButton, row, 2, Qt::AlignRight | Qt::AlignVCenter);
|
||||||
|
|
@ -314,53 +313,28 @@ EndpointWidget::EndpointWidget(uint64_t idx, EndpointHandler* eph, QWidget *pare
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Role ExtendedCheckBoxes setup
|
* Role ExtendedCheckBoxes setup
|
||||||
*/
|
*/
|
||||||
|
|
||||||
uint8_t assignedRoles = eph->getRoles();
|
|
||||||
defaultRolesCheckBoxes.at(Roles::ROLE_ALL)->setCheckState(assignedRoles == Roles::ROLE_ALL ? Qt::Checked : Qt::Unchecked);
|
|
||||||
//todo duditas de &
|
|
||||||
defaultRolesCheckBoxes.at(Roles::ROLE_ALL)->setDisabled(assignedRoles == Roles::ROLE_ALL ? true : false);
|
|
||||||
defaultRolesCheckBoxes.at(Roles::ROLE_ALL)->setText(STRING_ROLE_ALL);
|
|
||||||
|
|
||||||
defaultRolesCheckBoxes.at(Roles::ROLE_CONSOLE)->setCheckState(assignedRoles & Roles::ROLE_CONSOLE ? Qt::Checked : Qt::Unchecked);
|
|
||||||
defaultRolesCheckBoxes.at(Roles::ROLE_CONSOLE)->setDisabled(assignedRoles & Roles::ROLE_CONSOLE ? true : false);
|
|
||||||
defaultRolesCheckBoxes.at(Roles::ROLE_CONSOLE)->setText(STRING_ROLE_CONSOLE);
|
|
||||||
|
|
||||||
defaultRolesCheckBoxes.at(Roles::ROLE_MULTIMEDIA)->setCheckState(assignedRoles & Roles::ROLE_MULTIMEDIA ? Qt::Checked : Qt::Unchecked);
|
|
||||||
defaultRolesCheckBoxes.at(Roles::ROLE_MULTIMEDIA)->setDisabled(assignedRoles & Roles::ROLE_MULTIMEDIA ? true : false);
|
|
||||||
defaultRolesCheckBoxes.at(Roles::ROLE_MULTIMEDIA)->setText(STRING_ROLE_MULTIMEDIA);
|
|
||||||
|
|
||||||
defaultRolesCheckBoxes.at(Roles::ROLE_COMMUNICATIONS)->setCheckState(assignedRoles & Roles::ROLE_COMMUNICATIONS ? Qt::Checked : Qt::Unchecked);
|
|
||||||
defaultRolesCheckBoxes.at(Roles::ROLE_COMMUNICATIONS)->setDisabled(assignedRoles & Roles::ROLE_COMMUNICATIONS ? true : false);
|
|
||||||
defaultRolesCheckBoxes.at(Roles::ROLE_COMMUNICATIONS)->setText(STRING_ROLE_COMMUNICATIONS);
|
|
||||||
|
|
||||||
connect(defaultRolesCheckBoxes.at(Roles::ROLE_ALL), &QCheckBox::stateChanged,[this] {
|
|
||||||
this->eph->setRoles(Roles::ROLE_ALL);
|
|
||||||
});
|
|
||||||
connect(defaultRolesCheckBoxes.at(Roles::ROLE_CONSOLE), &QCheckBox::stateChanged,[this] {
|
|
||||||
this->eph->setRoles(Roles::ROLE_CONSOLE);
|
|
||||||
});
|
|
||||||
connect(defaultRolesCheckBoxes.at(Roles::ROLE_MULTIMEDIA), &QCheckBox::stateChanged,[this] {
|
|
||||||
this->eph->setRoles(Roles::ROLE_MULTIMEDIA);
|
|
||||||
});
|
|
||||||
|
|
||||||
connect(defaultRolesCheckBoxes.at(Roles::ROLE_COMMUNICATIONS), &QCheckBox::stateChanged,[this] {
|
|
||||||
this->eph->setRoles(Roles::ROLE_COMMUNICATIONS);
|
|
||||||
});
|
|
||||||
|
|
||||||
defaultRolesCheckBoxes.at(Roles::ROLE_ALL)->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
|
defaultRolesCheckBoxes.at(Roles::ROLE_ALL)->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
|
||||||
widgetLayout->addWidget(defaultRolesCheckBoxes.at(Roles::ROLE_ALL),
|
uint8_t assignedRoles = eph->getRoles();
|
||||||
row, 0);
|
uint8_t col = 0;
|
||||||
widgetLayout->addWidget(defaultRolesCheckBoxes.at(Roles::ROLE_CONSOLE),
|
#define checkbox_setup(role, optor) do { \
|
||||||
row, 1);
|
defaultRolesCheckBoxes.at(role)->setCheckState(assignedRoles optor role ? Qt::Checked : Qt::Unchecked); \
|
||||||
widgetLayout->addWidget(defaultRolesCheckBoxes.at(Roles::ROLE_MULTIMEDIA),
|
defaultRolesCheckBoxes.at(role)->setDisabled(assignedRoles optor role ? true : false); \
|
||||||
row, 2);
|
defaultRolesCheckBoxes.at(role)->setText(STRING_##role); \
|
||||||
widgetLayout->addWidget(defaultRolesCheckBoxes.at(Roles::ROLE_COMMUNICATIONS),
|
connect(defaultRolesCheckBoxes.at(role), &QCheckBox::stateChanged,[this] { \
|
||||||
row, 3);
|
this->eph->setRoles(role); \
|
||||||
|
}); \
|
||||||
|
widgetLayout->addWidget(defaultRolesCheckBoxes.at(role), row, col++); \
|
||||||
|
} while(0)
|
||||||
|
|
||||||
|
checkbox_setup(ROLE_ALL, ==);
|
||||||
|
checkbox_setup(ROLE_CONSOLE, &);
|
||||||
|
checkbox_setup(ROLE_MULTIMEDIA, &);
|
||||||
|
checkbox_setup(ROLE_COMMUNICATIONS, &);
|
||||||
|
#undef checkbox_setup
|
||||||
row++;
|
row++;
|
||||||
|
|
||||||
/* ----------------------------------------------------------- */
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* EndpointVolume Polling time
|
* EndpointVolume Polling time
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue