Compare commits
2 commits
165aff07e4
...
1cee03aba6
| Author | SHA1 | Date | |
|---|---|---|---|
| 1cee03aba6 | |||
| a0ce3fa703 |
9 changed files with 173 additions and 34 deletions
|
|
@ -37,6 +37,22 @@ HRESULT EndpointNewSessionCallback::QueryInterface(REFIID riid, VOID **ppvInterf
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT EndpointNewSessionCallback::OnSessionCreated(IAudioSessionControl *NewSession) {
|
HRESULT EndpointNewSessionCallback::OnSessionCreated(IAudioSessionControl *NewSession) {
|
||||||
|
if (eph->getFlow() == Flows::FLOW_CAPTURE) return S_OK;
|
||||||
|
|
||||||
|
HRESULT result = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
|
||||||
|
IAudioSessionControl2* sessionControl;
|
||||||
|
//ISimmpleAudioVolume* sessionVolume;
|
||||||
|
if (FAILED(NewSession->QueryInterface(__uuidof(IAudioSessionControl2), (void**)&sessionControl))) { log_wdebugcpp(L"no nueva sesion......"); };
|
||||||
|
if (sessionControl) {
|
||||||
|
sessionControl->AddRef();
|
||||||
|
//sessionControl->QueryInterface(__uuidof(ISimpleAudioVolume), (void**)&sessionVolume);
|
||||||
|
Session* newSession = new Session(this->eph->getEndpoint(), sessionControl);
|
||||||
|
eph->addSession(newSession);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result == S_OK)
|
||||||
|
CoUninitialize();
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -267,7 +283,7 @@ Endpoint::Endpoint(IMMDevice* ep, uint64_t idx){
|
||||||
friendlyName = std::wstring(pv.pwszVal);
|
friendlyName = std::wstring(pv.pwszVal);
|
||||||
|
|
||||||
this->setFlow();
|
this->setFlow();
|
||||||
if (this->endpointState == EndpointState::ENDPOINT_ACTIVE && this->flow == Flows::FLOW_PLAYBACK) {
|
if (this->flow == Flows::FLOW_PLAYBACK) {
|
||||||
activateEndpointSessions();
|
activateEndpointSessions();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -299,6 +315,11 @@ void Endpoint::activateEndpointSessions() {
|
||||||
sessionEnumerator->Release();
|
sessionEnumerator->Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Endpoint::addSession(Session* session) {
|
||||||
|
session->setIndex(this->getSessionCount());
|
||||||
|
endpointSessions.push_back(session);
|
||||||
|
}
|
||||||
|
|
||||||
void Endpoint::activateEndpointVolume() {
|
void Endpoint::activateEndpointVolume() {
|
||||||
//bool extraThread = false;
|
//bool extraThread = false;
|
||||||
/*
|
/*
|
||||||
|
|
@ -517,6 +538,14 @@ size_t Endpoint::getSessionCount() {
|
||||||
return endpointSessions.size();
|
return endpointSessions.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Endpoint::registerNewSessionNotification(EndpointNewSessionCallback* ensc){
|
||||||
|
sessionManager->RegisterSessionNotification(ensc);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Endpoint::unregisterNewSessionNotification(EndpointNewSessionCallback* ensc){
|
||||||
|
sessionManager->UnregisterSessionNotification(ensc);
|
||||||
|
}
|
||||||
|
|
||||||
Endpoint::~Endpoint(){
|
Endpoint::~Endpoint(){
|
||||||
log_wdebugcpp(L"murio endpoint-san uwu");
|
log_wdebugcpp(L"murio endpoint-san uwu");
|
||||||
properties->Release();
|
properties->Release();
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,9 @@ class Endpoint {
|
||||||
/* sessions */
|
/* sessions */
|
||||||
std::vector<Session*> getSessions();
|
std::vector<Session*> getSessions();
|
||||||
size_t getSessionCount();
|
size_t getSessionCount();
|
||||||
|
void addSession(Session* session);
|
||||||
|
void registerNewSessionNotification(EndpointNewSessionCallback* ensc);
|
||||||
|
void unregisterNewSessionNotification(EndpointNewSessionCallback* ensc);
|
||||||
|
|
||||||
~Endpoint();
|
~Endpoint();
|
||||||
|
|
||||||
|
|
@ -135,7 +138,6 @@ class Overseer {
|
||||||
|
|
||||||
class EndpointNewSessionCallback : public IAudioSessionNotification {
|
class EndpointNewSessionCallback : public IAudioSessionNotification {
|
||||||
public:
|
public:
|
||||||
//EndpointSituationCallback(IMMDeviceEnumerator *deviceEnumerator, std::vector<Endpoint*> playbackDevices);
|
|
||||||
EndpointNewSessionCallback(EndpointHandler *eph);
|
EndpointNewSessionCallback(EndpointHandler *eph);
|
||||||
ULONG AddRef();
|
ULONG AddRef();
|
||||||
ULONG Release();
|
ULONG Release();
|
||||||
|
|
|
||||||
|
|
@ -71,6 +71,11 @@ HRESULT SessionStateCallback::OnGroupingParamChanged(LPCGUID NewGroupingParam, L
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT SessionStateCallback::OnStateChanged(AudioSessionState NewState) {
|
HRESULT SessionStateCallback::OnStateChanged(AudioSessionState NewState) {
|
||||||
|
/* enum _AudioSessionState {
|
||||||
|
* AudioSessionStateInactive,
|
||||||
|
* AudioSessionStateActive,
|
||||||
|
* AudioSessionStateExpired
|
||||||
|
* } AudioSessionState; */
|
||||||
/*
|
/*
|
||||||
* char *pszState = "?????";
|
* char *pszState = "?????";
|
||||||
*
|
*
|
||||||
|
|
@ -85,7 +90,6 @@ HRESULT SessionStateCallback::OnStateChanged(AudioSessionState NewState) {
|
||||||
* }
|
* }
|
||||||
* printf("New session state = %s\n", pszState);
|
* printf("New session state = %s\n", pszState);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -126,6 +130,20 @@ Session::Session(Endpoint* ep, IAudioSessionControl2* sessionControl, size_t idx
|
||||||
this->sessionControl = sessionControl;
|
this->sessionControl = sessionControl;
|
||||||
this->idx = idx;
|
this->idx = idx;
|
||||||
|
|
||||||
|
AudioSessionState msState;
|
||||||
|
sessionControl->GetState(&msState);
|
||||||
|
switch (msState) {
|
||||||
|
case AudioSessionState::AudioSessionStateActive:
|
||||||
|
this->sessionState = SessionState::ACTIVE;
|
||||||
|
break;
|
||||||
|
case AudioSessionState::AudioSessionStateInactive:
|
||||||
|
this->sessionState = SessionState::INACTIVE;
|
||||||
|
break;
|
||||||
|
case AudioSessionState::AudioSessionStateExpired:
|
||||||
|
this->sessionState = SessionState::EXPIRED;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
sessionControl->QueryInterface(__uuidof(ISimpleAudioVolume), (void**)&sessionVolume);
|
sessionControl->QueryInterface(__uuidof(ISimpleAudioVolume), (void**)&sessionVolume);
|
||||||
DWORD pid;
|
DWORD pid;
|
||||||
sessionControl->GetProcessId(&pid);
|
sessionControl->GetProcessId(&pid);
|
||||||
|
|
@ -180,6 +198,10 @@ void Session::setVolume(NGuid guid, int channel, float volume) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Session::setIndex(size_t idx) {
|
||||||
|
this->idx = idx;
|
||||||
|
}
|
||||||
|
|
||||||
void Session::setMute(NGuid guid, bool muted) {
|
void Session::setMute(NGuid guid, bool muted) {
|
||||||
GUID tempMsGuid = NGuidToGUID(guid);
|
GUID tempMsGuid = NGuidToGUID(guid);
|
||||||
if(FAILED(sessionVolume->SetMute(muted, &tempMsGuid))) { log_wdebugcpp(std::wstring(L"SessionVolume null?")); };
|
if(FAILED(sessionVolume->SetMute(muted, &tempMsGuid))) { log_wdebugcpp(std::wstring(L"SessionVolume null?")); };
|
||||||
|
|
@ -268,6 +290,15 @@ wchar_t* fileDescription = NULL;
|
||||||
return exePath;
|
return exePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//todo: conflicting names. change callback name
|
||||||
|
void Session::setState(SessionState state) {
|
||||||
|
sessionState = state;
|
||||||
|
}
|
||||||
|
|
||||||
|
SessionState Session::getState() {
|
||||||
|
return sessionState;
|
||||||
|
}
|
||||||
|
|
||||||
void Session::setStateCallback(SessionStateCallback *ssc){
|
void Session::setStateCallback(SessionStateCallback *ssc){
|
||||||
sessionControl->RegisterAudioSessionNotification((IAudioSessionEvents*) ssc);
|
sessionControl->RegisterAudioSessionNotification((IAudioSessionEvents*) ssc);
|
||||||
}
|
}
|
||||||
|
|
@ -275,3 +306,8 @@ void Session::setStateCallback(SessionStateCallback *ssc){
|
||||||
void Session::removeStateCallback(SessionStateCallback *ssc){
|
void Session::removeStateCallback(SessionStateCallback *ssc){
|
||||||
sessionControl->UnregisterAudioSessionNotification((IAudioSessionEvents*) ssc);
|
sessionControl->UnregisterAudioSessionNotification((IAudioSessionEvents*) ssc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Session::~Session() {
|
||||||
|
sessionControl->Release();
|
||||||
|
sessionVolume->Release();
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,19 +30,25 @@ class Session {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Session(Endpoint* ep, IAudioSessionControl2* sessionControl, size_t idx);
|
Session(Endpoint* ep, IAudioSessionControl2* sessionControl, size_t idx);
|
||||||
|
Session(Endpoint* ep, IAudioSessionControl2* sessionControl) : Session(ep, sessionControl, SIZE_MAX) {};
|
||||||
void setVolume(NGuid guid, int channel, float volume);
|
void setVolume(NGuid guid, int channel, float volume);
|
||||||
float getVolume(int channel);
|
float getVolume(int channel);
|
||||||
void setMute(NGuid guid, bool muted);
|
void setMute(NGuid guid, bool muted);
|
||||||
bool getMute();
|
bool getMute();
|
||||||
|
SessionState getState();
|
||||||
|
void setState(SessionState state);
|
||||||
|
void setIndex(size_t idx);
|
||||||
std::wstring getName();
|
std::wstring getName();
|
||||||
|
|
||||||
void setStateCallback(SessionStateCallback *ssc);
|
void setStateCallback(SessionStateCallback *ssc);
|
||||||
void removeStateCallback(SessionStateCallback *ssc);
|
void removeStateCallback(SessionStateCallback *ssc);
|
||||||
|
~Session();
|
||||||
//uint32_t getChannelCount();
|
//uint32_t getChannelCount();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::wstring fetchProcessName(DWORD pid);
|
std::wstring fetchProcessName(DWORD pid);
|
||||||
std::wstring sessionName;
|
std::wstring sessionName;
|
||||||
|
SessionState sessionState;
|
||||||
Endpoint* ep;
|
Endpoint* ep;
|
||||||
IAudioSessionControl2* sessionControl = nullptr;
|
IAudioSessionControl2* sessionControl = nullptr;
|
||||||
ISimpleAudioVolume* sessionVolume = nullptr;
|
ISimpleAudioVolume* sessionVolume = nullptr;
|
||||||
|
|
|
||||||
|
|
@ -9,13 +9,14 @@ EndpointHandler::EndpointHandler(uint64_t idx, Flows flow) {
|
||||||
this->ep = (flow == Flows::FLOW_PLAYBACK ? osh->getPlaybackEndpoints().at(idx) : osh->getCaptureEndpoints().at(idx));
|
this->ep = (flow == Flows::FLOW_PLAYBACK ? osh->getPlaybackEndpoints().at(idx) : osh->getCaptureEndpoints().at(idx));
|
||||||
|
|
||||||
epc = new EndpointVolumeCallback(ep);
|
epc = new EndpointVolumeCallback(ep);
|
||||||
|
ensc = new EndpointNewSessionCallback(this);
|
||||||
this->callbackInfo.caller = osh->getGuid();
|
this->callbackInfo.caller = osh->getGuid();
|
||||||
|
ep->registerNewSessionNotification(ensc);
|
||||||
//epName = ep->getName();
|
//epName = ep->getName();
|
||||||
this->setBackEndpointVolumeCallbackInfoContent(this->getState());
|
this->setBackEndpointVolumeCallbackInfoContent(this->getState());
|
||||||
osh->pushBackEndpointHandler(this, flow);
|
osh->pushBackEndpointHandler(this, flow);
|
||||||
|
|
||||||
if (this->flow == Flows::FLOW_PLAYBACK && this->getState() == EndpointState::ENDPOINT_ACTIVE) {
|
if (this->flow == Flows::FLOW_PLAYBACK) {
|
||||||
for (int i = 0; i < this->getSessionCount(); i++) {
|
for (int i = 0; i < this->getSessionCount(); i++) {
|
||||||
SessionHandler* sessionHandler = new SessionHandler(this, this->getSessions().at(i),i);
|
SessionHandler* sessionHandler = new SessionHandler(this, this->getSessions().at(i),i);
|
||||||
sessionHandlers.push_back(sessionHandler);
|
sessionHandlers.push_back(sessionHandler);
|
||||||
|
|
@ -148,6 +149,10 @@ void EndpointHandler::removeRoles(Roles newRole){
|
||||||
ep->removeRoles(newRole);
|
ep->removeRoles(newRole);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EndpointHandler::setAddSessionWidgetFunction(std::function<void(SessionHandler*)> addSessionWidget) {
|
||||||
|
this->addSessionWidget = addSessionWidget;
|
||||||
|
}
|
||||||
|
|
||||||
/* sessions */
|
/* sessions */
|
||||||
size_t EndpointHandler::getSessionCount() {
|
size_t EndpointHandler::getSessionCount() {
|
||||||
return ep->getSessionCount();
|
return ep->getSessionCount();
|
||||||
|
|
@ -161,8 +166,21 @@ std::vector<SessionHandler*> EndpointHandler::getSessionHandlers(){
|
||||||
return this->sessionHandlers;
|
return this->sessionHandlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Endpoint* EndpointHandler::getEndpoint() {
|
||||||
|
return this->ep;
|
||||||
|
}
|
||||||
|
|
||||||
|
void EndpointHandler::addSession(Session* session) {
|
||||||
|
ep->addSession(session);
|
||||||
|
|
||||||
|
SessionHandler* sessionHandler = new SessionHandler(this, session, (getSessionCount() - 1));
|
||||||
|
sessionHandlers.push_back(sessionHandler);
|
||||||
|
this->addSessionWidget(sessionHandler);
|
||||||
|
}
|
||||||
|
|
||||||
EndpointHandler::~EndpointHandler() {
|
EndpointHandler::~EndpointHandler() {
|
||||||
ep->removeVolumeCallback(epc);
|
ep->removeVolumeCallback(epc);
|
||||||
|
ep->unregisterNewSessionNotification(ensc);
|
||||||
epc->Release();
|
epc->Release();
|
||||||
delete ep;
|
delete ep;
|
||||||
}
|
}
|
||||||
|
|
@ -302,7 +320,6 @@ void OverseerHandler::setRemoveEndpointWidgetFunction(std::function<void(uint64_
|
||||||
this->removeEndpointWidget = removeEndpointWidget;
|
this->removeEndpointWidget = removeEndpointWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void OverseerHandler::setEndpointHandlers(std::vector<EndpointHandler*> ephs){
|
void OverseerHandler::setEndpointHandlers(std::vector<EndpointHandler*> ephs){
|
||||||
this->playbackEndpointHandlers = ephs;
|
this->playbackEndpointHandlers = ephs;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ class Endpoint;
|
||||||
class EndpointVolumeCallback;
|
class EndpointVolumeCallback;
|
||||||
class Overseer;
|
class Overseer;
|
||||||
class SessionHandler;
|
class SessionHandler;
|
||||||
|
class EndpointNewSessionCallback;
|
||||||
|
|
||||||
struct BackEndpointVolumeCallbackInfo {
|
struct BackEndpointVolumeCallbackInfo {
|
||||||
NGuid caller;
|
NGuid caller;
|
||||||
|
|
@ -61,6 +62,12 @@ public:
|
||||||
/* sessions */
|
/* sessions */
|
||||||
size_t getSessionCount();
|
size_t getSessionCount();
|
||||||
std::vector<SessionHandler*> getSessionHandlers();
|
std::vector<SessionHandler*> getSessionHandlers();
|
||||||
|
void createNewSession();
|
||||||
|
Endpoint* getEndpoint();
|
||||||
|
|
||||||
|
/*Session*/
|
||||||
|
void addSession(Session* session);
|
||||||
|
void setAddSessionWidgetFunction(std::function<void(SessionHandler*)> addSessionWidget);
|
||||||
|
|
||||||
~EndpointHandler();
|
~EndpointHandler();
|
||||||
private:
|
private:
|
||||||
|
|
@ -76,7 +83,9 @@ private:
|
||||||
uint64_t frontIdx = INT_MAX;
|
uint64_t frontIdx = INT_MAX;
|
||||||
};
|
};
|
||||||
EndpointHandlerFrontVisibility ephfv;
|
EndpointHandlerFrontVisibility ephfv;
|
||||||
|
EndpointNewSessionCallback* ensc;
|
||||||
std::vector<SessionHandler*> sessionHandlers;
|
std::vector<SessionHandler*> sessionHandlers;
|
||||||
|
std::function<void(SessionHandler*)> addSessionWidget;
|
||||||
//QSlider *slidy;
|
//QSlider *slidy;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -104,7 +113,6 @@ public:
|
||||||
EndpointHandler* addEndpoint(std::wstring endpointId, Flows *flow);
|
EndpointHandler* addEndpoint(std::wstring endpointId, Flows *flow);
|
||||||
NGuid getGuid();
|
NGuid getGuid();
|
||||||
|
|
||||||
/* Session's */
|
|
||||||
/*
|
/*
|
||||||
* void setSessionVolumeCallback(std::function<void(float)> changeSessionVolume);
|
* void setSessionVolumeCallback(std::function<void(float)> changeSessionVolume);
|
||||||
* void setSessionVolume(float newValue, );
|
* void setSessionVolume(float newValue, );
|
||||||
|
|
@ -120,7 +128,6 @@ private:
|
||||||
|
|
||||||
/* Session's */
|
/* Session's */
|
||||||
std::function<void(float)> changeSessionVolume;
|
std::function<void(float)> changeSessionVolume;
|
||||||
|
|
||||||
//std::function<void(uint64_t /* device */, uint32_t /* channel */, float /* value */)> updateFrontVolumeCallback;
|
//std::function<void(uint64_t /* device */, uint32_t /* channel */, float /* value */)> updateFrontVolumeCallback;
|
||||||
//std::function<void(uint64_t /* device */, bool /* mute */)> updateFrontMuteCallback;
|
//std::function<void(uint64_t /* device */, bool /* mute */)> updateFrontMuteCallback;
|
||||||
|
|
||||||
|
|
|
||||||
25
src/global.h
25
src/global.h
|
|
@ -31,24 +31,31 @@ enum AudioChannel {
|
||||||
};
|
};
|
||||||
|
|
||||||
enum EndpointState {
|
enum EndpointState {
|
||||||
ENDPOINT_ACTIVE = (1 << 0),
|
ENDPOINT_ACTIVE = (1 << 0),
|
||||||
ENDPOINT_DISABLED = (1 << 1),
|
ENDPOINT_DISABLED = (1 << 1),
|
||||||
ENDPOINT_NOTPRESENT = (1 << 2),
|
ENDPOINT_NOTPRESENT = (1 << 2),
|
||||||
ENDPOINT_UNPLUGGED = (1 << 3),
|
ENDPOINT_UNPLUGGED = (1 << 3),
|
||||||
ENDPOINT_ALL = 0x0F
|
ENDPOINT_ALL = 0x0F
|
||||||
|
};
|
||||||
|
|
||||||
|
enum SessionState {
|
||||||
|
ACTIVE = (1 << 0),
|
||||||
|
INACTIVE = (1 << 1),
|
||||||
|
EXPIRED = (1 << 2),
|
||||||
|
ALL = 0x07
|
||||||
};
|
};
|
||||||
|
|
||||||
enum Flows {
|
enum Flows {
|
||||||
FLOW_PLAYBACK = (1 << 0),
|
FLOW_PLAYBACK = (1 << 0),
|
||||||
FLOW_CAPTURE = (1 << 1),
|
FLOW_CAPTURE = (1 << 1),
|
||||||
FLOW_BOTH = (1 << 2),
|
FLOW_BOTH = (1 << 2),
|
||||||
};
|
};
|
||||||
|
|
||||||
enum Roles {
|
enum Roles {
|
||||||
ROLE_CONSOLE = (1 << 0),
|
ROLE_CONSOLE = (1 << 0),
|
||||||
ROLE_MULTIMEDIA = (1 << 1),
|
ROLE_MULTIMEDIA = (1 << 1),
|
||||||
ROLE_COMMUNICATIONS = (1 << 2),
|
ROLE_COMMUNICATIONS = (1 << 2),
|
||||||
ROLE_ALL = 0x07,
|
ROLE_ALL = 0x07,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct NGuid {
|
struct NGuid {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#include "qtclasses.h"
|
#include "qtclasses.h"
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
EndpointWidgetEvent<T>::EndpointWidgetEvent(QEvent::Type type, T payload) : QEvent(type){
|
CustomWidgetEvent<T>::CustomWidgetEvent(QEvent::Type type, T payload) : QEvent(type){
|
||||||
this->payload = payload;
|
this->payload = payload;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -97,7 +97,7 @@ void SessionWidget::updateMainVolume(int newValue){
|
||||||
|
|
||||||
EndpointWidget::EndpointWidget(uint64_t idx, EndpointHandler* eph, QWidget *parent) : QWidget(parent){
|
EndpointWidget::EndpointWidget(uint64_t idx, EndpointHandler* eph, QWidget *parent) : QWidget(parent){
|
||||||
//todo: based on qgridlayout, name+mute should be its own widget, same with channels
|
//todo: based on qgridlayout, name+mute should be its own widget, same with channels
|
||||||
int row = 0;
|
row = 0;
|
||||||
this->idx = idx;
|
this->idx = idx;
|
||||||
this->eph = eph;
|
this->eph = eph;
|
||||||
//todo: sussy
|
//todo: sussy
|
||||||
|
|
@ -255,7 +255,7 @@ EndpointWidget::EndpointWidget(uint64_t idx, EndpointHandler* eph, QWidget *pare
|
||||||
});
|
});
|
||||||
timer->start(10);
|
timer->start(10);
|
||||||
|
|
||||||
/* sessions */
|
/* First SessionWidget batch */
|
||||||
for (size_t i = 0; i < eph->getSessionCount(); i++) {
|
for (size_t i = 0; i < eph->getSessionCount(); i++) {
|
||||||
SessionWidget* sessionWidget = new SessionWidget(i, eph->getSessionHandlers().at(i), this);
|
SessionWidget* sessionWidget = new SessionWidget(i, eph->getSessionHandlers().at(i), this);
|
||||||
layout->addWidget(sessionWidget, row, 4);
|
layout->addWidget(sessionWidget, row, 4);
|
||||||
|
|
@ -263,6 +263,11 @@ EndpointWidget::EndpointWidget(uint64_t idx, EndpointHandler* eph, QWidget *pare
|
||||||
sessionWidgets.push_back(sessionWidget);
|
sessionWidgets.push_back(sessionWidget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* New SessionWidget callback */
|
||||||
|
eph->setAddSessionWidgetFunction([this](SessionHandler* sessionHandler) {
|
||||||
|
QCoreApplication::instance()->postEvent(this, new CustomWidgetEvent<SessionHandler*>((QEvent::Type)CustomQEvent::SessionWidgetCreated, sessionHandler));
|
||||||
|
});
|
||||||
|
|
||||||
//todo parent?
|
//todo parent?
|
||||||
layout->addItem(new QSpacerItem(1, 1, QSizePolicy::Minimum, QSizePolicy::Minimum), 1, 0);
|
layout->addItem(new QSpacerItem(1, 1, QSizePolicy::Minimum, QSizePolicy::Minimum), 1, 0);
|
||||||
layout->addItem(new QSpacerItem(1, 1, QSizePolicy::Minimum, QSizePolicy::Minimum), 4, 0);
|
layout->addItem(new QSpacerItem(1, 1, QSizePolicy::Minimum, QSizePolicy::Minimum), 4, 0);
|
||||||
|
|
@ -271,6 +276,28 @@ EndpointWidget::EndpointWidget(uint64_t idx, EndpointHandler* eph, QWidget *pare
|
||||||
log_debugcpp("ENDPOINT_WIDGETED");
|
log_debugcpp("ENDPOINT_WIDGETED");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EndpointWidget::addSessionWidget(CustomWidgetEvent<SessionHandler*>* ev){
|
||||||
|
SessionWidget* sw = new SessionWidget(this->sessionWidgets.size(), ev->payload, this);
|
||||||
|
this->layout->addWidget(sw, row, 4);
|
||||||
|
row++;
|
||||||
|
sessionWidgets.push_back(sw);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void EndpointWidget::customEvent(QEvent* ev) {
|
||||||
|
if (ev->type() == (QEvent::Type)CustomQEvent::SessionWidgetCreated) {
|
||||||
|
ev->setAccepted(true);
|
||||||
|
this->addSessionWidget((CustomWidgetEvent<SessionHandler*>*) ev);
|
||||||
|
return;
|
||||||
|
} else if (ev->type() == (QEvent::Type)CustomQEvent::SessionWidgetObsolete) {
|
||||||
|
ev->setAccepted(true);
|
||||||
|
//this->addEndpointWidget((CustomWidgetEvent<EndpointHandler*>*)ev);
|
||||||
|
}
|
||||||
|
// Make sure the rest of events are handled
|
||||||
|
QWidget::customEvent(ev);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
EndpointWidget::~EndpointWidget() {
|
EndpointWidget::~EndpointWidget() {
|
||||||
timer->stop();
|
timer->stop();
|
||||||
delete timer;
|
delete timer;
|
||||||
|
|
@ -280,17 +307,17 @@ EndpointWidget::~EndpointWidget() {
|
||||||
void MainWindow::customEvent(QEvent* ev) {
|
void MainWindow::customEvent(QEvent* ev) {
|
||||||
if (ev->type() == CustomQEvent::EndpointWidgetObsolete) {
|
if (ev->type() == CustomQEvent::EndpointWidgetObsolete) {
|
||||||
ev->setAccepted(true);
|
ev->setAccepted(true);
|
||||||
this->removeEndpointWidget((EndpointWidgetEvent<uint64_t>*)ev);
|
this->removeEndpointWidget((CustomWidgetEvent<uint64_t>*)ev);
|
||||||
return;
|
return;
|
||||||
} else if (ev->type() == (QEvent::Type)CustomQEvent::EndpointWidgetCreated) {
|
} else if (ev->type() == (QEvent::Type)CustomQEvent::EndpointWidgetCreated) {
|
||||||
ev->setAccepted(true);
|
ev->setAccepted(true);
|
||||||
this->addEndpointWidget((EndpointWidgetEvent<EndpointHandler*>*)ev);
|
this->addEndpointWidget((CustomWidgetEvent<EndpointHandler*>*)ev);
|
||||||
}
|
}
|
||||||
// Make sure the rest of events are handled
|
// Make sure the rest of events are handled
|
||||||
QMainWindow::customEvent(ev);
|
QMainWindow::customEvent(ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::removeEndpointWidget(EndpointWidgetEvent<uint64_t>* ev){
|
void MainWindow::removeEndpointWidget(CustomWidgetEvent<uint64_t>* ev){
|
||||||
uint64_t i = ev->payload;
|
uint64_t i = ev->payload;
|
||||||
this->ews.at(i)->setParent(nullptr);
|
this->ews.at(i)->setParent(nullptr);
|
||||||
this->layout->removeWidget(ews.at(i));
|
this->layout->removeWidget(ews.at(i));
|
||||||
|
|
@ -311,7 +338,7 @@ void MainWindow::removeEndpointWidget(EndpointWidgetEvent<uint64_t>* ev){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::addEndpointWidget(EndpointWidgetEvent<EndpointHandler*>* ev){
|
void MainWindow::addEndpointWidget(CustomWidgetEvent<EndpointHandler*>* ev){
|
||||||
EndpointWidget* epw = new EndpointWidget(this->ews.size(), ev->payload, widget);
|
EndpointWidget* epw = new EndpointWidget(this->ews.size(), ev->payload, widget);
|
||||||
this->layout->addWidget(epw);
|
this->layout->addWidget(epw);
|
||||||
ews.push_back(epw);
|
ews.push_back(epw);
|
||||||
|
|
@ -497,11 +524,11 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
|
||||||
});
|
});
|
||||||
|
|
||||||
osh->setRemoveEndpointWidgetFunction([this](uint64_t index) {
|
osh->setRemoveEndpointWidgetFunction([this](uint64_t index) {
|
||||||
QCoreApplication::instance()->postEvent(this, new EndpointWidgetEvent<uint64_t>((QEvent::Type)CustomQEvent::EndpointWidgetObsolete, index));
|
QCoreApplication::instance()->postEvent(this, new CustomWidgetEvent<uint64_t>((QEvent::Type)CustomQEvent::EndpointWidgetObsolete, index));
|
||||||
});
|
});
|
||||||
|
|
||||||
osh->setAddEndpointWidgetFunction([this](EndpointHandler* eph) {
|
osh->setAddEndpointWidgetFunction([this](EndpointHandler* eph) {
|
||||||
QCoreApplication::instance()->postEvent(this, new EndpointWidgetEvent<EndpointHandler*>((QEvent::Type)CustomQEvent::EndpointWidgetCreated, eph));
|
QCoreApplication::instance()->postEvent(this, new CustomWidgetEvent<EndpointHandler*>((QEvent::Type)CustomQEvent::EndpointWidgetCreated, eph));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -58,15 +58,17 @@
|
||||||
*/
|
*/
|
||||||
enum CustomQEvent {
|
enum CustomQEvent {
|
||||||
EndpointWidgetObsolete = 1001,
|
EndpointWidgetObsolete = 1001,
|
||||||
EndpointWidgetCreated = 1002,
|
EndpointWidgetCreated = 1002,
|
||||||
EndpointDefaultChange = 1003,
|
EndpointDefaultChange = 1003,
|
||||||
|
SessionWidgetCreated = 1004,
|
||||||
|
SessionWidgetObsolete = 1005
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
class EndpointWidgetEvent : public QEvent {
|
class CustomWidgetEvent : public QEvent {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
EndpointWidgetEvent(QEvent::Type type, T payload);
|
CustomWidgetEvent(QEvent::Type type, T payload);
|
||||||
T payload;
|
T payload;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
@ -130,7 +132,14 @@ public slots:
|
||||||
void updateMainVolume(int newValue);
|
void updateMainVolume(int newValue);
|
||||||
void updateMute(int checked);
|
void updateMute(int checked);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void customEvent(QEvent* ev) override;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void addSessionWidget(CustomWidgetEvent<SessionHandler*>* ev);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
int row;
|
||||||
QCheckBox *muteButton = nullptr;
|
QCheckBox *muteButton = nullptr;
|
||||||
QLabel *mainLabel = nullptr, *leftChannelLabel = nullptr, *rightChannelLabel = nullptr;
|
QLabel *mainLabel = nullptr, *leftChannelLabel = nullptr, *rightChannelLabel = nullptr;
|
||||||
QSlider *mainSlider = nullptr;
|
QSlider *mainSlider = nullptr;
|
||||||
|
|
@ -140,7 +149,6 @@ private:
|
||||||
QGridLayout *mainMuteLayout = nullptr;
|
QGridLayout *mainMuteLayout = nullptr;
|
||||||
std::map<Roles, ExtendedCheckBox*> defaultRolesCheckBoxes;
|
std::map<Roles, ExtendedCheckBox*> defaultRolesCheckBoxes;
|
||||||
|
|
||||||
|
|
||||||
EndpointHandler* eph;
|
EndpointHandler* eph;
|
||||||
size_t defaultRolesVectorSize = 4;
|
size_t defaultRolesVectorSize = 4;
|
||||||
QTimer* timer = nullptr;
|
QTimer* timer = nullptr;
|
||||||
|
|
@ -168,8 +176,8 @@ protected:
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void trayIconActivated(QSystemTrayIcon::ActivationReason reason);
|
void trayIconActivated(QSystemTrayIcon::ActivationReason reason);
|
||||||
void removeEndpointWidget(EndpointWidgetEvent<uint64_t>* ev);
|
void removeEndpointWidget(CustomWidgetEvent<uint64_t>* ev);
|
||||||
void addEndpointWidget(EndpointWidgetEvent<EndpointHandler*>* ev);
|
void addEndpointWidget(CustomWidgetEvent<EndpointHandler*>* ev);
|
||||||
void reorderEndpointWidgetCollection();
|
void reorderEndpointWidgetCollection();
|
||||||
//TODO: destroy/empty existing EndpointWidgets
|
//TODO: destroy/empty existing EndpointWidgets
|
||||||
//void setEndpointHandlers(std::vector<EndpointHandler*> *ephs);
|
//void setEndpointHandlers(std::vector<EndpointHandler*> *ephs);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue