Skip to content

Commit

Permalink
Fix search for model specific audio files for switches.
Browse files Browse the repository at this point in the history
  • Loading branch information
philmoz committed Oct 30, 2023
1 parent 745bb8d commit 3289857
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions radio/src/audio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,16 +335,15 @@ void getSwitchAudioFile(char * filename, swsrc_t index)
{
char * str = getModelAudioPath(filename);

if (index <= MAX_SWITCHES * 3) {
if (index <= SWSRC_LAST_SWITCH) {
div_t swinfo = switchInfo(index);
*str++ = 'S';
*str++ = switchGetLetter(swinfo.quot);
const char * positions[] = { "-up", "-mid", "-down" };
strcpy(str, positions[swinfo.rem]);
}
else {
index -= MAX_SWITCHES * 3;
div_t swinfo = div((int)index, XPOTS_MULTIPOS_COUNT);
div_t swinfo = div((int)(index - SWSRC_FIRST_MULTIPOS_SWITCH), XPOTS_MULTIPOS_COUNT);
*str++ = 'S';
*str++ = '1' + swinfo.quot;
*str++ = '1' + swinfo.rem;
Expand Down Expand Up @@ -412,7 +411,7 @@ void referenceModelAudioFiles()

// Switches Audio Files <switchname>-[up|mid|down].wav
for (unsigned i = 0; i <= MAX_SWITCH_POSITIONS && !found; i++) {
getSwitchAudioFile(path, i);
getSwitchAudioFile(path, SWSRC_FIRST_SWITCH+i);
// TRACE("referenceModelAudioFiles(): searching for %s in %s (%d)", path, fno.fname, i);
if (!strcasecmp(filename, fno.fname)) {
sdAvailableSwitchAudioFiles.setBit(i);
Expand Down

0 comments on commit 3289857

Please sign in to comment.