Only change output mode if the new output mode is different

custom
ailurux 2 months ago
parent 4f08a0838a
commit 285c4928af
  1. 12
      src/tangara/audio/audio_fsm.cpp

@ -390,16 +390,20 @@ void AudioState::react(const OutputModeChanged& ev) {
if (ev.set_to) {
new_mode = *ev.set_to;
}
std::shared_ptr<IAudioOutput> new_output;
switch (new_mode) {
case drivers::NvsStorage::Output::kBluetooth:
sOutput = sBtOutput;
sI2SOutput->mode(IAudioOutput::Modes::kOff);
new_output = sBtOutput;
break;
case drivers::NvsStorage::Output::kHeadphones:
sOutput = sI2SOutput;
sBtOutput->mode(IAudioOutput::Modes::kOff);
new_output = sI2SOutput;
break;
}
if (new_output == sOutput) {
return;
}
sOutput->mode(IAudioOutput::Modes::kOff);
sOutput = new_output;
sSampleProcessor->SetOutput(sOutput);
updateOutputMode();

Loading…
Cancel
Save