#include "gstmaruinterface.h"
#include "gstmarudevice.h"
-static GStaticMutex gst_avcodec_mutex = G_STATIC_MUTEX_INIT;
+static GMutex gst_avcodec_mutex;
#define CODEC_DEVICE_MEM_SIZE 32 * 1024 * 1024
gst_maru_codec_device_open (CodecDevice *dev, int media_type)
{
int fd;
- void *mmapbuf;
CODEC_LOG (DEBUG, "enter: %s\n", __func__);
CODEC_LOG (DEBUG, "before mmap. buf_size: %d\n", dev->buf_size);
- g_static_mutex_lock (&gst_avcodec_mutex);
+ g_mutex_lock (&gst_avcodec_mutex);
if (!device_mem) {
device_mem = mmap (NULL, CODEC_DEVICE_MEM_SIZE, PROT_READ | PROT_WRITE,
MAP_SHARED, fd, 0);
if (device_mem == MAP_FAILED) {
perror("Failed to map device memory of codec.");
dev->buf = NULL;
+ g_mutex_unlock (&gst_avcodec_mutex);
return -1;
}
}
opened_cnt++;
- g_static_mutex_unlock (&gst_avcodec_mutex);
+ g_mutex_unlock (&gst_avcodec_mutex);
dev->buf = device_mem;
gst_maru_codec_device_close (CodecDevice *dev)
{
int fd = 0;
- void *mmapbuf = NULL;
CODEC_LOG (DEBUG, "enter: %s\n", __func__);
ioctl(fd, CODEC_CMD_RELEASE_BUFFER, &dev->mem_info.offset);
- g_static_mutex_lock (&gst_avcodec_mutex);
+ g_mutex_lock (&gst_avcodec_mutex);
opened_cnt--;
if (!opened_cnt) {
CODEC_LOG (INFO, "Release memory region of %p.\n", device_mem);
}
}
device_mem = NULL;
- g_static_mutex_unlock (&gst_avcodec_mutex);
+ g_mutex_unlock (&gst_avcodec_mutex);
dev->buf = NULL;
return -1;
}
- g_static_mutex_lock (&gst_avcodec_mutex);
+ g_mutex_lock (&gst_avcodec_mutex);
ret = codec_init (ctx, codec, dev);
- g_static_mutex_unlock (&gst_avcodec_mutex);
+ g_mutex_unlock (&gst_avcodec_mutex);
return ret;
}
CODEC_LOG (DEBUG, "gst_maru_avcodec_close\n");
- g_static_mutex_lock (&gst_avcodec_mutex);
+ g_mutex_lock (&gst_avcodec_mutex);
codec_deinit (ctx, dev);
- g_static_mutex_unlock (&gst_avcodec_mutex);
+ g_mutex_unlock (&gst_avcodec_mutex);
ret = gst_maru_codec_device_close (dev);