Skip to content

Commit

Permalink
Simplfied Channel Status slots
Browse files Browse the repository at this point in the history
  • Loading branch information
kshitij98 committed Jun 12, 2018
1 parent 5372b09 commit b6cdbfa
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 42 deletions.
52 changes: 14 additions & 38 deletions src/effects/effectchainslot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,16 +206,7 @@ void EffectChainSlot::setDescription(const QString& description) {
}

void EffectChainSlot::enableForInputChannel(const ChannelHandleAndGroup& handle_group) {
// TODO(Be): remove m_enabledChannels from this class and move this logic
// to EffectChainSlot
bool bWasAlreadyEnabled = m_enabledInputChannels.contains(handle_group);
if (!bWasAlreadyEnabled) {
m_enabledInputChannels.insert(handle_group);
}

// The allocation of EffectStates below may be expensive, so avoid it if
// not needed.
if (bWasAlreadyEnabled) {
if (m_enabledInputChannels.contains(handle_group)) {
return;
}

Expand Down Expand Up @@ -258,23 +249,20 @@ void EffectChainSlot::enableForInputChannel(const ChannelHandleAndGroup& handle_
request->EnableInputChannelForChain.pEffectStatesMapArray = pEffectStatesMapArray;

m_pEffectsManager->writeRequest(request);
slotChainChannelStatusChanged(handle_group.name(), true);
}

bool EffectChainSlot::enabledForChannel(const ChannelHandleAndGroup& handle_group) const {
return m_enabledInputChannels.contains(handle_group);
m_enabledInputChannels.insert(handle_group);
}

void EffectChainSlot::disableForInputChannel(const ChannelHandleAndGroup& handle_group) {
if (m_enabledInputChannels.remove(handle_group)) {
EffectsRequest* request = new EffectsRequest();
request->type = EffectsRequest::DISABLE_EFFECT_CHAIN_FOR_INPUT_CHANNEL;
request->pTargetChain = m_pEngineEffectChain;
request->DisableInputChannelForChain.pChannelHandle = &handle_group.handle();
m_pEffectsManager->writeRequest(request);

slotChainChannelStatusChanged(handle_group.name(), false);
if (!m_enabledInputChannels.remove(handle_group)) {
return;
}

EffectsRequest* request = new EffectsRequest();
request->type = EffectsRequest::DISABLE_EFFECT_CHAIN_FOR_INPUT_CHANNEL;
request->pTargetChain = m_pEngineEffectChain;
request->DisableInputChannelForChain.pChannelHandle = &handle_group.handle();
m_pEffectsManager->writeRequest(request);
}

void EffectChainSlot::setMix(const double& dMix) {
Expand Down Expand Up @@ -412,14 +400,6 @@ void EffectChainSlot::setSuperParameterDefaultValue(double value) {
m_pControlChainSuperParameter->setDefaultValue(value);
}

void EffectChainSlot::slotChainChannelStatusChanged(const QString& group,
bool enabled) {
ChannelInfo* pInfo = m_channelInfoByName.value(group, NULL);
if (pInfo != NULL && pInfo->pEnabled != NULL) {
pInfo->pEnabled->set(enabled);
}
}

void EffectChainSlot::slotChainEffectChanged(unsigned int effectSlotNumber) {
qDebug() << debugString() << "slotChainEffectChanged" << effectSlotNumber;
EffectSlotPointer pSlot;
Expand Down Expand Up @@ -494,8 +474,6 @@ void EffectChainSlot::registerInputChannel(const ChannelHandleAndGroup& handle_g
return;
}

qDebug() << "registerInputChannel" << handle_group;

double initialValue = 0.0;
int deckNumber;
if (PlayerManager::isDeckGroup(handle_group.name(), &deckNumber) &&
Expand All @@ -509,15 +487,14 @@ void EffectChainSlot::registerInputChannel(const ChannelHandleAndGroup& handle_g

ChannelInfo* pInfo = new ChannelInfo(handle_group, pEnableControl);
m_channelInfoByName[handle_group.name()] = pInfo;

// m_channelStatusMapper will emit a mapped(handle_group.name()) signal whenever
// the valueChanged(double) signal is emitted by pEnableControl
m_channelStatusMapper.setMapping(pEnableControl, handle_group.name());
connect(pEnableControl, SIGNAL(valueChanged(double)),
&m_channelStatusMapper, SLOT(map()));

if (pInfo->pEnabled->toBool()) {
enableForInputChannel(pInfo->handle_group);
} else {
disableForInputChannel(pInfo->handle_group);
}
slotChannelStatusChanged(handle_group.name());
}

void EffectChainSlot::slotEffectLoaded(EffectPointer pEffect, unsigned int slotNumber) {
Expand Down Expand Up @@ -583,7 +560,6 @@ void EffectChainSlot::slotControlChainPrevPreset(double v) {
}

void EffectChainSlot::slotChannelStatusChanged(const QString& group) {
qDebug() << "slotChannelStatusChanged";
ChannelInfo* pChannelInfo = m_channelInfoByName.value(group, NULL);
if (pChannelInfo != NULL && pChannelInfo->pEnabled != NULL) {
bool bEnable = pChannelInfo->pEnabled->toBool();
Expand Down
4 changes: 0 additions & 4 deletions src/effects/effectchainslot.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ class EffectChainSlot : public QObject {
// Activates EffectChain processing for the provided channel.
// TODO(Kshitij) : Make this function private once EffectRack layer is removed
void enableForInputChannel(const ChannelHandleAndGroup& handle_group);
bool enabledForChannel(const ChannelHandleAndGroup& handle_group) const;
const QSet<ChannelHandleAndGroup>& enabledChannels() const;
void disableForInputChannel(const ChannelHandleAndGroup& handle_group);

Expand Down Expand Up @@ -158,10 +157,7 @@ class EffectChainSlot : public QObject {

private slots:
void sendParameterUpdate();

void slotChainEffectChanged(unsigned int effectSlotNumber);
void slotChainChannelStatusChanged(const QString& group, bool enabled);

void slotEffectLoaded(EffectPointer pEffect, unsigned int slotNumber);
// Clears the effect in the given position in the loaded EffectChain.
void slotClearEffect(unsigned int iEffectSlotNumber);
Expand Down

0 comments on commit b6cdbfa

Please sign in to comment.