FS#5748 - Fix Skipping Audio in Simulator on OS X (caused by excessive surface blitting in SDL)

Attached to Project: Rockbox
Opened by Emanuel Zephir (ezephir) - Monday, 31 July 2006, 03:18 GMT
Task Type Patches
Category Simulator
Status Closed
Assigned To Dan Everton (safetydan)
Operating System All players
Severity Critical
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No


The SDL simulator on OS X when compiled skips while playing audio. The message reported is:

sdl_audio_callback: No Data.

Upon investigation, this behaviour only occurs when the simulator window was visible. Upon closer investigation, the Simulator draws to the screen twice, once with SDL_UpdateRect() and again with SDL_Flip(). According to the SDL Documentation (, SDL_Flip is equivalent to updating the whole screen with SDL_UpdateRect().

When hardware aceleration is available, SDL_UpdateRect() AFAIK is bad when double buffering is used because the backbuffer is a frame behind the current LCD display. If only a region of it is updated, as the original code did, the output will contain a mixture of the new LCD and the one a frame before it.

Because of the incorrect behavior when the program is double buffered, and the redundancy that keeps the OS X version of the simulator, I removed the call to SDL_UpdateRect(). The program output seems to still be correct, and the OS X version no longer skips on any of the computers I've tested on.
This task depends upon

Closed by  Dominik Riebeling (bluebrother)
Monday, 31 July 2006, 16:34 GMT
Reason for closing:  Accepted
Comment by Dan Everton (safetydan) - Monday, 31 July 2006, 08:18 GMT
I've tried this patch under Linux and it doesn't seem to make any difference. I'll investigate some more though.