summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian@centricular.com>2016-02-27 20:31:15 +0200
committerSebastian Dröge <sebastian@centricular.com>2016-02-27 20:31:15 +0200
commitcc6e102643c1bae928316dca9f34db028fb9a67e (patch)
treeb51b02cd5ce8bc5aa8debfbd84aaeeeed7f7e1fc
parentd01e390c8273303570d9059a0c2e45a4c0130e02 (diff)
downloadgstreamer-plugins-good-cc6e102643c1bae928316dca9f34db028fb9a67e.tar.gz
goom: Initialize the goom struct only once we know width/height and recreate it if those change
Fixes crash when the width and/or height is changing. https://bugzilla.gnome.org/show_bug.cgi?id=762765
-rw-r--r--gst/goom/gstgoom.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/gst/goom/gstgoom.c b/gst/goom/gstgoom.c
index 6700f75c9..a941ab07a 100644
--- a/gst/goom/gstgoom.c
+++ b/gst/goom/gstgoom.c
@@ -50,9 +50,6 @@
GST_DEBUG_CATEGORY (goom_debug);
#define GST_CAT_DEFAULT goom_debug
-#define DEFAULT_WIDTH 320
-#define DEFAULT_HEIGHT 240
-
/* signals and args */
enum
{
@@ -129,11 +126,9 @@ gst_goom_class_init (GstGoomClass * klass)
static void
gst_goom_init (GstGoom * goom)
{
- goom->width = DEFAULT_WIDTH;
- goom->height = DEFAULT_HEIGHT;
+ goom->width = -1;
+ goom->height = -1;
goom->channels = 0;
-
- goom->plugin = goom_init (goom->width, goom->height);
}
static void
@@ -152,8 +147,15 @@ gst_goom_setup (GstAudioVisualizer * base)
{
GstGoom *goom = GST_GOOM (base);
- goom->width = GST_VIDEO_INFO_WIDTH (&base->vinfo);
- goom->height = GST_VIDEO_INFO_HEIGHT (&base->vinfo);
+ if (!goom->plugin ||
+ goom->width != GST_VIDEO_INFO_WIDTH (&base->vinfo) ||
+ goom->height != GST_VIDEO_INFO_HEIGHT (&base->vinfo)) {
+ goom->width = GST_VIDEO_INFO_WIDTH (&base->vinfo);
+ goom->height = GST_VIDEO_INFO_HEIGHT (&base->vinfo);
+ if (goom->plugin)
+ goom_close (goom->plugin);
+ goom->plugin = goom_init (goom->width, goom->height);
+ }
return TRUE;
}
@@ -168,6 +170,9 @@ gst_goom_render (GstAudioVisualizer * base, GstBuffer * audio,
gint16 *adata;
gint i;
+ if (!goom->plugin)
+ return FALSE;
+
/* get next GOOM_SAMPLES, we have at least this amount of samples */
gst_buffer_map (audio, &amap, GST_MAP_READ);
adata = (gint16 *) amap.data;