fixed newly arisen race cons (busywaits)

This commit is contained in:
Hane 2025-01-18 18:01:35 +01:00
commit 53f9506115
4 changed files with 59 additions and 11 deletions

View file

@ -119,11 +119,13 @@ class EndpointVolumeCallback : public IAudioEndpointVolumeCallback {
HRESULT QueryInterface(REFIID riid, VOID **ppvInterface);
HRESULT OnNotify(PAUDIO_VOLUME_NOTIFICATION_DATA update);
void updateVolumeInfo(AUDIO_VOLUME_NOTIFICATION_DATA newVolume, float* channelVolumes);
void reportFinished();
//~EndpointVolumeCallback();
private:
ULONG ref = 1;
Endpoint* ep;
bool wait = false;
};
class EndpointSituationCallback : public IMMNotificationClient {
@ -137,10 +139,11 @@ class EndpointSituationCallback : public IMMNotificationClient {
HRESULT OnDeviceRemoved(LPCWSTR pwstrDeviceId);
HRESULT OnDeviceStateChanged(LPCWSTR pwstrDeviceId, DWORD dwNewState);
HRESULT OnPropertyValueChanged(LPCWSTR pwstrDeviceId, const PROPERTYKEY key);
void reportFinishedStateChange();
private:
ULONG ref = 1;
Overseer* os;
bool isEpStateChanging = false;
};
class Overseer {
@ -156,6 +159,8 @@ class Overseer {
void createEndpoints(Flows flow);
Endpoint* addEndpoint(std::wstring endpointId, /* out */ Flows* flow);
void reportFinishedStateChange();
std::mutex playbackMutex;
std::mutex captureMutex;
@ -196,9 +201,10 @@ class EndpointNewSessionCallback : public IAudioSessionNotification {
ULONG Release();
HRESULT QueryInterface(REFIID riid, VOID **ppvInterface);
HRESULT OnSessionCreated(IAudioSessionControl *NewSession);
static void createSessionThread(SessionThreadParams params);
void createSessionThread(SessionThreadParams params);
private:
bool wait = false;
ULONG ref = 1;
EndpointHandler *eph;