Skip to content

Commit

Permalink
refactor(soundmanagerutil): Rename AudioPathType::MASTER enum member
Browse files Browse the repository at this point in the history
Also, convert the legacy `enum` to a scoped `enum class` and switch the
enum to PascalCase.
  • Loading branch information
Holzhaus committed Sep 9, 2023
1 parent c9e9d36 commit 43535a7
Show file tree
Hide file tree
Showing 15 changed files with 226 additions and 224 deletions.
4 changes: 2 additions & 2 deletions src/engine/channels/engineaux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ EngineChannel::ActiveState EngineAux::updateActiveState() {
}

void EngineAux::onInputConfigured(const AudioInput& input) {
if (input.getType() != AudioPath::AUXILIARY) {
if (input.getType() != AudioPathType::Auxiliary) {
// This is an error!
qDebug() << "WARNING: EngineAux connected to AudioInput for a non-auxiliary type!";
return;
Expand All @@ -56,7 +56,7 @@ void EngineAux::onInputConfigured(const AudioInput& input) {
}

void EngineAux::onInputUnconfigured(const AudioInput& input) {
if (input.getType() != AudioPath::AUXILIARY) {
if (input.getType() != AudioPathType::Auxiliary) {
// This is an error!
qDebug() << "WARNING: EngineAux connected to AudioInput for a non-auxiliary type!";
return;
Expand Down
4 changes: 2 additions & 2 deletions src/engine/channels/enginedeck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ void EngineDeck::receiveBuffer(
}

void EngineDeck::onInputConfigured(const AudioInput& input) {
if (input.getType() != AudioPath::VINYLCONTROL) {
if (input.getType() != AudioPathType::VinylControl) {
// This is an error!
qDebug() << "WARNING: EngineDeck connected to AudioInput for a non-vinylcontrol type!";
return;
Expand All @@ -142,7 +142,7 @@ void EngineDeck::onInputConfigured(const AudioInput& input) {
}

void EngineDeck::onInputUnconfigured(const AudioInput& input) {
if (input.getType() != AudioPath::VINYLCONTROL) {
if (input.getType() != AudioPathType::VinylControl) {
// This is an error!
qDebug() << "WARNING: EngineDeck connected to AudioInput for a non-vinylcontrol type!";
return;
Expand Down
4 changes: 2 additions & 2 deletions src/engine/channels/enginemicrophone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ EngineChannel::ActiveState EngineMicrophone::updateActiveState() {
}

void EngineMicrophone::onInputConfigured(const AudioInput& input) {
if (input.getType() != AudioPath::MICROPHONE) {
if (input.getType() != AudioPathType::Microphone) {
// This is an error!
qWarning() << "EngineMicrophone connected to AudioInput for a non-Microphone type!";
return;
Expand All @@ -54,7 +54,7 @@ void EngineMicrophone::onInputConfigured(const AudioInput& input) {
}

void EngineMicrophone::onInputUnconfigured(const AudioInput& input) {
if (input.getType() != AudioPath::MICROPHONE) {
if (input.getType() != AudioPathType::Microphone) {
// This is an error!
qWarning() << "EngineMicrophone connected to AudioInput for a non-Microphone type!";
return;
Expand Down
152 changes: 76 additions & 76 deletions src/engine/enginemaster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -941,22 +941,22 @@ const CSAMPLE* EngineMaster::getChannelBuffer(const QString& group) const {

const CSAMPLE* EngineMaster::buffer(const AudioOutput& output) const {
switch (output.getType()) {
case AudioOutput::MASTER:
case AudioPathType::Main:
return getMainBuffer();
break;
case AudioOutput::BOOTH:
case AudioPathType::Booth:
return getBoothBuffer();
break;
case AudioOutput::HEADPHONES:
case AudioPathType::Headphones:
return getHeadphoneBuffer();
break;
case AudioOutput::BUS:
case AudioPathType::Bus:
return getOutputBusBuffer(output.getIndex());
break;
case AudioOutput::DECK:
case AudioPathType::Deck:
return getDeckBuffer(output.getIndex());
break;
case AudioOutput::RECORD_BROADCAST:
case AudioPathType::RecordBroadcast:
return getSidechainBuffer();
break;
default:
Expand All @@ -966,107 +966,107 @@ const CSAMPLE* EngineMaster::buffer(const AudioOutput& output) const {

void EngineMaster::onOutputConnected(const AudioOutput& output) {
switch (output.getType()) {
case AudioOutput::MASTER:
case AudioPathType::Main:
// overwrite config option if a main output is configured
m_pMainEnabled->forceSet(1.0);
break;
case AudioOutput::HEADPHONES:
case AudioPathType::Headphones:
m_pMainEnabled->forceSet(1.0);
m_pHeadphoneEnabled->forceSet(1.0);
break;
case AudioOutput::BOOTH:
case AudioPathType::Booth:
m_pMainEnabled->forceSet(1.0);
m_pBoothEnabled->forceSet(1.0);
break;
case AudioOutput::BUS:
m_bBusOutputConnected[output.getIndex()] = true;
break;
case AudioOutput::DECK:
// We don't track enabled decks.
break;
case AudioOutput::RECORD_BROADCAST:
// We don't track enabled sidechain.
break;
default:
break;
case AudioPathType::Bus:
m_bBusOutputConnected[output.getIndex()] = true;
break;
case AudioPathType::Deck:
// We don't track enabled decks.
break;
case AudioPathType::RecordBroadcast:
// We don't track enabled sidechain.
break;
default:
break;
}
}

void EngineMaster::onOutputDisconnected(const AudioOutput& output) {
switch (output.getType()) {
case AudioOutput::MASTER:
// not used, because we need the main buffer for headphone mix
// and recording/broadcasting as well
break;
case AudioOutput::BOOTH:
m_pBoothEnabled->forceSet(0.0);
break;
case AudioOutput::HEADPHONES:
m_pHeadphoneEnabled->forceSet(0.0);
break;
case AudioOutput::BUS:
m_bBusOutputConnected[output.getIndex()] = false;
break;
case AudioOutput::DECK:
// We don't track enabled decks.
break;
case AudioOutput::RECORD_BROADCAST:
// We don't track enabled sidechain.
break;
default:
break;
case AudioPathType::Main:
// not used, because we need the main buffer for headphone mix
// and recording/broadcasting as well
break;
case AudioPathType::Booth:
m_pBoothEnabled->forceSet(0.0);
break;
case AudioPathType::Headphones:
m_pHeadphoneEnabled->forceSet(0.0);
break;
case AudioPathType::Bus:
m_bBusOutputConnected[output.getIndex()] = false;
break;
case AudioPathType::Deck:
// We don't track enabled decks.
break;
case AudioPathType::RecordBroadcast:
// We don't track enabled sidechain.
break;
default:
break;
}
}

void EngineMaster::onInputConnected(const AudioInput& input) {
switch (input.getType()) {
case AudioInput::MICROPHONE:
m_pNumMicsConfigured->set(m_pNumMicsConfigured->get() + 1);
break;
case AudioInput::AUXILIARY:
// We don't track enabled auxiliary inputs.
break;
case AudioInput::VINYLCONTROL:
// We don't track enabled vinyl control inputs.
break;
case AudioInput::RECORD_BROADCAST:
m_bExternalRecordBroadcastInputConnected = true;
break;
default:
break;
case AudioPathType::Microphone:
m_pNumMicsConfigured->set(m_pNumMicsConfigured->get() + 1);
break;
case AudioPathType::Auxiliary:
// We don't track enabled auxiliary inputs.
break;
case AudioPathType::VinylControl:
// We don't track enabled vinyl control inputs.
break;
case AudioPathType::RecordBroadcast:
m_bExternalRecordBroadcastInputConnected = true;
break;
default:
break;
}
}

void EngineMaster::onInputDisconnected(const AudioInput& input) {
switch (input.getType()) {
case AudioInput::MICROPHONE:
m_pNumMicsConfigured->set(m_pNumMicsConfigured->get() - 1);
break;
case AudioInput::AUXILIARY:
// We don't track enabled auxiliary inputs.
break;
case AudioInput::VINYLCONTROL:
// We don't track enabled vinyl control inputs.
break;
case AudioInput::RECORD_BROADCAST:
m_bExternalRecordBroadcastInputConnected = false;
break;
default:
break;
case AudioPathType::Microphone:
m_pNumMicsConfigured->set(m_pNumMicsConfigured->get() - 1);
break;
case AudioPathType::Auxiliary:
// We don't track enabled auxiliary inputs.
break;
case AudioPathType::VinylControl:
// We don't track enabled vinyl control inputs.
break;
case AudioPathType::RecordBroadcast:
m_bExternalRecordBroadcastInputConnected = false;
break;
default:
break;
}
}

void EngineMaster::registerNonEngineChannelSoundIO(SoundManager* pSoundManager) {
pSoundManager->registerInput(AudioInput(AudioPath::RECORD_BROADCAST, 0, 2),
m_pEngineSideChain);
pSoundManager->registerInput(AudioInput(AudioPathType::RecordBroadcast, 0, 2),
m_pEngineSideChain);

pSoundManager->registerOutput(AudioOutput(AudioOutput::MASTER, 0, 2), this);
pSoundManager->registerOutput(AudioOutput(AudioOutput::HEADPHONES, 0, 2), this);
pSoundManager->registerOutput(AudioOutput(AudioOutput::BOOTH, 0, 2), this);
pSoundManager->registerOutput(AudioOutput(AudioPathType::Main, 0, 2), this);
pSoundManager->registerOutput(AudioOutput(AudioPathType::Headphones, 0, 2), this);
pSoundManager->registerOutput(AudioOutput(AudioPathType::Booth, 0, 2), this);
for (int o = EngineChannel::LEFT; o <= EngineChannel::RIGHT; o++) {
pSoundManager->registerOutput(AudioOutput(AudioOutput::BUS, 0, 2, o), this);
pSoundManager->registerOutput(AudioOutput(AudioPathType::Bus, 0, 2, o), this);
}
pSoundManager->registerOutput(AudioOutput(AudioOutput::RECORD_BROADCAST, 0, 2), this);
pSoundManager->registerOutput(AudioOutput(AudioPathType::RecordBroadcast, 0, 2), this);
}

bool EngineMaster::sidechainMixRequired() const {
Expand Down
2 changes: 1 addition & 1 deletion src/engine/sidechain/enginesidechain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void EngineSideChain::addSideChainWorker(SideChainWorker* pWorker) {
void EngineSideChain::receiveBuffer(const AudioInput& input,
const CSAMPLE* pBuffer,
unsigned int iFrames) {
VERIFY_OR_DEBUG_ASSERT(input.getType() == AudioInput::RECORD_BROADCAST) {
VERIFY_OR_DEBUG_ASSERT(input.getType() == AudioPathType::RecordBroadcast) {
qDebug() << "WARNING: AudioInput type is not RECORD_BROADCAST. Ignoring incoming buffer.";
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/mixer/auxiliary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Auxiliary::Auxiliary(PlayerManager* pParent,
ChannelHandleAndGroup channelGroup = pEngine->registerChannelGroup(group);
EngineAux* pAuxiliary = new EngineAux(channelGroup, pEffectsManager);
pEngine->addChannel(pAuxiliary);
AudioInput auxInput = AudioInput(AudioPath::AUXILIARY, 0, 2, index);
AudioInput auxInput = AudioInput(AudioPathType::Auxiliary, 0, 2, index);
pSoundManager->registerInput(auxInput, pAuxiliary);

m_pInputConfigured = make_parented<ControlProxy>(group, "input_configured", this);
Expand Down
2 changes: 1 addition & 1 deletion src/mixer/microphone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Microphone::Microphone(PlayerManager* pParent,
EngineMicrophone* pMicrophone =
new EngineMicrophone(channelGroup, pEffectsManager);
pEngine->addChannel(pMicrophone);
AudioInput micInput = AudioInput(AudioPath::MICROPHONE, 0, 2, index);
AudioInput micInput = AudioInput(AudioPathType::Microphone, 0, 2, index);
pSoundManager->registerInput(micInput, pMicrophone);

m_pInputConfigured = make_parented<ControlProxy>(group, "input_configured", this);
Expand Down
4 changes: 2 additions & 2 deletions src/mixer/playermanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,12 +428,12 @@ void PlayerManager::addDeckInner() {

// Register the deck output with SoundManager.
m_pSoundManager->registerOutput(
AudioOutput(AudioOutput::DECK, 0, 2, deckIndex), m_pEngine);
AudioOutput(AudioPathType::Deck, 0, 2, deckIndex), m_pEngine);

// Register vinyl input signal with deck for passthrough support.
EngineDeck* pEngineDeck = pDeck->getEngineDeck();
m_pSoundManager->registerInput(
AudioInput(AudioInput::VINYLCONTROL, 0, 2, deckIndex), pEngineDeck);
AudioInput(AudioPathType::VinylControl, 0, 2, deckIndex), pEngineDeck);

// Setup equalizer and QuickEffect chain for this deck.
m_pEffectsManager->addDeck(handleGroup);
Expand Down
10 changes: 5 additions & 5 deletions src/soundio/soundmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ SoundDeviceStatus SoundManager::setupDevices() {

// Statically connect the Network Device to the Sidechain
if (pDevice->getDeviceId().name == kNetworkDeviceInternalName) {
AudioOutput out(AudioPath::RECORD_BROADCAST, 0, 2, 0);
AudioOutput out(AudioPathType::RecordBroadcast, 0, 2, 0);
outputs.append(out);
if (m_config.getForceNetworkClock() && !jackApiUsed()) {
pNewMasterClockRef = pDevice;
Expand All @@ -420,11 +420,11 @@ SoundDeviceStatus SoundManager::setupDevices() {
}

if (!m_config.getForceNetworkClock() || jackApiUsed()) {
if (out.getType() == AudioOutput::MASTER) {
if (out.getType() == AudioPathType::Main) {
pNewMasterClockRef = pDevice;
} else if ((out.getType() == AudioOutput::DECK ||
out.getType() == AudioOutput::BUS)
&& !pNewMasterClockRef) {
} else if ((out.getType() == AudioPathType::Deck ||
out.getType() == AudioPathType::Bus) &&
!pNewMasterClockRef) {
pNewMasterClockRef = pDevice;
}
}
Expand Down
18 changes: 9 additions & 9 deletions src/soundio/soundmanagerconfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ bool SoundManagerConfig::readFromDisk() {
continue;
}
AudioOutput out(AudioOutput::fromXML(outElement));
if (out.getType() == AudioPath::INVALID) {
if (out.getType() == AudioPathType::Invalid) {
continue;
}
bool dupe(false);
Expand All @@ -199,7 +199,7 @@ bool SoundManagerConfig::readFromDisk() {
continue;
}
AudioInput in(AudioInput::fromXML(inElement));
if (in.getType() == AudioPath::INVALID) {
if (in.getType() == AudioPathType::Invalid) {
continue;
}
bool dupe(false);
Expand Down Expand Up @@ -350,9 +350,9 @@ void SoundManagerConfig::setCorrectDeckCount(int configuredDeckCount) {
++it) {
const int index = it.value().getIndex();
const AudioPathType type = it.value().getType();
if ((type == AudioInput::DECK ||
type == AudioInput::VINYLCONTROL ||
type == AudioInput::AUXILIARY) &&
if ((type == AudioPathType::Deck ||
type == AudioPathType::VinylControl ||
type == AudioPathType::Auxiliary) &&
index + 1 > minimum_deck_count) {
qDebug() << "Found an input connection above current deck count";
minimum_deck_count = index + 1;
Expand All @@ -363,7 +363,7 @@ void SoundManagerConfig::setCorrectDeckCount(int configuredDeckCount) {
++it) {
const int index = it.value().getIndex();
const AudioPathType type = it.value().getType();
if (type == AudioOutput::DECK && index + 1 > minimum_deck_count) {
if (type == AudioPathType::Deck && index + 1 > minimum_deck_count) {
qDebug() << "Found an output connection above current deck count";
minimum_deck_count = index + 1;
}
Expand Down Expand Up @@ -438,9 +438,9 @@ void SoundManagerConfig::addOutput(const SoundDeviceId &device, const AudioOutpu

void SoundManagerConfig::addInput(const SoundDeviceId &device, const AudioInput &in) {
m_inputs.insert(device, in);
if (in.getType() == AudioPath::MICROPHONE) {
if (in.getType() == AudioPathType::Microphone) {
m_iNumMicInputs++;
} else if (in.getType() == AudioPath::RECORD_BROADCAST) {
} else if (in.getType() == AudioPathType::RecordBroadcast) {
m_bExternalRecordBroadcastConnected = true;
}
}
Expand Down Expand Up @@ -519,7 +519,7 @@ void SoundManagerConfig::loadDefaults(SoundManager* soundManager, unsigned int f
if (pDevice->getNumOutputChannels() < 2) {
continue;
}
AudioOutput masterOut(AudioPath::MASTER, 0, 2, 0);
AudioOutput masterOut(AudioPathType::Main, 0, 2, 0);
addOutput(pDevice->getDeviceId(), masterOut);
defaultSampleRate = pDevice->getDefaultSampleRate();
break;
Expand Down
Loading

0 comments on commit 43535a7

Please sign in to comment.