Skip to content

Commit

Permalink
Don't propagate expander sense pins if no expander connected
Browse files Browse the repository at this point in the history
  • Loading branch information
danngreen committed Jan 18, 2025
1 parent 317852e commit 68e15a6
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions firmware/src/audio/audio.cc
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ void AudioStream::step() {
}

void AudioStream::start() {
update_audio_settings();
if (ext_audio_connected)
codec_ext_.start();
codec_.start();
}

void AudioStream::handle_overruns() {
Expand Down Expand Up @@ -372,21 +374,23 @@ void AudioStream::propagate_sense_pins(uint32_t jack_senses) {
i++;
}

for (unsigned i = 0; auto &plug_detect : ext_plug_detects) {
bool sense = AudioExpander::jack_is_patched(jack_senses, i);
if (ext_audio_connected) {
for (unsigned i = 0; auto &plug_detect : ext_plug_detects) {
bool sense = AudioExpander::jack_is_patched(jack_senses, i);

plug_detect.update(sense);
plug_detect.update(sense);

if (plug_detect.changed()) {
if (i < AudioExpander::NumInJacks) {
auto panel_in_jack = AudioExpander::exp_to_panel_input(i);
player.set_input_jack_patched_status(panel_in_jack, sense);
} else {
auto panel_out_jack = AudioExpander::exp_to_panel_output(i - AudioExpander::NumInJacks);
player.set_output_jack_patched_status(panel_out_jack, sense);
if (plug_detect.changed()) {
if (i < AudioExpander::NumInJacks) {
auto panel_in_jack = AudioExpander::exp_to_panel_input(i);
player.set_input_jack_patched_status(panel_in_jack, sense);
} else {
auto panel_out_jack = AudioExpander::exp_to_panel_output(i - AudioExpander::NumInJacks);
player.set_output_jack_patched_status(panel_out_jack, sense);
}
}
i++;
}
i++;
}

param_state.jack_senses = jack_senses;
Expand Down

0 comments on commit 68e15a6

Please sign in to comment.