Opened 7 years ago
Closed 7 years ago
#10033 closed feature request (fixed)
SCI: PHANT2: Reduce latency of starting movie clips and phone button sounds
Reported by: | dafioram | Owned by: | csnover |
---|---|---|---|
Priority: | low | Component: | Engine: SCI |
Version: | Keywords: | sci32 | |
Cc: | Game: | Phantasmagoria 2 |
Description
Game: Phant 2 GOG CD/DOS 001.0.06
ScummVM: 1.10.0git-4161-gcb3191a
OS: Ubuntu 16.04
In the original game and scummvm's implementation there is a perceptible lag between when you click and when a movie starts. Same thing when pressing the phone buttons to dial and the corresponding tone sound.
Attachments (3)
Change History (17)
comment:1 by , 7 years ago
Summary: | PHANT2: Reduce latency of starting movie clips and phone button sounds → SCI: PHANT2: Reduce latency of starting movie clips and phone button sounds |
---|
comment:2 by , 7 years ago
comment:3 by , 7 years ago
When I play on ubuntu the phone has about 1 sec delays and on windows it is about 0.2 seconds so I guess that is os dependent.
The videos in curtis's apartment are fine, but most of the videos in the office have the lag, about 2 seconds. Since a lot of the first few chapters are videos in the office this is noticeable.
The attached saved game is a good example. Click on the door on the right and you will see the lag.
comment:4 by , 7 years ago
For that office save, I’m not sure if this is another place where the GOG release is broken, but there is supposed to be music in the hallway and the delay before the video starts playing is the music being faded out.
Perhaps the phone situation will be improved with PR#1007, assuming it is compiled with SDL2. The game does a mode switch when playing videos and I can see this being slower than it needs to be if the window manager is being told to make unnecessary changes to the window. Otherwise, it may need to be performance profiled. I got totally confused and thought this was Ubuntu on a phone having trouble with the video mode switching. That patch doesn’t affect anything sound-related.
comment:5 by , 7 years ago
Yes, there is music playing and when I click the door, the music starts to fade out and when it is finished the video starts. So I guess thats how the game was made, its seems unnecessary, but okay.
comment:6 by , 7 years ago
Attached is profile data.
I profiled my linux build in release mode. My test was to go to the phone and click buttons for about 20 seconds. Both had the phone lag and it seemed to be the same.
comment:7 by , 7 years ago
The game played on DOSBOX has no phone lag and the videos have a slight delay (1 sec).
comment:8 by , 7 years ago
comment:9 by , 7 years ago
On Linux, once you set the buffer size to 1024 in ScummVM, the only difference between DOSBox and ScummVM should end up being the version of SDL in use. Could you try compiling ScummVM with SDL1.2 instead and see what happens? SDL2 in particular has some really questionable-looking pulseaudio code with some PA_STREAM_ADJUST_LATENCY
define that messes with a bunch of stuff, which seems like it is the source of that half-size samples warning (because it does this for some reason).
comment:10 by , 7 years ago
You might have to give me some help on getting sdl1.2 setup with the scummvm build.
I've installed sdl1.2 using apt-get install libsdl2-dev
this puts the config in /usr/bin/sdl-config
. I then specify the sdl config given above in the build using --with-sdl-prefix.
When I run make after a successful build it says it cannot find sdl.h whats the best way of setting the scummvm configure so that it finds my sdl headers (and maybe libs)?
Also, for the previous tests I have done they were using sdl 2.0.4 (instead of 2.0.5) if that matters for this audio latency issue.
comment:11 by , 7 years ago
All you should need to do is install libsdl1.2-dev
and then run SDL_CONFIG=sdl-config ./configure [the rest of your configure options]
.
comment:12 by , 7 years ago
I tested sdl1.2 in release with buffer sizes of both 1024 and 8196 and the audio latency was the same as with sdl2.
comment:13 by , 7 years ago
For what it’s worth, I installed DOSBox in my Debian Testing VM from apt and it had the same amount of (excessive) audio latency as ScummVM regardless of the audio buffer size, so at least on my end I don’t see the latency having anything to do specifically with how ScummVM is setting up SDL or generating audio.
comment:14 by , 7 years ago
Owner: | set to |
---|---|
Resolution: | → fixed |
Status: | new → closed |
Thanks for your report! A patch for the audio latency of Curtis’s phone has been added in commit 4a75fbab1b508f4240615c62811e2c8828534177 and will be available in daily builds 1.10.0git-4851 and later. As mentioned earlier with the videos, the delay before starting the videos is the game fading out ambient audio.
This patch also addresses issues in other games (Lighthouse train power, KQ7 jumping rabbit at start of chapter 1) where the games restart audio samples on every frame, since we were rendering too much audio data which caused some looping audio artefacts that didn’t normally exist in the original engine.
I was not ever able to reduce my Linux VM system audio latency so I could not verify this issue is addressed in Linux, but I was able to verify that the problem existed and is now fixed in macOS, so I have to assume that any similar issue on a well-behaved Linux machine will be fixed as well.
Are there specific video clips where you notice latency? The game waits while fading out the music before certain clips, but ones like navigation in Curtis’s apartment should be fairly quick. I see about 50ms (3 frames) of latency here between click and the first frame of video.
The phone is… dumb. It doesn’t play the sound effect until you release the mouse button, there are only 7 DTMF samples which it chooses randomly, and the samples aren’t loopable (the samples contain more than just a pure tone). So outside of maybe changing the trigger to be mouse-down instead of mouse-up, I don’t think there is anything that can be done with the resources that come with the game to meaningfully improve the phone behaviour.