dynamically updated session name
This commit is contained in:
parent
170d52067b
commit
0880305b23
11 changed files with 51 additions and 36 deletions
|
|
@ -1,6 +1,6 @@
|
|||
QMAKE_CXXFLAGS += --target=x86_64-w64-mingw32 -g -gcodeview
|
||||
QMAKE_LFLAGS += --target=x86_64-w64-mingw32 -g -Wl,-pdb= -v
|
||||
LIBS += -LC:/capybara/libclang/x86_64-w64-mingw32/lib -lWinmm -lodbc32 -lodbccp32 -luuid -loleaut32 -lole32 -lshell32 -ladvapi32 -lcomdlg32 -lwinspool -lgdi32 -luser32 -lkernel32
|
||||
LIBS += -LC:/capybara/libclang/x86_64-w64-mingw32/lib -lWinmm -lodbc32 -lodbccp32 -luuid -loleaut32 -lole32 -lshell32 -ladvapi32 -lcomdlg32 -lwinspool -lgdi32 -luser32 -lkernel32 -lpropsys
|
||||
#"kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" -luuid -loleaut32 -lole32 -lshell32 -ladvapi32 -lcomdlg32 -lwinspool -lgdi32 -luser32 -lkernel32
|
||||
DEFINES += DEBUG QT_LOGGING_TO_CONSOLE=1 WIN32_LEAN_AND_MEAN
|
||||
CONFIG += debug
|
||||
|
|
|
|||
|
|
@ -133,14 +133,16 @@ HRESULT EndpointVolumeCallback::OnNotify(PAUDIO_VOLUME_NOTIFICATION_DATA pNotify
|
|||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* EndpointSituationCallback::EndpointSituationCallback(IMMDeviceEnumerator *deviceEnumerator, std::vector<Endpoint*> playbackDevices){
|
||||
* this->deviceEnumerator = deviceEnumerator;
|
||||
* EndpointSituationCallback::EndpointSituationCallback(std::vector<Endpoint*>* playbackDevices, std::vector<Endpoint*>* captureDevices){
|
||||
* this->captureDevices = captureDevices;
|
||||
* this->playbackDevices = playbackDevices;
|
||||
* }
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
ULONG EndpointSituationCallback::AddRef(){
|
||||
return InterlockedIncrement(&ref);
|
||||
}
|
||||
|
|
@ -226,15 +228,11 @@ HRESULT EndpointSituationCallback::OnDeviceStateChanged(LPCWSTR pwstrDeviceId, D
|
|||
|
||||
HRESULT EndpointSituationCallback::OnPropertyValueChanged(LPCWSTR pwstrDeviceId, const PROPERTYKEY key) {
|
||||
|
||||
/*
|
||||
* log_debugcpp(" -->Changed device property " +
|
||||
* key.fmtid.Data1 + key.fmtid.Data2 + key.fmtid.Data3 + "\n" +
|
||||
* key.fmtid.Data4[0]+ key.fmtid.Data4[1]+ "\n"+
|
||||
* key.fmtid.Data4[2]+ key.fmtid.Data4[3] + "\n"+
|
||||
* key.fmtid.Data4[4]+ key.fmtid.Data4[5] + "\n"+
|
||||
* key.fmtid.Data4[6]+ key.fmtid.Data4[7]+ "\n"+
|
||||
* " pid " + key.pid);
|
||||
*/
|
||||
/* Lacking impl again? */
|
||||
PWSTR test;
|
||||
HRESULT ctrl = PSGetNameFromPropertyKey(key, &test);
|
||||
if (ctrl == S_OK) log_wdebugcpp(test);
|
||||
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
|
@ -256,10 +254,10 @@ Endpoint::Endpoint(IMMDevice* ep, uint64_t idx){
|
|||
|
||||
reloadEndpointChannels();
|
||||
|
||||
/* todo: check header
|
||||
* if(FAILED(endpoint->Activate(__uuidof(IAudioMeterInformation),
|
||||
* CLSCTX_ALL, NULL, (void**)&endpointPeakMeter))) { log_debugcpp("peakbros..."); }
|
||||
*/
|
||||
//todo: check header
|
||||
// if(FAILED(endpoint->Activate(__uuidof(IAudioMeterInformation),
|
||||
// CLSCTX_ALL, NULL, (void**)&endpointPeakMeter))) { log_debugcpp("peakbros..."); }
|
||||
|
||||
|
||||
//todo:: atexit into exit Gather ID
|
||||
LPWSTR tempString = nullptr;
|
||||
|
|
@ -668,7 +666,7 @@ Endpoint* Overseer::addEndpoint(std::wstring endpointId, /* out */Flows* flow =
|
|||
return endpoint;
|
||||
}
|
||||
|
||||
Overseer::Overseer() { //: epsc(deviceEnumerator, playbackDevices){
|
||||
Overseer::Overseer() { //: epsc(&playbackDevices, &captureDevices){
|
||||
//Initializing COM library
|
||||
log_debugcpp("Initializing Overseer");
|
||||
initCOMLibrary();
|
||||
|
|
|
|||
|
|
@ -61,9 +61,9 @@ class Endpoint {
|
|||
unsigned long endpointState;
|
||||
Roles endpointRoles = (Roles)0;
|
||||
uint64_t idx;
|
||||
/* Not implemented in llvm-mingw. Sad!
|
||||
* IAudioMeterInformation *endpointPeakMeter = nullptr;
|
||||
*/
|
||||
//Not implemented in llvm-mingw. Sad!
|
||||
//IAudioMeterInformation *endpointPeakMeter = nullptr;
|
||||
|
||||
};
|
||||
|
||||
class EndpointVolumeCallback : public IAudioEndpointVolumeCallback {
|
||||
|
|
@ -85,6 +85,7 @@ class EndpointVolumeCallback : public IAudioEndpointVolumeCallback {
|
|||
class EndpointSituationCallback : public IMMNotificationClient {
|
||||
public:
|
||||
//EndpointSituationCallback(IMMDeviceEnumerator *deviceEnumerator, std::vector<Endpoint*> playbackDevices, std::vector<Endpoint*> captureDevices);
|
||||
//EndpointSituationCallback(std::vector<Endpoint*>* playbackDevices, std::vector<Endpoint*>* captureDevices);
|
||||
ULONG AddRef();
|
||||
ULONG Release();
|
||||
HRESULT QueryInterface(REFIID riid, VOID **ppvInterface);
|
||||
|
|
@ -97,15 +98,16 @@ class EndpointSituationCallback : public IMMNotificationClient {
|
|||
private:
|
||||
ULONG ref = 1;
|
||||
//IMMDeviceEnumerator *deviceEnumerator;
|
||||
//std::vector<Endpoint*> playbackDevices;
|
||||
//std::vector<Endpoint*> captureDevices;
|
||||
//std::vector<Endpoint*>* playbackDevices;
|
||||
//std::vector<Endpoint*>* captureDevices;
|
||||
};
|
||||
|
||||
class Overseer {
|
||||
//TODO singleton?
|
||||
|
||||
public:
|
||||
Overseer();
|
||||
void openControlPanel();
|
||||
//todo: restore/overseer
|
||||
std::vector<Endpoint*> getPlaybackEndpoints();
|
||||
std::vector<Endpoint*> getCaptureEndpoints();
|
||||
|
||||
|
|
|
|||
|
|
@ -37,6 +37,8 @@ HRESULT SessionStateCallback::QueryInterface(REFIID riid, VOID **ppvInterface) {
|
|||
}
|
||||
|
||||
HRESULT SessionStateCallback::OnDisplayNameChanged(LPCWSTR NewDisplayName, LPCGUID EventContext) {
|
||||
sh->setName(std::wstring(NewDisplayName));
|
||||
sh->getVolumeInfo()->isNameChanged = true;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
|
@ -150,6 +152,10 @@ std::wstring Session::getName() {
|
|||
return sessionName;
|
||||
}
|
||||
|
||||
void Session::setName(std::wstring newName) {
|
||||
this->sessionName = newName;
|
||||
}
|
||||
|
||||
bool Session::getMute() {
|
||||
BOOL mut;
|
||||
if(FAILED(sessionVolume->GetMute(&mut))) { /* TIP: Below */ }
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ class Session {
|
|||
void setState(SessionState state);
|
||||
void setIndex(size_t idx);
|
||||
std::wstring getName();
|
||||
|
||||
void setName(std::wstring newName);
|
||||
void setStateCallback(SessionStateCallback *ssc);
|
||||
void removeStateCallback(SessionStateCallback *ssc);
|
||||
~Session();
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
#include <combaseapi.h>
|
||||
#include <initguid.h>
|
||||
#include <Propidl.h>
|
||||
#include <propsys.h>
|
||||
#include <functiondiscoverykeys_devpkey.h>
|
||||
//#include <debugapi.h>
|
||||
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ public:
|
|||
void setVolume(int channel, float volume);
|
||||
|
||||
std::wstring getName();
|
||||
void setName(std::wstring newName);
|
||||
std::wstring getId();
|
||||
|
||||
void setFrontVisibilityInfo(EndpointState state, uint64_t frontIdx);
|
||||
|
|
|
|||
|
|
@ -32,6 +32,10 @@ std::wstring SessionHandler::getName(){
|
|||
return session->getName();
|
||||
}
|
||||
|
||||
void SessionHandler::setName(std::wstring newName){
|
||||
session->setName(newName);
|
||||
}
|
||||
|
||||
bool SessionHandler::getMute(){
|
||||
return session->getMute();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ struct SessionVolumeInfo {
|
|||
bool muted;
|
||||
float mainVolume;
|
||||
NGuid caller;
|
||||
|
||||
bool isNameChanged = false;
|
||||
//size_t channels;
|
||||
//std::vector<float> channelVolumes;
|
||||
};
|
||||
|
|
@ -29,6 +29,7 @@ class SessionHandler {
|
|||
void setState(SessionState state);
|
||||
uint64_t getFrontIndex();
|
||||
std::wstring getName();
|
||||
void setName(std::wstring newName);
|
||||
void reviseSessionShowing(SessionState state);
|
||||
SessionVolumeInfo* getVolumeInfo();
|
||||
|
||||
|
|
|
|||
|
|
@ -79,7 +79,6 @@ QRect MainWindow::setSizePosition(QScreen* screen, int width, int height) {
|
|||
|
||||
void MainWindow::compose() {
|
||||
//We need dynamically added child widgets to expand so that we know their height
|
||||
|
||||
/*
|
||||
* Setting correct widget widths and heights
|
||||
*/
|
||||
|
|
@ -103,7 +102,7 @@ void MainWindow::compose() {
|
|||
|
||||
for (auto *epw : ews) {
|
||||
if (!epw) continue;
|
||||
epw->setSize(windowWidth, screenHeight);
|
||||
epw->calculateSize(windowWidth, screenHeight);
|
||||
log_debugcpp("epw loop");
|
||||
}
|
||||
|
||||
|
|
@ -198,6 +197,8 @@ SessionWidget::SessionWidget(uint64_t idx, SessionHandler* sh, QWidget *parent)
|
|||
connect(volumePoller, &QTimer::timeout, [this, sh](){
|
||||
//if (memcmp(osh->callbackInfo[idx]->caller, osh->getGuid(), sizeof(NGuid)) == 0) return; CHECK IF THIS PROGRAM GENERATED THE FUNSIES IS NO LONGER IN USE FOR NOW.
|
||||
//todo: global + constexpr + ratio
|
||||
if (sh->getVolumeInfo()->isNameChanged)
|
||||
mainLabel->setText(QString::fromStdWString(sh->getName()));
|
||||
const float roundingFactor = 0.005;
|
||||
mainSlider->blockSignals(true);
|
||||
muteButton->blockSignals(true);
|
||||
|
|
@ -216,7 +217,7 @@ SessionWidget::SessionWidget(uint64_t idx, SessionHandler* sh, QWidget *parent)
|
|||
volumePoller->start(10);
|
||||
}
|
||||
|
||||
void SessionWidget::setSize(uint64_t width, uint64_t height) {
|
||||
void SessionWidget::calculateSize(uint64_t width, uint64_t height) {
|
||||
/* og 1080p 120% testing values */
|
||||
this->mainLabel->setMaximumWidth((int)(width * 0.30) /*1/16ish 1080p*/);
|
||||
this->mainLabel->setMinimumWidth((int)(width * 0.30) /*1/16ish 1080p*/);
|
||||
|
|
@ -565,7 +566,7 @@ void MainWindow::reorderEndpointWidgetCollection() {
|
|||
ews.resize(firstNullPosition + 1);
|
||||
}
|
||||
|
||||
void EndpointWidget::setSize(uint64_t width, uint64_t height) {
|
||||
void EndpointWidget::calculateSize(uint64_t width, uint64_t height) {
|
||||
/* og 1080p 120% testing values */
|
||||
this->mainLabel->setMaximumWidth((int)width * 0.35 /* 1080p 120%*/);
|
||||
this->mainLabel->setMinimumWidth((int)width * 0.35 /* 1080p 120%*/);
|
||||
|
|
@ -574,7 +575,7 @@ void EndpointWidget::setSize(uint64_t width, uint64_t height) {
|
|||
this->cw->setMaximumSize(QSize(QWIDGETSIZE_MAX, height * 0.06));
|
||||
}
|
||||
for (auto sw : sessionWidgets){
|
||||
if (sw) sw->setSize(width, height);
|
||||
if (sw) sw->calculateSize(width, height);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -745,8 +746,9 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
|
|||
* Set of function callback definitons for EndpointSituationCallback
|
||||
*/
|
||||
osh->setChangeFrontDefaultsFunction([this](Roles role, std::wstring endpointId) {
|
||||
//Sigh... I hope to get this right when librole is done...
|
||||
EndpointWidget *newDef = nullptr, *oldDef = nullptr;
|
||||
for (int i = 0; i < ews.size(); i++) {
|
||||
for (uint64_t i = 0; i < ews.size(); i++) {
|
||||
auto epw = this->ews.at(i);
|
||||
if (!epw) continue;
|
||||
if (epw->getEndpointHandler()->getId() == endpointId) {
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ Q_OBJECT
|
|||
public:
|
||||
SessionWidget(uint64_t idx, SessionHandler* sh, QWidget *parent /* = nullptr */);
|
||||
~SessionWidget();
|
||||
void setSize(uint64_t width, uint64_t height);
|
||||
void calculateSize(uint64_t width, uint64_t height);
|
||||
public slots:
|
||||
void updateMainVolume(int newValue);
|
||||
void updateMute(int checked);
|
||||
|
|
@ -135,7 +135,7 @@ public:
|
|||
void setIndex(uint64_t idx);
|
||||
uint64_t getIndex();
|
||||
//void setVolume(int channel, float volume);
|
||||
void setSize(uint64_t width, uint64_t height);
|
||||
void calculateSize(uint64_t width, uint64_t height);
|
||||
|
||||
~EndpointWidget();
|
||||
//void updateMainVolume(float newValue);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue