wip partial refactor

This commit is contained in:
Hane 2023-08-10 21:34:09 +02:00
commit bc82ec72ed
7 changed files with 114 additions and 53 deletions

View file

@ -1,5 +1,9 @@
#include <backlasses.h>
EndpointCallback::EndpointCallback(Endpoint* ep){
this.ep = ep;
}
ULONG EndpointCallback::AddRef(){
return InterlockedIncrement(&ref);
}
@ -33,10 +37,11 @@ HRESULT EndpointCallback::QueryInterface(REFIID riid, VOID **ppvInterface) {
HRESULT EndpointCallback::OnNotify(PAUDIO_VOLUME_NOTIFICATION_DATA pNotify) {
if (pNotify == NULL) return E_INVALIDARG;
LPGUID guid = osh->getOverseer()->getGuid();
if (pNotify->guidEventContext != *guid) {
osh->parseExternalEndpointCallback(this, pNotify);
AUDIO_VOLUME_NOTIFICATION_DATA eventData = *pNotify;
LPGUID guid = osh->getOverseer()->getGuid();
if (eventData.guidEventContext != *guid) {
osh->parseExternalEndpointCallback(this, eventData);
}
return S_OK;
}
@ -56,6 +61,15 @@ Endpoint::Endpoint(IMMDevice* ep){
friendlyName = pv.pwszVal;
}
void Endpoint::setIndex(uint64_t idx){
this.idx = idx;
}
uint64_t Endpoint::getIndex(){
return idx;
}
LPWSTR Endpoint::getName(){
return friendlyName;
}
@ -112,11 +126,11 @@ void Endpoint::setMute() {
}
void Endpoint::setCallback(EndpointCallback *epc){
endpointVolume->RegisterControlChangeNotify((IAudioEndpointVolumeCallback*)*epc);
endpointVolume->RegisterControlChangeNotify((IAudioEndpointVolumeCallback*)epc);
}
void Endpoint::removeCallback(EndpointCallback *epc){
endpointVolume->UnregisterControlChangeNotify((IAudioEndpointVolumeCallback*)*epc);
endpointVolume->UnregisterControlChangeNotify((IAudioEndpointVolumeCallback*)epc);
}
Endpoint::~Endpoint(){
@ -160,6 +174,7 @@ void Overseer::reloadEndpoints() {
IMMDevice *temp;
if(deviceCollection->Item(i, &temp) != 0) { log_debugcpp("si"); };
Endpoint *endpoint = new Endpoint(temp);
endpoint->setIndex(i);
this->playbackDevices.push_back(endpoint);
//TODO: le porblemx std::cout << "ola" << std::endl;
}

View file

@ -5,6 +5,7 @@
#include "global.h"
#include <vector>
#include <iostream>
#include <wstring>
#include <Windows.h>
#include <mmdeviceapi.h>
@ -19,12 +20,12 @@
//#include <comip.h>
#include <Winerror.h>
class EndpointWidget;
//class EndpointWidget;
class EndpointCallback : public IAudioEndpointVolumeCallback {
public:
EndpointCallback();
EndpointCallback(Endpoint* ep);
ULONG AddRef();
ULONG Release();
@ -33,7 +34,8 @@ class EndpointCallback : public IAudioEndpointVolumeCallback {
~EndpointCallback();
private:
ULONG ref;
ULONG ref = 1;
Endpoint* ep;
PAUDIO_VOLUME_NOTIFICATION_DATA update;
};
@ -41,6 +43,8 @@ class Endpoint {
public:
Endpoint(IMMDevice* endpoint);
uint64_t getIndex();
void setIndex(uint64_t idx);
void setVolume(int channel, float volume);
/* float getLeftChannelVolume(); */
/* float getRightChannelVolume(); */
@ -56,7 +60,8 @@ class Endpoint {
IMMDevice* endpoint;
IAudioEndpointVolume *endpointVolume ;
IPropertyStore *properties;
LPWSTR friendlyName;
std::wstring friendlyName;
uint64_t idx;
// LPWSTR endpointID = NULL;
};