Skip to content

Commit

Permalink
Fix PC Speaker going silent after a while
Browse files Browse the repository at this point in the history
For example, in Crystal Caves (any episode) the PC Speaker emits the expected
beeps and boops until some point during the game's intro. From then on, it no
longer outputted any sound.

This started with commit 84cf57b.
  • Loading branch information
carlosefr committed Oct 2, 2024
1 parent 9b4147f commit 7ce9ed4
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 7ce9ed4

Please sign in to comment.