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

@ -231,14 +231,14 @@ HRESULT EndpointSituationCallback::OnPropertyValueChanged(LPCWSTR pwstrDeviceId,
Endpoint::Endpoint(IMMDevice* ep, uint64_t idx){
this->endpoint = ep;
this->idx = idx;
/*
* It can't multiflag, it's that stupid. MS momento.
* Only shows most relevant flag according to MS, i.e. 0110 sends 0010
*/
//todo: preguntitas owindows dword no es uint32_t even tho mingw mingas
if(FAILED(endpoint->GetState(&this->endpointState))) {exit(-2);};
if(this->endpointState == EndpointState::ENDPOINT_ACTIVE) {
activateEndpointVolume();
}
@ -250,7 +250,7 @@ Endpoint::Endpoint(IMMDevice* ep, uint64_t idx){
// CLSCTX_ALL, NULL, (void**)&endpointPeakMeter))) { log_debugcpp("peakbros..."); }
//todo:: atexit into exit Gather ID
//todo: atexit into exit Gather ID
LPWSTR tempString = nullptr;
if (FAILED(endpoint->GetId(&tempString))) {exit(-1);};
endpointId = std::wstring(tempString);
@ -259,10 +259,10 @@ Endpoint::Endpoint(IMMDevice* ep, uint64_t idx){
endpoint->OpenPropertyStore(STGM_READ, &properties);
this->updateName();
this->setFlow();
if (this->flow == Flows::FLOW_PLAYBACK) {
activateEndpointSessions();
log_debugcpp("plays back");
}
}
@ -277,7 +277,8 @@ void Endpoint::updateName() {
store_name(PKEY_Device_FriendlyName, pv, friendlyName);
store_name(PKEY_Device_DeviceDesc, pv, descriptionName);
store_name(PKEY_DeviceInterface_FriendlyName, pv, deviceName);
#undef store_name
#undef store_name
log_wdebugcpp(L"Endpoint name: " + friendlyName);
}
void Endpoint::activateEndpointSessions() {
@ -511,6 +512,7 @@ void Endpoint::setFlow() {
EDataFlow MSflow;
HRESULT vafllar = flowGetter->GetDataFlow(&MSflow);
this->flow = (MSflow == EDataFlow::eRender ? Flows::FLOW_PLAYBACK : Flows::FLOW_CAPTURE);
log_debugcpp("Endpoint flow: " + std::to_string(flow));
flowGetter->Release();
}
@ -584,13 +586,12 @@ void Overseer::reloadEndpoints(Flows flow) {
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;
for (unsigned int i = 0; i < numEndpoints; i++){
if(deviceCollection->Item(i, &temp) != 0) { log_debugcpp("si"); };
Endpoint *endpoint = new Endpoint(temp, i);
if (flow == Flows::FLOW_PLAYBACK)
this->playbackDevices.push_back(endpoint);
else
@ -626,9 +627,8 @@ void Overseer::reloadEndpoints(Flows flow) {
temp->GetId(&id);
int comparison = CompareStringEx(LOCALE_NAME_USER_DEFAULT, 0, eptId.c_str(), -987, id, -987, NULL, NULL, 0);
if (comparison - 2 == 0) {
log_wdebugcpp(L"ola defaul playback de "
+ std::to_wstring(i) + L" es " + id);
playbackDevices.at(j)->assignRoles((Roles)(1 << i));
log_wdebugcpp(L"ola defaul playback de " + std::to_wstring(i) + L" es " + id);
playbackDevices.at(j)->assignRoles((Roles)(1 << i));
}
}
} else {

View file

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

View file

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

View file

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