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"
|
||||
VPATH += "$$PWD\src" "$$PWD\src\qt" "$$PWD\src\back" "$$PWD\src\cont"
|
||||
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"
|
||||
|
|
|
|||
|
|
@ -3,12 +3,35 @@
|
|||
Endpoint::Endpoint(IMMDevice* ep){
|
||||
this->endpoint = ep;
|
||||
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) {
|
||||
if(FAILED(endpointVolume->SetMasterVolumeLevelScalar(volume, NULL))) { log_debugcpp("si"); };
|
||||
}
|
||||
|
||||
//Endpoint::~Endpoint(){
|
||||
// free(friendlyName);
|
||||
// properties->Release();
|
||||
// endpointVolume->Release();
|
||||
// endpoint->Release();
|
||||
//}
|
||||
|
||||
|
||||
void Overseer::initCOMLibrary(){
|
||||
if(FAILED(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED))) { log_debugcpp("si"); };
|
||||
|
|
@ -67,6 +90,13 @@ std::vector<Endpoint*> Overseer::getPlaybackEndpoints() {
|
|||
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);
|
||||
|
||||
//IMMDeviceEnumerator** Overseer::setOrigin();
|
||||
|
|
|
|||
|
|
@ -1,9 +1,7 @@
|
|||
#pragma once
|
||||
#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 <iostream>
|
||||
|
||||
|
|
@ -25,11 +23,16 @@ class Endpoint {
|
|||
public:
|
||||
Endpoint(IMMDevice* endpoint);
|
||||
void setVolume(float volume);
|
||||
float getVolume();
|
||||
LPWSTR getName();
|
||||
//~Endpoint();
|
||||
|
||||
private:
|
||||
IMMDevice* endpoint;
|
||||
IAudioEndpointVolume *endpointVolume;
|
||||
|
||||
IAudioEndpointVolume *endpointVolume ;
|
||||
IPropertyStore *properties;
|
||||
LPWSTR friendlyName;
|
||||
// LPWSTR endpointID = NULL;
|
||||
};
|
||||
|
||||
class Overseer {
|
||||
|
|
@ -43,6 +46,7 @@ class Overseer {
|
|||
//int getDefaultCaptureEndpoint(Endpoint** defaultEndpoint);
|
||||
//int getCaptureEndpoints(std::vector<Endpoint*> *captureEndpoints);
|
||||
//IMMDeviceEnumerator** setOrigin();
|
||||
//~Overseer();
|
||||
|
||||
private:
|
||||
unsigned int numPlaybackEndpoints;
|
||||
|
|
|
|||
|
|
@ -109,9 +109,13 @@ void PrintEndpointNames() {
|
|||
hr = endpointPtr->Activate(IID_IAudioEndpointVolume, CLSCTX_ALL, NULL, (void**)&endpointVolumePtr);
|
||||
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);
|
||||
|
||||
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
|
||||
//Y justo despues, el que da control a nivel sonoro xdddddddddddddddddddddddddddddddddddddddddddddd
|
||||
hr = endpointPtr->Activate(__uuidof(IAudioSessionManager2), CLSCTX_ALL, NULL, (void**) &sessionManagerPtr);
|
||||
|
|
@ -159,7 +163,7 @@ void PrintEndpointNames() {
|
|||
SAFE_RELEASE(endpointVolumePtr);
|
||||
SAFE_RELEASE(sessionManagerPtr);
|
||||
SAFE_RELEASE(sessionEnumeratorPtr);
|
||||
SAFE_RELEASE(sessionControlPtr);
|
||||
//SAFE_RELEASE(sessionControlPtr);
|
||||
SAFE_RELEASE(sessionControl2Ptr);
|
||||
SAFE_RELEASE(sessionVolumePtr);
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -4,12 +4,21 @@ Overseer OverseerHandler::os;
|
|||
|
||||
EndpointHandler::EndpointHandler(Endpoint *ept, QObject *parent) : QObject(parent) {
|
||||
this->ept = ept;
|
||||
eptName = QString::fromStdWString(ept->getName());
|
||||
}
|
||||
|
||||
void EndpointHandler::setValue(int value){
|
||||
ept->setVolume((float)value / 100);
|
||||
}
|
||||
|
||||
QString EndpointHandler::getName(){
|
||||
return eptName;
|
||||
}
|
||||
|
||||
float EndpointHandler::getVolume(){
|
||||
return ept->getVolume();
|
||||
}
|
||||
|
||||
Overseer OverseerHandler::getOverseer(){
|
||||
return os;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#pragma once
|
||||
#include <QObject>
|
||||
#include "global.h"
|
||||
#include "backlasses.h"
|
||||
|
||||
|
||||
|
|
@ -8,15 +9,17 @@ class EndpointHandler : public QObject {
|
|||
|
||||
public:
|
||||
EndpointHandler(Endpoint *ept, QObject *parent = nullptr);
|
||||
|
||||
QString getName();
|
||||
float getVolume();
|
||||
|
||||
private:
|
||||
Endpoint *ept;
|
||||
QString eptName;
|
||||
//QSlider *slidy;
|
||||
|
||||
public slots:
|
||||
void setValue(int value);
|
||||
|
||||
|
||||
|
||||
//signals:
|
||||
|
||||
|
|
|
|||
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);
|
||||
widget = new QWidget();
|
||||
layout = new QGridLayout();
|
||||
pintas = new QLabel(tr("Defaulto da"));
|
||||
|
||||
widget->setLayout(layout);
|
||||
setCentralWidget(widget);
|
||||
layout->addWidget(pintas, 0, 0);
|
||||
//layout->addWidget(pintas, 0, 0);
|
||||
|
||||
setWindowTitle("slidea resbala nu c");
|
||||
|
||||
setEndpointHandlers(ephs);
|
||||
for (unsigned int i = 0; i < this->ephs->size(); i++){
|
||||
QLabel *pintas = new QLabel(ephs->at(i)->getName());
|
||||
QSlider *teSlider = new QSlider(Qt::Horizontal);
|
||||
teSlider->setFocusPolicy(Qt::StrongFocus);
|
||||
teSlider->setTickPosition(QSlider::TicksBothSides);
|
||||
teSlider->setTickInterval(5);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
#include <QLabel>
|
||||
#include <QSlider>
|
||||
#include <QGridLayout>
|
||||
//#include "global.h"
|
||||
#include "contclasses.h"
|
||||
//#include <Q>
|
||||
//#include <QWidgets>
|
||||
|
|
@ -19,13 +20,14 @@ class MainWindow : public QMainWindow {
|
|||
|
||||
public:
|
||||
MainWindow(std::vector<EndpointHandler*> *ephs, QWidget *parent = nullptr);
|
||||
void setEndpointHandlers(std::vector<EndpointHandler*> *ephs);
|
||||
|
||||
private:
|
||||
std::vector<EndpointHandler*> *ephs;
|
||||
std::vector<QSlider> *sliders;
|
||||
QWidget *widget;
|
||||
QGridLayout *layout;
|
||||
QLabel *pintas;
|
||||
//QLabel *pintas;
|
||||
|
||||
//public slots:
|
||||
// void setEndpointHandlers(std::vector<EndpointHandler*> *ephs);
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ int main (int argc, char* argv[]) {
|
|||
//INIT FRONT
|
||||
QScopedPointer<QApplication> app(createApplication(argc, argv));
|
||||
MainWindow window = MainWindow(ephs);
|
||||
window.setEndpointHandlers(ephs);
|
||||
//window.setEndpointHandlers(ephs);
|
||||
app->setStyle("windowsvista");
|
||||
window.show();
|
||||
return app->exec();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue