ref: ab14960e3a24208709270fb11476f0bbb629b145
parent: 628ba41ead3e50fe71581131fd2fa22c50739df6
author: Simon Howard <[email protected]>
date: Sun Aug 30 19:04:54 EDT 2009
Make I_OPL_StopSong work. Subversion-branch: /branches/opl-branch Subversion-revision: 1647
--- a/src/i_oplmusic.c
+++ b/src/i_oplmusic.c
@@ -598,6 +598,11 @@
return NULL;
}
+static void VoiceNoteOff(opl_voice_t *voice)
+{
+ WriteRegister(OPL_REGS_FREQ_2 + voice->index, voice->freq >> 8);
+}
+
static void NoteOffEvent(opl_track_data_t *track, midi_event_t *event)
{
opl_voice_t *voice;
@@ -619,10 +624,8 @@
return;
}
- // Note off.
+ VoiceNoteOff(voice);
- WriteRegister(OPL_REGS_FREQ_2 + voice->index, voice->freq >> 8);
-
// Finished with this voice now.
ReleaseVoice(voice);
@@ -913,9 +916,26 @@
static void I_OPL_StopSong(void)
{
+ unsigned int i;
+
if (!music_initialised)
{
return;
+ }
+
+ // Stop all playback.
+
+ OPL_ClearCallbacks();
+
+ // Free all voices.
+
+ for (i=0; i<OPL_NUM_VOICES; ++i)
+ {
+ if (voices[i].channel != NULL)
+ {
+ VoiceNoteOff(&voices[i]);
+ ReleaseVoice(&voices[i]);
+ }
}
}