Skip to content

Commit

Permalink
Call audio backend shutdown if the library init or buffer alloc fails :
Browse files Browse the repository at this point in the history
Issue reported by Hubert Maier for AmigaOS4, but it is actually generic
and was present in older releases, too

Also call amiga_sysinit() before the other two in amiga-specific builds
  • Loading branch information
sezero committed Apr 3, 2024
1 parent dbda2ca commit 20a8ba2
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/player/wildmidi.c
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,10 @@ int main(int argc, char **argv) {
config_file[sizeof(config_file) - 1] = 0;
}

#ifdef WILDMIDI_AMIGA
amiga_sysinit();
#endif

printf("Initializing Sound System (%s)\n", available_outputs[playback_id]->name);

if (available_outputs[playback_id]->open_out(output, &rate) == -1) {
Expand All @@ -550,26 +554,25 @@ int main(int argc, char **argv) {
(libraryver>> 8) & 255,
(libraryver ) & 255);
if (WildMidi_Init(config_file, rate, mixer_options) == -1) {
available_outputs[playback_id]->close_out();
fprintf(stderr, "%s\r\n", WildMidi_GetError());
WildMidi_ClearError();
return (1);
}

printf(" + Volume up e Better resampling n Next Midi\n");
printf(" - Volume down l Log volume q Quit\n");
printf(" , 1sec Seek Back r Reverb . 1sec Seek Forward\n");
printf(" m save as midi p Pause On/Off\n\n");

output_buffer = malloc(16384);
if (output_buffer == NULL) {
fprintf(stderr, "Not enough memory, exiting\n");
available_outputs[playback_id]->close_out();
WildMidi_Shutdown();
return (1);
}

#ifdef WILDMIDI_AMIGA
amiga_sysinit();
#endif
printf(" + Volume up e Better resampling n Next Midi\n");
printf(" - Volume down l Log volume q Quit\n");
printf(" , 1sec Seek Back r Reverb . 1sec Seek Forward\n");
printf(" m save as midi p Pause On/Off\n\n");

wm_inittty();

WildMidi_MasterVolume(master_volume);
Expand Down

0 comments on commit 20a8ba2

Please sign in to comment.