Skip to content

Commit

Permalink
Merge pull request #537 from carlosefr/carlosefr/crystal
Browse files Browse the repository at this point in the history
Fix PC Speaker going silent after a while
  • Loading branch information
schellingb authored Oct 9, 2024
2 parents 9b4147f + 7ce9ed4 commit f172143
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/hardware/pcspeaker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,10 @@ void PCSPEAKER_SetCounter(Bitu cntr,Bitu mode) {
return;
}
spkr.pit_mode=mode;

//DBP: Delay sound output until second event to avoid crackling audio when initialized but not used
if (!spkr.enabled && spkr.used > 1) {
if(spkr.chan) spkr.chan->Enable(true);
spkr.enabled=true;
}
if (!spkr.enabled && spkr.used > 1) spkr.enabled=true;
if (spkr.chan) spkr.chan->Enable(spkr.enabled);
}

void PCSPEAKER_SetType(Bitu mode) {
Expand Down Expand Up @@ -248,11 +247,10 @@ void PCSPEAKER_SetType(Bitu mode) {
spkr.mode=SPKR_PIT_ON;
break;
};

//DBP: Delay sound output until second event to avoid crackling audio when initialized but not used
if (!spkr.enabled && (spkr.used > 1 || mode > 1)) {
if(spkr.chan) spkr.chan->Enable(true);
spkr.enabled=true;
}
if (!spkr.enabled && (spkr.used > 1 || mode > 1)) spkr.enabled=true;
if (spkr.chan) spkr.chan->Enable(spkr.enabled);
}

static void PCSPEAKER_CallBack(Bitu len) {
Expand Down

0 comments on commit f172143

Please sign in to comment.