wip: endpoint meter

This commit is contained in:
Hane 2024-04-30 21:30:58 +02:00
commit 6bda4702df
7 changed files with 41 additions and 11 deletions

View file

@ -246,10 +246,6 @@ Endpoint::Endpoint(IMMDevice* ep, uint64_t idx){
// CLSCTX_ALL, NULL, (void**)&audioClient))) { log_debugcpp("audioclntbros..."); }
//audioClient->GetDevicePeriod(&defTime, &minTime);
//todo: check header
//if(FAILED(endpoint->Activate(__uuidof(IAudioMeterInformation),
// CLSCTX_ALL, NULL, (void**)&endpointPeakMeter))) { log_debugcpp("peakbros..."); }
//endpointPeakMeter->GetPeakValue(&test);
}
reloadEndpointChannels();
@ -323,6 +319,12 @@ void Endpoint::activateEndpointVolume() {
if (this->endpointVolume == nullptr){
HRESULT result = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
endpoint->Activate(IID_IAudioEndpointVolume, CLSCTX_ALL, NULL, (void**)&this->endpointVolume);
//todo: check header
if(FAILED(endpoint->Activate(__uuidof(IAudioMeterInformation),
CLSCTX_ALL, NULL, (void**)&endpointPeakMeter))) { log_debugcpp("peakbros..."); }
//
//if (endpointVolume == nullptr) { //why they returning 0 after dealing with the error jfc CO_E_NOTINITIALIZED) {
//CoInitializeEx(NULL, COINIT_MULTITHREADED | COINIT_DISABLE_OLE1DDE);
//extraThread = true;
@ -356,6 +358,13 @@ std::wstring Endpoint::getId(){
return endpointId;
}
float Endpoint::getPeakVolume() {
float peakVol;
if(endpointPeakMeter) endpointPeakMeter->GetPeakValue(&peakVol);
else return 0;
return peakVol;
}
float Endpoint::getVolume(int channel){
float volume;
if (channel == AudioChannel::CHANNEL_MAIN) {