back to front now works without hangs?
This commit is contained in:
parent
966cf91a23
commit
d1f0bcaf26
5 changed files with 166 additions and 78 deletions
|
|
@ -38,34 +38,46 @@ 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];
|
||||
* }
|
||||
*/
|
||||
|
||||
float extraChannelVol[pNotify->nChannels];
|
||||
bool multiChannel = false;
|
||||
AUDIO_VOLUME_NOTIFICATION_DATA eventData = *pNotify;
|
||||
if(pNotify->nChannels > 1) {
|
||||
multiChannel = true;
|
||||
for (UINT i = 0; i < pNotify->nChannels; i++){
|
||||
extraChannelVol[i] = pNotify->afChannelVolumes[i];
|
||||
}
|
||||
}
|
||||
NGuid* guid = osh->getGuid();
|
||||
|
||||
if (memcmp(guid, &eventData, 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);
|
||||
// osh->callbackInfo[this->ep->getIndex()]->caller = (NGuid)pNotify->guidEventContext;
|
||||
memcpy(osh->callbackInfo[this->ep->getIndex()]->caller, &pNotify->guidEventContext,sizeof(NGuid) );
|
||||
|
||||
if(multiChannel)
|
||||
for(UINT i = 0; i < eventData.nChannels; i++) {
|
||||
osh->updateVolumeCallback(this->ep->getIndex(), (uint32_t)i, extraChannelVol[i]);
|
||||
}
|
||||
else
|
||||
osh->updateVolumeCallback(this->ep->getIndex(), (uint32_t)0, pNotify->afChannelVolumes[0]);
|
||||
}
|
||||
osh->callbackInfo[this->ep->getIndex()]->muted = pNotify->bMuted;
|
||||
osh->callbackInfo[this->ep->getIndex()]->mainVolume = pNotify->fMasterVolume;
|
||||
osh->callbackInfo[this->ep->getIndex()]->channels = pNotify->nChannels;
|
||||
|
||||
UINT i = 0;
|
||||
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;
|
||||
}
|
||||
|
|
@ -118,9 +130,10 @@ uint32_t Endpoint::getChannelCount(){
|
|||
bool Endpoint::getMute(){
|
||||
BOOL mut;
|
||||
if(FAILED(endpointVolume->GetMute(&mut))) { log_debugcpp("si"); }
|
||||
log_debugcpp("back BOOL is " << mut);
|
||||
//TODO: mutex test
|
||||
//log_debugcpp("back BOOL is " << mut);
|
||||
bool mute = (bool)mut;
|
||||
log_debugcpp("translate to bool " << mute);
|
||||
//log_debugcpp("translate to bool " << mute);
|
||||
return mute;
|
||||
}
|
||||
|
||||
|
|
@ -140,12 +153,14 @@ bool Endpoint::getMute(){
|
|||
|
||||
|
||||
void Endpoint::setVolume(NGuid* guid, int channel, float volume) {
|
||||
//TODO: mutex test
|
||||
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))) { //log_debugcpp("MASTER VOLUME FAILED");
|
||||
};
|
||||
} else {
|
||||
log_debugcpp("Windows: Channel being updated: " << channel);
|
||||
if(FAILED(endpointVolume->SetChannelVolumeLevelScalar(channel, volume, &tempMsGuid))) { log_debugcpp("CHANNEL "<< channel <<" VOLUME FAILED"); };
|
||||
//log_debugcpp("Windows: Channel being updated: " << channel);
|
||||
if(FAILED(endpointVolume->SetChannelVolumeLevelScalar(channel, volume, &tempMsGuid))) { /* log_debugcpp("CHANNEL "<< channel <<" VOLUME FAILED"); */ };
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue