# HG changeset patch # User Stefano D'Angelo # Date 1211154731 -7200 # Node ID 1e67df1a1edc2111b108e21de8d672675ffb7d78 # Parent 8da9705862e558577aacfe97daa838ed5f6b48d9 Implemented query_format() callback in all effect plugins diff -r 8da9705862e5 -r 1e67df1a1edc src/audiocompress/audacious-glue.c --- a/src/audiocompress/audacious-glue.c Sun May 18 16:59:05 2008 +0200 +++ b/src/audiocompress/audacious-glue.c Mon May 19 01:52:11 2008 +0200 @@ -37,6 +37,7 @@ static void myPrefs(void); static int myModify(gpointer * data, gint length, AFormat fmt, gint srate, gint nch); +static void myQueryFormat(AFormat * fmt, gint * rate, gint * nch); static int inited = 0; @@ -48,6 +49,7 @@ .about = myAbout, .configure = myPrefs, .mod_samples = myModify, + .query_format = myQueryFormat, }; EffectPlugin *audiocompress_eplist[] = { &xmms_plugin, NULL }; @@ -76,6 +78,14 @@ inited = 0; } +void myQueryFormat(AFormat * fmt, gint * rate, gint * nch) +{ + if ((*fmt != FMT_S16_NE) || + (*fmt != FMT_S16_LE && G_BYTE_ORDER == G_LITTLE_ENDIAN) || + (*fmt != FMT_S16_BE && G_BYTE_ORDER == G_BIG_ENDIAN)) + *fmt = FMT_S16_NE; +} + int myModify(gpointer * data, gint length, AFormat fmt, gint srate, gint nch) { if (fmt == FMT_S16_NE || diff -r 8da9705862e5 -r 1e67df1a1edc src/crystalizer/crystalizer.c --- a/src/crystalizer/crystalizer.c Sun May 18 16:59:05 2008 +0200 +++ b/src/crystalizer/crystalizer.c Mon May 19 01:52:11 2008 +0200 @@ -27,13 +27,15 @@ static void init(void); static void configure(void); static int mod_samples(gpointer *d, gint length, AFormat afmt, gint srate, gint nch); +static void query_format(AFormat * fmt, gint * rate, gint * nch); EffectPlugin crystalizer_ep = { .description = "Crystalizer", /* Description */ .init = init, .configure = configure, - .mod_samples = mod_samples + .mod_samples = mod_samples, + .query_format = query_format }; static GtkWidget *conf_dialog = NULL; @@ -138,6 +140,14 @@ gtk_widget_show(conf_dialog); } +static void query_format(AFormat * fmt, gint * rate, gint * nch) +{ + if (!(*fmt == FMT_S16_NE || + (*fmt == FMT_S16_LE && G_BYTE_ORDER == G_LITTLE_ENDIAN) || + (*fmt == FMT_S16_BE && G_BYTE_ORDER == G_BIG_ENDIAN))) + *fmt = FMT_S16_NE; +} + static int mod_samples(gpointer *d, gint length, AFormat afmt, gint srate, gint nch) { gint i; diff -r 8da9705862e5 -r 1e67df1a1edc src/echo_plugin/echo.c --- a/src/echo_plugin/echo.c Sun May 18 16:59:05 2008 +0200 +++ b/src/echo_plugin/echo.c Mon May 19 01:52:11 2008 +0200 @@ -11,6 +11,7 @@ static void init(void); static void cleanup(void); static int mod_samples(gpointer * d, gint length, AFormat afmt, gint srate, gint nch); +static void query_format(AFormat * fmt, gint * rate, gint * nch); #define MAX_SRATE 50000 #define MAX_CHANNELS 2 @@ -27,6 +28,7 @@ .about = echo_about, .configure = echo_configure, .mod_samples = mod_samples, + .query_format = query_format, }; static gint16 *buffer = NULL; @@ -59,6 +61,14 @@ buffer = NULL; } +static void query_format(AFormat * fmt, gint * rate, gint * nch) +{ + if (!(*fmt == FMT_S16_NE || + (*fmt == FMT_S16_LE && G_BYTE_ORDER == G_LITTLE_ENDIAN) || + (*fmt == FMT_S16_BE && G_BYTE_ORDER == G_BIG_ENDIAN))) + *fmt = FMT_S16_NE; +} + static int mod_samples(gpointer * d, gint length, AFormat afmt, gint srate, gint nch) { gint i, in, out, buf, r_ofs, fb_div; diff -r 8da9705862e5 -r 1e67df1a1edc src/stereo_plugin/stereo.c --- a/src/stereo_plugin/stereo.c Sun May 18 16:59:05 2008 +0200 +++ b/src/stereo_plugin/stereo.c Mon May 19 01:52:11 2008 +0200 @@ -9,6 +9,7 @@ static void about(void); static void configure(void); static int mod_samples(gpointer *d, gint length, AFormat afmt, gint srate, gint nch); +static void query_format(AFormat * fmt, gint * rate, gint * nch); @@ -18,7 +19,8 @@ .init = init, .about = about, .configure = configure, - .mod_samples = mod_samples + .mod_samples = mod_samples, + .query_format = query_format }; static const char *about_text = N_("Extra Stereo Plugin\n\n" @@ -140,6 +142,17 @@ gtk_widget_show(conf_dialog); } +static void query_format(AFormat * fmt, gint * rate, gint * nch) +{ + if (!(*fmt == FMT_S16_NE || + (*fmt == FMT_S16_LE && G_BYTE_ORDER == G_LITTLE_ENDIAN) || + (*fmt == FMT_S16_BE && G_BYTE_ORDER == G_BIG_ENDIAN))) + *fmt = FMT_S16_NE; + + if (*nch != 2) + *nch = 2; +} + static int mod_samples(gpointer *d, gint length, AFormat afmt, gint srate, gint nch) { gint i; diff -r 8da9705862e5 -r 1e67df1a1edc src/voice_removal/voice_removal.c --- a/src/voice_removal/voice_removal.c Sun May 18 16:59:05 2008 +0200 +++ b/src/voice_removal/voice_removal.c Mon May 19 01:52:11 2008 +0200 @@ -28,16 +28,29 @@ static int apply_effect (gpointer *d, gint length, AFormat afmt, gint srate, gint nch); +static void query_format (AFormat *fmt, gint *rate, gint *nch); static EffectPlugin xmms_plugin = { .description = "Voice Removal Plugin", .mod_samples = apply_effect, + .query_format = query_format }; EffectPlugin *voice_eplist[] = { &xmms_plugin, NULL }; DECLARE_PLUGIN(voice_removal, NULL, NULL, NULL, NULL, voice_eplist, NULL, NULL, NULL); +static void query_format (AFormat *fmt, gint *rate, gint *nch) +{ + if (!((*fmt == FMT_S16_NE) || + (*fmt == FMT_S16_LE && G_BYTE_ORDER == G_LITTLE_ENDIAN) || + (*fmt == FMT_S16_BE && G_BYTE_ORDER == G_BIG_ENDIAN))) + *fmt = FMT_S16_NE; + + if (*nch != 2) + *nch = 2; +} + static int apply_effect (gpointer *d, gint length, AFormat afmt, gint srate, gint nch) { int x;