wip: meter bar

This commit is contained in:
Hane 2024-04-28 18:26:44 +02:00
commit 20a82b42d4
9 changed files with 104 additions and 36 deletions

View file

@ -6,9 +6,9 @@ DEFINES += DEBUG QT_LOGGING_TO_CONSOLE=1 WIN32_LEAN_AND_MEAN
CONFIG += debug CONFIG += debug
QT += widgets network QT += widgets network
INCLUDEPATH += "$$PWD\src" "$$PWD\src\qt" "$$PWD\src\back" "$$PWD\src\cont" INCLUDEPATH += "$$PWD\src" "$$PWD\src\qt" "$$PWD\src\back" "$$PWD\src\back\reimpl" "$$PWD\src\cont"
DESTPATH += "$$PWD\src" "$$PWD\src\qt" "$$PWD\src\back" "$$PWD\src\cont" DESTPATH += "$$PWD\src" "$$PWD\src\qt" "$$PWD\src\back" "$$PWD\src\back\reimpl" "$$PWD\src\cont"
VPATH += "$$PWD\src" "$$PWD\src\qt" "$$PWD\src\back" "$$PWD\src\cont" VPATH += "$$PWD\src" "$$PWD\src\qt" "$$PWD\src\back" "$$PWD\src\back\reimpl" "$$PWD\src\cont"
SOURCES += qtestmain.cpp qtclasses.cpp backlasses.cpp backsessionclasses.cpp contclasses.cpp contsessionclasses.cpp SOURCES += qtestmain.cpp qtclasses.cpp backlasses.cpp backsessionclasses.cpp contclasses.cpp contsessionclasses.cpp
HEADERS += qtclasses.h backlasses.h backsessionclasses.h contclasses.h contsessionclasses.h global.h debug.h backfuncs.h ipolicyconfig.h msinclude.h HEADERS += qtclasses.h backlasses.h backsessionclasses.h contclasses.h contsessionclasses.h global.h debug.h backfuncs.h ipolicyconfig.h msinclude.h

View file

