full functionality restored, slight cleanup

This commit is contained in:
Hane 2023-08-16 23:18:36 +02:00
commit d024179011
5 changed files with 27 additions and 150 deletions

View file

@ -39,17 +39,7 @@ HRESULT EndpointCallback::QueryInterface(REFIID riid, VOID **ppvInterface) {
HRESULT EndpointCallback::OnNotify(PAUDIO_VOLUME_NOTIFICATION_DATA pNotify) {
if (pNotify == NULL) return E_INVALIDARG;
/*
* float extraChannelVol[pNotify->nChannels];
* for (UINT i = 0; i < pNotify->nChannels; i++){
* AUDIO_VOLUME_NOTIFICATION_DATA eventData = *pNotify;
* extraChannelVol[i] = pNotify->afChannelVolumes[i];
* }
*/
// osh->callbackInfo[this->ep->getIndex()]->caller = (NGuid)pNotify->guidEventContext;
memcpy(osh->callbackInfo[this->ep->getIndex()]->caller, &pNotify->guidEventContext,sizeof(NGuid) );
osh->callbackInfo[this->ep->getIndex()]->muted = pNotify->bMuted;
osh->callbackInfo[this->ep->getIndex()]->mainVolume = pNotify->fMasterVolume;
osh->callbackInfo[this->ep->getIndex()]->channels = pNotify->nChannels;
@ -58,34 +48,10 @@ HRESULT EndpointCallback::OnNotify(PAUDIO_VOLUME_NOTIFICATION_DATA pNotify) {
do {
osh->callbackInfo[this->ep->getIndex()]->channelVolumes[i] = pNotify->afChannelVolumes[i];
} while(i++ < pNotify->nChannels);
//osh->receiveBackEndpointCallback(this->ep->getIndex());
/* NGuid* guid = osh->getGuid();
* //AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
* if (memcmp(guid, &eventData.guidEventContext, sizeof(*guid)) == 0) {
* //log_debugcpp("Onnanokotify says You Shall Not Update Thy Interface.");
* } else {
* //log_debugcpp("Onnanokotify says Stored: " << guid->data1);
* //log_debugcpp("Onnanokotify says Grace of God: " << eventData.guidEventContext.Data1);
* osh->updateMuteCallback(this->ep->getIndex(), eventData.bMuted);
* osh->updateVolumeCallback(this->ep->getIndex(), AudioChannel::CHANNEL_MAIN ,eventData.fMasterVolume);
* //log_debugcpp("Onnanokotify says Reported Channel Qty: " << eventData.nChannels);
*
*
* for(UINT i = 0; i < eventData.nChannels; i++) {
* osh->updateVolumeCallback(this->ep->getIndex(), (uint32_t)i, extraChannelVol[i]);
* }
* }
*/
return S_OK;
}
/* EndpointCallback::~EndpointCallback(){
* PAUDIO_VOLUME_NOTIFICATION_DATA->Release();
* } */
Endpoint::Endpoint(IMMDevice* ep, uint64_t idx){
this->endpoint = ep;
this->idx = idx;
@ -129,11 +95,8 @@ uint32_t Endpoint::getChannelCount(){
bool Endpoint::getMute(){
BOOL mut;
if(FAILED(endpointVolume->GetMute(&mut))) { log_debugcpp("si"); }
//TODO: mutex test
//log_debugcpp("back BOOL is " << mut);
if(FAILED(endpointVolume->GetMute(&mut))) { /* TIP: Below */ }
bool mute = (bool)mut;
//log_debugcpp("translate to bool " << mute);
return mute;
}
@ -153,25 +116,18 @@ bool Endpoint::getMute(){
void Endpoint::setVolume(NGuid* guid, int channel, float volume) {
//TODO: mutex test
//TIP: There used to be log messages here. Now, it's a ghost town.
GUID tempMsGuid = NGuidToGUID(guid);
if (channel == AudioChannel::CHANNEL_MAIN) {
if(FAILED(endpointVolume->SetMasterVolumeLevelScalar(volume, &tempMsGuid))) { //log_debugcpp("MASTER VOLUME FAILED");
};
if(FAILED(endpointVolume->SetMasterVolumeLevelScalar(volume, &tempMsGuid))) {};
} else {
//log_debugcpp("Windows: Channel being updated: " << channel);
if(FAILED(endpointVolume->SetChannelVolumeLevelScalar(channel, volume, &tempMsGuid))) { /* log_debugcpp("CHANNEL "<< channel <<" VOLUME FAILED"); */ };
if(FAILED(endpointVolume->SetChannelVolumeLevelScalar(channel, volume, &tempMsGuid))) { };
}
}
void Endpoint::setMute(NGuid* guid, bool muted) {
//BOOL mut;
//log_debugcpp("bool mute arrives as " << mut);
//if(FAILED(endpointVolume->GetMute(&mut))) { log_debugcpp("si"); }
//log_debugcpp("translate to BOOL as " << mut);
//TODO: use new funcs
GUID tempMsGuid = NGuidToGUID(guid);
if(FAILED(endpointVolume->SetMute(muted, &tempMsGuid))) { log_debugcpp("MUTE FAILED"); };
if(FAILED(endpointVolume->SetMute(muted, &tempMsGuid))) { /* TIP: Above */ };
}
void Endpoint::setCallback(EndpointCallback *epc){