mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-24 09:10:36 +00:00
sys/: Use a mutex protected list to marshal navigation events into the stream thread from whichever thread sends them.
Original commit message from CVS: * sys/ximage/ximagesink.c: (gst_ximagesink_chain), (gst_ximagesink_send_pending_navigation), (gst_ximagesink_navigation_send_event), (gst_ximagesink_finalize), (gst_ximagesink_init): * sys/ximage/ximagesink.h: * sys/xvimage/xvimagesink.c: (gst_xvimagesink_chain), (gst_xvimagesink_send_pending_navigation), (gst_xvimagesink_navigation_send_event), (gst_xvimagesink_finalize), (gst_xvimagesink_init): * sys/xvimage/xvimagesink.h: Use a mutex protected list to marshal navigation events into the stream thread from whichever thread sends them.
This commit is contained in:
parent
1636a1c814
commit
ec937dfcea
5 changed files with 175 additions and 43 deletions
16
ChangeLog
16
ChangeLog
|
@ -1,3 +1,19 @@
|
|||
2005-02-16 Jan Schmidt <thaytan@mad.scientist.com>
|
||||
|
||||
* sys/ximage/ximagesink.c: (gst_ximagesink_chain),
|
||||
(gst_ximagesink_send_pending_navigation),
|
||||
(gst_ximagesink_navigation_send_event), (gst_ximagesink_finalize),
|
||||
(gst_ximagesink_init):
|
||||
* sys/ximage/ximagesink.h:
|
||||
* sys/xvimage/xvimagesink.c: (gst_xvimagesink_chain),
|
||||
(gst_xvimagesink_send_pending_navigation),
|
||||
(gst_xvimagesink_navigation_send_event),
|
||||
(gst_xvimagesink_finalize), (gst_xvimagesink_init):
|
||||
* sys/xvimage/xvimagesink.h:
|
||||
Use a mutex protected list to marshal navigation
|
||||
events into the stream thread from whichever thread
|
||||
sends them.
|
||||
|
||||
2005-02-15 Tim-Philipp Müller <tim at centricular dot net>
|
||||
|
||||
* gst/speed/demo-mp3.c: (time_tick_cb), (main):
|
||||
|
|
|
@ -48,6 +48,7 @@ MotifWmHints, MwmHints;
|
|||
static void gst_ximagesink_buffer_free (GstBuffer * buffer);
|
||||
static void gst_ximagesink_ximage_destroy (GstXImageSink * ximagesink,
|
||||
GstXImage * ximage);
|
||||
static void gst_ximagesink_send_pending_navigation (GstXImageSink * ximagesink);
|
||||
|
||||
/* ElementFactory information */
|
||||
static GstElementDetails gst_ximagesink_details =
|
||||
|
@ -1156,6 +1157,7 @@ gst_ximagesink_chain (GstPad * pad, GstData * data)
|
|||
gst_buffer_unref (buf);
|
||||
|
||||
gst_ximagesink_handle_xevents (ximagesink, pad);
|
||||
gst_ximagesink_send_pending_navigation (ximagesink);
|
||||
|
||||
g_mutex_unlock (ximagesink->stream_lock);
|
||||
}
|
||||
|
@ -1257,20 +1259,35 @@ gst_ximagesink_interface_init (GstImplementsInterfaceClass * klass)
|
|||
klass->supported = gst_ximagesink_interface_supported;
|
||||
}
|
||||
|
||||
/*
|
||||
* This function is called with the stream-lock held
|
||||
*/
|
||||
static void
|
||||
gst_ximagesink_navigation_send_event (GstNavigation * navigation,
|
||||
GstStructure * structure)
|
||||
gst_ximagesink_send_pending_navigation (GstXImageSink * ximagesink)
|
||||
{
|
||||
GstXImageSink *ximagesink = GST_XIMAGESINK (navigation);
|
||||
GstEvent *event;
|
||||
gint x_offset, y_offset;
|
||||
GSList *cur;
|
||||
GSList *pend_events;
|
||||
|
||||
g_mutex_lock (ximagesink->nav_lock);
|
||||
pend_events = ximagesink->pend_nav_events;
|
||||
ximagesink->pend_nav_events = NULL;
|
||||
g_mutex_unlock (ximagesink->nav_lock);
|
||||
|
||||
cur = pend_events;
|
||||
while (cur) {
|
||||
GstEvent *event = cur->data;
|
||||
GstStructure *structure;
|
||||
double x, y;
|
||||
gint x_offset, y_offset;
|
||||
|
||||
if (!GST_PAD_PEER (GST_VIDEOSINK_PAD (ximagesink)))
|
||||
return;
|
||||
if (event) {
|
||||
structure = event->event_data.structure.structure;
|
||||
|
||||
event = gst_event_new (GST_EVENT_NAVIGATION);
|
||||
event->event_data.structure.structure = structure;
|
||||
if (!GST_PAD_PEER (GST_VIDEOSINK_PAD (ximagesink))) {
|
||||
gst_event_unref (event);
|
||||
cur = g_slist_next (cur);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* We are not converting the pointer coordinates as there's no hardware
|
||||
scaling done here. The only possible scaling is done by videoscale and
|
||||
|
@ -1279,7 +1296,8 @@ gst_ximagesink_navigation_send_event (GstNavigation * navigation,
|
|||
is centered in the window. */
|
||||
|
||||
x_offset = ximagesink->xwindow->width - GST_VIDEOSINK_WIDTH (ximagesink);
|
||||
y_offset = ximagesink->xwindow->height - GST_VIDEOSINK_HEIGHT (ximagesink);
|
||||
y_offset =
|
||||
ximagesink->xwindow->height - GST_VIDEOSINK_HEIGHT (ximagesink);
|
||||
|
||||
if (gst_structure_get_double (structure, "pointer_x", &x)) {
|
||||
x -= x_offset / 2;
|
||||
|
@ -1290,7 +1308,29 @@ gst_ximagesink_navigation_send_event (GstNavigation * navigation,
|
|||
gst_structure_set (structure, "pointer_y", G_TYPE_DOUBLE, y, NULL);
|
||||
}
|
||||
|
||||
gst_pad_send_event (gst_pad_get_peer (GST_VIDEOSINK_PAD (ximagesink)), event);
|
||||
gst_pad_send_event (gst_pad_get_peer (GST_VIDEOSINK_PAD (ximagesink)),
|
||||
event);
|
||||
}
|
||||
cur = g_slist_next (cur);
|
||||
}
|
||||
|
||||
g_slist_free (pend_events);
|
||||
}
|
||||
|
||||
static void
|
||||
gst_ximagesink_navigation_send_event (GstNavigation * navigation,
|
||||
GstStructure * structure)
|
||||
{
|
||||
GstXImageSink *ximagesink = GST_XIMAGESINK (navigation);
|
||||
GstEvent *event;
|
||||
|
||||
event = gst_event_new (GST_EVENT_NAVIGATION);
|
||||
event->event_data.structure.structure = structure;
|
||||
|
||||
g_mutex_lock (ximagesink->nav_lock);
|
||||
ximagesink->pend_nav_events =
|
||||
g_slist_prepend (ximagesink->pend_nav_events, event);
|
||||
g_mutex_unlock (ximagesink->nav_lock);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1561,6 +1601,19 @@ gst_ximagesink_finalize (GObject * object)
|
|||
g_mutex_free (ximagesink->pool_lock);
|
||||
ximagesink->pool_lock = NULL;
|
||||
}
|
||||
if (ximagesink->nav_lock) {
|
||||
g_mutex_free (ximagesink->nav_lock);
|
||||
ximagesink->nav_lock = NULL;
|
||||
}
|
||||
|
||||
while (ximagesink->pend_nav_events) {
|
||||
GstEvent *event = ximagesink->pend_nav_events->data;
|
||||
|
||||
ximagesink->pend_nav_events =
|
||||
g_slist_delete_link (ximagesink->pend_nav_events,
|
||||
ximagesink->pend_nav_events);
|
||||
gst_event_unref (event);
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
@ -1605,6 +1658,9 @@ gst_ximagesink_init (GstXImageSink * ximagesink)
|
|||
|
||||
ximagesink->par = NULL;
|
||||
|
||||
ximagesink->nav_lock = g_mutex_new ();
|
||||
ximagesink->pend_nav_events = NULL;
|
||||
|
||||
GST_FLAG_SET (ximagesink, GST_ELEMENT_THREAD_SUGGESTED);
|
||||
GST_FLAG_SET (ximagesink, GST_ELEMENT_EVENT_AWARE);
|
||||
}
|
||||
|
|
|
@ -132,6 +132,9 @@ struct _GstXImageSink {
|
|||
|
||||
gboolean synchronous;
|
||||
gboolean sw_scaling_failed;
|
||||
|
||||
GMutex *nav_lock;
|
||||
GSList *pend_nav_events;
|
||||
};
|
||||
|
||||
struct _GstXImageSinkClass {
|
||||
|
|
|
@ -49,7 +49,8 @@ MotifWmHints, MwmHints;
|
|||
static void gst_xvimagesink_buffer_free (GstBuffer * buffer);
|
||||
static void gst_xvimagesink_xvimage_destroy (GstXvImageSink * xvimagesink,
|
||||
GstXvImage * xvimage);
|
||||
|
||||
static void
|
||||
gst_xvimagesink_send_pending_navigation (GstXvImageSink * xvimagesink);
|
||||
|
||||
/* ElementFactory information */
|
||||
static GstElementDetails gst_xvimagesink_details =
|
||||
|
@ -1466,6 +1467,7 @@ gst_xvimagesink_chain (GstPad * pad, GstData * data)
|
|||
gst_buffer_unref (buf);
|
||||
|
||||
gst_xvimagesink_handle_xevents (xvimagesink, pad);
|
||||
gst_xvimagesink_send_pending_navigation (xvimagesink);
|
||||
|
||||
g_mutex_unlock (xvimagesink->stream_lock);
|
||||
}
|
||||
|
@ -1571,19 +1573,34 @@ gst_xvimagesink_interface_init (GstImplementsInterfaceClass * klass)
|
|||
klass->supported = gst_xvimagesink_interface_supported;
|
||||
}
|
||||
|
||||
/*
|
||||
* This function is called with the stream-lock held
|
||||
*/
|
||||
static void
|
||||
gst_xvimagesink_navigation_send_event (GstNavigation * navigation,
|
||||
GstStructure * structure)
|
||||
gst_xvimagesink_send_pending_navigation (GstXvImageSink * xvimagesink)
|
||||
{
|
||||
GstXvImageSink *xvimagesink = GST_XVIMAGESINK (navigation);
|
||||
GstEvent *event;
|
||||
GSList *cur;
|
||||
GSList *pend_events;
|
||||
|
||||
g_mutex_lock (xvimagesink->nav_lock);
|
||||
pend_events = xvimagesink->pend_nav_events;
|
||||
xvimagesink->pend_nav_events = NULL;
|
||||
g_mutex_unlock (xvimagesink->nav_lock);
|
||||
|
||||
cur = pend_events;
|
||||
while (cur) {
|
||||
GstEvent *event = cur->data;
|
||||
GstStructure *structure;
|
||||
double x, y;
|
||||
|
||||
if (!GST_PAD_PEER (GST_VIDEOSINK_PAD (xvimagesink)))
|
||||
return;
|
||||
if (event) {
|
||||
structure = event->event_data.structure.structure;
|
||||
|
||||
event = gst_event_new (GST_EVENT_NAVIGATION);
|
||||
event->event_data.structure.structure = structure;
|
||||
if (!GST_PAD_PEER (GST_VIDEOSINK_PAD (xvimagesink))) {
|
||||
gst_event_unref (event);
|
||||
cur = g_slist_next (cur);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Converting pointer coordinates to the non scaled geometry */
|
||||
if (gst_structure_get_double (structure, "pointer_x", &x)) {
|
||||
|
@ -1600,6 +1617,27 @@ gst_xvimagesink_navigation_send_event (GstNavigation * navigation,
|
|||
gst_pad_send_event (gst_pad_get_peer (GST_VIDEOSINK_PAD (xvimagesink)),
|
||||
event);
|
||||
}
|
||||
cur = g_slist_next (cur);
|
||||
}
|
||||
|
||||
g_slist_free (pend_events);
|
||||
}
|
||||
|
||||
static void
|
||||
gst_xvimagesink_navigation_send_event (GstNavigation * navigation,
|
||||
GstStructure * structure)
|
||||
{
|
||||
GstXvImageSink *xvimagesink = GST_XVIMAGESINK (navigation);
|
||||
GstEvent *event;
|
||||
|
||||
event = gst_event_new (GST_EVENT_NAVIGATION);
|
||||
event->event_data.structure.structure = structure;
|
||||
|
||||
g_mutex_lock (xvimagesink->nav_lock);
|
||||
xvimagesink->pend_nav_events =
|
||||
g_slist_prepend (xvimagesink->pend_nav_events, event);
|
||||
g_mutex_unlock (xvimagesink->nav_lock);
|
||||
}
|
||||
|
||||
static void
|
||||
gst_xvimagesink_navigation_init (GstNavigationInterface * iface)
|
||||
|
@ -1951,6 +1989,19 @@ gst_xvimagesink_finalize (GObject * object)
|
|||
g_mutex_free (xvimagesink->pool_lock);
|
||||
xvimagesink->pool_lock = NULL;
|
||||
}
|
||||
if (xvimagesink->nav_lock) {
|
||||
g_mutex_free (xvimagesink->nav_lock);
|
||||
xvimagesink->nav_lock = NULL;
|
||||
}
|
||||
|
||||
while (xvimagesink->pend_nav_events) {
|
||||
GstEvent *event = xvimagesink->pend_nav_events->data;
|
||||
|
||||
xvimagesink->pend_nav_events =
|
||||
g_slist_delete_link (xvimagesink->pend_nav_events,
|
||||
xvimagesink->pend_nav_events);
|
||||
gst_event_unref (event);
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
@ -2001,6 +2052,9 @@ gst_xvimagesink_init (GstXvImageSink * xvimagesink)
|
|||
|
||||
GST_FLAG_SET (xvimagesink, GST_ELEMENT_THREAD_SUGGESTED);
|
||||
GST_FLAG_SET (xvimagesink, GST_ELEMENT_EVENT_AWARE);
|
||||
|
||||
xvimagesink->nav_lock = g_mutex_new ();
|
||||
xvimagesink->pend_nav_events = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -154,6 +154,9 @@ struct _GstXvImageSink {
|
|||
GSList *image_pool;
|
||||
|
||||
gboolean synchronous;
|
||||
|
||||
GMutex *nav_lock;
|
||||
GSList *pend_nav_events;
|
||||
};
|
||||
|
||||
struct _GstXvImageSinkClass {
|
||||
|
|
Loading…
Reference in a new issue