We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 757

Summary: Child thread wait for events stops main thread
Product: SDL Reporter: Ron Howe <drdhowe>
Component: threadAssignee: Ryan C. Gordon <icculus>
Status: RESOLVED INVALID QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2    
Version: HG 2.0   
Hardware: x86   
OS: Linux   
Attachments: Program is minimal main display thread and child event thread

Description Ron Howe 2009-06-24 06:22:00 UTC
Created attachment 334 [details]
Program is minimal main display thread and child event thread

The program can be compiled with libsdl 1.2.0 or 1.3.0

With libsdl 1.2.0 Bug 640 is evident

With libsdl 1.3.0 Bug 640 is fixed but the main thread
hangs when the child eventThread is waiting for events

The program simulates a webcam viewer (was cut down from luvcview)

Main thread runs a loop continuously displaying a changing SDL_YUVOverlay onto a 480x672 frame.

Child thread runs a loop using SDL_PollEvent to handle keyboard and mouse (movement and button) events, allowing quitting

Main thread hangs unless mouse moved, or button or key pressed

This problem can sometimes be avoided by moving the event polling and handling into the main thread's display loop.
Comment 1 Sam Lantinga 2009-06-30 22:08:35 UTC
SDL_PollEvent() and SDL_WaitEvent() can only be called from the thread that initialized the video subsystem.  Other threads should be using SDL_PeepEvents() (which doesn't process events, just returns any that were previously queued)