wip: fixed wrong index for epw creation

This commit is contained in:
Hane 2024-04-24 02:03:07 +02:00
commit 4756a00156
4 changed files with 32 additions and 14 deletions

View file

@ -250,7 +250,7 @@ Endpoint::Endpoint(IMMDevice* ep, uint64_t idx){
// CLSCTX_ALL, NULL, (void**)&endpointPeakMeter))) { log_debugcpp("peakbros..."); } // CLSCTX_ALL, NULL, (void**)&endpointPeakMeter))) { log_debugcpp("peakbros..."); }
//todo:: atexit into exit Gather ID //todo: atexit into exit Gather ID
LPWSTR tempString = nullptr; LPWSTR tempString = nullptr;
if (FAILED(endpoint->GetId(&tempString))) {exit(-1);}; if (FAILED(endpoint->GetId(&tempString))) {exit(-1);};
endpointId = std::wstring(tempString); endpointId = std::wstring(tempString);
@ -259,10 +259,10 @@ Endpoint::Endpoint(IMMDevice* ep, uint64_t idx){
endpoint->OpenPropertyStore(STGM_READ, &properties); endpoint->OpenPropertyStore(STGM_READ, &properties);
this->updateName(); this->updateName();
this->setFlow(); this->setFlow();
if (this->flow == Flows::FLOW_PLAYBACK) { if (this->flow == Flows::FLOW_PLAYBACK) {
activateEndpointSessions(); activateEndpointSessions();
log_debugcpp("plays back");
} }
} }
@ -278,6 +278,7 @@ void Endpoint::updateName() {
store_name(PKEY_Device_DeviceDesc, pv, descriptionName); store_name(PKEY_Device_DeviceDesc, pv, descriptionName);
store_name(PKEY_DeviceInterface_FriendlyName, pv, deviceName); store_name(PKEY_DeviceInterface_FriendlyName, pv, deviceName);
#undef store_name #undef store_name
log_wdebugcpp(L"Endpoint name: " + friendlyName);
} }
void Endpoint::activateEndpointSessions() { void Endpoint::activateEndpointSessions() {
@ -511,6 +512,7 @@ void Endpoint::setFlow() {
EDataFlow MSflow; EDataFlow MSflow;
HRESULT vafllar = flowGetter->GetDataFlow(&MSflow); HRESULT vafllar = flowGetter->GetDataFlow(&MSflow);
this->flow = (MSflow == EDataFlow::eRender ? Flows::FLOW_PLAYBACK : Flows::FLOW_CAPTURE); this->flow = (MSflow == EDataFlow::eRender ? Flows::FLOW_PLAYBACK : Flows::FLOW_CAPTURE);
log_debugcpp("Endpoint flow: " + std::to_string(flow));
flowGetter->Release(); flowGetter->Release();
} }
@ -584,13 +586,12 @@ void Overseer::reloadEndpoints(Flows flow) {
if(numEndpoints == 0) { log_debugcpp("si"); }; if(numEndpoints == 0) { log_debugcpp("si"); };
/* /*
* Retrieving actual endpoints and storing them on their own class * Retrieving actual endpoints and storing them on their own collection
*/ */
IMMDevice *temp; IMMDevice *temp;
for (unsigned int i = 0; i < numEndpoints; i++){ for (unsigned int i = 0; i < numEndpoints; i++){
if(deviceCollection->Item(i, &temp) != 0) { log_debugcpp("si"); }; if(deviceCollection->Item(i, &temp) != 0) { log_debugcpp("si"); };
Endpoint *endpoint = new Endpoint(temp, i); Endpoint *endpoint = new Endpoint(temp, i);
if (flow == Flows::FLOW_PLAYBACK) if (flow == Flows::FLOW_PLAYBACK)
this->playbackDevices.push_back(endpoint); this->playbackDevices.push_back(endpoint);
else else
@ -626,8 +627,7 @@ void Overseer::reloadEndpoints(Flows flow) {
temp->GetId(&id); temp->GetId(&id);
int comparison = CompareStringEx(LOCALE_NAME_USER_DEFAULT, 0, eptId.c_str(), -987, id, -987, NULL, NULL, 0); int comparison = CompareStringEx(LOCALE_NAME_USER_DEFAULT, 0, eptId.c_str(), -987, id, -987, NULL, NULL, 0);
if (comparison - 2 == 0) { if (comparison - 2 == 0) {
log_wdebugcpp(L"ola defaul playback de " log_wdebugcpp(L"ola defaul playback de " + std::to_wstring(i) + L" es " + id);
+ std::to_wstring(i) + L" es " + id);
playbackDevices.at(j)->assignRoles((Roles)(1 << i)); playbackDevices.at(j)->assignRoles((Roles)(1 << i));
} }
} }

View file

@ -2,6 +2,7 @@
#include <vector> #include <vector>
#include <iostream> #include <iostream>
#include <fstream>
#include <string> #include <string>
#include <bitset> #include <bitset>
#include <climits> #include <climits>

View file

@ -104,6 +104,11 @@ void MainWindow::compose() {
if (!epw) continue; if (!epw) continue;
epw->calculateSize(windowWidth, screenHeight); epw->calculateSize(windowWidth, screenHeight);
log_debugcpp("epw loop"); log_debugcpp("epw loop");
log_debugcpp("epw roles: " + std::to_string(epw->getEndpointHandler()->getRoles()));
//std::bitset<sizeof(uint8_t)> content =
print_as_binary(8, uint8_t, (epw->getEndpointHandler()->getRoles()));
//log_debugcpp(content);
varToBitset<sizeof(uint8_t), uint8_t>(epw->getEndpointHandler()->getRoles());
} }
/* /*
@ -121,6 +126,10 @@ void MainWindow::compose() {
} }
windowHeight += mainMenuBar->height(); windowHeight += mainMenuBar->height();
log_debugcpp("windowHeight final value: " + std::to_string(windowHeight)); log_debugcpp("windowHeight final value: " + std::to_string(windowHeight));
//Undoing scrolling
scrollArea->verticalScrollBar()->setValue(0);
/* /*
* Establishing initial window size and position * Establishing initial window size and position
*/ */
@ -310,6 +319,7 @@ EndpointWidget::EndpointWidget(EndpointHandler* eph, QWidget *parent, uint64_t i
row = 0; row = 0;
this->idx = idx; this->idx = idx;
this->eph = eph; this->eph = eph;
//todo: sussy //todo: sussy
this->eph->setState(EndpointState::ENDPOINT_ACTIVE, idx); this->eph->setState(EndpointState::ENDPOINT_ACTIVE, idx);
this->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); this->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
@ -573,8 +583,8 @@ void MainWindow::reorderEndpointWidgetCollection() {
void EndpointWidget::calculateSize(uint64_t width, uint64_t height) { void EndpointWidget::calculateSize(uint64_t width, uint64_t height) {
/* og 1080p 120% testing values */ /* og 1080p 120% testing values */
this->mainLabel->setMaximumWidth((int)width * 0.35 /* 1080p 120%*/); this->mainLabel->setMaximumWidth((int)width * 0.50 /* 1080p 120%*/);
this->mainLabel->setMinimumWidth((int)width * 0.35 /* 1080p 120%*/); this->mainLabel->setMinimumWidth((int)width * 0.50 /* 1080p 120%*/);
if (cw) { if (cw) {
this->cw->setMinimumSize(QSize(1, height * 0.06)); this->cw->setMinimumSize(QSize(1, height * 0.06));
this->cw->setMaximumSize(QSize(QWIDGETSIZE_MAX, height * 0.06)); this->cw->setMaximumSize(QSize(QWIDGETSIZE_MAX, height * 0.06));
@ -674,6 +684,8 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
//todo: ratio //todo: ratio
setWindowFlags(Qt::Window | Qt::MSWindowsFixedSizeDialogHint); setWindowFlags(Qt::Window | Qt::MSWindowsFixedSizeDialogHint);
setWindowFlags(Qt::FramelessWindowHint | Qt::ToolTip); setWindowFlags(Qt::FramelessWindowHint | Qt::ToolTip);
setAttribute(Qt::WA_TranslucentBackground);
setStyleSheet("background-color: rgba(255,182,193,90%);");
setWindowTitle(STRING_TITLE); setWindowTitle(STRING_TITLE);
connect(qApp, &QGuiApplication::applicationStateChanged, this, [=](Qt::ApplicationState state){ connect(qApp, &QGuiApplication::applicationStateChanged, this, [=](Qt::ApplicationState state){
if(state == Qt::ApplicationState::ApplicationInactive) hide(); if(state == Qt::ApplicationState::ApplicationInactive) hide();
@ -851,14 +863,18 @@ void MainWindow::trayIconActivated(QSystemTrayIcon::ActivationReason reason) {
} }
void MainWindow::reloadEndpointWidgets() { void MainWindow::reloadEndpointWidgets() {
size_t i = 2; size_t i = 0;
ews.resize(2); ews.resize(2);
//widgetLayout->addItem(&lastRowSpacer, i++, 0); //widgetLayout->addItem(&lastRowSpacer, i++, 0);
//todo: -log flag
//std::wofstream log("log.txt");
for (size_t epwIndex = 2; i < (osh->getPlaybackEndpointHandlers().size()); i++) { for (size_t epwIndex = 2; i < (osh->getPlaybackEndpointHandlers().size()); i++) {
if (osh->getPlaybackEndpointHandlers().at(i)->getState() == EndpointState::ENDPOINT_ACTIVE){ if (osh->getPlaybackEndpointHandlers().at(i)->getState() == EndpointState::ENDPOINT_ACTIVE){
log_debugcpp("EPWidget creation"); log_debugcpp("EPWidget creation");
//osh->getPlaybackEndpointHandlers().at(i)->getCallbackInfo()->caller = osh->getGuid(); //osh->getPlaybackEndpointHandlers().at(i)->getCallbackInfo()->caller = osh->getGuid();
EndpointWidget *epw = new EndpointWidget(osh->getPlaybackEndpointHandlers().at(i), widget); EndpointWidget *epw = new EndpointWidget(osh->getPlaybackEndpointHandlers().at(i), widget);
log_wdebugcpp(L"epw name: " + epw->getEndpointHandler()->getName());
if ((epw->getEndpointHandler()->getRoles() == Roles::ROLE_ALL) || if ((epw->getEndpointHandler()->getRoles() == Roles::ROLE_ALL) ||
(epw->getEndpointHandler()->getRoles() & Roles::ROLE_MULTIMEDIA)) (epw->getEndpointHandler()->getRoles() & Roles::ROLE_MULTIMEDIA))
{ ews[0] = epw; widgetLayout->addWidget(epw, 0, 0); epw->setIndex(0); } { ews[0] = epw; widgetLayout->addWidget(epw, 0, 0); epw->setIndex(0); }

View file

@ -19,6 +19,7 @@
#include <QCheckBox> #include <QCheckBox>
#include <QTimer> #include <QTimer>
#include <QScrollArea> #include <QScrollArea>
#include <QScrollBar>
#include <QSize> #include <QSize>
#include <QMenuBar> #include <QMenuBar>
#include <QMenu> #include <QMenu>