wip: endpoint meter
This commit is contained in:
parent
20a82b42d4
commit
6bda4702df
7 changed files with 41 additions and 11 deletions
|
|
@ -246,10 +246,6 @@ Endpoint::Endpoint(IMMDevice* ep, uint64_t idx){
|
||||||
// CLSCTX_ALL, NULL, (void**)&audioClient))) { log_debugcpp("audioclntbros..."); }
|
// CLSCTX_ALL, NULL, (void**)&audioClient))) { log_debugcpp("audioclntbros..."); }
|
||||||
//audioClient->GetDevicePeriod(&defTime, &minTime);
|
//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();
|
||||||
|
|
@ -323,6 +319,12 @@ void Endpoint::activateEndpointVolume() {
|
||||||
if (this->endpointVolume == nullptr){
|
if (this->endpointVolume == nullptr){
|
||||||
HRESULT result = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
|
HRESULT result = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
|
||||||
endpoint->Activate(IID_IAudioEndpointVolume, CLSCTX_ALL, NULL, (void**)&this->endpointVolume);
|
endpoint->Activate(IID_IAudioEndpointVolume, CLSCTX_ALL, NULL, (void**)&this->endpointVolume);
|
||||||
|
|
||||||
|
//todo: check header
|
||||||
|
if(FAILED(endpoint->Activate(__uuidof(IAudioMeterInformation),
|
||||||
|
CLSCTX_ALL, NULL, (void**)&endpointPeakMeter))) { log_debugcpp("peakbros..."); }
|
||||||
|
//
|
||||||
|
|
||||||
//if (endpointVolume == nullptr) { //why they returning 0 after dealing with the error jfc CO_E_NOTINITIALIZED) {
|
//if (endpointVolume == nullptr) { //why they returning 0 after dealing with the error jfc CO_E_NOTINITIALIZED) {
|
||||||
//CoInitializeEx(NULL, COINIT_MULTITHREADED | COINIT_DISABLE_OLE1DDE);
|
//CoInitializeEx(NULL, COINIT_MULTITHREADED | COINIT_DISABLE_OLE1DDE);
|
||||||
//extraThread = true;
|
//extraThread = true;
|
||||||
|
|
@ -356,6 +358,13 @@ std::wstring Endpoint::getId(){
|
||||||
return endpointId;
|
return endpointId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float Endpoint::getPeakVolume() {
|
||||||
|
float peakVol;
|
||||||
|
if(endpointPeakMeter) endpointPeakMeter->GetPeakValue(&peakVol);
|
||||||
|
else return 0;
|
||||||
|
return peakVol;
|
||||||
|
}
|
||||||
|
|
||||||
float Endpoint::getVolume(int channel){
|
float Endpoint::getVolume(int channel){
|
||||||
float volume;
|
float volume;
|
||||||
if (channel == AudioChannel::CHANNEL_MAIN) {
|
if (channel == AudioChannel::CHANNEL_MAIN) {
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ class Endpoint {
|
||||||
void removeRoles(Roles role);
|
void removeRoles(Roles role);
|
||||||
void setFlow();
|
void setFlow();
|
||||||
Flows getFlow();
|
Flows getFlow();
|
||||||
|
float getPeakVolume();
|
||||||
std::wstring getId();
|
std::wstring getId();
|
||||||
std::wstring getName();
|
std::wstring getName();
|
||||||
void updateName();
|
void updateName();
|
||||||
|
|
@ -66,7 +67,7 @@ class Endpoint {
|
||||||
unsigned long endpointState;
|
unsigned long endpointState;
|
||||||
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! todo: mingw patch
|
||||||
IAudioMeterInformation *endpointPeakMeter = nullptr;
|
IAudioMeterInformation *endpointPeakMeter = nullptr;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -133,6 +133,10 @@ void EndpointHandler::setState(uint8_t state, uint64_t index){
|
||||||
this->setBackEndpointVolumeCallbackInfoContent(state);
|
this->setBackEndpointVolumeCallbackInfoContent(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float EndpointHandler::getPeakVolume() {
|
||||||
|
return ep->getPeakVolume();
|
||||||
|
}
|
||||||
|
|
||||||
uint8_t EndpointHandler::getRoles(){
|
uint8_t EndpointHandler::getRoles(){
|
||||||
return ep->getRoles();
|
return ep->getRoles();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,7 @@ public:
|
||||||
void setState(uint8_t state);
|
void setState(uint8_t state);
|
||||||
void setState(uint8_t state, uint64_t idx);
|
void setState(uint8_t state, uint64_t idx);
|
||||||
|
|
||||||
|
float getPeakVolume();
|
||||||
/* sessions */
|
/* sessions */
|
||||||
size_t getSessionCount();
|
size_t getSessionCount();
|
||||||
std::vector<SessionHandler*> getSessionHandlers();
|
std::vector<SessionHandler*> getSessionHandlers();
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,10 @@ CustomWidgetEvent<T>::CustomWidgetEvent(QEvent::Type type, T payload) : QEvent(t
|
||||||
this->payload = payload;
|
this->payload = payload;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MeterSlider::setPeakValue(float peakValue) {
|
||||||
|
this->peakValue = peakValue;
|
||||||
|
}
|
||||||
|
|
||||||
void MeterSlider::paintEvent(QPaintEvent *event) {
|
void MeterSlider::paintEvent(QPaintEvent *event) {
|
||||||
//Q_D(QSlider);
|
//Q_D(QSlider);
|
||||||
/*
|
/*
|
||||||
|
|
@ -23,11 +27,15 @@ void MeterSlider::paintEvent(QPaintEvent *event) {
|
||||||
QStyle *style = QApplication::style();
|
QStyle *style = QApplication::style();
|
||||||
int lol = style->pixelMetric(QStyle::PM_SliderSpaceAvailable);
|
int lol = style->pixelMetric(QStyle::PM_SliderSpaceAvailable);
|
||||||
QPainter painter(this);
|
QPainter painter(this);
|
||||||
painter.setPen(Qt::blue);
|
//painter.setPen(Qt::blue);
|
||||||
painter.setOpacity(1.0);
|
painter.setOpacity(1.0);
|
||||||
painter.setClipping(false);
|
painter.setClipping(false);
|
||||||
painter.setCompositionMode(QPainter::CompositionMode::CompositionMode_Source);
|
painter.setCompositionMode(QPainter::CompositionMode::CompositionMode_Source);
|
||||||
painter.fillRect(0, (this->height() / 2) - 3, this->width(), 4, Qt::black);
|
float peakLength = (this->width() * (this->peakValue));
|
||||||
|
//const qreal dpr = painter->device()->devicePixelRatio();
|
||||||
|
QStyleOptionSlider slider = QStyleOptionSlider();
|
||||||
|
QRect test = QApplication::style()->subControlRect(QStyle::CC_Slider, (QStyleOptionComplex*)&slider, QStyle::SC_SliderHandle);
|
||||||
|
painter.fillRect(0, (this->height() / 2) - 3, (this->width() * (this->peakValue)), 4, Qt::green);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExtendedCheckBox::customEvent(QEvent* ev) {
|
void ExtendedCheckBox::customEvent(QEvent* ev) {
|
||||||
|
|
@ -482,6 +490,8 @@ EndpointWidget::EndpointWidget(EndpointHandler* eph, QWidget *parent, uint64_t i
|
||||||
mainSlider->blockSignals(true);
|
mainSlider->blockSignals(true);
|
||||||
muteButton->blockSignals(true);
|
muteButton->blockSignals(true);
|
||||||
mainSlider->setValue((int)((eph->getCallbackInfo()->mainVolume + roundingFactor) * 100));
|
mainSlider->setValue((int)((eph->getCallbackInfo()->mainVolume + roundingFactor) * 100));
|
||||||
|
mainSlider->setPeakValue(eph->getPeakVolume());
|
||||||
|
mainSlider->update();
|
||||||
mainVolumeLabel->setText(QString::number(mainSlider->value()));
|
mainVolumeLabel->setText(QString::number(mainSlider->value()));
|
||||||
muteButton->setCheckState((eph->getCallbackInfo()->muted == false ? Qt::Unchecked : Qt::Checked));
|
muteButton->setCheckState((eph->getCallbackInfo()->muted == false ? Qt::Unchecked : Qt::Checked));
|
||||||
muteButton->setText(eph->getCallbackInfo()->muted ? STRING_UNMUTE : STRING_MUTE);
|
muteButton->setText(eph->getCallbackInfo()->muted ? STRING_UNMUTE : STRING_MUTE);
|
||||||
|
|
@ -496,7 +506,7 @@ EndpointWidget::EndpointWidget(EndpointHandler* eph, QWidget *parent, uint64_t i
|
||||||
mainSlider->blockSignals(false);
|
mainSlider->blockSignals(false);
|
||||||
muteButton->blockSignals(false);
|
muteButton->blockSignals(false);
|
||||||
});
|
});
|
||||||
timer->start(10);
|
timer->start(2);
|
||||||
|
|
||||||
/* First Widget batch */
|
/* First Widget batch */
|
||||||
for (size_t i = 0; i < eph->getSessionCount(); i++) {
|
for (size_t i = 0; i < eph->getSessionCount(); i++) {
|
||||||
|
|
|
||||||
|
|
@ -27,8 +27,12 @@
|
||||||
#include <QToolBar>
|
#include <QToolBar>
|
||||||
#include <QWindow>
|
#include <QWindow>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
#include <QStyle>
|
||||||
|
#include <QStyleOptionComplex>
|
||||||
|
#include <QStyleOptionSlider>
|
||||||
#include <QStylePainter>
|
#include <QStylePainter>
|
||||||
#include <QStyleOptionSlider>
|
#include <QStyleOptionSlider>
|
||||||
|
|
||||||
//#include <QScrollBar>
|
//#include <QScrollBar>
|
||||||
/*
|
/*
|
||||||
* #else
|
* #else
|
||||||
|
|
@ -71,12 +75,13 @@ public:
|
||||||
|
|
||||||
class MeterSlider : public QSlider {
|
class MeterSlider : public QSlider {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
private:
|
||||||
|
float peakValue;
|
||||||
protected:
|
protected:
|
||||||
void paintEvent(QPaintEvent *event) override;
|
void paintEvent(QPaintEvent *event) override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
void setPeakValue(float peakValue);
|
||||||
using QSlider::QSlider;
|
using QSlider::QSlider;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class ExtendedCheckBox : public QCheckBox {
|
class ExtendedCheckBox : public QCheckBox {
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ int main (int argc, char* argv[]) {
|
||||||
* log_debugcpp(a.toStdString());
|
* log_debugcpp(a.toStdString());
|
||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
//QApplication::setStyle("Fusion");
|
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();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue