wip: meter bar
This commit is contained in:
parent
cdadee58fc
commit
20a82b42d4
9 changed files with 104 additions and 36 deletions
|
|
@ -241,14 +241,18 @@ Endpoint::Endpoint(IMMDevice* ep, uint64_t idx){
|
|||
|
||||
if(this->endpointState == EndpointState::ENDPOINT_ACTIVE) {
|
||||
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();
|
||||
|
||||
//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;
|
||||
|
|
@ -494,20 +498,8 @@ void Endpoint::removeRoles(Roles role){
|
|||
|
||||
void Endpoint::setFlow() {
|
||||
IMMEndpoint* flowGetter;
|
||||
//this should be as simple as writing IID_IMMEndpoint, but it just won't find the macro, so I copied it. Sad.
|
||||
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;
|
||||
if(FAILED(this->endpoint->QueryInterface((const _GUID)manual, (void**)&flowGetter)))
|
||||
//this should be as simple as writing IID_IMMEndpoint, but it just won't find the macro, so I reimpl it. Sad.
|
||||
if(FAILED(this->endpoint->QueryInterface(__uuidof(IMMEndpoint), (void**)&flowGetter)))
|
||||
{ log_debugcpp("no flow..."); }
|
||||
EDataFlow MSflow;
|
||||
HRESULT vafllar = flowGetter->GetDataFlow(&MSflow);
|
||||
|
|
|
|||
|
|
@ -52,7 +52,9 @@ class Endpoint {
|
|||
|
||||
std::vector<Session*> endpointSessions;
|
||||
uint32_t channelCount = 0;
|
||||
IMMDevice* endpoint;
|
||||
IMMDevice *endpoint;
|
||||
IAudioClient *audioClient;
|
||||
int64_t defTime, minTime;
|
||||
IAudioSessionManager2 *sessionManager;
|
||||
Flows flow;
|
||||
IAudioEndpointVolume *endpointVolume = nullptr;
|
||||
|
|
@ -65,7 +67,7 @@ class Endpoint {
|
|||
Roles endpointRoles = (Roles)0;
|
||||
uint64_t idx;
|
||||
//Not implemented in llvm-mingw. Sad!
|
||||
//IAudioMeterInformation *endpointPeakMeter = nullptr;
|
||||
IAudioMeterInformation *endpointPeakMeter = nullptr;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -26,3 +26,34 @@
|
|||
#include "ipolicyconfig.h"
|
||||
#include <Mmreg.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; */
|
||||
|
|
|
|||
|
|
@ -27,10 +27,7 @@ public:
|
|||
EndpointHandler(uint64_t idx, Flows flow);
|
||||
void setBackEndpointVolumeCallbackInfoContent(uint8_t state);
|
||||
|
||||
//these two, currently unused. If I use them, I should feel bad.
|
||||
//EndpointVolumeCallback* getEndpointVolumeCallback();
|
||||
//Endpoint* getEndpoint();
|
||||
|
||||
//todo: replace all getEndpointHandler()
|
||||
//todo: name refactor
|
||||
BackEndpointVolumeCallbackInfo* getCallbackInfo();
|
||||
uint32_t getChannelCount();
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ std::bitset<sizeof(T) * 8> varToBitset(T info) {
|
|||
return content;
|
||||
}
|
||||
|
||||
#define print_as_binary(info) varToBitset<decltype(info)>(info)
|
||||
#define print_as_binary(info) varToBitset<decltype(info)>(info).to_string()
|
||||
|
||||
#ifndef _WIN32
|
||||
#define log_debugcpp(str) do { \
|
||||
|
|
@ -69,7 +69,7 @@ std::bitset<sizeof(T) * 8> varToBitset(T info) {
|
|||
#else
|
||||
#define log_debugcpp(str)
|
||||
#define log_wdebugcpp(str)
|
||||
#define print_as_binary(len, type, info)
|
||||
#define print_as_binary(info)
|
||||
#define log_to_file(fmt, cnt...)
|
||||
#define initialize_file_log() false
|
||||
#define close_file_log_buffer()
|
||||
|
|
|
|||
|
|
@ -5,6 +5,31 @@ CustomWidgetEvent<T>::CustomWidgetEvent(QEvent::Type type, T payload) : QEvent(t
|
|||
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) {
|
||||
//QEvent::Type tipo = ev->type();
|
||||
if (ev->type() == (QEvent::Type)CustomQEvent::EndpointDefaultChange) {
|
||||
|
|
@ -106,7 +131,7 @@ void MainWindow::compose() {
|
|||
if (!epw) continue;
|
||||
epw->calculateSize(windowWidth, screenHeight);
|
||||
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 =
|
||||
//content);
|
||||
//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);
|
||||
mainLabel = new QLabel(QString::fromStdWString(eph->getName()), this);
|
||||
mainSlider = new QSlider(Qt::Horizontal, this);
|
||||
mainSlider = new MeterSlider(Qt::Horizontal, this);
|
||||
mainVolumeLabel = new QLabel(this);
|
||||
|
||||
if (this->eph->getState() != EndpointState::ENDPOINT_ACTIVE) {
|
||||
|
|
@ -749,6 +774,8 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
|
|||
scrollArea->setWidgetResizable(true);
|
||||
scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
|
||||
scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
//scrollArea->verticalScrollBar()->setSingleStep(1);
|
||||
|
||||
scrollArea->setStyleSheet("QScrollBar:vertical { width: 4px; }");
|
||||
//scrollArea->setMinimumWidth(500);
|
||||
setCentralWidget(scrollArea);
|
||||
|
|
|
|||
|
|
@ -26,7 +26,9 @@
|
|||
#include <QScreen>
|
||||
#include <QToolBar>
|
||||
#include <QWindow>
|
||||
|
||||
#include <QPainter>
|
||||
#include <QStylePainter>
|
||||
#include <QStyleOptionSlider>
|
||||
//#include <QScrollBar>
|
||||
/*
|
||||
* #else
|
||||
|
|
@ -64,10 +66,19 @@ class CustomWidgetEvent : public QEvent {
|
|||
public:
|
||||
CustomWidgetEvent(QEvent::Type type, T payload);
|
||||
T payload;
|
||||
|
||||
};
|
||||
//Q_DECLARE_METATYPE(EndpointWidgetEvent)
|
||||
|
||||
class MeterSlider : public QSlider {
|
||||
Q_OBJECT
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
|
||||
public:
|
||||
using QSlider::QSlider;
|
||||
|
||||
};
|
||||
|
||||
class ExtendedCheckBox : public QCheckBox {
|
||||
Q_OBJECT
|
||||
protected:
|
||||
|
|
@ -166,7 +177,7 @@ private:
|
|||
QCheckBox *muteButton = nullptr;
|
||||
QLabel *mainLabel = nullptr;
|
||||
QLabel *mainVolumeLabel = nullptr;
|
||||
QSlider *mainSlider = nullptr;
|
||||
MeterSlider *mainSlider = nullptr;
|
||||
std::vector<QSlider*> channelSliders;
|
||||
std::vector<QLabel*> channelLabels;
|
||||
QGridLayout *widgetLayout = nullptr;
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@
|
|||
#include <QLocalServer>
|
||||
#include <QString>
|
||||
#include <QFile>
|
||||
#include <QStringList>
|
||||
#include <QStyleFactory>
|
||||
//#include "contclasses.h"
|
||||
#define INIT_FILELOG
|
||||
#include "qtclasses.h"
|
||||
|
|
@ -44,7 +46,13 @@ void closeDebugFileLog() {
|
|||
*/
|
||||
|
||||
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
|
||||
//https://stackoverflow.com/questions/48060989/qt-show-application-if-currently-running
|
||||
initialize_file_log();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue