mic back/cont & plug/unplug done; devicead/rem to go
This commit is contained in:
parent
44ccde6ac8
commit
6f8455c63d
5 changed files with 129 additions and 46 deletions
|
|
@ -53,18 +53,28 @@ HRESULT EndpointVolumeCallback::OnNotify(PAUDIO_VOLUME_NOTIFICATION_DATA pNotify
|
|||
}
|
||||
|
||||
//memcpy(&osh->getPlaybackEndpointHandlers().at(this->ep->getIndex())->getCallbackInfo()->caller, &pNotify->guidEventContext,sizeof(NGuid) );
|
||||
|
||||
|
||||
osh->getPlaybackEndpointHandlers().at(this->ep->getIndex())->getCallbackInfo()->muted = pNotify->bMuted;
|
||||
osh->getPlaybackEndpointHandlers().at(this->ep->getIndex())->getCallbackInfo()->mainVolume = pNotify->fMasterVolume;
|
||||
osh->getPlaybackEndpointHandlers().at(this->ep->getIndex())->getCallbackInfo()->channels = pNotify->nChannels;
|
||||
Flows flow = this->ep->getFlow();
|
||||
EndpointHandler* eph = nullptr;
|
||||
if (flow & Flows::FLOW_PLAYBACK) {
|
||||
eph = osh->getPlaybackEndpointHandlers().at(this->ep->getIndex());
|
||||
} else {
|
||||
eph = osh->getCaptureEndpointHandlers().at(this->ep->getIndex());
|
||||
}
|
||||
|
||||
eph->getCallbackInfo()->muted = pNotify->bMuted;
|
||||
eph->getCallbackInfo()->mainVolume = pNotify->fMasterVolume;
|
||||
eph->getCallbackInfo()->channels = pNotify->nChannels;
|
||||
|
||||
|
||||
UINT j = 0;
|
||||
//todo: do while here caused stack corruption; sus
|
||||
while(j < pNotify->nChannels) {
|
||||
osh->getPlaybackEndpointHandlers().at(this->ep->getIndex())->getCallbackInfo()->channelVolumes[j] = pNotify->afChannelVolumes[j];
|
||||
j++;
|
||||
}
|
||||
UINT j = 0;
|
||||
//todo: do while here caused stack corruption; sus
|
||||
while(j < pNotify->nChannels) {
|
||||
if (flow & Flows::FLOW_PLAYBACK)
|
||||
eph->getCallbackInfo()->channelVolumes[j] = pNotify->afChannelVolumes[j];
|
||||
else
|
||||
eph->getCallbackInfo()->channelVolumes[j] = pNotify->afChannelVolumes[j];
|
||||
j++;
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
|
@ -191,7 +201,9 @@ Endpoint::Endpoint(IMMDevice* ep, uint64_t idx){
|
|||
//todo: preguntitas owindows dword no es uint32_t even tho mingw mingas
|
||||
if(FAILED(endpoint->GetState(&this->endpointState))) {exit(-1);};
|
||||
|
||||
activateEndpointVolume();
|
||||
if(this->endpointState == EndpointState::ENDPOINT_ACTIVE) {
|
||||
activateEndpointVolume();
|
||||
}
|
||||
|
||||
reloadEndpointChannels();
|
||||
|
||||
|
|
@ -214,6 +226,8 @@ Endpoint::Endpoint(IMMDevice* ep, uint64_t idx){
|
|||
friendlyName = L"Unnamed Not Present Endpoint";
|
||||
else
|
||||
friendlyName = std::wstring(pv.pwszVal);
|
||||
|
||||
this->setFlow();
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -222,13 +236,27 @@ Endpoint::Endpoint(IMMDevice* ep, uint64_t idx){
|
|||
|
||||
|
||||
void Endpoint::activateEndpointVolume() {
|
||||
if (this->endpointVolume == nullptr)
|
||||
if(FAILED(endpoint->Activate(IID_IAudioEndpointVolume, CLSCTX_ALL, NULL, (void**)&this->endpointVolume))) { log_debugcpp(std::string("no endpointVolume (IAudioEndpointVolume)")); };
|
||||
//bool extraThread = false;
|
||||
/*
|
||||
* Forgive me, for MS has sinned, and now I must too.
|
||||
*/
|
||||
if (this->endpointVolume == nullptr){
|
||||
HRESULT result = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
|
||||
endpoint->Activate(IID_IAudioEndpointVolume, CLSCTX_ALL, NULL, (void**)&this->endpointVolume);
|
||||
//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;
|
||||
//goto initialized;
|
||||
//}
|
||||
//log_debugcpp(std::string("no endpointVolume (IAudioEndpointVolume)"));
|
||||
if (result == S_OK)
|
||||
CoUninitialize();
|
||||
}
|
||||
}
|
||||
|
||||
void Endpoint::reloadEndpointChannels() {
|
||||
if (this->endpointState == DEVICE_STATE_ACTIVE) {
|
||||
if (FAILED(endpointVolume->GetChannelCount(&channelCount))) {};/* log_debugcpp("get channel count fail"); */
|
||||
if (FAILED(endpointVolume->GetChannelCount(&channelCount))) {log_debugcpp("get channel count fail");};/* */
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -272,8 +300,10 @@ bool Endpoint::getMute(){
|
|||
|
||||
void Endpoint::setState(uint8_t state){
|
||||
this->endpointState = state;
|
||||
if(state == EndpointState::ENDPOINT_ACTIVE)
|
||||
if(state == EndpointState::ENDPOINT_ACTIVE) {
|
||||
this->activateEndpointVolume();
|
||||
this->reloadEndpointChannels();
|
||||
}
|
||||
}
|
||||
|
||||
size_t Endpoint::getState(){
|
||||
|
|
@ -468,7 +498,7 @@ void Overseer::reloadEndpoints(Flows flow) {
|
|||
for (unsigned int i = 0; i < numEndpoints; i++){
|
||||
if(deviceCollection->Item(i, &temp) != 0) { log_debugcpp("si"); };
|
||||
Endpoint *endpoint = new Endpoint(temp, i);
|
||||
endpoint->setFlow();
|
||||
|
||||
//endpoint->setIndex(i);
|
||||
if (flow == Flows::FLOW_PLAYBACK)
|
||||
this->playbackDevices.push_back(endpoint);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue