1er real; slider x ept ok no evts no map

This commit is contained in:
Hane 2023-02-03 03:04:08 +01:00
commit 3ea2e739ae
10 changed files with 317 additions and 51 deletions

73
src/back/backlasses.cpp Normal file
View file

@ -0,0 +1,73 @@
#include <backlasses.h>
Endpoint::Endpoint(IMMDevice* ep){
this->endpoint = ep;
if(FAILED(endpoint->Activate(IID_IAudioEndpointVolume, CLSCTX_ALL, NULL, (void**)&endpointVolume))) { log_debugcpp("si"); };
}
void Endpoint::setVolume(float volume) {
if(FAILED(endpointVolume->SetMasterVolumeLevelScalar(volume, NULL))) { log_debugcpp("si"); };
}
void Overseer::initCOMLibrary(){
if(FAILED(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED))) { log_debugcpp("si"); };
//Retrieving endpoint enumerator
//MMDeviceEnumerator es el CLSID de toda la vaina de MMDevicear
if(FAILED(CoCreateInstance( __uuidof(MMDeviceEnumerator), NULL,
CLSCTX_ALL, __uuidof(IMMDeviceEnumerator),
(void**)&deviceEnumerator)) )
{ log_debugcpp("si"); };
}
void Overseer::reloadEndpoints() {
IMMDeviceCollection *deviceCollection;
// | DEVICE_STATE_DISABLED | DEVICE_STATE_NOTPRESENT | DEVICE_STATE_UNPLUGGED
if(FAILED(deviceEnumerator->EnumAudioEndpoints(eRender, DEVICE_STATE_ACTIVE, &deviceCollection) ))
{ log_debugcpp("si"); };
//Counting them
if(FAILED(deviceCollection->GetCount(&numPlaybackEndpoints))) { log_debugcpp("si");};
if(numPlaybackEndpoints == 0) { log_debugcpp("si"); };
//Retrieving actual endpoints and storing them on their own class
for (unsigned int i = 0; i < numPlaybackEndpoints; i++){
IMMDevice *temp;
if(deviceCollection->Item(i, &temp) != 0) { log_debugcpp("si"); };
Endpoint *endpoint = new Endpoint(temp);
this->playbackDevices.push_back(endpoint);
//TODO: le porblemx std::cout << "ola" << std::endl;
}
deviceCollection->Release();
}
Overseer::Overseer(){
//Initializing COM library
initCOMLibrary();
//Obtaining playback endpoint collection on this point in time
reloadEndpoints();
}
//Overseer::int getDefaultPlaybackEndpoint(Endpoint** defaultEndpoint){
//if (FAILED(deviceEnumerator->GetDefaultAudioEndpoint(eRender, eConsole, &endpointPtr)))
// return 1;
//return 0;
//}
//int Overseer::getDefaultCaptureEndpoint(Endpoint** defaultEndpoint);
std::vector<Endpoint*> Overseer::getPlaybackEndpoints() {
return playbackDevices;
}
//int Overseer::getCaptureEndpoints(std::vector<Endpoint*> *captureEndpoints);
//IMMDeviceEnumerator** Overseer::setOrigin();