In one of these applications I keep getting crashes either "application defined exception" or "crash in ntdll.dll".
First, I'll explain what my program should do:
The user pressed a key (to cause some action) and the application should play a certain wave file. (nothing new
However, when there is already a sound playing, then that sound should stop playing.
I'm using this code:
- Code: Select all
procedure TSnd.PlayTick;
begin
If Tick.Active Then Begin
Tick.Stop;
Tick.WaitForStop;
End;
Tick.PlayStock( 0);
end;
This seems to work fine most of the time, but sometimes it crashes, this is the stackcall:
- Code: Select all
TWaveAudioOut.InternalClose
TStockAudioPlayer.stop
PlayTick
You can easily reproduce it by just adding a button and put the code above in the onclick. Start and keep pressing enter.
It looks like that the wave component is still receiving and processing messages from the windows audio timer threads (or whatever they are called) even when the wave component says it is stopped and/or has disposed of resources.
Any help would be much appreciated.