diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2012-10-03 16:26:24 +0200 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2012-10-03 16:26:24 +0200 |
commit | bb65f0fc2176b2ebf0f1be682008609e8bd2cb0a (patch) | |
tree | d0070ad2ef70b1a7c2ed77cec098d03402d0871f /src/layer_video.cpp | |
parent | 920067622e7ba72dd6947eb8e7875719315872b9 (diff) | |
download | osc-graphics-bb65f0fc2176b2ebf0f1be682008609e8bd2cb0a.tar.gz |
simplified mutex locking idiom by introducing Mutex class (wrapper around SDL_mutex)
* can be instantiated
* can derive from class Mutex to inherit the lock()/unlock() methods
also fixed LayerList destructor
Diffstat (limited to 'src/layer_video.cpp')
-rw-r--r-- | src/layer_video.cpp | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/src/layer_video.cpp b/src/layer_video.cpp index 1734d9e..859455f 100644 --- a/src/layer_video.cpp +++ b/src/layer_video.cpp @@ -6,7 +6,6 @@ #include <math.h> #include <SDL.h> -#include <SDL_thread.h> #include <SDL_rotozoom.h> /* HACK: older SDL_gfx versions define GFX_ALPHA_ADJUST in the header */ @@ -37,9 +36,8 @@ static void display_cb(void *data, void *id); } LayerVideo::LayerVideo(const char *name, SDL_Rect geo, float opacity, - const char *url) : - Layer(name), mp(NULL), surf(NULL), - mutex(SDL_CreateMutex()) + const char *url) + : Layer(name), mp(NULL), surf(NULL) { /* static initialization */ if (!vlcinst) { @@ -243,12 +241,12 @@ LayerVideo::frame(SDL_Surface *target) if (surf->w != geov.w || surf->h != geov.h) { SDL_Surface *surf_scaled; - SDL_LockMutex(mutex); + mutex.lock(); surf_scaled = zoomSurface(surf, (double)geov.w/surf->w, (double)geov.h/surf->h, SMOOTHING_ON); - SDL_UnlockMutex(mutex); + mutex.unlock(); if (alpha < SDL_ALPHA_OPAQUE) { if (surf_scaled->format->Amask) @@ -267,9 +265,9 @@ LayerVideo::frame(SDL_Surface *target) else SDL_SetAlpha(surf, SDL_SRCALPHA | SDL_RLEACCEL, alpha); - SDL_LockMutex(mutex); + mutex.lock(); SDL_BlitSurface(surf, NULL, target, &geov); - SDL_UnlockMutex(mutex); + mutex.unlock(); } } @@ -283,7 +281,6 @@ LayerVideo::~LayerVideo() if (mp) libvlc_media_player_release(mp); libvlc_release(vlcinst); - SDL_DestroyMutex(mutex); if (surf) SDL_FreeSurface(surf); } |