@ -241,14 +241,18 @@ Endpoint::Endpoint(IMMDevice* ep, uint64_t idx){
if(this->endpointState == EndpointState::ENDPOINT_ACTIVE) { if(this->endpointState == EndpointState::ENDPOINT_ACTIVE) {
activateEndpointVolume(); activateEndpointVolume();
//if(FAILED(endpoint->Activate(__uuidof(IAudioClient),
// CLSCTX_ALL, NULL, (void**)&audioClient))) { log_debugcpp("audioclntbros..."); }
//audioClient->GetDevicePeriod(&defTime, &minTime);
//todo: check header
//if(FAILED(endpoint->Activate(__uuidof(IAudioMeterInformation),
// CLSCTX_ALL, NULL, (void**)&endpointPeakMeter))) { log_debugcpp("peakbros..."); }
//endpointPeakMeter->GetPeakValue(&test);
} }
reloadEndpointChannels(); reloadEndpointChannels();
//todo: check header
// if(FAILED(endpoint->Activate(__uuidof(IAudioMeterInformation),
// 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;
@ -494,20 +498,8 @@ void Endpoint::removeRoles(Roles role){
void Endpoint::setFlow() { void Endpoint::setFlow() {
IMMEndpoint* flowGetter; IMMEndpoint* flowGetter;
//this should be as simple as writing IID_IMMEndpoint, but it just won't find the macro, so I copied it. Sad. //this should be as simple as writing IID_IMMEndpoint, but it just won't find the macro, so I reimpl it. Sad.
GUID manual; if(FAILED(this->endpoint->QueryInterface(__uuidof(IMMEndpoint), (void**)&flowGetter)))
manual.Data1 = 0x1be09788;
manual.Data2 = 0x6894;
manual.Data3 = 0x4089;
manual.Data4[0] = 0x85;
manual.Data4[1] = 0x86;
manual.Data4[2] = 0x9a;
manual.Data4[3] = 0x2a;
manual.Data4[4] = 0x6c;
manual.Data4[5] = 0x26;
manual.Data4[6] = 0x5a;
manual.Data4[7] = 0xc5;
if(FAILED(this->endpoint->QueryInterface((const _GUID)manual, (void**)&flowGetter)))
{ log_debugcpp("no flow..."); } { log_debugcpp("no flow..."); }
EDataFlow MSflow; EDataFlow MSflow;
HRESULT vafllar = flowGetter->GetDataFlow(&MSflow); HRESULT vafllar = flowGetter->GetDataFlow(&MSflow);

View file

@ -52,7 +52,9 @@ class Endpoint {
std::vector<Session*> endpointSessions; std::vector<Session*> endpointSessions;
uint32_t channelCount = 0; uint32_t channelCount = 0;
IMMDevice* endpoint; IMMDevice *endpoint;
IAudioClient *audioClient;
int64_t defTime, minTime;
IAudioSessionManager2 *sessionManager; IAudioSessionManager2 *sessionManager;
Flows flow; Flows flow;
IAudioEndpointVolume *endpointVolume = nullptr; IAudioEndpointVolume *endpointVolume = nullptr;
@ -65,7 +67,7 @@ class Endpoint {
Roles endpointRoles = (Roles)0; Roles endpointRoles = (Roles)0;
uint64_t idx; uint64_t idx;
//Not implemented in llvm-mingw. Sad! //Not implemented in llvm-mingw. Sad!
//IAudioMeterInformation *endpointPeakMeter = nullptr; IAudioMeterInformation *endpointPeakMeter = nullptr;
}; };

View file

@ -26,3 +26,34 @@
#include "ipolicyconfig.h" #include "ipolicyconfig.h"
#include <Mmreg.h> #include <Mmreg.h>
#include <tlhelp32.h> #include <tlhelp32.h>
#include "audiometerinfo.h"
// IAudioMeterInformation
/* GUID manual; */
/* manual.Data1 = 0xc02216f6; */
/* manual.Data2 = 0x8c67; */
/* manual.Data3 = 0x4b5b; */
/* manual.Data4[0] = 0x9d; */
/* manual.Data4[1] = 0x00; */
/* manual.Data4[2] = 0xd0; */
/* manual.Data4[3] = 0x08; */
/* manual.Data4[4] = 0xe7; */
/* manual.Data4[5] = 0x3e; */
/* manual.Data4[6] = 0x00; */
/* manual.Data4[7] = 0x64; */
//if(FAILED(endpoint->Activate((const _GUID) manual,
//IMMEndpoint
/* GUID manual; */
/* manual.Data1 = 0x1be09788; */
/* manual.Data2 = 0x6894; */
/* manual.Data3 = 0x4089; */
/* manual.Data4[0] = 0x85; */
/* manual.Data4[1] = 0x86; */
/* manual.Data4[2] = 0x9a; */
/* manual.Data4[3] = 0x2a; */
/* manual.Data4[4] = 0x6c; */
/* manual.Data4[5] = 0x26; */
/* manual.Data4[6] = 0x5a; */
/* manual.Data4[7] = 0xc5; */

View file

@ -27,10 +27,7 @@ public:
EndpointHandler(uint64_t idx, Flows flow); EndpointHandler(uint64_t idx, Flows flow);
void setBackEndpointVolumeCallbackInfoContent(uint8_t state); void setBackEndpointVolumeCallbackInfoContent(uint8_t state);
//these two, currently unused. If I use them, I should feel bad. //todo: replace all getEndpointHandler()
//EndpointVolumeCallback* getEndpointVolumeCallback();
//Endpoint* getEndpoint();
//todo: name refactor //todo: name refactor
BackEndpointVolumeCallbackInfo* getCallbackInfo(); BackEndpointVolumeCallbackInfo* getCallbackInfo();
uint32_t getChannelCount(); uint32_t getChannelCount();

View file

@ -30,7 +30,7 @@ std::bitset<sizeof(T) * 8> varToBitset(T info) {
return content; return content;
} }
#define print_as_binary(info) varToBitset<decltype(info)>(info) #define print_as_binary(info) varToBitset<decltype(info)>(info).to_string()
#ifndef _WIN32 #ifndef _WIN32
#define log_debugcpp(str) do { \ #define log_debugcpp(str) do { \
@ -69,7 +69,7 @@ std::bitset<sizeof(T) * 8> varToBitset(T info) {
#else #else
#define log_debugcpp(str) #define log_debugcpp(str)
#define log_wdebugcpp(str) #define log_wdebugcpp(str)
#define print_as_binary(len, type, info) #define print_as_binary(info)
#define log_to_file(fmt, cnt...) #define log_to_file(fmt, cnt...)
#define initialize_file_log() false #define initialize_file_log() false
#define close_file_log_buffer() #define close_file_log_buffer()

View file

@ -5,6 +5,31 @@ CustomWidgetEvent<T>::CustomWidgetEvent(QEvent::Type type, T payload) : QEvent(t
this->payload = payload; this->payload = payload;
} }
void MeterSlider::paintEvent(QPaintEvent *event) {
//Q_D(QSlider);
/*
* QStylePainter p(this);
* QStyleOptionSlider opt;
* initStyleOption(&opt);
*
* opt.subControls = QStyle::SC_SliderGroove | QStyle::SC_SliderHandle;
* //if (d->tickPosition != NoTicks)
* // opt.subControls |= QStyle::SC_SliderTickmarks;
*
* //p.drawComplexControl(QStyle::CC_Slider, opt);
*/
QSlider::paintEvent(event);
QStyle *style = QApplication::style();
int lol = style->pixelMetric(QStyle::PM_SliderSpaceAvailable);
QPainter painter(this);
painter.setPen(Qt::blue);
painter.setOpacity(1.0);
painter.setClipping(false);
painter.setCompositionMode(QPainter::CompositionMode::CompositionMode_Source);
painter.fillRect(0, (this->height() / 2) - 3, this->width(), 4, Qt::black);
}
void ExtendedCheckBox::customEvent(QEvent* ev) { void ExtendedCheckBox::customEvent(QEvent* ev) {
//QEvent::Type tipo = ev->type(); //QEvent::Type tipo = ev->type();
if (ev->type() == (QEvent::Type)CustomQEvent::EndpointDefaultChange) { if (ev->type() == (QEvent::Type)CustomQEvent::EndpointDefaultChange) {
@ -106,7 +131,7 @@ 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: " + print_as_binary((epw->getEndpointHandler()->getRoles())).to_string()); log_debugcpp("epw roles: " + print_as_binary((epw->getEndpointHandler()->getRoles())));
//std::bitset<sizeof(uint8_t)> content = //std::bitset<sizeof(uint8_t)> content =
//content); //content);
//varToBitset<sizeof(uint8_t), uint8_t>(epw->getEndpointHandler()->getRoles()); //varToBitset<sizeof(uint8_t), uint8_t>(epw->getEndpointHandler()->getRoles());
@ -360,7 +385,7 @@ EndpointWidget::EndpointWidget(EndpointHandler* eph, QWidget *parent, uint64_t i
*/ */
muteButton = new QCheckBox(this); muteButton = new QCheckBox(this);
mainLabel = new QLabel(QString::fromStdWString(eph->getName()), this); mainLabel = new QLabel(QString::fromStdWString(eph->getName()), this);
mainSlider = new QSlider(Qt::Horizontal, this); mainSlider = new MeterSlider(Qt::Horizontal, this);
mainVolumeLabel = new QLabel(this); mainVolumeLabel = new QLabel(this);
if (this->eph->getState() != EndpointState::ENDPOINT_ACTIVE) { if (this->eph->getState() != EndpointState::ENDPOINT_ACTIVE) {
@ -749,6 +774,8 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
scrollArea->setWidgetResizable(true); scrollArea->setWidgetResizable(true);
scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
//scrollArea->verticalScrollBar()->setSingleStep(1);
scrollArea->setStyleSheet("QScrollBar:vertical { width: 4px; }"); scrollArea->setStyleSheet("QScrollBar:vertical { width: 4px; }");
//scrollArea->setMinimumWidth(500); //scrollArea->setMinimumWidth(500);
setCentralWidget(scrollArea); setCentralWidget(scrollArea);

View file

@ -26,7 +26,9 @@
#include <QScreen> #include <QScreen>
#include <QToolBar> #include <QToolBar>
#include <QWindow> #include <QWindow>
#include <QPainter>
#include <QStylePainter>
#include <QStyleOptionSlider>
//#include <QScrollBar> //#include <QScrollBar>
/* /*
* #else * #else
@ -64,10 +66,19 @@ class CustomWidgetEvent : public QEvent {
public: public:
CustomWidgetEvent(QEvent::Type type, T payload); CustomWidgetEvent(QEvent::Type type, T payload);
T payload; T payload;
}; };
//Q_DECLARE_METATYPE(EndpointWidgetEvent) //Q_DECLARE_METATYPE(EndpointWidgetEvent)
class MeterSlider : public QSlider {
Q_OBJECT
protected:
void paintEvent(QPaintEvent *event) override;
public:
using QSlider::QSlider;
};
class ExtendedCheckBox : public QCheckBox { class ExtendedCheckBox : public QCheckBox {
Q_OBJECT Q_OBJECT
protected: protected:
@ -166,7 +177,7 @@ private:
QCheckBox *muteButton = nullptr; QCheckBox *muteButton = nullptr;
QLabel *mainLabel = nullptr; QLabel *mainLabel = nullptr;
QLabel *mainVolumeLabel = nullptr; QLabel *mainVolumeLabel = nullptr;
QSlider *mainSlider = nullptr; MeterSlider *mainSlider = nullptr;
std::vector<QSlider*> channelSliders; std::vector<QSlider*> channelSliders;
std::vector<QLabel*> channelLabels; std::vector<QLabel*> channelLabels;
QGridLayout *widgetLayout = nullptr; QGridLayout *widgetLayout = nullptr;

View file

@ -5,6 +5,8 @@
#include <QLocalServer> #include <QLocalServer>
#include <QString> #include <QString>
#include <QFile> #include <QFile>
#include <QStringList>
#include <QStyleFactory>
//#include "contclasses.h" //#include "contclasses.h"
#define INIT_FILELOG #define INIT_FILELOG
#include "qtclasses.h" #include "qtclasses.h"
@ -44,7 +46,13 @@ void closeDebugFileLog() {
*/ */
int main (int argc, char* argv[]) { int main (int argc, char* argv[]) {
//QApplication::setStyle("windowsvista"); /*
* QStringList styles = QStyleFactory::keys();
* for(QString a : styles) {
* log_debugcpp(a.toStdString());
* }
*/
//QApplication::setStyle("Fusion");
//Check if running //Check if running
//https://stackoverflow.com/questions/48060989/qt-show-application-if-currently-running //https://stackoverflow.com/questions/48060989/qt-show-application-if-currently-running
initialize_file_log(); initialize_file_log();