poll merge squash
This commit is contained in:
parent
308a0486b6
commit
40bee90610
21 changed files with 2753 additions and 261 deletions
|
|
@ -1,43 +1,105 @@
|
|||
#pragma once
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
|
||||
#include "debug.h"
|
||||
#include "msinclude.h"
|
||||
#include "backsessionclasses.h"
|
||||
#include "global.h"
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
#include "contclasses.h"
|
||||
|
||||
#include <Windows.h>
|
||||
#include <mmdeviceapi.h>
|
||||
#include <combaseapi.h>
|
||||
#include <initguid.h>
|
||||
#include <functiondiscoverykeys_devpkey.h>
|
||||
|
||||
#include <endpointvolume.h>
|
||||
#include <audiopolicy.h>
|
||||
#include <audioclient.h>
|
||||
//#include <comdef.h>
|
||||
//#include <comip.h>
|
||||
#include <Winerror.h>
|
||||
class EndpointVolumeCallback;
|
||||
class Session;
|
||||
|
||||
class Endpoint {
|
||||
|
||||
public:
|
||||
Endpoint(IMMDevice* endpoint);
|
||||
void setVolume(int channel, float volume);
|
||||
/* float getLeftChannelVolume(); */
|
||||
/* float getRightChannelVolume(); */
|
||||
Endpoint(IMMDevice* endpoint, uint64_t idx);
|
||||
//todo: how to forward declare delegate constructors?
|
||||
Endpoint(IMMDevice* endpoint) : Endpoint(endpoint, 0) {};
|
||||
void reloadEndpointChannels();
|
||||
uint64_t getIndex();
|
||||
void setIndex(uint64_t idx);
|
||||
void setVolume(NGuid guid, int channel, float volume);
|
||||
uint32_t getChannelCount();
|
||||
float getVolume(int channel);
|
||||
void setMute();
|
||||
void setMute(NGuid guid, bool muted);
|
||||
bool getMute();
|
||||
LPWSTR getName();
|
||||
void setState(uint8_t state);
|
||||
size_t getState();
|
||||
Roles getRoles();
|
||||
void setRoles(Roles role);
|
||||
void assignRoles(Roles role);
|
||||
void removeRoles(Roles role);
|
||||
void setFlow();
|
||||
Flows getFlow();
|
||||
std::wstring getId();
|
||||
std::wstring getName();
|
||||
|
||||
void setVolumeCallback(EndpointVolumeCallback *epc);
|
||||
void removeVolumeCallback(EndpointVolumeCallback *epc);
|
||||
|
||||
/* sessions */
|
||||
std::vector<Session*> getSessions();
|
||||
size_t getSessionCount();
|
||||
void addSession(Session* session);
|
||||
void registerNewSessionNotification(EndpointNewSessionCallback* ensc);
|
||||
void unregisterNewSessionNotification(EndpointNewSessionCallback* ensc);
|
||||
|
||||
~Endpoint();
|
||||
|
||||
private:
|
||||
void inline activateEndpointVolume();
|
||||
void inline activateEndpointSessions();
|
||||
|
||||
std::vector<Session*> endpointSessions;
|
||||
uint32_t channelCount = 0;
|
||||
IMMDevice* endpoint;
|
||||
IAudioEndpointVolume *endpointVolume ;
|
||||
IAudioSessionManager2 *sessionManager;
|
||||
Flows flow;
|
||||
IAudioEndpointVolume *endpointVolume = nullptr;
|
||||
IPropertyStore *properties;
|
||||
LPWSTR friendlyName;
|
||||
// LPWSTR endpointID = NULL;
|
||||
std::wstring friendlyName;
|
||||
std::wstring endpointId;
|
||||
unsigned long endpointState;
|
||||
Roles endpointRoles = (Roles)0;
|
||||
uint64_t idx;
|
||||
/* Not implemented in llvm-mingw. Sad!
|
||||
* IAudioMeterInformation *endpointPeakMeter = nullptr;
|
||||
*/
|
||||
};
|
||||
|
||||
class EndpointVolumeCallback : public IAudioEndpointVolumeCallback {
|
||||
|
||||
public:
|
||||
EndpointVolumeCallback(Endpoint* ep);
|
||||
|
||||
ULONG AddRef();
|
||||
ULONG Release();
|
||||
HRESULT QueryInterface(REFIID riid, VOID **ppvInterface);
|
||||
HRESULT OnNotify(PAUDIO_VOLUME_NOTIFICATION_DATA update);
|
||||
//~EndpointVolumeCallback();
|
||||
|
||||
private:
|
||||
ULONG ref = 1;
|
||||
Endpoint* ep;
|
||||
};
|
||||
|
||||
class EndpointSituationCallback : public IMMNotificationClient {
|
||||
public:
|
||||
//EndpointSituationCallback(IMMDeviceEnumerator *deviceEnumerator, std::vector<Endpoint*> playbackDevices);
|
||||
ULONG AddRef();
|
||||
ULONG Release();
|
||||
HRESULT QueryInterface(REFIID riid, VOID **ppvInterface);
|
||||
HRESULT OnDefaultDeviceChanged(EDataFlow flow, ERole role, LPCWSTR pwstrDeviceId);
|
||||
HRESULT OnDeviceAdded(LPCWSTR pwstrDeviceId);
|
||||
HRESULT OnDeviceRemoved(LPCWSTR pwstrDeviceId);
|
||||
HRESULT OnDeviceStateChanged(LPCWSTR pwstrDeviceId, DWORD dwNewState);
|
||||
HRESULT OnPropertyValueChanged(LPCWSTR pwstrDeviceId, const PROPERTYKEY key);
|
||||
|
||||
void fill(IMMDeviceEnumerator *deviceEnumerator, std::vector<Endpoint*> playbackDevices, std::vector<Endpoint*> captureDevices);
|
||||
private:
|
||||
ULONG ref = 1;
|
||||
IMMDeviceEnumerator *deviceEnumerator;
|
||||
std::vector<Endpoint*> playbackDevices;
|
||||
std::vector<Endpoint*> captureDevices;
|
||||
};
|
||||
|
||||
class Overseer {
|
||||
|
|
@ -45,7 +107,14 @@ class Overseer {
|
|||
public:
|
||||
Overseer();
|
||||
std::vector<Endpoint*> getPlaybackEndpoints();
|
||||
void reloadEndpoints();
|
||||
std::vector<Endpoint*> getCaptureEndpoints();
|
||||
|
||||
void reloadEndpoints(Flows flow);
|
||||
Endpoint* addEndpoint(std::wstring endpointId, /* out */ Flows* flow);
|
||||
NGuid getGuid();
|
||||
//void setEndpointStatusCallback();
|
||||
//void setEndpointStatusCallback();
|
||||
|
||||
//~Overseer();
|
||||
//int getDefaultPlaybackEndpoint(Endpoint** defaultEndpoint);
|
||||
//int getDefaultCaptureEndpoint(Endpoint** defaultEndpoint);
|
||||
|
|
@ -54,12 +123,28 @@ class Overseer {
|
|||
~Overseer();
|
||||
|
||||
private:
|
||||
unsigned int numPlaybackEndpoints;
|
||||
NGuid guid;
|
||||
|
||||
IMMDeviceEnumerator *deviceEnumerator;
|
||||
EndpointSituationCallback epsc;
|
||||
//IPolicyConfig *policyConfig;
|
||||
std::vector<Endpoint*> playbackDevices;
|
||||
std::vector<Endpoint*> captureDevices;
|
||||
void initCOMLibrary();
|
||||
//IMMDeviceCollection *deviceCollection;
|
||||
//int numCaptureEndpoints;
|
||||
//std::vector<Endpoint*> *captureDevices;
|
||||
};
|
||||
|
||||
class EndpointNewSessionCallback : public IAudioSessionNotification {
|
||||
public:
|
||||
EndpointNewSessionCallback(EndpointHandler *eph);
|
||||
ULONG AddRef();
|
||||
ULONG Release();
|
||||
HRESULT QueryInterface(REFIID riid, VOID **ppvInterface);
|
||||
HRESULT OnSessionCreated(IAudioSessionControl *NewSession);
|
||||
|
||||
private:
|
||||
ULONG ref = 1;
|
||||
EndpointHandler *eph;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue