Refactored program structure
This commit is contained in:
parent
e43e4c0569
commit
80685f1a21
10 changed files with 140 additions and 96 deletions
|
|
@ -1,7 +1,7 @@
|
|||
#include <backlasses.h>
|
||||
|
||||
EndpointCallback::EndpointCallback(Endpoint* ep){
|
||||
this.ep = ep;
|
||||
this->ep = ep;
|
||||
}
|
||||
|
||||
ULONG EndpointCallback::AddRef(){
|
||||
|
|
@ -36,13 +36,15 @@ HRESULT EndpointCallback::QueryInterface(REFIID riid, VOID **ppvInterface) {
|
|||
}
|
||||
|
||||
HRESULT EndpointCallback::OnNotify(PAUDIO_VOLUME_NOTIFICATION_DATA pNotify) {
|
||||
if (pNotify == NULL) return E_INVALIDARG;
|
||||
AUDIO_VOLUME_NOTIFICATION_DATA eventData = *pNotify;
|
||||
LPGUID guid = osh->getOverseer()->getGuid();
|
||||
|
||||
if (eventData.guidEventContext != *guid) {
|
||||
osh->parseExternalEndpointCallback(this, eventData);
|
||||
}
|
||||
if (pNotify == NULL) return E_INVALIDARG;
|
||||
/*
|
||||
* AUDIO_VOLUME_NOTIFICATION_DATA eventData = *pNotify;
|
||||
* LPGUID guid = osh->getOverseer()->getGuid();
|
||||
*
|
||||
* if (eventData.guidEventContext != *guid) {
|
||||
* osh->parseExternalEndpointCallback(this, eventData);
|
||||
* }
|
||||
*/
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
|
@ -58,11 +60,11 @@ Endpoint::Endpoint(IMMDevice* ep){
|
|||
endpoint->OpenPropertyStore(STGM_READ, &properties);
|
||||
PROPVARIANT pv;
|
||||
properties->GetValue(PKEY_Device_FriendlyName , &pv);
|
||||
friendlyName = pv.pwszVal;
|
||||
friendlyName = std::wstring(pv.pwszVal);
|
||||
}
|
||||
|
||||
void Endpoint::setIndex(uint64_t idx){
|
||||
this.idx = idx;
|
||||
this->idx = idx;
|
||||
}
|
||||
|
||||
uint64_t Endpoint::getIndex(){
|
||||
|
|
@ -70,7 +72,7 @@ uint64_t Endpoint::getIndex(){
|
|||
}
|
||||
|
||||
|
||||
LPWSTR Endpoint::getName(){
|
||||
std::wstring Endpoint::getName(){
|
||||
return friendlyName;
|
||||
}
|
||||
|
||||
|
|
@ -118,10 +120,10 @@ void Endpoint::setVolume(int channel, float volume) {
|
|||
}
|
||||
|
||||
void Endpoint::setMute() {
|
||||
log_debugcpp("bool mute arrives as " << mut);
|
||||
BOOL mut;
|
||||
//log_debugcpp("bool mute arrives as " << mut);
|
||||
if(FAILED(endpointVolume->GetMute(&mut))) { log_debugcpp("si"); }
|
||||
log_debugcpp("translate to BOOL as " << mute);
|
||||
log_debugcpp("translate to BOOL as " << mut);
|
||||
if(FAILED(endpointVolume->SetMute((mut == false ? 1 : 0), NULL))) { log_debugcpp("si"); };
|
||||
}
|
||||
|
||||
|
|
@ -135,7 +137,6 @@ void Endpoint::removeCallback(EndpointCallback *epc){
|
|||
|
||||
Endpoint::~Endpoint(){
|
||||
log_debugcpp("cum");
|
||||
free(friendlyName);
|
||||
properties->Release();
|
||||
endpointVolume->Release();
|
||||
endpoint->Release();
|
||||
|
|
@ -153,8 +154,18 @@ void Overseer::initCOMLibrary(){
|
|||
(void**)&deviceEnumerator)) )
|
||||
{ log_debugcpp("si"); };
|
||||
|
||||
if(FAILED(CoCreateGuid(guid))) { log_debugcpp("guyyyyyy"); };
|
||||
|
||||
/*
|
||||
* LPGUID tempGuid = nullptr;
|
||||
* if(FAILED(CoCreateGuid(tempGuid))) { log_debugcpp("Failed to obtain GUID"); };
|
||||
*
|
||||
* this->guid.data1 = tempGuid->Data1;
|
||||
* this->guid.data2 = tempGuid->Data2;
|
||||
* this->guid.data3 = tempGuid->Data3;
|
||||
* for (int i = 0; i < 8; i++){
|
||||
* this->guid.data4[i] = tempGuid->Data4[i];
|
||||
* }
|
||||
*/
|
||||
//TODO: Release lpguid?
|
||||
}
|
||||
|
||||
void Overseer::reloadEndpoints() {
|
||||
|
|
@ -184,6 +195,7 @@ void Overseer::reloadEndpoints() {
|
|||
|
||||
Overseer::Overseer(){
|
||||
//Initializing COM library
|
||||
log_debugcpp("Initializing Overseer");
|
||||
initCOMLibrary();
|
||||
|
||||
//Obtaining playback endpoint collection on this point in time
|
||||
|
|
@ -198,7 +210,8 @@ Overseer::Overseer(){
|
|||
|
||||
//int Overseer::getDefaultCaptureEndpoint(Endpoint** defaultEndpoint);
|
||||
|
||||
LPGUID Overseer::getGuid() {
|
||||
//TODO guid
|
||||
NGuid Overseer::getGuid() {
|
||||
return guid;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue