player_v2a - fix crash when playing two identical sounds
|Reported by:||SF/quietust||Owned by:||Kirben|
My original player_v2a code simply maintained a list of
sound objects which would be directly called to start
and stop playback; the object selected is based on the
CRC-32 of the code segment in the sound resource.
There's just one problem - there are multiple sound
resources which share the same code (and often data)
segments, and if two of them are played simultaneously
it will cause problems (only one sound will play, it will
play at double speed, and when the 2nd sound is
stopped ScummVM will crash).
In Maniac Mansion, the problem could be observed when
turning off the circuit breakers (alarm plays at double
speed, crashes when the alarm stops) or running at
Turbo speed (Ctrl+F) while using the Hunk-O-Matic.
The attached patch fixes this by adding a copy()
method to class V2A_Sound and appropriate copy
constructors to each of the subclasses (and deleting the
copy when the sound is done playing).
Ticket imported from: #820427. Ticket imported from: patches/391.