Commit Graph
91 Commits
Author SHA1 Message Date
Eugene Sandulenko e657e060e0 DIRECTOR: Fix potential race condition
If sound is ended during execution, we may refer to the freed memory
2022-12-09 01:26:32 +01:00
Eugene Sandulenko 7e69d548d7 DIRECTOR: Consider looped sounds not playing after first iteration
Fixed exit door in the7colors, where the frame had a looping
birds chirping sound together with the following Lingo:

  if the soundbusy of 2 then go to the frame

And that led to an infinite loop and inability to pass through the
opened door.

The original apparently is returning 0 in-between the sound loops
since it manually restarts the sound after its completion. We, in
contrast, are optimizing that and using LoopedAudioStream
since f48dbb43b6
2022-12-08 23:14:54 +01:00
Eugene Sandulenko 3703fee378 DIRECTOR: Do not reset looping handle early
playStream() is called right after setting loopPtr, which was leading
to immediate reset of loopPtr. Thus, we were not able to control
the looping sounds
2022-12-08 23:14:54 +01:00
Vladimir Serbinenko 0670d1a16a DIRECTOR: Switch to openFileOrDataFork 2022-12-04 20:16:21 +01:00
eientei 6fd98e2e34 DIRECTOR: Workaround in hasLoopBounds where start can be != 0 and end = 0 2022-12-01 01:18:11 +01:00
Roland van Laar 8b310f1271 DIRECTOR: Fix memory leak in sound
Delete the stream gotten from _macresman->getDataFork.

Made the stream copying more explicit by aligning the variables names
with the function logic.
2022-11-30 10:54:49 +01:00
Hubert Maier 1eef5da741 DIRECTOR: Correct spelling mistake
comming -> coming
2022-10-27 15:56:09 +02:00
Misty De Meo 028bc85dc4 DIRECTOR: copy sound streams in AudioFileDecoder
It's possible for audio playback to still be underway at the time the
AudioFileDecoder is destroyed. For Mac games, destroying the _macresman
will also destroy the stream, feeing the pointer while it may be read from
in another thread. Copying the audio instead of just fetching the stream
from the MacResMan ensures that new stream will outlive the MacResMan if
necessary.

Fixes https://bugs.scummvm.org/ticket/13881.
2022-10-23 21:09:30 -07:00
Roland van Laar a2dc39d444 DIRECTOR: Fix unchecked return value
Only try to open the datafork when `open` succeeded.

Fixes COVERITY: 1465739
2022-10-07 17:14:10 +02:00
Roland van Laar 0091a20fe9 DIRECTOR: limit files closed by closeResFile
Lingo function `closeResFile` is only responsible for closing resource
file opened by `openResFile`. Register in `openResFile` which files
where opened and close only those files in `closeResFile`.

- Rename `_openResFiles` to `_allOpenResFiles` and
- Add new `_openResFiles` hashmap to track which files were opened in
  `openResFile`.
2022-09-23 22:55:50 +02:00
Scott Percival cb0455e34d DIRECTOR: Fix audio loop use-after-free 2022-09-12 15:52:18 +02:00
Scott Percival 7fc407bc4b DIRECTOR: Plug more memory leaks 2022-09-12 15:52:18 +02:00
Scott Percival f48dbb43b6 DIRECTOR: Use LoopableAudioStream for score audio loops
For looping sounds, the original code polled the score and created a new
AudioStream every time the previous iteration finished playing. The
downside of this approach is the sound needs to be fully resampled and
buffered after each playback, which can be heard as a gap between loops.

To fix this, loops now use a LoopableAudioStream. The reason why the
previous code did not was to allow for a specific edge case.
In Director, when a looping audio channel is set to cast member 0, the
loop is allowed to finish the current iteration before the audio stops.
Originally there wasn't a way of doing that, but now the
LoopableAudioStream classes can stop playing after a number of
iterations. As such, we keep a copy of the LoopableAudioStream handle
and call for the loop to stop when the cast member gets set to 0.

Improves looped audio playback in Eastern Mind.

Fixes the guitar solo between the transition from BLAST.DXR to INTRO.DXR
in Meet MediaBand.

Fixes the audio transition between n.am and s.am in Meet MediaBand.
2022-08-28 10:31:00 +00:00
Scott Percival 7c9badd57c DIRECTOR: Add debug level for sound events 2022-07-23 23:49:35 +02:00
Eugene Sandulenko abea37c9bb ALL: Update ScummVM project license to GPLv3+ 2021-12-26 18:48:43 +01:00
Misty De Meo 9d2492b4f8 DIRECTOR: stop sound before playing stream 2021-12-13 07:14:45 +01:00
Misty De Meo 1e9ecf405e DIRECTOR: allocate more than 2 audio channels 2021-11-19 22:58:59 -05:00
Misty De Meo 753c1c2fd9 DIRECTOR: handle macbinary audio streams 2021-11-07 20:39:51 +01:00
Scott Percival 53da0c8170 DIRECTOR: Fix file handle leak in getAudioStream 2021-11-07 11:57:29 +08:00
Scott Percival 7c145266b6 DIRECTOR: Case-scrub paths used by AudioFileDecoder::getAudioStream
Fixes the music on the Intro Menu screen of Total Distortion.
2021-09-19 10:45:53 +08:00
Logan B 21afa1457a DIRECTOR: Add AIFC detection 2021-09-17 20:34:16 +03:00
Roland van Laar 9dc24508d0 DIRECTOR: Handle sndCommand 0x8050
0x8050 seems to be handled the same as 0x8051.
Was added to allow for 'Double Click' demo movie.
2021-08-13 23:32:38 +02:00
djsrv 0a92826957 DIRECTOR: Fix whitespace 2021-08-12 13:18:27 -04:00
djsrv 50c7cefc2c DIRECTOR: Keep playing sounds when movie switches 2021-08-12 13:18:27 -04:00
djsrv 1493ca291b DIRECTOR: Improve empty sound channel behavior 2021-08-07 13:20:23 -04:00
djsrv 0b39f10a08 DIRECTOR: Change _movieChanged to movieChanged 2021-08-07 13:20:23 -04:00
djsrv 02aace0598 DIRECTOR: Use ':' as directory separator 2021-08-07 10:44:37 +02:00
djsrv d06126591e DIRECTOR: Create consts for min and max sampled sound menus
Fewer magic numbers. I also replaced the _sampleSounds hashmap with a
constant-size array.
2021-07-28 01:52:03 -04:00
Orgad Shaneh ea00c159ca DIRECTOR: Another fix for C++<11 2021-07-28 07:51:11 +03:00
djsrv 7e13add452 DIRECTOR: Fix memory leaks 2021-07-27 23:50:44 -04:00
djsrv e39a63c5e5 DIRECTOR: Fix submenu bounds check 2021-07-27 23:10:34 -04:00
djsrv 00a1ba2ee8 DIRECTOR: Disable puppet sounds when the movie changes 2021-07-27 22:54:25 -04:00
djsrv a16d823201 DIRECTOR: Improve puppetSound
Most variants of puppetSounds don't actually start the sound immediately
but wait until the frame is updated. So I've created a SoundID struct
which stores a reference to a cast member or externals sound, and that
is used to store the puppetSound until it's actually supposed to start.
In addition, puppet status is now per-channel instead of a universal
flag.
2021-07-27 22:54:16 -04:00
djsrv 8a9b1cd09c DIRECTOR: Give each window its own sound manager
This Should prevent conflicts between the sound channels of movies
running in parallel.
2021-07-27 22:42:09 -04:00
ysj1173886760 99642ec18e DIRECTOR: fix the behaviour of puppet sound. 2021-07-25 14:39:25 +08:00
Scott Percival 6ba16f7b40 DIRECTOR: Fix sound playFile behaviour
A call to AudioFileDecoder::getAudioStream() was missed during the
refactor in 682d2dbb6c, meaning that any
sound invoked by "sound playFile" would loop.

Fixes the narration text in Chop Suey (e.g. TABLE.DIR) from looping and
being unable to progress.
2021-07-23 23:48:34 +08:00
ysj1173886760 4cbc1cc5ff DIRECTOR: clean the code. 2021-07-21 20:43:56 +08:00
ysj1173886760 b31bd5f231 DIRECTOR: add movingChanging flag to deal with the sound which will playing across the movie. 2021-07-20 19:34:07 +08:00
djsrv 38ca2062b8 DIRECTOR: Handle D4 differences in sound looping behavior 2021-07-19 13:38:55 -04:00
ysj1173886760 682d2dbb6c DIRECTOR: modify the interface and amend the implementation of sound decoder. 2021-07-19 18:26:25 +08:00
ysj1173886760 01ce9792f8 DIRECTOR: implement sub-looping sounds for snd resources 2021-07-19 18:26:25 +08:00
ysj1173886760 8d12017e78 DIRECTOR: implement the soundEnabled and the soundLevel. 2021-07-19 10:41:22 +08:00
ysj1173886760 1d4d0a2f39 DIRECTOR: implement setting and getting sound level in director sound 2021-07-19 10:41:22 +08:00
ysj1173886760 f15497f164 DIRECTOR: implement sound enabled for director sounds 2021-07-19 10:41:22 +08:00
ysj1173886760 876f998a05 DIRECTOR: check and play queued fplay sound in score. Amend the implementation of playFPlaySound 2021-07-19 10:41:22 +08:00
ysj1173886760 d1abdb94be DIRECTOR: implement playFPlaySound in Director sound 2021-07-19 10:41:22 +08:00
djsrv 8e5af4d295 DIRECTOR: Don't repeat sound if playback ends
We should only check if the last sound we saw in this channel is the
same, not if playback of the sound has ended. Otherwise, this can cause
a sound to incorrectly loop like in Meet Mediaband.
2021-07-16 12:53:54 -04:00
ysj1173886760 fcb49bbd15 DIRECTOR: implement playExternalSound for DirectorSound, organize the code 2021-07-14 18:00:50 +08:00
ysj1173886760 8282f8556f DIRECTOR: implement loading external sound file 2021-07-14 18:00:50 +08:00
ysj1173886760 154c4aaa47 DIRECTOR: amend loadStream in SNDDecoder 2021-07-14 18:00:49 +08:00