guid sent and validated for mute
This commit is contained in:
parent
7e741f3bca
commit
a24bba35be
7 changed files with 72 additions and 65 deletions
|
|
@ -8,5 +8,5 @@ INCLUDEPATH += "$$PWD\src" "$$PWD\src\qt" "$$PWD\src\back" "$$PWD\src\cont"
|
||||||
DESTPATH += "$$PWD\src" "$$PWD\src\qt" "$$PWD\src\back" "$$PWD\src\cont"
|
DESTPATH += "$$PWD\src" "$$PWD\src\qt" "$$PWD\src\back" "$$PWD\src\cont"
|
||||||
VPATH += "$$PWD\src" "$$PWD\src\qt" "$$PWD\src\back" "$$PWD\src\cont"
|
VPATH += "$$PWD\src" "$$PWD\src\qt" "$$PWD\src\back" "$$PWD\src\cont"
|
||||||
SOURCES += qtestmain.cpp qtclasses.cpp backlasses.cpp contclasses.cpp
|
SOURCES += qtestmain.cpp qtclasses.cpp backlasses.cpp contclasses.cpp
|
||||||
HEADERS += qtclasses.h backlasses.h contclasses.h global.h debug.h
|
HEADERS += qtclasses.h backlasses.h contclasses.h global.h debug.h backfuncs.h
|
||||||
#DESTDIR += "build"
|
#DESTDIR += "build"
|
||||||
|
|
|
||||||
33
src/back/backfuncs.h
Normal file
33
src/back/backfuncs.h
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
GUID NGuidToGUID(NGuid* guid){
|
||||||
|
GUID msGuid = GUID();
|
||||||
|
msGuid.Data1 = guid->data1;
|
||||||
|
msGuid.Data2 = guid->data2;
|
||||||
|
msGuid.Data3 = guid->data3;
|
||||||
|
msGuid.Data1 = guid->data1;
|
||||||
|
for (int i = 0; i < 8; i++){
|
||||||
|
msGuid.Data4[i] = guid->data4[i];
|
||||||
|
log_debugcpp("MSGUID DATA4 BYTE " << i << ": ");
|
||||||
|
log_debugcpp(print_as_binary(8, uint32_t, msGuid.Data4[i]));
|
||||||
|
}
|
||||||
|
log_debugcpp("MSGUID DATA1: " << msGuid.Data1);
|
||||||
|
log_debugcpp("MSGUID DATA2: " << msGuid.Data2);
|
||||||
|
log_debugcpp("MSGUID DATA3: " << msGuid.Data3);
|
||||||
|
|
||||||
|
return msGuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
NGuid GUIDToNGuid(LPGUID msGuid){
|
||||||
|
NGuid guid = NGuid();
|
||||||
|
guid.data1 = msGuid->Data1;
|
||||||
|
guid.data2 = msGuid->Data2;
|
||||||
|
guid.data3 = msGuid->Data3;
|
||||||
|
for (int i = 0; i < 8; i++){
|
||||||
|
guid.data4[i] = msGuid->Data4[i];
|
||||||
|
log_debugcpp("GUID DATA4 BYTE " << i << ": ");
|
||||||
|
log_debugcpp(print_as_binary(8, uint32_t, guid.data4[i]));
|
||||||
|
}
|
||||||
|
log_debugcpp("GUID DATA1: " << guid.data1);
|
||||||
|
log_debugcpp("GUID DATA2: " << guid.data2);
|
||||||
|
log_debugcpp("GUID DATA3: " << guid.data3);
|
||||||
|
return guid;
|
||||||
|
}
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#include <backlasses.h>
|
#include <backlasses.h>
|
||||||
|
#include <backfuncs.h>
|
||||||
|
|
||||||
EndpointCallback::EndpointCallback(Endpoint* ep){
|
EndpointCallback::EndpointCallback(Endpoint* ep){
|
||||||
this->ep = ep;
|
this->ep = ep;
|
||||||
|
|
@ -37,14 +38,17 @@ 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;
|
||||||
/*
|
|
||||||
* AUDIO_VOLUME_NOTIFICATION_DATA eventData = *pNotify;
|
AUDIO_VOLUME_NOTIFICATION_DATA eventData = *pNotify;
|
||||||
* LPGUID guid = osh->getOverseer()->getGuid();
|
NGuid* guid = osh->getGuid();
|
||||||
*
|
|
||||||
* if (eventData.guidEventContext != *guid) {
|
if (memcmp(guid, &eventData, sizeof(guid)) == 0) {
|
||||||
* osh->parseExternalEndpointCallback(this, eventData);
|
log_debugcpp("perlitas");
|
||||||
* }
|
} else {
|
||||||
*/
|
log_debugcpp("Onnanokotify says Stored: " << guid->data1);
|
||||||
|
log_debugcpp("Onnanokotify says Grace of God: " << eventData.guidEventContext.Data1);
|
||||||
|
}
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -119,12 +123,14 @@ void Endpoint::setVolume(int channel, float volume) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Endpoint::setMute() {
|
void Endpoint::setMute(NGuid* guid) {
|
||||||
BOOL mut;
|
BOOL mut;
|
||||||
//log_debugcpp("bool mute arrives as " << mut);
|
//log_debugcpp("bool mute arrives as " << mut);
|
||||||
if(FAILED(endpointVolume->GetMute(&mut))) { log_debugcpp("si"); }
|
if(FAILED(endpointVolume->GetMute(&mut))) { log_debugcpp("si"); }
|
||||||
log_debugcpp("translate to BOOL as " << mut);
|
log_debugcpp("translate to BOOL as " << mut);
|
||||||
if(FAILED(endpointVolume->SetMute((mut == false ? 1 : 0), NULL))) { log_debugcpp("si"); };
|
//TODO: use new funcs
|
||||||
|
GUID tempMsGuid = NGuidToGUID(guid);
|
||||||
|
if(FAILED(endpointVolume->SetMute((mut == false ? 1 : 0), &tempMsGuid))) { log_debugcpp("si"); };
|
||||||
}
|
}
|
||||||
|
|
||||||
void Endpoint::setCallback(EndpointCallback *epc){
|
void Endpoint::setCallback(EndpointCallback *epc){
|
||||||
|
|
@ -142,8 +148,7 @@ Endpoint::~Endpoint(){
|
||||||
endpoint->Release();
|
endpoint->Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Overseer::initCOMLibrary() {
|
||||||
void Overseer::initCOMLibrary(){
|
|
||||||
if(FAILED(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE))) {
|
if(FAILED(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE))) {
|
||||||
log_debugcpp("si"); };
|
log_debugcpp("si"); };
|
||||||
|
|
||||||
|
|
@ -155,30 +160,13 @@ void Overseer::initCOMLibrary(){
|
||||||
(void**)&deviceEnumerator)) )
|
(void**)&deviceEnumerator)) )
|
||||||
{ log_debugcpp("si"); };
|
{ log_debugcpp("si"); };
|
||||||
|
|
||||||
|
|
||||||
GUID tempGuid;
|
GUID tempGuid;
|
||||||
/*
|
|
||||||
* HRESULT her = CoCreateGuid(&tempGuid);
|
|
||||||
* std::bitset<32> bon(her);
|
|
||||||
* //if (hr == EPT_S_CANT_CREATE)
|
|
||||||
* log_debugcpp("Failed to obtain GUID: " /\*<< std::hex *\/<< her << std::dec << " " << bon);
|
|
||||||
*/
|
|
||||||
if(FAILED(CoCreateGuid(&tempGuid))) { log_debugcpp("Failed to obtain GUID: " ); };
|
if(FAILED(CoCreateGuid(&tempGuid))) { log_debugcpp("Failed to obtain GUID: " ); };
|
||||||
|
|
||||||
|
|
||||||
this->guid.data1 = tempGuid.Data1;
|
this->guid = GUIDToNGuid(&tempGuid);
|
||||||
this->guid.data2 = tempGuid.Data2;
|
|
||||||
this->guid.data3 = tempGuid.Data3;
|
|
||||||
for (int i = 0; i < 8; i++){
|
|
||||||
this->guid.data4[i] = tempGuid.Data4[i];
|
|
||||||
log_debugcpp("GUID DATA4 BYTE " << i << ": ");
|
|
||||||
log_debugcpp(print_as_binary(8, uint32_t, this->guid.data4[i]));
|
|
||||||
}
|
|
||||||
log_debugcpp("GUID DATA1: " << this->guid.data1);
|
|
||||||
log_debugcpp("GUID DATA2: " << this->guid.data2);
|
|
||||||
log_debugcpp("GUID DATA3: " << this->guid.data3);
|
|
||||||
|
|
||||||
//TODO: Release lpguid?
|
//TODO: Release lpguid?
|
||||||
|
//TODO: Uninitialize COM
|
||||||
}
|
}
|
||||||
|
|
||||||
void Overseer::reloadEndpoints() {
|
void Overseer::reloadEndpoints() {
|
||||||
|
|
@ -224,8 +212,8 @@ Overseer::Overseer(){
|
||||||
//int Overseer::getDefaultCaptureEndpoint(Endpoint** defaultEndpoint);
|
//int Overseer::getDefaultCaptureEndpoint(Endpoint** defaultEndpoint);
|
||||||
|
|
||||||
//TODO guid
|
//TODO guid
|
||||||
NGuid Overseer::getGuid() {
|
NGuid* Overseer::getGuid() {
|
||||||
return guid;
|
return &guid;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Endpoint*> Overseer::getPlaybackEndpoints() {
|
std::vector<Endpoint*> Overseer::getPlaybackEndpoints() {
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,6 @@
|
||||||
//done by qt by def #define UNICODE
|
//done by qt by def #define UNICODE
|
||||||
|
|
||||||
//#include "debug.h"
|
//#include "debug.h"
|
||||||
#include "global.h"
|
|
||||||
#include "contclasses.h"
|
|
||||||
/* #include <vector> */
|
/* #include <vector> */
|
||||||
/* #include <iostream> */
|
/* #include <iostream> */
|
||||||
/* #include <wstring> */
|
/* #include <wstring> */
|
||||||
|
|
@ -22,6 +20,7 @@
|
||||||
//#include <comip.h>
|
//#include <comip.h>
|
||||||
#include <Winerror.h>
|
#include <Winerror.h>
|
||||||
|
|
||||||
|
#include "global.h"
|
||||||
#include "contclasses.h"
|
#include "contclasses.h"
|
||||||
|
|
||||||
class EndpointCallback;
|
class EndpointCallback;
|
||||||
|
|
@ -36,7 +35,7 @@ class Endpoint {
|
||||||
/* float getLeftChannelVolume(); */
|
/* float getLeftChannelVolume(); */
|
||||||
/* float getRightChannelVolume(); */
|
/* float getRightChannelVolume(); */
|
||||||
float getVolume(int channel);
|
float getVolume(int channel);
|
||||||
void setMute();
|
void setMute(NGuid* guid);
|
||||||
bool getMute();
|
bool getMute();
|
||||||
std::wstring getName();
|
std::wstring getName();
|
||||||
void setCallback(EndpointCallback *epc);
|
void setCallback(EndpointCallback *epc);
|
||||||
|
|
@ -75,7 +74,7 @@ class Overseer {
|
||||||
Overseer();
|
Overseer();
|
||||||
std::vector<Endpoint*> getPlaybackEndpoints();
|
std::vector<Endpoint*> getPlaybackEndpoints();
|
||||||
void reloadEndpoints();
|
void reloadEndpoints();
|
||||||
NGuid getGuid();
|
NGuid* getGuid();
|
||||||
//~Overseer();
|
//~Overseer();
|
||||||
//int getDefaultPlaybackEndpoint(Endpoint** defaultEndpoint);
|
//int getDefaultPlaybackEndpoint(Endpoint** defaultEndpoint);
|
||||||
//int getDefaultCaptureEndpoint(Endpoint** defaultEndpoint);
|
//int getDefaultCaptureEndpoint(Endpoint** defaultEndpoint);
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ EndpointHandler::EndpointHandler(uint64_t idx) {
|
||||||
this->ep = endpoints.at(idx);
|
this->ep = endpoints.at(idx);
|
||||||
epc = new EndpointCallback(ep);
|
epc = new EndpointCallback(ep);
|
||||||
//epName = ep->getName();
|
//epName = ep->getName();
|
||||||
//ep->setCallback(*epc);
|
ep->setCallback(epc);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EndpointHandler::setIndex(uint64_t idx){
|
void EndpointHandler::setIndex(uint64_t idx){
|
||||||
|
|
@ -29,10 +29,10 @@ void EndpointHandler::setValue(int channel, int value){
|
||||||
else ep->setVolume(channel, (float)value / 100);
|
else ep->setVolume(channel, (float)value / 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EndpointHandler::setMute(){
|
void EndpointHandler::setMute(NGuid* guid){
|
||||||
//Qt momento, de ahi el param?
|
//Qt momento, de ahi el param?
|
||||||
log_debugcpp("kinda handling the muting tbh");
|
log_debugcpp("kinda handling the muting tbh");
|
||||||
ep->setMute();
|
ep->setMute(guid);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::wstring EndpointHandler::getName(){
|
std::wstring EndpointHandler::getName(){
|
||||||
|
|
@ -94,24 +94,10 @@ void OverseerHandler::reloadEndpointHandlers(){
|
||||||
//setEndpointHandlers(ephs);
|
//setEndpointHandlers(ephs);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* void OverseerHandler::parseExternalEndpointCallback(EndpointCallback *fEpc, PAUDIO_VOLUME_NOTIFICATION_DATA pNotify){
|
NGuid* OverseerHandler::getGuid() {
|
||||||
* log_debugcpp("parsing in da ovasiar");
|
return os.getGuid();
|
||||||
* for (uint64_t i = 0; i < endpointHandlers.size(); i++){
|
}
|
||||||
* if(endpointHandlers.at(i)->eph->epc == fEpc) {
|
|
||||||
* endpointHandlers.at(i)->muteButton->setText(endpointHandlers.at(i)->eph->getMute() ? STRING_UNMUTE : STRING_MUTE);
|
|
||||||
* break;
|
|
||||||
* }
|
|
||||||
* }
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* connect(mainSlider, &QSlider::valueChanged, [this](int newValue){this->eph->setValue(ENDPOINT_MASTER_VOLUME, newValue); });
|
|
||||||
* connect(leftChannelSlider, &QSlider::valueChanged, [this](int newValue){ this->eph->setValue(ENDPOINT_LEFT_CHANNEL_VOLUME, newValue); this->leftChannelLabel->setText(QString::number(newValue)); });
|
|
||||||
* connect(rightChannelSlider, &QSlider::valueChanged, [this](int newValue){ this->eph->setValue(ENDPOINT_RIGHT_CHANNEL_VOLUME, newValue); this->rightChannelLabel->setText(QString::number(newValue)); });
|
|
||||||
* connect(muteButton, &QPushButton::clicked, [this](bool clicked){ log_debugcpp("cliqui" << clicked << "cloqui"); this->eph->setMute(); this->muteButton->setText(this->eph->getMute() ? STRING_UNMUTE : STRING_MUTE); });
|
|
||||||
* log_debugcpp("ENDPOINT_WIDGETED");
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
void OverseerHandler::setEndpointHandlers(std::vector<EndpointHandler*> ews){
|
void OverseerHandler::setEndpointHandlers(std::vector<EndpointHandler*> ews){
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,8 @@ class EndpointHandler {
|
||||||
public:
|
public:
|
||||||
EndpointHandler(uint64_t idx);
|
EndpointHandler(uint64_t idx);
|
||||||
//TODO: get();
|
//TODO: get();
|
||||||
Endpoint *ep;
|
Endpoint *ep = nullptr;
|
||||||
EndpointCallback *epc;
|
EndpointCallback *epc = nullptr;
|
||||||
//std::wstring epName;
|
//std::wstring epName;
|
||||||
|
|
||||||
void setIndex(uint64_t idx);
|
void setIndex(uint64_t idx);
|
||||||
|
|
@ -29,7 +29,7 @@ public:
|
||||||
bool getMute();
|
bool getMute();
|
||||||
|
|
||||||
void setValue(int channel, int value);
|
void setValue(int channel, int value);
|
||||||
void setMute();
|
void setMute(NGuid* guid);
|
||||||
~EndpointHandler();
|
~EndpointHandler();
|
||||||
private:
|
private:
|
||||||
uint64_t idx;
|
uint64_t idx;
|
||||||
|
|
@ -50,6 +50,7 @@ public:
|
||||||
std::vector<Endpoint*> getPlaybackEndpoints();
|
std::vector<Endpoint*> getPlaybackEndpoints();
|
||||||
uint64_t getPlaybackEndpointsCount();
|
uint64_t getPlaybackEndpointsCount();
|
||||||
void reloadEndpointHandlers();
|
void reloadEndpointHandlers();
|
||||||
|
NGuid* getGuid();
|
||||||
|
|
||||||
//void parseExternalEndpointCallback(EndpointCallback *epc, PAUDIO_VOLUME_NOTIFICATION_DATA pNotify);
|
//void parseExternalEndpointCallback(EndpointCallback *epc, PAUDIO_VOLUME_NOTIFICATION_DATA pNotify);
|
||||||
//static Overseer* getOverseer();
|
//static Overseer* getOverseer();
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ EndpointWidget::EndpointWidget(EndpointHandler* eph, QWidget *parent) : QWidget(
|
||||||
connect(mainSlider, &QSlider::valueChanged, [this](int newValue){this->eph->setValue(ENDPOINT_MASTER_VOLUME, newValue); });
|
connect(mainSlider, &QSlider::valueChanged, [this](int newValue){this->eph->setValue(ENDPOINT_MASTER_VOLUME, newValue); });
|
||||||
connect(leftChannelSlider, &QSlider::valueChanged, [this](int newValue){ this->eph->setValue(ENDPOINT_LEFT_CHANNEL_VOLUME, newValue); this->leftChannelLabel->setText(QString::number(newValue)); });
|
connect(leftChannelSlider, &QSlider::valueChanged, [this](int newValue){ this->eph->setValue(ENDPOINT_LEFT_CHANNEL_VOLUME, newValue); this->leftChannelLabel->setText(QString::number(newValue)); });
|
||||||
connect(rightChannelSlider, &QSlider::valueChanged, [this](int newValue){ this->eph->setValue(ENDPOINT_RIGHT_CHANNEL_VOLUME, newValue); this->rightChannelLabel->setText(QString::number(newValue)); });
|
connect(rightChannelSlider, &QSlider::valueChanged, [this](int newValue){ this->eph->setValue(ENDPOINT_RIGHT_CHANNEL_VOLUME, newValue); this->rightChannelLabel->setText(QString::number(newValue)); });
|
||||||
connect(muteButton, &QPushButton::clicked, [this](bool clicked){ log_debugcpp("cliqui" << clicked << "cloqui"); this->eph->setMute(); this->muteButton->setText(this->eph->getMute() ? STRING_UNMUTE : STRING_MUTE); });
|
connect(muteButton, &QPushButton::clicked, [this](bool clicked){ log_debugcpp("cliqui" << clicked << "cloqui"); this->eph->setMute(osh->getGuid()); this->muteButton->setText(this->eph->getMute() ? STRING_UNMUTE : STRING_MUTE); });
|
||||||
log_debugcpp("ENDPOINT_WIDGETED");
|
log_debugcpp("ENDPOINT_WIDGETED");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue