summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarl-Anton Ingmarsson <ca.ingmarsson@gmail.com>2009-06-07 01:12:50 +0200
committerJan Schmidt <thaytan@noraisin.net>2009-06-20 15:21:45 +0100
commit636ae49bee677ee56f6c480c78f6f4eda8eeab51 (patch)
tree490ee4577b972bd5a20e24c0648e4a721db61c03
parent3fa60712f2f86591d7ab7b0c454e1676ad72b751 (diff)
downloadgst-plugins-bad-636ae49bee677ee56f6c480c78f6f4eda8eeab51.tar.gz
gst-plugins-bad-636ae49bee677ee56f6c480c78f6f4eda8eeab51.tar.bz2
gst-plugins-bad-636ae49bee677ee56f6c480c78f6f4eda8eeab51.zip
vdpaumpegdec: use mutex to protect mpeg_dec->seeking from concurrent access
-rw-r--r--sys/vdpau/gstvdpmpegdec.c14
-rw-r--r--sys/vdpau/gstvdpmpegdec.h3
2 files changed, 16 insertions, 1 deletions
diff --git a/sys/vdpau/gstvdpmpegdec.c b/sys/vdpau/gstvdpmpegdec.c
index bcff055f..759eb7f9 100644
--- a/sys/vdpau/gstvdpmpegdec.c
+++ b/sys/vdpau/gstvdpmpegdec.c
@@ -840,10 +840,16 @@ normal_seek (GstVdpMpegDec * mpeg_dec, GstEvent * event)
gst_event_new_seek (rate, GST_FORMAT_BYTES, flags,
cur_type, bytes_cur, stop_type, bytes_stop);
- mpeg_dec->seeking = TRUE;
+ g_mutex_lock (mpeg_dec->mutex);
/* do the seek */
res = gst_pad_push_event (mpeg_dec->sink, peer_event);
+
+ if (res)
+ mpeg_dec->seeking = TRUE;
+
+ g_mutex_unlock (mpeg_dec->mutex);
+
} else
res = FALSE;
@@ -929,13 +935,16 @@ gst_vdp_mpeg_dec_sink_event (GstPad * pad, GstEvent * event)
stop, position);
}
+ g_mutex_lock (mpeg_dec->mutex);
/* if we seek ourselves we don't push out a newsegment now since we
* use the calculated timestamp of the first frame for this */
if (mpeg_dec->seeking) {
gst_event_unref (event);
res = TRUE;
+ g_mutex_unlock (mpeg_dec->mutex);
goto done;
}
+ g_mutex_unlock (mpeg_dec->mutex);
convert_error:
res = gst_pad_push_event (mpeg_dec->src, event);
@@ -1069,6 +1078,8 @@ gst_vdp_mpeg_dec_init (GstVdpMpegDec * mpeg_dec, GstVdpMpegDecClass * gclass)
mpeg_dec->vdp_info.backward_reference = VDP_INVALID_HANDLE;
gst_vdp_mpeg_dec_reset (mpeg_dec);
+
+ mpeg_dec->mutex = g_mutex_new ();
}
static void
@@ -1077,6 +1088,7 @@ gst_vdp_mpeg_dec_finalize (GObject * object)
GstVdpMpegDec *mpeg_dec = (GstVdpMpegDec *) object;
g_object_unref (mpeg_dec->adapter);
+ g_mutex_free (mpeg_dec->mutex);
}
static void
diff --git a/sys/vdpau/gstvdpmpegdec.h b/sys/vdpau/gstvdpmpegdec.h
index b60c9f59..66a41805 100644
--- a/sys/vdpau/gstvdpmpegdec.h
+++ b/sys/vdpau/gstvdpmpegdec.h
@@ -78,6 +78,9 @@ struct _GstVdpMpegDec
GstSegment segment;
gboolean seeking;
gint64 byterate;
+
+ /* mutex */
+ GMutex *mutex;
};