wip: dynamically updated endpoint name
This commit is contained in:
parent
0880305b23
commit
1b2ab191ca
5 changed files with 55 additions and 29 deletions
|
|
@ -134,13 +134,10 @@ HRESULT EndpointVolumeCallback::OnNotify(PAUDIO_VOLUME_NOTIFICATION_DATA pNotify
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* EndpointSituationCallback::EndpointSituationCallback(std::vector<Endpoint*>* playbackDevices, std::vector<Endpoint*>* captureDevices){
|
||||
* this->captureDevices = captureDevices;
|
||||
* this->playbackDevices = playbackDevices;
|
||||
* }
|
||||
*/
|
||||
|
||||
EndpointSituationCallback::EndpointSituationCallback(Overseer* os){
|
||||
this->os = os;
|
||||
}
|
||||
|
||||
|
||||
ULONG EndpointSituationCallback::AddRef(){
|
||||
|
|
@ -227,13 +224,7 @@ HRESULT EndpointSituationCallback::OnDeviceStateChanged(LPCWSTR pwstrDeviceId, D
|
|||
}
|
||||
|
||||
HRESULT EndpointSituationCallback::OnPropertyValueChanged(LPCWSTR pwstrDeviceId, const PROPERTYKEY key) {
|
||||
|
||||
/* Lacking impl again? */
|
||||
PWSTR test;
|
||||
HRESULT ctrl = PSGetNameFromPropertyKey(key, &test);
|
||||
if (ctrl == S_OK) log_wdebugcpp(test);
|
||||
|
||||
|
||||
os->updateEndpointInfo(std::wstring(pwstrDeviceId));
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
|
@ -266,20 +257,29 @@ Endpoint::Endpoint(IMMDevice* ep, uint64_t idx){
|
|||
log_wdebugcpp(endpointId);
|
||||
CoTaskMemFree(tempString);
|
||||
|
||||
endpoint->OpenPropertyStore(STGM_READ, &properties);
|
||||
PROPVARIANT pv;
|
||||
properties->GetValue(PKEY_Device_FriendlyName , &pv);
|
||||
if (pv.pwszVal == nullptr)
|
||||
friendlyName = L"Unnamed Not Present Endpoint";
|
||||
else
|
||||
friendlyName = std::wstring(pv.pwszVal);
|
||||
endpoint->OpenPropertyStore(STGM_READ, &properties);
|
||||
this->updateName();
|
||||
|
||||
this->setFlow();
|
||||
this->setFlow();
|
||||
if (this->flow == Flows::FLOW_PLAYBACK) {
|
||||
activateEndpointSessions();
|
||||
}
|
||||
}
|
||||
|
||||
void Endpoint::updateName() {
|
||||
PROPVARIANT pv;
|
||||
#define store_name(key, propvariant, wstr) do { \
|
||||
properties->GetValue(key , &propvariant); \
|
||||
if (pv.pwszVal == nullptr) wstr = L"Unnamed Not Present Endpoint"; \
|
||||
else wstr = std::wstring(pv.pwszVal); \
|
||||
} while (0)
|
||||
|
||||
store_name(PKEY_Device_FriendlyName, pv, friendlyName);
|
||||
store_name(PKEY_Device_DeviceDesc, pv, descriptionName);
|
||||
store_name(PKEY_DeviceInterface_FriendlyName, pv, deviceName);
|
||||
#undef store_name
|
||||
}
|
||||
|
||||
void Endpoint::activateEndpointSessions() {
|
||||
//sessionManager;
|
||||
if (FAILED(endpoint->Activate(__uuidof(IAudioSessionManager2), CLSCTX_ALL, NULL, (void**) &sessionManager))) { log_wdebugcpp(L"sesionbros..."); return; }
|
||||
|
|
@ -666,7 +666,7 @@ Endpoint* Overseer::addEndpoint(std::wstring endpointId, /* out */Flows* flow =
|
|||
return endpoint;
|
||||
}
|
||||
|
||||
Overseer::Overseer() { //: epsc(&playbackDevices, &captureDevices){
|
||||
Overseer::Overseer() : epsc(this){
|
||||
//Initializing COM library
|
||||
log_debugcpp("Initializing Overseer");
|
||||
initCOMLibrary();
|
||||
|
|
@ -719,6 +719,18 @@ std::vector<Endpoint*> Overseer::getCaptureEndpoints() {
|
|||
return captureDevices;
|
||||
}
|
||||
|
||||
void Overseer::updateEndpointInfo(std::wstring endpointId) {
|
||||
log_wdebugcpp(L"new name Endpoint id: " + endpointId);
|
||||
//todo: reintroduce capture devices
|
||||
for(auto ep : playbackDevices) {
|
||||
if (ep->getId() == endpointId) {
|
||||
ep->updateName();
|
||||
osh->updateFrontEndpointName(ep);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Overseer::~Overseer(){
|
||||
log_debugcpp("cum");
|
||||
deviceEnumerator->Release();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue