Nuro: Play a video at a fixed 25 fps with non-thread-safe read and render
Problem. You have a Frame class and a VideoPlayer with two calls: read() returns the next frame or signals the end of the video, and render(frame) draws a frame. Implement on_play_click() so the whole video plays from first frame to last.
Requirements.
- Frames must be shown at a strict 25 frames per second.
- Neither
read()norrender()is thread-safe, so calls to each must be serialised.
Approach described. A producer thread calls read() and fills a bounded buffer; a consumer thread takes frames off it and calls render() on a fixed timer. Locks and condition variables handle the hand-off and the end-of-video signal.
Same round. An intern candidate also got a second problem: decide whether a set of 2D points is mirror-symmetric about some vertical line.
Comments 0
No comments yet. Ask the author something, or add what happened in your own round.