152 lines
3.8 KiB
C++
152 lines
3.8 KiB
C++
#include "backlasses.h"
|
|
#include "contclasses.h"
|
|
//TODO: pragma once
|
|
|
|
//TODO: ?????
|
|
Overseer OverseerHandler::os;
|
|
|
|
EndpointHandler::EndpointHandler(uint64_t idx) {
|
|
//std::vector<Endpoint*> endpoints = osh->getPlaybackEndpoints().at(idx);
|
|
this->ep = osh->getPlaybackEndpoints().at(idx);
|
|
epc = new EndpointCallback(ep);
|
|
//epName = ep->getName();
|
|
ep->setCallback(epc);
|
|
}
|
|
|
|
uint32_t EndpointHandler::getChannelCount(){
|
|
return ep->getChannelCount();
|
|
}
|
|
|
|
void EndpointHandler::setIndex(uint64_t idx){
|
|
this->idx = idx;
|
|
}
|
|
|
|
uint64_t EndpointHandler::getIndex(){
|
|
return idx;
|
|
}
|
|
|
|
/*
|
|
* -1 for master volume
|
|
*/
|
|
void EndpointHandler::setVolume(NGuid* guid, int channel, int value){
|
|
if (channel == ENDPOINT_MASTER_VOLUME)
|
|
ep->setVolume(guid, channel, (float)value / 100);
|
|
else ep->setVolume(guid, channel, (float)value / 100);
|
|
}
|
|
|
|
void EndpointHandler::setMute(NGuid* guid, bool muted){
|
|
//Qt momento, de ahi el param?
|
|
//TODO: mutex test
|
|
//log_debugcpp("kinda handling the muting tbh");
|
|
ep->setMute(guid, muted);
|
|
}
|
|
|
|
std::wstring EndpointHandler::getName(){
|
|
return ep->getName();
|
|
}
|
|
|
|
float EndpointHandler::getVolume(int channel){
|
|
return ep->getVolume(channel);
|
|
}
|
|
|
|
bool EndpointHandler::getMute(){
|
|
return ep->getMute();
|
|
}
|
|
|
|
EndpointHandler::~EndpointHandler() {
|
|
ep->removeCallback(epc);
|
|
epc->Release();
|
|
delete ep;
|
|
}
|
|
|
|
std::vector<Endpoint*> OverseerHandler::getPlaybackEndpoints() {
|
|
return this->os.getPlaybackEndpoints();
|
|
}
|
|
|
|
|
|
std::vector<EndpointHandler*> OverseerHandler::getEndpointHandlers(){
|
|
return endpointHandlers;
|
|
}
|
|
|
|
uint64_t OverseerHandler::getPlaybackEndpointsCount(){
|
|
return this->os.getPlaybackEndpoints().size();
|
|
}
|
|
|
|
void OverseerHandler::reloadEndpointHandlers(){
|
|
//std::vector<EndpointHandler*>* ephs = new std::vector<EndpointHandler*>;
|
|
log_debugcpp(" VSize: " << this->getPlaybackEndpointsCount());
|
|
|
|
for(uint64_t i = 0; i < this->getPlaybackEndpointsCount(); i++){
|
|
log_debugcpp("Creating handler " << i);
|
|
|
|
if(i < (this->endpointHandlers.size()) &&
|
|
this->endpointHandlers.at(i) != nullptr)
|
|
delete endpointHandlers.at(i);
|
|
|
|
EndpointHandler* eph = new EndpointHandler(i);
|
|
log_debugcpp("Created handler " << i << ", adding to vector. " << " VSize: " << this->getPlaybackEndpointsCount());
|
|
|
|
if (i >= this->endpointHandlers.size())
|
|
endpointHandlers.push_back(eph);
|
|
else endpointHandlers.at(i) = eph;
|
|
}
|
|
//setEndpointHandlers(ephs);
|
|
}
|
|
|
|
NGuid* OverseerHandler::getGuid() {
|
|
return this->os.getGuid();
|
|
}
|
|
|
|
void OverseerHandler::setEndpointHandlers(std::vector<EndpointHandler*> ephs){
|
|
this->endpointHandlers = ephs;
|
|
}
|
|
|
|
void OverseerHandler::setFrontVolumeCallback(std::function<void(uint64_t, uint32_t, float)> f) {
|
|
this->updateFrontVolumeCallback = f;
|
|
}
|
|
|
|
void OverseerHandler::setFrontMuteCallback(std::function<void(uint64_t, bool)> f) {
|
|
this->updateFrontMuteCallback = f;
|
|
}
|
|
|
|
/*
|
|
* void OverseerHandler::updateMuteCallback(uint64_t idx, bool muted){
|
|
* updateFrontMuteCallback(idx, muted);
|
|
* }
|
|
*/
|
|
|
|
/*
|
|
* void OverseerHandler::updateMainVolumeCallback(uint64_t idx, float newVal){
|
|
*
|
|
* }
|
|
*/
|
|
|
|
/*
|
|
* void OverseerHandler::updateVolumeCallback(uint64_t idx, uint32_t channel, float newVal){
|
|
* if (channel == (uint32_t)AudioChannel::CHANNEL_MAIN) {
|
|
* //TODO: mutex test
|
|
* //log_debugcpp("mainvolcallback float: " << newVal);
|
|
* updateFrontVolumeCallback(idx, AudioChannel::CHANNEL_MAIN, newVal);
|
|
* return;
|
|
* }
|
|
*
|
|
*
|
|
* // convert channel to bitmask
|
|
* uint32_t i = 0;
|
|
* while (i < channel)
|
|
* i++;
|
|
* uint32_t mask = (1 << i);
|
|
* //TODO: Mutex test
|
|
* //log_debugcpp("Back->Cont Channel: " << mask << " volcallback float: " << newVal);
|
|
*
|
|
* updateFrontVolumeCallback(idx, mask, newVal);
|
|
* }
|
|
*/
|
|
|
|
/*
|
|
* void OverseerHandler::receiveBackEndpointCallback(uint64_t index) {
|
|
* if (memcmp(os.getGuid(), callbackInfo.caller, sizeof(*guid)) != 0)
|
|
* updateFrontCallback(uint64_t index, &callbackInfo);
|
|
*
|
|
* }
|
|
*/
|