SDL icon indicating copy to clipboard operation
SDL copied to clipboard

Inconsistency between render and sound playback upon dragging a window

Open fortwoone opened this issue 3 years ago • 3 comments

Hello there, I noticed something odd about how window dragging was handled. You see, when you drag a window (at least in Windows), the graphics render stops, but not the sound playback as it's played in background threads. Is there a way to fix this? (this can happen in any project containing both GFX and sounds, even if I personally use Pygame which wraps around this library)

fortwoone avatar Nov 26 '22 14:11 fortwoone

This is not trivially fixable. What's happening is related to this issue: https://github.com/libsdl-org/SDL/issues/1059

Lokathor avatar Nov 26 '22 15:11 Lokathor

Are you using delta-time calculations in your project? It will tell you how long things took when the window was dragged, at least (which can inform where graphics should be to stay in sync with audio, or vice versa).

slime73 avatar Nov 26 '22 15:11 slime73

This is not trivially fixable. What's happening is related to this issue: #1059

True, except I actually mean to freeze the game whenever the window is dragged, rather than let it run anyway

fortwoone avatar Nov 27 '22 10:11 fortwoone

We don't stop all threads while the window is being dragged. You can use SDL_SetWindowsMessageHook() to set a function to detect when this is happening if you'd like to pause your threads yourself.

slouken avatar Nov 07 '23 23:11 slouken