libxmp / xmp-cli

Command-line mod player using libxmp
GNU General Public License v2.0
75 stars 22 forks source link

Fix Windows crash-on-exit caused by freeing in-use buffers. #20

Closed AliceLR closed 3 years ago

AliceLR commented 3 years ago

This fixes a crash caused by freeing buffers that are still in use after failed waveOutUnprepareHeader calls. Calling waveOutReset first stops playback and releases the buffers, allowing waveOutUnprepareHeader to succeed consistently. Fixes #19.

sezero commented 3 years ago

BTW, do you have write permissions, or should I apply this?

AliceLR commented 3 years ago

I have not encountered any crashes with the MikMod CLI player but when I run it with this setup it uses Open Sound System and not WinMM. edit: also, I do not have write permissions.

sezero commented 3 years ago

it uses Open Sound System and not WinMM

Eh? msys has OSS?

AliceLR commented 3 years ago

Apparently! It is the default output for my current build of libmikmod/MikMod player and I don't even have WinMM as an option.

$ mikmod -n
-= MikMod 3.2.8 =-
(c) 2004 Raphael Assenat and others - see file AUTHORS for complete list
Sound engine version 3.3.11

Available drivers are :
 1 Open Sound System driver v1.7
 2 Wav disk writer (music.wav) v1.3
 3 AIFF disk writer (music.aiff) v1.2
 4 Raw disk writer (music.raw) v1.1
 5 Piped Output driver v0.2
 6 Standard output driver v1.1
 7 Nosound Driver v3.0
sezero commented 3 years ago

configure --disable-alldrv --enable-win Cmake has a similar option, as I remember.

AliceLR commented 3 years ago

Okay, got MikMod to finally build with that driver and looked at it. MikMod is not affected by the same bug because MikMod_Exit calls MikMod_DisableOutput_internal() -> driver->PlayStop() -> waveOutReset() before it calls driver->Exit() -> the equivalent code here.