From 7deabe5e6b2c63a18267fd38a1865273ed500503 Mon Sep 17 00:00:00 2001 From: Jan Schmidt Date: Thu, 22 Oct 2009 00:33:26 +0100 Subject: Fix intermittent pixel-aspect-ratio warnings. Don't cache a pointer to the GValue containing the pixel-aspect-ratio, as it may end up being accessed after those caps have been destroyed. Instead, store the pixel-aspect-ratio fraction values directly. --- src/backend/bacon-video-widget-gst-0.10.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/backend/bacon-video-widget-gst-0.10.c b/src/backend/bacon-video-widget-gst-0.10.c index 84258974b..8a68caf96 100644 --- a/src/backend/bacon-video-widget-gst-0.10.c +++ b/src/backend/bacon-video-widget-gst-0.10.c @@ -200,7 +200,8 @@ struct BaconVideoWidgetPrivate gint video_height; /* Movie height */ gboolean window_resized; /* Whether the window has already been resized for this media */ - const GValue *movie_par; /* Movie pixel aspect ratio */ + gint movie_par_n; /* Movie pixel aspect ratio numerator */ + gint movie_par_d; /* Movie pixel aspect ratio denominator */ gint video_width_pixels; /* Scaled movie width */ gint video_height_pixels; /* Scaled movie height */ gint video_fps_n; @@ -455,16 +456,8 @@ get_media_size (BaconVideoWidget *bvw, gint *width, gint *height) } else { /* Use the movie pixel aspect ratio if any */ - if (bvw->priv->movie_par) { - movie_par_n = gst_value_get_fraction_numerator (bvw->priv->movie_par); - movie_par_d = - gst_value_get_fraction_denominator (bvw->priv->movie_par); - } - else { - /* Square pixels */ - movie_par_n = 1; - movie_par_d = 1; - } + movie_par_n = bvw->priv->movie_par_n; + movie_par_d = bvw->priv->movie_par_d; } GST_DEBUG ("movie PAR is %d/%d", movie_par_n, movie_par_d); @@ -2118,6 +2111,8 @@ caps_set (GObject * obj, /* Get video decoder caps */ s = gst_caps_get_structure (caps, 0); if (s) { + const GValue *movie_par; + /* We need at least width/height and framerate */ if (!(gst_structure_get_fraction (s, "framerate", &bvw->priv->video_fps_n, &bvw->priv->video_fps_d) && @@ -2126,7 +2121,16 @@ caps_set (GObject * obj, return; /* Get the movie PAR if available */ - bvw->priv->movie_par = gst_structure_get_value (s, "pixel-aspect-ratio"); + movie_par = gst_structure_get_value (s, "pixel-aspect-ratio"); + if (movie_par) { + bvw->priv->movie_par_n = gst_value_get_fraction_numerator (movie_par); + bvw->priv->movie_par_d = gst_value_get_fraction_denominator (movie_par); + } + else { + /* Square pixels */ + bvw->priv->movie_par_n = 1; + bvw->priv->movie_par_d = 1; + } /* Now set for real */ bacon_video_widget_set_aspect_ratio (bvw, bvw->priv->ratio_type); -- cgit v1.2.1