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();
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ class Endpoint {
|
|||
Flows getFlow();
|
||||
std::wstring getId();
|
||||
std::wstring getName();
|
||||
void updateName();
|
||||
|
||||
void setVolumeCallback(EndpointVolumeCallback *epc);
|
||||
void removeVolumeCallback(EndpointVolumeCallback *epc);
|
||||
|
|
@ -57,6 +58,8 @@ class Endpoint {
|
|||
IAudioEndpointVolume *endpointVolume = nullptr;
|
||||
IPropertyStore *properties;
|
||||
std::wstring friendlyName;
|
||||
std::wstring descriptionName;
|
||||
std::wstring deviceName;
|
||||
std::wstring endpointId;
|
||||
unsigned long endpointState;
|
||||
Roles endpointRoles = (Roles)0;
|
||||
|
|
@ -84,8 +87,7 @@ class EndpointVolumeCallback : public IAudioEndpointVolumeCallback {
|
|||
|
||||
class EndpointSituationCallback : public IMMNotificationClient {
|
||||
public:
|
||||
//EndpointSituationCallback(IMMDeviceEnumerator *deviceEnumerator, std::vector<Endpoint*> playbackDevices, std::vector<Endpoint*> captureDevices);
|
||||
//EndpointSituationCallback(std::vector<Endpoint*>* playbackDevices, std::vector<Endpoint*>* captureDevices);
|
||||
EndpointSituationCallback(Overseer* os);
|
||||
ULONG AddRef();
|
||||
ULONG Release();
|
||||
HRESULT QueryInterface(REFIID riid, VOID **ppvInterface);
|
||||
|
|
@ -97,9 +99,7 @@ class EndpointSituationCallback : public IMMNotificationClient {
|
|||
|
||||
private:
|
||||
ULONG ref = 1;
|
||||
//IMMDeviceEnumerator *deviceEnumerator;
|
||||
//std::vector<Endpoint*>* playbackDevices;
|
||||
//std::vector<Endpoint*>* captureDevices;
|
||||
Overseer* os;
|
||||
};
|
||||
|
||||
class Overseer {
|
||||
|
|
@ -107,9 +107,9 @@ class Overseer {
|
|||
public:
|
||||
Overseer();
|
||||
void openControlPanel();
|
||||
//todo: restore/overseer
|
||||
std::vector<Endpoint*> getPlaybackEndpoints();
|
||||
std::vector<Endpoint*> getCaptureEndpoints();
|
||||
void updateEndpointInfo(std::wstring endpointId);
|
||||
|
||||
void reloadEndpoints(Flows flow);
|
||||
Endpoint* addEndpoint(std::wstring endpointId, /* out */ Flows* flow);
|
||||
|
|
|
|||
|
|
@ -294,6 +294,13 @@ void OverseerHandler::changeFrontDefaultsCallback(Roles role, std::wstring endpo
|
|||
this->changeFrontDefaults(role, endpointId);
|
||||
}
|
||||
|
||||
void OverseerHandler::updateFrontEndpointName(Endpoint* ep) {
|
||||
//todo: reintroduce capture devices
|
||||
for (auto eph : playbackEndpointHandlers) {
|
||||
if (eph->getEndpoint() == ep) eph->getCallbackInfo()->updateName = true;
|
||||
}
|
||||
}
|
||||
|
||||
void OverseerHandler::reviseEndpointShowing(std::wstring endpointId, EndpointState state) {
|
||||
std::vector<EndpointHandler*> allHandlers;
|
||||
allHandlers.insert(allHandlers.end(), this->captureEndpointHandlers.begin(), this->captureEndpointHandlers.end());
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ struct BackEndpointVolumeCallbackInfo {
|
|||
float mainVolume;
|
||||
size_t channels;
|
||||
std::vector<float> channelVolumes;
|
||||
bool updateName = false;
|
||||
};
|
||||
|
||||
class EndpointHandler {
|
||||
|
|
@ -30,7 +31,7 @@ public:
|
|||
//EndpointVolumeCallback* getEndpointVolumeCallback();
|
||||
//Endpoint* getEndpoint();
|
||||
|
||||
//std::wstring epName;
|
||||
//todo: name refactor
|
||||
BackEndpointVolumeCallbackInfo* getCallbackInfo();
|
||||
uint32_t getChannelCount();
|
||||
|
||||
|
|
@ -103,6 +104,7 @@ public:
|
|||
void setChangeFrontDefaultsFunction(std::function<void(Roles, std::wstring)> changeFrontDefaults);
|
||||
void changeFrontDefaultsCallback(Roles role, std::wstring endpointId);
|
||||
|
||||
void updateFrontEndpointName(Endpoint* ep);
|
||||
//void setReviseEndpointShowingFunction(std::function<void(std::wstring, EndpointState)> reviseEndpointShowing);
|
||||
void reviseEndpointShowing(std::wstring endpointId, EndpointState state);
|
||||
void setRemoveEndpointWidgetFunction(std::function<void(uint64_t)> removeEndpointWidget);
|
||||
|
|
|
|||
|
|
@ -420,6 +420,11 @@ EndpointWidget::EndpointWidget(EndpointHandler* eph, QWidget *parent, uint64_t i
|
|||
//if (memcmp(osh->callbackInfo[idx]->caller, osh->getGuid(), sizeof(NGuid)) == 0) return; CHECK IF THIS PROGRAM GENERATED THE FUNSIES IS NO LONGER IN USE FOR NOW.
|
||||
//todo: global + constexpr + ratio
|
||||
const float roundingFactor = 0.005;
|
||||
if (eph->getCallbackInfo()->updateName) {
|
||||
eph->getCallbackInfo()->updateName = false;
|
||||
mainLabel->setText(QString::fromStdWString(eph->getName()));
|
||||
mainLabel->setMinimumHeight(mainLabel->sizeHint().height());
|
||||
}
|
||||
mainSlider->blockSignals(true);
|
||||
muteButton->blockSignals(true);
|
||||
mainSlider->setValue((int)((eph->getCallbackInfo()->mainVolume + roundingFactor) * 100));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue