Attempt to fix overrun, which is caused by buffer writing thread
way faster than buffer reading thread in some platforms.