fixed race cons ep/eph coll, unwanted session state update crash

+ some minor code cleanup
This commit is contained in:
Hane 2025-01-15 21:47:35 +01:00
commit 59a92fa34b
7 changed files with 144 additions and 127 deletions

View file

@ -58,8 +58,8 @@ class Endpoint {
float getVolume(int channel);
void setMute(NGuid guid, bool muted);
bool getMute();
void setState(uint8_t state);
size_t getState();
void setState(EndpointState state);
EndpointState getState();
Roles getRoles();
void setRoles(Roles role);
void assignRoles(Roles role);
@ -101,7 +101,7 @@ class Endpoint {
std::wstring descriptionName;
std::wstring deviceName;
std::wstring endpointId;
unsigned long endpointState;
EndpointState endpointState;
Roles endpointRoles = (Roles)0;
uint64_t idx;
//Not implemented in llvm-mingw. Sad! todo: mingw patch
@ -118,6 +118,7 @@ class EndpointVolumeCallback : public IAudioEndpointVolumeCallback {
ULONG Release();
HRESULT QueryInterface(REFIID riid, VOID **ppvInterface);
HRESULT OnNotify(PAUDIO_VOLUME_NOTIFICATION_DATA update);
void updateVolumeInfo(AUDIO_VOLUME_NOTIFICATION_DATA newVolume, float* channelVolumes);
//~EndpointVolumeCallback();
private:
@ -146,15 +147,18 @@ class Overseer {
public:
Overseer();
void registerEndpointSituationCallback();
NGuid getGuid();
std::vector<Endpoint*> getPlaybackEndpoints();
std::vector<Endpoint*> getCaptureEndpoints();
void updateEndpointInfo(std::wstring endpointId);
void reloadEndpoints(Flows flow);
void createEndpoints(Flows flow);
Endpoint* addEndpoint(std::wstring endpointId, /* out */ Flows* flow);
std::mutex playbackMutex;
std::mutex captureMutex;
//void setEndpointStatusCallback();
//void setEndpointStatusCallback();
@ -166,8 +170,6 @@ class Overseer {
~Overseer();
private:
std::wstring exeAbsPath;
void initCOMLibrary();
NGuid guid;
@ -177,7 +179,6 @@ class Overseer {
std::vector<Endpoint*> playbackDevices;
std::vector<Endpoint*> captureDevices;
IPolicyConfig7* policyConfig;
friend class Endpoint;
//IMMDeviceCollection *deviceCollection;
@ -222,7 +223,9 @@ namespace Environment {
bool isToRunAtStartup();
uint32_t getAccentColor();
//todo: binary path cache unused
static std::wstring exeAbsPath;
static uint32_t exeAbsPathLen;
static bool lightMode;
static bool startup = false;
static HKEY scope;