[audacious-plugins] - Merge updated blur-scope plugin to fix segfaults.
Michael Schwendt
mschwendt at fedoraproject.org
Fri Oct 8 20:05:24 UTC 2010
commit 2bfe57ad6276305afe46d474c6ddb4e8d430930d
Author: Michael Schwendt <mschwendt at fedoraproject.org>
Date: Fri Oct 8 22:05:19 2010 +0200
- Merge updated blur-scope plugin to fix segfaults.
audacious-plugins-2.4.0-blur-scope-update.patch | 525 +++++++++++++++++++++++
audacious-plugins.spec | 8 +-
2 files changed, 532 insertions(+), 1 deletions(-)
---
diff --git a/audacious-plugins-2.4.0-blur-scope-update.patch b/audacious-plugins-2.4.0-blur-scope-update.patch
new file mode 100644
index 0000000..ad95d4f
--- /dev/null
+++ b/audacious-plugins-2.4.0-blur-scope-update.patch
@@ -0,0 +1,525 @@
+diff -Nur audacious-plugins-fedora-2.4.0-orig/src/blur_scope/blur_scope.c audacious-plugins-fedora-2.4.0/src/blur_scope/blur_scope.c
+--- audacious-plugins-fedora-2.4.0-orig/src/blur_scope/blur_scope.c 2010-08-26 01:07:50.000000000 +0200
++++ audacious-plugins-fedora-2.4.0/src/blur_scope/blur_scope.c 2010-09-30 19:20:08.000000000 +0200
+@@ -1,4 +1,8 @@
+-/* BMP - Cross-platform multimedia player
++/*
++ * Blur Scope plugin for Audacious
++ * Copyright (C) 2010 John Lindgren
++ *
++ * Based on BMP - Cross-platform multimedia player:
+ * Copyright (C) 2003-2004 BMP development team.
+ *
+ * Based on XMMS:
+@@ -19,33 +23,24 @@
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+-#include "config.h"
+-
+-#include <glib.h>
+ #include <gtk/gtk.h>
+ #include <string.h>
+
+ #include <audacious/configdb.h>
+-#include <audacious/i18n.h>
+ #include <audacious/plugin.h>
+
+ #include "blur_scope.h"
+
+-static GtkWidget *area = NULL;
+-static gboolean config_read = FALSE;
++#define D_WIDTH 256
++#define D_HEIGHT 128
+
+-static void bscope_init(void);
++static gboolean bscope_init (void);
+ static void bscope_cleanup(void);
+ static void bscope_playback_stop(void);
+ static void bscope_render_pcm(gint16 data[2][512]);
+-/* static GtkWidget * bscope_get_widget (void); */
+-static void * bscope_get_widget (void);
+-
+-BlurScopeConfig bscope_cfg;
+-
+-enum { SCOPE_TOGGLE, SCOPE_CLOSE };
++static void /* GtkWidget */ * bscope_get_widget (void);
+
+-VisPlugin bscope_vp = {
++static VisPlugin bscope_vp = {
+ .description = "Blur Scope", /* description */
+ .num_pcm_chs_wanted = 1, /* Number of PCM channels wanted */
+ .num_freq_chs_wanted = 0, /* Number of freq channels wanted */
+@@ -57,197 +52,138 @@
+ .get_widget = bscope_get_widget,
+ };
+
+-VisPlugin *bscope_vplist[] = { &bscope_vp, NULL };
++static VisPlugin * bscope_vplist[] = {& bscope_vp, NULL};
+
+-DECLARE_PLUGIN(bscope, NULL, NULL, NULL, NULL, NULL, NULL, bscope_vplist,NULL);
++SIMPLE_VISUAL_PLUGIN (bscope, bscope_vplist)
+
+-#define D_WIDTH 256
+-#define D_HEIGHT 128
+-#define min(x,y) ((x)<(y)?(x):(y))
+-gint width = D_WIDTH;
+-gint height = D_HEIGHT;
+-gint bpl = (D_WIDTH + 2);
+-
+-static GStaticMutex rgb_buf_mutex = G_STATIC_MUTEX_INIT;
+-static guchar *rgb_buf = NULL;
+-static GdkRgbCmap *cmap = NULL;
++gint color = 0xFF3F7F;
+
+-inline static void
+-draw_pixel_8(guchar * buffer, gint x, gint y, guchar c)
+-{
+- if (buffer == NULL)
+- return;
++static GtkWidget * area = NULL;
++static gint width, height, stride, image_size;
++static guint32 * image = NULL, * corner = NULL;
+
+- buffer[((y + 1) * bpl) + (x + 1)] = c;
++static gboolean bscope_init (void)
++{
++ mcs_handle_t * db = aud_cfg_db_open ();
++ aud_cfg_db_get_int (db, "BlurScope", "color", & color);
++ aud_cfg_db_close (db);
++ return TRUE;
+ }
+
+-inline static void
+-bscope_resize_video(gint w, gint h)
++static void bscope_cleanup (void)
+ {
+- g_static_mutex_lock(&rgb_buf_mutex);
++ mcs_handle_t * db = aud_cfg_db_open ();
++ aud_cfg_db_set_int (db, "BlurScope", "color", color);
++ aud_cfg_db_close (db);
+
++ g_free (image);
++ image = NULL;
++}
++
++static void bscope_resize (gint w, gint h)
++{
+ width = w;
+ height = h;
+- bpl = (width + 2);
+-
+- if (rgb_buf != NULL) {
+- g_free(rgb_buf);
+- rgb_buf = NULL;
+- }
+-
+- rgb_buf = g_malloc0((w + 2) * (h + 2));
+-
+- g_static_mutex_unlock(&rgb_buf_mutex);
++ stride = width + 2;
++ image_size = (stride << 2) * (height + 2);
++ image = g_realloc (image, image_size);
++ memset (image, 0, image_size);
++ corner = image + stride + 1;
+ }
+
+-gboolean
+-bscope_reconfigure(GtkWidget *widget, GdkEventConfigure *event, gpointer unused)
++static void bscope_draw (void)
+ {
+- bscope_resize_video(event->width, event->height);
++ if (area == NULL || area->window == NULL)
++ return;
+
+- return FALSE;
++ cairo_t * cr = gdk_cairo_create (area->window);
++ cairo_surface_t * surf = cairo_image_surface_create_for_data ((guchar *)
++ image, CAIRO_FORMAT_RGB24, width, height, stride << 2);
++ cairo_set_source_surface (cr, surf, 0, 0);
++ cairo_paint (cr);
++ cairo_surface_destroy (surf);
++ cairo_destroy (cr);
+ }
+
+-void
+-bscope_read_config(void)
++static gboolean configure_event (GtkWidget * widget, GdkEventConfigure * event)
+ {
+- mcs_handle_t *db;
+-
+- if (!config_read) {
+- bscope_cfg.color = 0xFF3F7F;
+- db = aud_cfg_db_open();
+-
+- if (db) {
+- aud_cfg_db_get_int(db, "BlurScope", "color",
+- (int *) &bscope_cfg.color);
+- aud_cfg_db_close(db);
+- }
+- config_read = TRUE;
+- }
++ bscope_resize (event->width, event->height);
++ return TRUE;
+ }
+
+-
+-void
+-bscope_blur_8(guchar * ptr, gint w, gint h, gint bpl_)
++static gboolean expose_event (GtkWidget * widget)
+ {
+- register guint i, sum;
+- register guchar *iptr;
+-
+- iptr = ptr + bpl_ + 1;
+- i = bpl_ * h;
+- while (i--) {
+- sum = (iptr[-bpl_] + iptr[-1] + iptr[1] + iptr[bpl_]) >> 2;
+- if (sum > 2)
+- sum -= 2;
+- *(iptr++) = sum;
+- }
++ bscope_draw ();
++ return TRUE;
+ }
+
+-void
+-generate_cmap(void)
++static void /* GtkWidget */ * bscope_get_widget (void)
+ {
+- guint32 colors[256], i, red, blue, green;
++ area = gtk_drawing_area_new ();
++ gtk_widget_set_size_request (area, D_WIDTH, D_HEIGHT);
++ bscope_resize (D_WIDTH, D_HEIGHT);
+
+- red = (guint32) (bscope_cfg.color / 0x10000);
+- green = (guint32) ((bscope_cfg.color % 0x10000) / 0x100);
+- blue = (guint32) (bscope_cfg.color % 0x100);
+- for (i = 255; i > 0; i--) {
+- colors[i] =
+- (((guint32) (i * red / 256) << 16) |
+- ((guint32) (i * green / 256) << 8) |
+- ((guint32) (i * blue / 256)));
+- }
+- colors[0] = 0;
+- if (cmap) {
+- gdk_rgb_cmap_free(cmap);
+- }
+- cmap = gdk_rgb_cmap_new(colors, 256);
++ g_signal_connect (area, "expose-event", (GCallback) expose_event, NULL);
++ g_signal_connect (area, "configure-event", (GCallback) configure_event, NULL);
++ g_signal_connect (area, "destroy", (GCallback) gtk_widget_destroyed, & area);
++
++ return area;
+ }
+
+-static void
+-bscope_init(void)
++static void bscope_playback_stop (void)
+ {
+- bscope_read_config();
+- generate_cmap();
++ g_return_if_fail (image != NULL);
++ memset (image, 0, image_size);
++ bscope_draw ();
+ }
+
+-/* static GtkWidget * bscope_get_widget (void) */
+-static void * bscope_get_widget (void)
++static void bscope_blur (void)
+ {
+- if (area == NULL)
++ for (gint y = 0; y < height; y ++)
+ {
+- area = gtk_drawing_area_new ();
+- gtk_widget_set_size_request (area, D_WIDTH, D_HEIGHT);
+- bscope_resize_video (D_WIDTH, D_HEIGHT);
+-
+- g_signal_connect (area, "configure-event", (GCallback)
+- bscope_reconfigure, NULL);
+- g_signal_connect (area, "destroy", (GCallback) gtk_widget_destroyed,
+- & area);
+- }
++ guint32 * p = corner + stride * y;
++ guint32 * end = p + width;
++ guint32 * plast = p - stride;
++ guint32 * pnext = p + stride;
+
+- return area;
++ /* We do a quick and dirty average of four color values, first masking
++ * off the lowest two bits. Over a large area, this masking has the net
++ * effect of subtracting 1.5 from each value, which by a happy chance
++ * is just right for a gradual fade effect. */
++ for (; p < end; p ++)
++ * p = ((* plast ++ & 0xFCFCFC) + (p[-1] & 0xFCFCFC) + (p[1] &
++ 0xFCFCFC) + (* pnext ++ & 0xFCFCFC)) >> 2;
++ }
+ }
+
+-static void
+-bscope_cleanup(void)
++static inline void draw_vert_line (gint x, guint y1, gint y2)
+ {
+- if (cmap) {
+- gdk_rgb_cmap_free(cmap);
+- cmap = NULL;
+- }
++ gint y, h;
+
+- area = NULL;
+-}
++ if (y1 < y2) {y = y1 + 1; h = y2 - y1;}
++ else if (y2 < y1) {y = y2; h = y1 - y2;}
++ else {y = y1; h = 1;}
+
+-static void
+-bscope_playback_stop(void)
+-{
+- if (GTK_WIDGET_REALIZED(area))
+- gdk_window_clear(area->window);
+-}
++ guint32 * p = corner + y * stride + x;
+
+-static inline void
+-draw_vert_line(guchar * buffer, gint x, gint y1, gint y2)
+-{
+- int y;
+- if (y1 < y2) {
+- for (y = y1 + 1; y <= y2; y++)
+- draw_pixel_8(buffer, x, y, 0xFF);
+- }
+- else if (y2 < y1) {
+- for (y = y2; y < y1; y++)
+- draw_pixel_8(buffer, x, y, 0xFF);
+- }
+- else
+- draw_pixel_8(buffer, x, y1, 0xFF);
++ for (; h --; p += stride)
++ * p = color;
+ }
+
+-static void
+-bscope_render_pcm(gint16 data[2][512])
++static void bscope_render_pcm (gint16 data[2][512])
+ {
+- gint i, y, prev_y;
++ bscope_blur ();
+
+- g_static_mutex_lock(&rgb_buf_mutex);
+-
+- bscope_blur_8(rgb_buf, width, height, bpl);
+- prev_y = (height / 2) + (data[0][0] >> 9);
++ gint prev_y = (height / 2) + (data[0][0] >> 9);
+ prev_y = CLAMP (prev_y, 0, height - 1);
+- for (i = 0; i < width; i++) {
+- y = (height / 2) + (data[0][i * 512 / width] >> 9);
++
++ for (gint i = 0; i < width; i ++)
++ {
++ gint y = (height / 2) + (data[0][i * 512 / width] >> 9);
+ y = CLAMP (y, 0, height - 1);
+- draw_vert_line(rgb_buf, i, prev_y, y);
++ draw_vert_line (i, prev_y, y);
+ prev_y = y;
+ }
+
+- GDK_THREADS_ENTER();
+- if (area != NULL)
+- gdk_draw_indexed_image(area->window, area->style->white_gc, 0, 0,
+- width, height, GDK_RGB_DITHER_NONE,
+- rgb_buf + bpl + 1, (width + 2), cmap);
+- GDK_THREADS_LEAVE();
+-
+- g_static_mutex_unlock(&rgb_buf_mutex);
+-
+- return;
++ bscope_draw ();
+ }
+diff -Nur audacious-plugins-fedora-2.4.0-orig/src/blur_scope/blur_scope.h audacious-plugins-fedora-2.4.0/src/blur_scope/blur_scope.h
+--- audacious-plugins-fedora-2.4.0-orig/src/blur_scope/blur_scope.h 2010-08-26 01:07:50.000000000 +0200
++++ audacious-plugins-fedora-2.4.0/src/blur_scope/blur_scope.h 2010-09-21 19:20:06.000000000 +0200
+@@ -1,15 +1,33 @@
++/*
++ * Blur Scope plugin for Audacious
++ * Copyright (C) 2010 John Lindgren
++ *
++ * Based on BMP - Cross-platform multimedia player:
++ * Copyright (C) 2003-2004 BMP development team.
++ *
++ * Based on XMMS:
++ * Copyright (C) 1998-2003 XMMS development team.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
++ */
++
+ #ifndef BLUR_SCOPE_H
+ #define BLUR_SCOPE_H
+
+ void bscope_configure(void);
+-void bscope_read_config(void);
+-
+-typedef struct {
+- guint32 color;
+-} BlurScopeConfig;
+-
+-extern BlurScopeConfig bscope_cfg;
+
+-void generate_cmap(void);
++extern gint color;
+
+ #endif
+diff -Nur audacious-plugins-fedora-2.4.0-orig/src/blur_scope/config.c audacious-plugins-fedora-2.4.0/src/blur_scope/config.c
+--- audacious-plugins-fedora-2.4.0-orig/src/blur_scope/config.c 2010-08-26 01:07:50.000000000 +0200
++++ audacious-plugins-fedora-2.4.0/src/blur_scope/config.c 2010-09-21 19:20:06.000000000 +0200
+@@ -1,14 +1,34 @@
+-#include "config.h"
++/*
++ * Blur Scope plugin for Audacious
++ * Copyright (C) 2010 John Lindgren
++ *
++ * Based on BMP - Cross-platform multimedia player:
++ * Copyright (C) 2003-2004 BMP development team.
++ *
++ * Based on XMMS:
++ * Copyright (C) 1998-2003 XMMS development team.
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
++ */
+
+-#include <glib.h>
+ #include <gtk/gtk.h>
+
+-#include <audacious/configdb.h>
+ #include <audacious/i18n.h>
+-#include <audacious/plugin.h>
+
+ #include "blur_scope.h"
+-
++#include "config.h"
+
+ static GtkWidget *configure_win = NULL;
+ static GtkWidget *vbox, *options_frame, *options_vbox;
+@@ -18,39 +38,33 @@
+ static void
+ configure_ok(GtkWidget * w, gpointer data)
+ {
+- mcs_handle_t *db;
+- gdouble color[3];
++ gdouble c[3];
+
+ gtk_color_selection_get_color(GTK_COLOR_SELECTION(options_colorpicker),
+- color);
+- bscope_cfg.color =
+- ((guint32) (255.0 * color[0]) << 16) |
+- ((guint32) (255.0 * color[1]) << 8) | ((guint32) (255.0 * color[2]));
+- db = aud_cfg_db_open();
+- aud_cfg_db_set_int(db, "BlurScope", "color", bscope_cfg.color);
+- aud_cfg_db_close(db);
+- generate_cmap();
++ c);
++ color =
++ ((guint32) (255.0 * c[0]) << 16) |
++ ((guint32) (255.0 * c[1]) << 8) | ((guint32) (255.0 * c[2]));
+ gtk_widget_destroy(configure_win);
+ }
+
+ static void
+ configure_cancel(GtkWidget * w, gpointer data)
+ {
+- bscope_cfg.color = GPOINTER_TO_UINT(data);
+- generate_cmap();
++ color = GPOINTER_TO_UINT(data);
+ gtk_widget_destroy(configure_win);
+ }
+
+ static void
+ color_changed(GtkWidget * w, gpointer data)
+ {
+- gdouble color[3];
++ gdouble c[3];
++
+ gtk_color_selection_get_color(GTK_COLOR_SELECTION(options_colorpicker),
+- color);
+- bscope_cfg.color =
+- ((guint32) (255.0 * color[0]) << 16) |
+- ((guint32) (255.0 * color[1]) << 8) | ((guint32) (255.0 * color[2]));
+- generate_cmap();
++ c);
++ color =
++ ((guint32) (255.0 * c[0]) << 16) |
++ ((guint32) (255.0 * c[1]) << 8) | ((guint32) (255.0 * c[2]));
+ }
+
+ void
+@@ -58,14 +72,13 @@
+ {
+ /* FIXME: convert to GtkColorSelectionDialog */
+
+- gdouble color[3];
++ gdouble c[3];
+ if (configure_win)
+ return;
+
+- bscope_read_config();
+- color[0] = ((gdouble) (bscope_cfg.color / 0x10000)) / 256;
+- color[1] = ((gdouble) ((bscope_cfg.color % 0x10000) / 0x100)) / 256;
+- color[2] = ((gdouble) (bscope_cfg.color % 0x100)) / 256;
++ c[0] = ((gdouble) (color / 0x10000)) / 256;
++ c[1] = ((gdouble) ((color % 0x10000) / 0x100)) / 256;
++ c[2] = ((gdouble) (color % 0x100)) / 256;
+
+ configure_win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+ gtk_container_set_border_width(GTK_CONTAINER(configure_win), 10);
+@@ -88,7 +101,7 @@
+
+ options_colorpicker = gtk_color_selection_new();
+ gtk_color_selection_set_color(GTK_COLOR_SELECTION(options_colorpicker),
+- color);
++ c);
+ g_signal_connect(G_OBJECT(options_colorpicker), "color_changed",
+ G_CALLBACK(color_changed), NULL);
+
+@@ -111,7 +124,7 @@
+ cancel = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
+ g_signal_connect(G_OBJECT(cancel), "clicked",
+ G_CALLBACK(configure_cancel),
+- GUINT_TO_POINTER(bscope_cfg.color));
++ GUINT_TO_POINTER(color));
+ GTK_WIDGET_SET_FLAGS(cancel, GTK_CAN_DEFAULT);
+ gtk_box_pack_start(GTK_BOX(bbox), cancel, TRUE, TRUE, 0);
+ gtk_widget_show(cancel);
+diff -Nur audacious-plugins-fedora-2.4.0-orig/src/blur_scope/Makefile audacious-plugins-fedora-2.4.0/src/blur_scope/Makefile
+--- audacious-plugins-fedora-2.4.0-orig/src/blur_scope/Makefile 2010-08-26 01:07:50.000000000 +0200
++++ audacious-plugins-fedora-2.4.0/src/blur_scope/Makefile 2010-09-21 19:20:06.000000000 +0200
+@@ -9,5 +9,5 @@
+ plugindir := ${plugindir}/${VISUALIZATION_PLUGIN_DIR}
+
+ CFLAGS += ${PLUGIN_CFLAGS}
+-CPPFLAGS += ${PLUGIN_CPPFLAGS} ${MOWGLI_CFLAGS} ${GTK_CFLAGS} ${GLIB_CFLAGS} -I../..
+-LIBS += ${GTK_LIBS} ${GLIB_LIBS}
++CPPFLAGS += -std=c99 ${PLUGIN_CPPFLAGS} ${MOWGLI_CFLAGS} ${GTK_CFLAGS} -I../..
++LIBS += ${GTK_LIBS}
diff --git a/audacious-plugins.spec b/audacious-plugins.spec
index 8c9b42f..811a5e4 100644
--- a/audacious-plugins.spec
+++ b/audacious-plugins.spec
@@ -6,7 +6,7 @@
Name: audacious-plugins
Version: 2.4.0
-Release: 5%{?dist}
+Release: 6%{?dist}
Summary: Plugins for the Audacious audio player
Group: Applications/Multimedia
URL: http://audacious-media-player.org/
@@ -31,6 +31,8 @@ Patch3: audacious-plugins-2.4-strip-m3u-lines.patch
Patch4: audacious-plugins-2.4.0-scrobbler-no-null.diff.patch
# from upstream hg - BSD/GPL only
Patch5: audacious-plugins-2.4.0-psf-update.patch
+# from upstream hg
+Patch6: audacious-plugins-2.4.0-blur-scope-update.patch
BuildRequires: audacious-devel >= %{aud_ver}
BuildRequires: gettext
@@ -142,6 +144,7 @@ providers may build it with libsidplay 2 instead.
%patch3 -p1 -b .m3u-whitespace
%patch4 -p1 -b .scrobbler-no-null
%patch5 -p1 -b .psf-update
+%patch6 -p1 -b .blur-scope-update
for i in src/ladspa/ladspa.c
do
@@ -231,6 +234,9 @@ update-desktop-database &> /dev/null || :
%changelog
+* Fri Oct 8 2010 Michael Schwendt <mschwendt at fedoraproject.org> - 2.4.0-6
+- Merge updated blur-scope plugin to fix segfaults.
+
* Fri Oct 8 2010 Michael Schwendt <mschwendt at fedoraproject.org> - 2.4.0-5
- Merge psf.so (OpenPSF PSF1/PSF2 Audio Plugin) from upstream hg to
resolve licensing issue.
More information about the scm-commits
mailing list