add session
This commit is contained in:
parent
574c6f039e
commit
0dd016bb16
6 changed files with 79 additions and 28 deletions
|
|
@ -283,7 +283,7 @@ Endpoint::Endpoint(IMMDevice* ep, uint64_t idx){
|
|||
friendlyName = std::wstring(pv.pwszVal);
|
||||
|
||||
this->setFlow();
|
||||
if (this->endpointState == EndpointState::ENDPOINT_ACTIVE && this->flow == Flows::FLOW_PLAYBACK) {
|
||||
if (this->flow == Flows::FLOW_PLAYBACK) {
|
||||
activateEndpointSessions();
|
||||
}
|
||||
}
|
||||
|
|
@ -538,6 +538,14 @@ size_t Endpoint::getSessionCount() {
|
|||
return endpointSessions.size();
|
||||
}
|
||||
|
||||
void Endpoint::registerNewSessionNotification(EndpointNewSessionCallback* ensc){
|
||||
sessionManager->RegisterSessionNotification(ensc);
|
||||
}
|
||||
|
||||
void Endpoint::unregisterNewSessionNotification(EndpointNewSessionCallback* ensc){
|
||||
sessionManager->UnregisterSessionNotification(ensc);
|
||||
}
|
||||
|
||||
Endpoint::~Endpoint(){
|
||||
log_wdebugcpp(L"murio endpoint-san uwu");
|
||||
properties->Release();
|
||||
|
|
|
|||
|
|
@ -40,6 +40,8 @@ class Endpoint {
|
|||
std::vector<Session*> getSessions();
|
||||
size_t getSessionCount();
|
||||
void addSession(Session* session);
|
||||
void registerNewSessionNotification(EndpointNewSessionCallback* ensc);
|
||||
void unregisterNewSessionNotification(EndpointNewSessionCallback* ensc);
|
||||
|
||||
~Endpoint();
|
||||
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
||||
epc = new EndpointVolumeCallback(ep);
|
||||
ensc = new EndpointNewSessionCallback(this);
|
||||
this->callbackInfo.caller = osh->getGuid();
|
||||
|
||||
ep->registerNewSessionNotification(ensc);
|
||||
//epName = ep->getName();
|
||||
this->setBackEndpointVolumeCallbackInfoContent(this->getState());
|
||||
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++) {
|
||||
SessionHandler* sessionHandler = new SessionHandler(this, this->getSessions().at(i),i);
|
||||
sessionHandlers.push_back(sessionHandler);
|
||||
|
|
@ -148,6 +149,10 @@ void EndpointHandler::removeRoles(Roles newRole){
|
|||
ep->removeRoles(newRole);
|
||||
}
|
||||
|
||||
void EndpointHandler::setAddSessionWidgetFunction(std::function<void(SessionHandler*)> addSessionWidget) {
|
||||
this->addSessionWidget = addSessionWidget;
|
||||
}
|
||||
|
||||
/* sessions */
|
||||
size_t EndpointHandler::getSessionCount() {
|
||||
return ep->getSessionCount();
|
||||
|
|
@ -168,14 +173,14 @@ Endpoint* EndpointHandler::getEndpoint() {
|
|||
void EndpointHandler::addSession(Session* session) {
|
||||
ep->addSession(session);
|
||||
|
||||
if (this->getState() == EndpointState::ENDPOINT_ACTIVE) {
|
||||
SessionHandler* sessionHandler = new SessionHandler(this, session, (getSessionCount() - 1));
|
||||
sessionHandlers.push_back(sessionHandler);
|
||||
}
|
||||
this->addSessionWidget(sessionHandler);
|
||||
}
|
||||
|
||||
EndpointHandler::~EndpointHandler() {
|
||||
ep->removeVolumeCallback(epc);
|
||||
ep->unregisterNewSessionNotification(ensc);
|
||||
epc->Release();
|
||||
delete ep;
|
||||
}
|
||||
|
|
@ -315,7 +320,6 @@ void OverseerHandler::setRemoveEndpointWidgetFunction(std::function<void(uint64_
|
|||
this->removeEndpointWidget = removeEndpointWidget;
|
||||
}
|
||||
|
||||
|
||||
void OverseerHandler::setEndpointHandlers(std::vector<EndpointHandler*> ephs){
|
||||
this->playbackEndpointHandlers = ephs;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ class Endpoint;
|
|||
class EndpointVolumeCallback;
|
||||
class Overseer;
|
||||
class SessionHandler;
|
||||
class EndpointNewSessionCallback;
|
||||
|
||||
struct BackEndpointVolumeCallbackInfo {
|
||||
NGuid caller;
|
||||
|
|
@ -66,6 +67,7 @@ public:
|
|||
|
||||
/*Session*/
|
||||
void addSession(Session* session);
|
||||
void setAddSessionWidgetFunction(std::function<void(SessionHandler*)> addSessionWidget);
|
||||
|
||||
~EndpointHandler();
|
||||
private:
|
||||
|
|
@ -81,7 +83,9 @@ private:
|
|||
uint64_t frontIdx = INT_MAX;
|
||||
};
|
||||
EndpointHandlerFrontVisibility ephfv;
|
||||
EndpointNewSessionCallback* ensc;
|
||||
std::vector<SessionHandler*> sessionHandlers;
|
||||
std::function<void(SessionHandler*)> addSessionWidget;
|
||||
//QSlider *slidy;
|
||||
};
|
||||
|
||||
|
|
@ -109,7 +113,6 @@ public:
|
|||
EndpointHandler* addEndpoint(std::wstring endpointId, Flows *flow);
|
||||
NGuid getGuid();
|
||||
|
||||
/* Session's */
|
||||
/*
|
||||
* void setSessionVolumeCallback(std::function<void(float)> changeSessionVolume);
|
||||
* void setSessionVolume(float newValue, );
|
||||
|
|
@ -125,7 +128,6 @@ private:
|
|||
|
||||
/* Session's */
|
||||
std::function<void(float)> changeSessionVolume;
|
||||
|
||||
//std::function<void(uint64_t /* device */, uint32_t /* channel */, float /* value */)> updateFrontVolumeCallback;
|
||||
//std::function<void(uint64_t /* device */, bool /* mute */)> updateFrontMuteCallback;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#include "qtclasses.h"
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
@ -97,7 +97,7 @@ void SessionWidget::updateMainVolume(int newValue){
|
|||
|
||||
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
|
||||
int row = 0;
|
||||
row = 0;
|
||||
this->idx = idx;
|
||||
this->eph = eph;
|
||||
//todo: sussy
|
||||
|
|
@ -255,7 +255,7 @@ EndpointWidget::EndpointWidget(uint64_t idx, EndpointHandler* eph, QWidget *pare
|
|||
});
|
||||
timer->start(10);
|
||||
|
||||
/* sessions */
|
||||
/* First SessionWidget batch */
|
||||
for (size_t i = 0; i < eph->getSessionCount(); i++) {
|
||||
SessionWidget* sessionWidget = new SessionWidget(i, eph->getSessionHandlers().at(i), this);
|
||||
layout->addWidget(sessionWidget, row, 4);
|
||||
|
|
@ -263,6 +263,11 @@ EndpointWidget::EndpointWidget(uint64_t idx, EndpointHandler* eph, QWidget *pare
|
|||
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?
|
||||
layout->addItem(new QSpacerItem(1, 1, QSizePolicy::Minimum, QSizePolicy::Minimum), 1, 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");
|
||||
}
|
||||
|
||||
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() {
|
||||
timer->stop();
|
||||
delete timer;
|
||||
|
|
@ -280,17 +307,17 @@ EndpointWidget::~EndpointWidget() {
|
|||
void MainWindow::customEvent(QEvent* ev) {
|
||||
if (ev->type() == CustomQEvent::EndpointWidgetObsolete) {
|
||||
ev->setAccepted(true);
|
||||
this->removeEndpointWidget((EndpointWidgetEvent<uint64_t>*)ev);
|
||||
this->removeEndpointWidget((CustomWidgetEvent<uint64_t>*)ev);
|
||||
return;
|
||||
} else if (ev->type() == (QEvent::Type)CustomQEvent::EndpointWidgetCreated) {
|
||||
ev->setAccepted(true);
|
||||
this->addEndpointWidget((EndpointWidgetEvent<EndpointHandler*>*)ev);
|
||||
this->addEndpointWidget((CustomWidgetEvent<EndpointHandler*>*)ev);
|
||||
}
|
||||
// Make sure the rest of events are handled
|
||||
QMainWindow::customEvent(ev);
|
||||
}
|
||||
|
||||
void MainWindow::removeEndpointWidget(EndpointWidgetEvent<uint64_t>* ev){
|
||||
void MainWindow::removeEndpointWidget(CustomWidgetEvent<uint64_t>* ev){
|
||||
uint64_t i = ev->payload;
|
||||
this->ews.at(i)->setParent(nullptr);
|
||||
this->layout->removeWidget(ews.at(i));
|
||||
|
|
@ -311,7 +338,7 @@ void MainWindow::removeEndpointWidget(EndpointWidgetEvent<uint64_t>* ev){
|
|||
return;
|
||||
}
|
||||
|
||||
void MainWindow::addEndpointWidget(EndpointWidgetEvent<EndpointHandler*>* ev){
|
||||
void MainWindow::addEndpointWidget(CustomWidgetEvent<EndpointHandler*>* ev){
|
||||
EndpointWidget* epw = new EndpointWidget(this->ews.size(), ev->payload, widget);
|
||||
this->layout->addWidget(epw);
|
||||
ews.push_back(epw);
|
||||
|
|
@ -497,11 +524,11 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
|
|||
});
|
||||
|
||||
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) {
|
||||
QCoreApplication::instance()->postEvent(this, new EndpointWidgetEvent<EndpointHandler*>((QEvent::Type)CustomQEvent::EndpointWidgetCreated, eph));
|
||||
QCoreApplication::instance()->postEvent(this, new CustomWidgetEvent<EndpointHandler*>((QEvent::Type)CustomQEvent::EndpointWidgetCreated, eph));
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -60,13 +60,15 @@ enum CustomQEvent {
|
|||
EndpointWidgetObsolete = 1001,
|
||||
EndpointWidgetCreated = 1002,
|
||||
EndpointDefaultChange = 1003,
|
||||
SessionWidgetCreated = 1004,
|
||||
SessionWidgetObsolete = 1005
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
class EndpointWidgetEvent : public QEvent {
|
||||
class CustomWidgetEvent : public QEvent {
|
||||
|
||||
public:
|
||||
EndpointWidgetEvent(QEvent::Type type, T payload);
|
||||
CustomWidgetEvent(QEvent::Type type, T payload);
|
||||
T payload;
|
||||
|
||||
};
|
||||
|
|
@ -130,7 +132,14 @@ public slots:
|
|||
void updateMainVolume(int newValue);
|
||||
void updateMute(int checked);
|
||||
|
||||
protected:
|
||||
void customEvent(QEvent* ev) override;
|
||||
|
||||
private slots:
|
||||
void addSessionWidget(CustomWidgetEvent<SessionHandler*>* ev);
|
||||
|
||||
private:
|
||||
int row;
|
||||
QCheckBox *muteButton = nullptr;
|
||||
QLabel *mainLabel = nullptr, *leftChannelLabel = nullptr, *rightChannelLabel = nullptr;
|
||||
QSlider *mainSlider = nullptr;
|
||||
|
|
@ -140,7 +149,6 @@ private:
|
|||
QGridLayout *mainMuteLayout = nullptr;
|
||||
std::map<Roles, ExtendedCheckBox*> defaultRolesCheckBoxes;
|
||||
|
||||
|
||||
EndpointHandler* eph;
|
||||
size_t defaultRolesVectorSize = 4;
|
||||
QTimer* timer = nullptr;
|
||||
|
|
@ -168,8 +176,8 @@ protected:
|
|||
|
||||
private slots:
|
||||
void trayIconActivated(QSystemTrayIcon::ActivationReason reason);
|
||||
void removeEndpointWidget(EndpointWidgetEvent<uint64_t>* ev);
|
||||
void addEndpointWidget(EndpointWidgetEvent<EndpointHandler*>* ev);
|
||||
void removeEndpointWidget(CustomWidgetEvent<uint64_t>* ev);
|
||||
void addEndpointWidget(CustomWidgetEvent<EndpointHandler*>* ev);
|
||||
void reorderEndpointWidgetCollection();
|
||||
//TODO: destroy/empty existing EndpointWidgets
|
||||
//void setEndpointHandlers(std::vector<EndpointHandler*> *ephs);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue