ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/SDL/video_sdl.cpp
(Generate patch)

Comparing BasiliskII/src/SDL/video_sdl.cpp (file contents):
Revision 1.21 by gbeauche, 2005-11-21T23:38:46Z vs.
Revision 1.22 by gbeauche, 2005-11-29T23:20:31Z

# Line 135 | Line 135 | static SDL_Color sdl_palette[256];                                     /
135   static bool sdl_palette_changed = false;                        // Flag: Palette changed, redraw thread must set new colors
136   static const int sdl_eventmask = SDL_MOUSEBUTTONDOWNMASK | SDL_MOUSEBUTTONUPMASK | SDL_MOUSEMOTIONMASK | SDL_KEYUPMASK | SDL_KEYDOWNMASK | SDL_VIDEOEXPOSEMASK | SDL_QUITMASK;
137  
138 + // Mutex to protect SDL events
139 + static SDL_mutex *sdl_events_lock = NULL;
140 + #define LOCK_EVENTS SDL_LockMutex(sdl_events_lock)
141 + #define UNLOCK_EVENTS SDL_UnlockMutex(sdl_events_lock)
142 +
143   // Mutex to protect palette
144   static SDL_mutex *sdl_palette_lock = NULL;
145   #define LOCK_PALETTE SDL_LockMutex(sdl_palette_lock)
# Line 1057 | Line 1062 | bool VideoInit(bool classic)
1062   #endif
1063  
1064          // Create Mutexes
1065 +        if ((sdl_events_lock = SDL_CreateMutex()) == NULL)
1066 +                return false;
1067          if ((sdl_palette_lock = SDL_CreateMutex()) == NULL)
1068                  return false;
1069          if ((frame_buffer_lock = SDL_CreateMutex()) == NULL)
# Line 1282 | Line 1289 | void VideoExit(void)
1289                  SDL_DestroyMutex(frame_buffer_lock);
1290          if (sdl_palette_lock)
1291                  SDL_DestroyMutex(sdl_palette_lock);
1292 +        if (sdl_events_lock)
1293 +                SDL_DestroyMutex(sdl_events_lock);
1294   }
1295  
1296  
# Line 1451 | Line 1460 | int16 video_mode_change(VidLocals *csSav
1460   void SDL_monitor_desc::switch_to_current_mode(void)
1461   {
1462          // Close and reopen display
1463 +        LOCK_EVENTS;
1464          video_close();
1465          video_open();
1466 +        UNLOCK_EVENTS;
1467  
1468          if (drv == NULL) {
1469                  ErrorAlert(STR_OPEN_WINDOW_ERR);
# Line 2074 | Line 2085 | static inline void do_video_refresh(void
2085          // Set new cursor image if it was changed
2086          if (cursor_changed && sdl_cursor) {
2087                  cursor_changed = false;
2088 +                LOCK_EVENTS;
2089                  SDL_FreeCursor(sdl_cursor);
2090                  sdl_cursor = SDL_CreateCursor(MacCursor + 4, MacCursor + 36, 16, 16, MacCursor[2], MacCursor[3]);
2091                  if (sdl_cursor)
2092                          SDL_SetCursor(sdl_cursor);
2093 +                UNLOCK_EVENTS;
2094          }
2095   #endif
2096  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines