151 lines
4.2 KiB
C++
151 lines
4.2 KiB
C++
#pragma once
|
|
//#define invoke_mem_fn(object,ptrToMember) ((object).*(ptrToMember))
|
|
//#define pinvoke_mem_fn(object,ptrToMember) ((object)->*(ptrToMember))
|
|
|
|
class EndpointWidget;
|
|
class Endpoint;
|
|
class EndpointVolumeCallback;
|
|
class Overseer;
|
|
|
|
enum AudioChannel {
|
|
CHANNEL_LEFT = (1 << 0),
|
|
CHANNEL_RIGHT = (1 << 1),
|
|
CHANNEL_MAIN = ~0,
|
|
};
|
|
|
|
enum EndpointState {
|
|
ENDPOINT_ACTIVE = (1 << 0),
|
|
ENDPOINT_DISABLED = (1 << 1),
|
|
ENDPOINT_NOTPRESENT = (1 << 2),
|
|
ENDPOINT_UNPLUGGED = (1 << 3),
|
|
ENDPOINT_ALL = 0x0F
|
|
};
|
|
|
|
enum Flows {
|
|
FLOW_PLAYBACK = (1 << 0),
|
|
FLOW_CAPTURE = (1 << 1),
|
|
FLOW_BOTH = (1 << 2),
|
|
};
|
|
|
|
enum Roles {
|
|
ROLE_CONSOLE = (1 << 0),
|
|
ROLE_MULTIMEDIA = (1 << 1),
|
|
ROLE_COMMUNICATIONS = (1 << 2),
|
|
ROLE_ALL = 0x07,
|
|
};
|
|
|
|
struct NGuid {
|
|
//todo: still leaking?
|
|
uint32_t data1;
|
|
uint16_t data2;
|
|
uint16_t data3;
|
|
unsigned char data4[8];
|
|
|
|
|
|
/* void freeData4(){ */
|
|
/* int i = 0; */
|
|
/* do{ */
|
|
/* if(this->data4 + i != nullptr) free(data4 + i); */
|
|
/* i++; */
|
|
/* }while (i < 8); */
|
|
/* } */
|
|
};
|
|
|
|
struct BackEndpointVolumeCallbackInfo {
|
|
NGuid caller;
|
|
bool muted;
|
|
float mainVolume;
|
|
size_t channels;
|
|
std::vector<float> channelVolumes;
|
|
};
|
|
|
|
class EndpointHandler {
|
|
|
|
public:
|
|
EndpointHandler(uint64_t idx, Flows flow);
|
|
void setBackEndpointVolumeCallbackInfoContent(uint8_t state);
|
|
|
|
//these two, currently unused. If I use them, I should feel bad.
|
|
//EndpointVolumeCallback* getEndpointVolumeCallback();
|
|
//Endpoint* getEndpoint();
|
|
|
|
//std::wstring epName;
|
|
BackEndpointVolumeCallbackInfo* getCallbackInfo();
|
|
uint32_t getChannelCount();
|
|
|
|
void setIndex(uint64_t idx);
|
|
uint64_t getIndex();
|
|
void setVolume(int channel, float volume);
|
|
|
|
std::wstring getName();
|
|
std::wstring getId();
|
|
|
|
void setFrontVisibilityInfo(EndpointState state, uint64_t frontIdx);
|
|
uint64_t getFrontVisibilityIndex();
|
|
EndpointState getFrontVisibilityState();
|
|
|
|
Flows getFlow();
|
|
float getVolume(int channel);
|
|
bool getMute();
|
|
size_t getState();
|
|
uint8_t getRoles();
|
|
void setRoles(Roles newRole);
|
|
void assignRoles(Roles newRole);
|
|
void removeRoles(Roles newRole);
|
|
|
|
void setVolume(NGuid guid, int channel, int value);
|
|
void setMute(NGuid guid, bool muted);
|
|
void setState(uint8_t state);
|
|
void setState(uint8_t state, uint64_t idx);
|
|
|
|
~EndpointHandler();
|
|
private:
|
|
uint64_t idx;
|
|
Endpoint *ep = nullptr;
|
|
EndpointVolumeCallback *epc = nullptr;
|
|
Flows flow;
|
|
BackEndpointVolumeCallbackInfo callbackInfo;
|
|
struct EndpointHandlerFrontVisibility {
|
|
EndpointState visibility = EndpointState::ENDPOINT_ALL;
|
|
uint64_t frontIdx = INT_MAX;
|
|
};
|
|
EndpointHandlerFrontVisibility ephfv;
|
|
//QSlider *slidy;
|
|
};
|
|
|
|
class OverseerHandler {
|
|
|
|
public:
|
|
OverseerHandler();
|
|
void setChangeFrontDefaultsFunction(std::function<void(Roles, std::wstring)> changeFrontDefaults);
|
|
void changeFrontDefaultsCallback(Roles role, std::wstring endpointId);
|
|
|
|
//void setReviseEndpointShowingFunction(std::function<void(std::wstring, EndpointState)> reviseEndpointShowing);
|
|
void reviseEndpointShowing(std::wstring endpointId, EndpointState state);
|
|
void setRemoveEndpointWidgetFunction(std::function<void(uint64_t)> removeEndpointWidget);
|
|
void setAddEndpointWidgetFunction(std::function<void(EndpointHandler*)> addEndpointWidget);
|
|
|
|
void setEndpointHandlers(std::vector<EndpointHandler*> ephs);
|
|
std::vector<EndpointHandler*> getPlaybackEndpointHandlers();
|
|
std::vector<EndpointHandler*> getCaptureEndpointHandlers();
|
|
std::vector<Endpoint*> getPlaybackEndpoints();
|
|
std::vector<Endpoint*> getCaptureEndpoints();
|
|
void pushBackEndpointHandler(EndpointHandler* eph, Flows flow);
|
|
uint64_t getPlaybackEndpointsCount();
|
|
uint64_t getCaptureEndpointsCount();
|
|
void reloadEndpointHandlers();
|
|
EndpointHandler* addEndpoint(std::wstring endpointId);
|
|
NGuid getGuid();
|
|
|
|
private:
|
|
Overseer *os;
|
|
std::vector<EndpointHandler*> playbackEndpointHandlers;
|
|
std::vector<EndpointHandler*> captureEndpointHandlers;
|
|
std::function<void(Roles, std::wstring /* endpointid */)> changeFrontDefaults;
|
|
std::function<void(uint64_t /* epw id */)> removeEndpointWidget;
|
|
std::function<void(EndpointHandler*)> addEndpointWidget;
|
|
|
|
//std::function<void(uint64_t /* device */, uint32_t /* channel */, float /* value */)> updateFrontVolumeCallback;
|
|
//std::function<void(uint64_t /* device */, bool /* mute */)> updateFrontMuteCallback;
|
|
|
|
};
|