decklink: use mutexes from glib instead of pthread

Signed-off-by: David Schleef <ds@schleef.org>
This commit is contained in:
Joshua M. Doe 2011-07-07 14:13:00 -04:00 committed by David Schleef
parent 382346a6f3
commit c830cf3e66
2 changed files with 8 additions and 9 deletions

View file

@ -28,7 +28,6 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <pthread.h>
#include <unistd.h> #include <unistd.h>
#include <fcntl.h> #include <fcntl.h>
@ -49,20 +48,20 @@ static BMDTimecodeFormat g_timecodeFormat = 0;
DeckLinkCaptureDelegate::DeckLinkCaptureDelegate ():m_refCount (0) DeckLinkCaptureDelegate::DeckLinkCaptureDelegate ():m_refCount (0)
{ {
pthread_mutex_init (&m_mutex, NULL); m_mutex = g_mutex_new();
} }
DeckLinkCaptureDelegate::~DeckLinkCaptureDelegate () DeckLinkCaptureDelegate::~DeckLinkCaptureDelegate ()
{ {
pthread_mutex_destroy (&m_mutex); g_mutex_free (m_mutex);
} }
ULONG ULONG
DeckLinkCaptureDelegate::AddRef (void) DeckLinkCaptureDelegate::AddRef (void)
{ {
pthread_mutex_lock (&m_mutex); g_mutex_lock (m_mutex);
m_refCount++; m_refCount++;
pthread_mutex_unlock (&m_mutex); g_mutex_unlock (m_mutex);
return (ULONG) m_refCount; return (ULONG) m_refCount;
} }
@ -70,9 +69,9 @@ DeckLinkCaptureDelegate::AddRef (void)
ULONG ULONG
DeckLinkCaptureDelegate::Release (void) DeckLinkCaptureDelegate::Release (void)
{ {
pthread_mutex_lock (&m_mutex); g_mutex_lock (m_mutex);
m_refCount--; m_refCount--;
pthread_mutex_unlock (&m_mutex); g_mutex_unlock (m_mutex);
if (m_refCount == 0) { if (m_refCount == 0) {
delete this; delete this;

View file

@ -19,7 +19,7 @@ class DeckLinkCaptureDelegate : public IDeckLinkInputCallback
private: private:
ULONG m_refCount; ULONG m_refCount;
pthread_mutex_t m_mutex; GMutex *m_mutex;
}; };
#endif #endif