From e6ef73471b73d622520db8076202c48764031469 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Fri, 11 Nov 2005 17:41:04 +0000 Subject: [PATCH] sys/xvimage/xvimagesink.c: Check whether peer pad exists before sending navigation events to it. Original commit message from CVS: * sys/xvimage/xvimagesink.c: (gst_xvimagesink_navigation_send_event): Check whether peer pad exists before sending navigation events to it. --- ChangeLog | 7 +++++++ sys/xvimage/xvimagesink.c | 40 +++++++++++++++++++++++---------------- 2 files changed, 31 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index 464f3b9587..c8bf58b263 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2005-11-11 Tim-Philipp Müller + + * sys/xvimage/xvimagesink.c: + (gst_xvimagesink_navigation_send_event): + Check whether peer pad exists before sending navigation events + to it. + 2005-11-11 Michael Smith * ext/vorbis/vorbisenc.c: (gst_vorbisenc_setup), diff --git a/sys/xvimage/xvimagesink.c b/sys/xvimage/xvimagesink.c index c911afc23e..64406c8df2 100644 --- a/sys/xvimage/xvimagesink.c +++ b/sys/xvimage/xvimagesink.c @@ -1710,25 +1710,33 @@ gst_xvimagesink_navigation_send_event (GstNavigation * navigation, GstStructure * structure) { GstXvImageSink *xvimagesink = GST_XVIMAGESINK (navigation); - GstEvent *event; - double x, y; + GstPad *peer; - event = gst_event_new_custom (GST_EVENT_NAVIGATION, structure); + if ((peer = gst_pad_get_peer (GST_VIDEO_SINK_PAD (xvimagesink)))) { + GstEvent *event; + gdouble x, y, xscale = 1.0, yscale = 1.0; - /* Converting pointer coordinates to the non scaled geometry */ - if (gst_structure_get_double (structure, "pointer_x", &x)) { - x *= GST_VIDEO_SINK_WIDTH (xvimagesink); - x /= xvimagesink->xwindow->width; - gst_structure_set (structure, "pointer_x", G_TYPE_DOUBLE, x, NULL); + event = gst_event_new_custom (GST_EVENT_NAVIGATION, structure); + + if (xvimagesink->xwindow) { + xscale = GST_VIDEO_SINK_WIDTH (xvimagesink) / xvimagesink->xwindow->width; + yscale = + GST_VIDEO_SINK_HEIGHT (xvimagesink) / xvimagesink->xwindow->height; + } + + /* Converting pointer coordinates to the non scaled geometry */ + if (gst_structure_get_double (structure, "pointer_x", &x)) { + gst_structure_set (structure, "pointer_x", G_TYPE_DOUBLE, + (gdouble) x * xscale, NULL); + } + if (gst_structure_get_double (structure, "pointer_y", &y)) { + gst_structure_set (structure, "pointer_y", G_TYPE_DOUBLE, + (gdouble) y * yscale, NULL); + } + + gst_pad_send_event (peer, event); + gst_object_unref (peer); } - if (gst_structure_get_double (structure, "pointer_y", &y)) { - y *= GST_VIDEO_SINK_HEIGHT (xvimagesink); - y /= xvimagesink->xwindow->height; - gst_structure_set (structure, "pointer_y", G_TYPE_DOUBLE, y, NULL); - } - - gst_pad_send_event (gst_pad_get_peer (GST_VIDEO_SINK_PAD (xvimagesink)), - event); } static void