global h, slidy boi starts where it should, name
This commit is contained in:
parent
3ea2e739ae
commit
e61c600019
10 changed files with 77 additions and 16 deletions
|
|
@ -4,5 +4,5 @@ INCLUDEPATH += "$$PWD\src" "$$PWD\src\qt" "$$PWD\src\back" "$$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\cont"
|
||||||
VPATH += "$$PWD\src" "$$PWD\src\qt" "$$PWD\src\back" "$$PWD\src\cont"
|
VPATH += "$$PWD\src" "$$PWD\src\qt" "$$PWD\src\back" "$$PWD\src\cont"
|
||||||
SOURCES += qtestmain.cpp qtclasses.cpp backlasses.cpp contclasses.cpp
|
SOURCES += qtestmain.cpp qtclasses.cpp backlasses.cpp contclasses.cpp
|
||||||
HEADERS += qtclasses.h backlasses.h contclasses.h
|
HEADERS += qtclasses.h backlasses.h contclasses.h global.h
|
||||||
#DESTDIR += "build"
|
#DESTDIR += "build"
|
||||||
|
|
|
||||||
|
|
@ -3,12 +3,35 @@
|
||||||
Endpoint::Endpoint(IMMDevice* ep){
|
Endpoint::Endpoint(IMMDevice* ep){
|
||||||
this->endpoint = ep;
|
this->endpoint = ep;
|
||||||
if(FAILED(endpoint->Activate(IID_IAudioEndpointVolume, CLSCTX_ALL, NULL, (void**)&endpointVolume))) { log_debugcpp("si"); };
|
if(FAILED(endpoint->Activate(IID_IAudioEndpointVolume, CLSCTX_ALL, NULL, (void**)&endpointVolume))) { log_debugcpp("si"); };
|
||||||
|
//Obtaining friendly name: IPropertyStore creates PROPVARIANT per field
|
||||||
|
// hr = endpointPtr->GetId(&endpointID);
|
||||||
|
endpoint->OpenPropertyStore(STGM_READ, &properties);
|
||||||
|
PROPVARIANT pv;
|
||||||
|
properties->GetValue(PKEY_Device_FriendlyName , &pv);
|
||||||
|
friendlyName = pv.pwszVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
LPWSTR Endpoint::getName(){
|
||||||
|
return friendlyName;
|
||||||
|
}
|
||||||
|
|
||||||
|
float Endpoint::getVolume(){
|
||||||
|
float volume;
|
||||||
|
if(FAILED(endpointVolume->GetMasterVolumeLevelScalar(&volume))) { log_debugcpp("si");}
|
||||||
|
return volume;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Endpoint::setVolume(float volume) {
|
void Endpoint::setVolume(float volume) {
|
||||||
if(FAILED(endpointVolume->SetMasterVolumeLevelScalar(volume, NULL))) { log_debugcpp("si"); };
|
if(FAILED(endpointVolume->SetMasterVolumeLevelScalar(volume, NULL))) { log_debugcpp("si"); };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Endpoint::~Endpoint(){
|
||||||
|
// free(friendlyName);
|
||||||
|
// properties->Release();
|
||||||
|
// endpointVolume->Release();
|
||||||
|
// endpoint->Release();
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
void Overseer::initCOMLibrary(){
|
void Overseer::initCOMLibrary(){
|
||||||
if(FAILED(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED))) { log_debugcpp("si"); };
|
if(FAILED(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED))) { log_debugcpp("si"); };
|
||||||
|
|
@ -67,6 +90,13 @@ std::vector<Endpoint*> Overseer::getPlaybackEndpoints() {
|
||||||
return playbackDevices;
|
return playbackDevices;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Overseer::~Overseer(){
|
||||||
|
// deviceEnumerator->Release();
|
||||||
|
// for(unsigned long long i = 0; i < playbackDevices.size(); i++){
|
||||||
|
//delete(playbackDevices.at(i));
|
||||||
|
//}
|
||||||
|
//}
|
||||||
|
|
||||||
//int Overseer::getCaptureEndpoints(std::vector<Endpoint*> *captureEndpoints);
|
//int Overseer::getCaptureEndpoints(std::vector<Endpoint*> *captureEndpoints);
|
||||||
|
|
||||||
//IMMDeviceEnumerator** Overseer::setOrigin();
|
//IMMDeviceEnumerator** Overseer::setOrigin();
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
#define log_debugcpp(str) do { \
|
|
||||||
std::cout << "[DEBUG]" << "(" << __FILE__ << ":" << __LINE__ << "): " << str << std::endl; \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
|
#include "global.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
|
@ -25,11 +23,16 @@ class Endpoint {
|
||||||
public:
|
public:
|
||||||
Endpoint(IMMDevice* endpoint);
|
Endpoint(IMMDevice* endpoint);
|
||||||
void setVolume(float volume);
|
void setVolume(float volume);
|
||||||
|
float getVolume();
|
||||||
|
LPWSTR getName();
|
||||||
|
//~Endpoint();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
IMMDevice* endpoint;
|
IMMDevice* endpoint;
|
||||||
IAudioEndpointVolume *endpointVolume;
|
IAudioEndpointVolume *endpointVolume ;
|
||||||
|
IPropertyStore *properties;
|
||||||
|
LPWSTR friendlyName;
|
||||||
|
// LPWSTR endpointID = NULL;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Overseer {
|
class Overseer {
|
||||||
|
|
@ -43,6 +46,7 @@ class Overseer {
|
||||||
//int getDefaultCaptureEndpoint(Endpoint** defaultEndpoint);
|
//int getDefaultCaptureEndpoint(Endpoint** defaultEndpoint);
|
||||||
//int getCaptureEndpoints(std::vector<Endpoint*> *captureEndpoints);
|
//int getCaptureEndpoints(std::vector<Endpoint*> *captureEndpoints);
|
||||||
//IMMDeviceEnumerator** setOrigin();
|
//IMMDeviceEnumerator** setOrigin();
|
||||||
|
//~Overseer();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
unsigned int numPlaybackEndpoints;
|
unsigned int numPlaybackEndpoints;
|
||||||
|
|
|
||||||
|
|
@ -109,8 +109,12 @@ void PrintEndpointNames() {
|
||||||
hr = endpointPtr->Activate(IID_IAudioEndpointVolume, CLSCTX_ALL, NULL, (void**)&endpointVolumePtr);
|
hr = endpointPtr->Activate(IID_IAudioEndpointVolume, CLSCTX_ALL, NULL, (void**)&endpointVolumePtr);
|
||||||
EXIT_ON_ERROR(hr)
|
EXIT_ON_ERROR(hr)
|
||||||
|
|
||||||
hr = endpointVolumePtr->SetMasterVolumeLevelScalar(0.4f, NULL);
|
//hr = endpointVolumePtr->SetMasterVolumeLevelScalar(0.4f, NULL);
|
||||||
|
//EXIT_ON_ERROR(hr);
|
||||||
|
float volume;
|
||||||
|
hr = endpointVolumePtr->GetMasterVolumeLevelScalar(&volume);
|
||||||
EXIT_ON_ERROR(hr);
|
EXIT_ON_ERROR(hr);
|
||||||
|
printf("Endpoint %d: \"%S\" volume: (%f)\n", 0, varName.pwszVal, volume);
|
||||||
|
|
||||||
//Registramos el gestor de sesiones para conseguir el handle que da el handle de sesiones a nivel informativo
|
//Registramos el gestor de sesiones para conseguir el handle que da el handle de sesiones a nivel informativo
|
||||||
//Y justo despues, el que da control a nivel sonoro xdddddddddddddddddddddddddddddddddddddddddddddd
|
//Y justo despues, el que da control a nivel sonoro xdddddddddddddddddddddddddddddddddddddddddddddd
|
||||||
|
|
@ -159,7 +163,7 @@ void PrintEndpointNames() {
|
||||||
SAFE_RELEASE(endpointVolumePtr);
|
SAFE_RELEASE(endpointVolumePtr);
|
||||||
SAFE_RELEASE(sessionManagerPtr);
|
SAFE_RELEASE(sessionManagerPtr);
|
||||||
SAFE_RELEASE(sessionEnumeratorPtr);
|
SAFE_RELEASE(sessionEnumeratorPtr);
|
||||||
SAFE_RELEASE(sessionControlPtr);
|
//SAFE_RELEASE(sessionControlPtr);
|
||||||
SAFE_RELEASE(sessionControl2Ptr);
|
SAFE_RELEASE(sessionControl2Ptr);
|
||||||
SAFE_RELEASE(sessionVolumePtr);
|
SAFE_RELEASE(sessionVolumePtr);
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -4,12 +4,21 @@ Overseer OverseerHandler::os;
|
||||||
|
|
||||||
EndpointHandler::EndpointHandler(Endpoint *ept, QObject *parent) : QObject(parent) {
|
EndpointHandler::EndpointHandler(Endpoint *ept, QObject *parent) : QObject(parent) {
|
||||||
this->ept = ept;
|
this->ept = ept;
|
||||||
|
eptName = QString::fromStdWString(ept->getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
void EndpointHandler::setValue(int value){
|
void EndpointHandler::setValue(int value){
|
||||||
ept->setVolume((float)value / 100);
|
ept->setVolume((float)value / 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString EndpointHandler::getName(){
|
||||||
|
return eptName;
|
||||||
|
}
|
||||||
|
|
||||||
|
float EndpointHandler::getVolume(){
|
||||||
|
return ept->getVolume();
|
||||||
|
}
|
||||||
|
|
||||||
Overseer OverseerHandler::getOverseer(){
|
Overseer OverseerHandler::getOverseer(){
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
#include "global.h"
|
||||||
#include "backlasses.h"
|
#include "backlasses.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -8,10 +9,12 @@ class EndpointHandler : public QObject {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
EndpointHandler(Endpoint *ept, QObject *parent = nullptr);
|
EndpointHandler(Endpoint *ept, QObject *parent = nullptr);
|
||||||
|
QString getName();
|
||||||
|
float getVolume();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Endpoint *ept;
|
Endpoint *ept;
|
||||||
|
QString eptName;
|
||||||
//QSlider *slidy;
|
//QSlider *slidy;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
|
||||||
4
src/global.h
Normal file
4
src/global.h
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
#pragma once
|
||||||
|
#define log_debugcpp(str) do { \
|
||||||
|
std::cout << "[DEBUG]" << "(" << __FILE__ << ":" << __LINE__ << "): " << str << std::endl; \
|
||||||
|
} while (0)
|
||||||
|
|
@ -5,22 +5,27 @@ MainWindow::MainWindow(std::vector<EndpointHandler*> *ephs, QWidget *parent) : Q
|
||||||
// setCentralWidget(centralWidget);
|
// setCentralWidget(centralWidget);
|
||||||
widget = new QWidget();
|
widget = new QWidget();
|
||||||
layout = new QGridLayout();
|
layout = new QGridLayout();
|
||||||
pintas = new QLabel(tr("Defaulto da"));
|
|
||||||
|
|
||||||
widget->setLayout(layout);
|
widget->setLayout(layout);
|
||||||
setCentralWidget(widget);
|
setCentralWidget(widget);
|
||||||
layout->addWidget(pintas, 0, 0);
|
//layout->addWidget(pintas, 0, 0);
|
||||||
|
|
||||||
setWindowTitle("slidea resbala nu c");
|
setWindowTitle("slidea resbala nu c");
|
||||||
|
|
||||||
setEndpointHandlers(ephs);
|
setEndpointHandlers(ephs);
|
||||||
for (unsigned int i = 0; i < this->ephs->size(); i++){
|
for (unsigned int i = 0; i < this->ephs->size(); i++){
|
||||||
|
QLabel *pintas = new QLabel(ephs->at(i)->getName());
|
||||||
QSlider *teSlider = new QSlider(Qt::Horizontal);
|
QSlider *teSlider = new QSlider(Qt::Horizontal);
|
||||||
teSlider->setFocusPolicy(Qt::StrongFocus);
|
teSlider->setFocusPolicy(Qt::StrongFocus);
|
||||||
teSlider->setTickPosition(QSlider::TicksBothSides);
|
teSlider->setTickPosition(QSlider::TicksBothSides);
|
||||||
teSlider->setTickInterval(5);
|
teSlider->setTickInterval(5);
|
||||||
teSlider->setSingleStep(1);
|
teSlider->setSingleStep(1);
|
||||||
layout->addWidget(teSlider, 0, i + 1);
|
teSlider->setRange(0,100);
|
||||||
|
float volume = ephs->at(i)->getVolume() * 100;
|
||||||
|
teSlider->setValue((int)volume);
|
||||||
|
log_debugcpp("ENDPOINT SET WITH VOLUME " << volume);
|
||||||
|
layout->addWidget(pintas, i, 0);
|
||||||
|
layout->addWidget(teSlider, i, 1);
|
||||||
connect(teSlider, &QSlider::valueChanged, ephs->at(i), &EndpointHandler::setValue);
|
connect(teSlider, &QSlider::valueChanged, ephs->at(i), &EndpointHandler::setValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QSlider>
|
#include <QSlider>
|
||||||
#include <QGridLayout>
|
#include <QGridLayout>
|
||||||
|
//#include "global.h"
|
||||||
#include "contclasses.h"
|
#include "contclasses.h"
|
||||||
//#include <Q>
|
//#include <Q>
|
||||||
//#include <QWidgets>
|
//#include <QWidgets>
|
||||||
|
|
@ -19,13 +20,14 @@ class MainWindow : public QMainWindow {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MainWindow(std::vector<EndpointHandler*> *ephs, QWidget *parent = nullptr);
|
MainWindow(std::vector<EndpointHandler*> *ephs, QWidget *parent = nullptr);
|
||||||
|
void setEndpointHandlers(std::vector<EndpointHandler*> *ephs);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<EndpointHandler*> *ephs;
|
std::vector<EndpointHandler*> *ephs;
|
||||||
std::vector<QSlider> *sliders;
|
std::vector<QSlider> *sliders;
|
||||||
QWidget *widget;
|
QWidget *widget;
|
||||||
QGridLayout *layout;
|
QGridLayout *layout;
|
||||||
QLabel *pintas;
|
//QLabel *pintas;
|
||||||
|
|
||||||
//public slots:
|
//public slots:
|
||||||
// void setEndpointHandlers(std::vector<EndpointHandler*> *ephs);
|
// void setEndpointHandlers(std::vector<EndpointHandler*> *ephs);
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ int main (int argc, char* argv[]) {
|
||||||
//INIT FRONT
|
//INIT FRONT
|
||||||
QScopedPointer<QApplication> app(createApplication(argc, argv));
|
QScopedPointer<QApplication> app(createApplication(argc, argv));
|
||||||
MainWindow window = MainWindow(ephs);
|
MainWindow window = MainWindow(ephs);
|
||||||
window.setEndpointHandlers(ephs);
|
//window.setEndpointHandlers(ephs);
|
||||||
app->setStyle("windowsvista");
|
app->setStyle("windowsvista");
|
||||||
window.show();
|
window.show();
|
||||||
return app->exec();
|
return app->exec();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue