# HG changeset patch # User Eugene Zagidullin # Date 1205361779 -10800 # Node ID 04ade98fafa3babdfe0f3be04ffa6351436d7f05 # Parent 1028f5cf9b4a2d5a0c744435e523da29959eb84b vis moved to separate flow. works in passthrough mode too diff -r 1028f5cf9b4a -r 04ade98fafa3 src/audacious/input.c --- a/src/audacious/input.c Thu Mar 06 11:59:18 2008 +0100 +++ b/src/audacious/input.c Thu Mar 13 01:42:59 2008 +0300 @@ -23,6 +23,8 @@ * Audacious or using our public API to be a derived work. */ +/* #define AUD_DEBUG */ + #ifdef HAVE_CONFIG_H # include "config.h" #endif @@ -55,6 +57,8 @@ #include "libSAD.h" +#define FMT_FRACBITS(a) ( (a) == FMT_FIXED32 ? __AUDACIOUS_ASSUMED_MAD_F_FRACBITS__ : 0 ) + G_LOCK_DEFINE_STATIC(vis_mutex); struct _VisNode { @@ -81,6 +85,7 @@ static int volume_l = -1, volume_r = -1; static SAD_dither_t *sad_state = NULL; static gint sad_nch = -1; +static AFormat sad_fmt = -1; InputPlayback * get_current_input_playback(void) @@ -155,13 +160,13 @@ } static SAD_dither_t* -init_sad(gint nch) +init_sad(AFormat fmt, gint nch) { gint ret; SAD_buffer_format in, out; - in.sample_format = SAD_SAMPLE_FLOAT; - in.fracbits = 0; + in.sample_format = sadfmt_from_afmt(fmt); + in.fracbits = FMT_FRACBITS(fmt); in.channels = nch; in.channels_order = SAD_CHORDER_INTERLEAVED; in.samplerate = 0; @@ -171,7 +176,8 @@ out.channels = nch; out.channels_order = SAD_CHORDER_SEPARATED; /* sic! --asphyx */ out.samplerate = 0; - + + AUDDBG("fmt=%d, nch=%d\n", fmt, nch); SAD_dither_t *state = SAD_dither_init(&in, &out, &ret); if (state != NULL) SAD_dither_set_dither(state, FALSE); return state; @@ -183,16 +189,17 @@ VisNode *vis_node; gint max; - if (fmt != FMT_FLOAT || nch > 2) return; + if (nch > 2) return; - if (sad_state == NULL || nch != sad_nch) { + if (sad_state == NULL || nch != sad_nch || fmt != sad_fmt) { if(sad_state != NULL) SAD_dither_free(sad_state); - sad_state = init_sad(nch); + sad_state = init_sad(fmt, nch); if(sad_state == NULL) return; sad_nch = nch; + sad_fmt = fmt; } - max = length / nch / sizeof(float); + max = length / nch / FMT_SIZEOF(fmt); max = CLAMP(max, 0, 512); vis_node = g_slice_new0(VisNode); diff -r 1028f5cf9b4a -r 04ade98fafa3 src/audacious/output.c --- a/src/audacious/output.c Thu Mar 06 11:59:18 2008 +0100 +++ b/src/audacious/output.c Thu Mar 13 01:42:59 2008 +0300 @@ -508,19 +508,28 @@ int *going /* 0 when time to stop */ ) { + static Flow *visualization_flow = NULL; static Flow *postproc_flow = NULL; static Flow *legacy_flow = NULL; OutputPlugin *op = playback->output; gint writeoffs; gpointer float_ptr; + + if (visualization_flow == NULL) + { + visualization_flow = flow_new(); + flow_link_element(visualization_flow, vis_flow); + } + + plugin_set_current((Plugin *)(playback->output)); + gint time = playback->output->written_time(); + + flow_execute(visualization_flow, time, &ptr, length, fmt, decoder_srate, nch); if (!bypass_dsp) { if(length <= 0 || sad_state_from_float == NULL || sad_state_to_float == NULL) return; - plugin_set_current((Plugin *)(playback->output)); - gint time = playback->output->written_time(); - if (legacy_flow == NULL) { legacy_flow = flow_new(); @@ -530,7 +539,6 @@ if (postproc_flow == NULL) { postproc_flow = flow_new(); - flow_link_element(postproc_flow, vis_flow); #ifdef USE_SRC flow_link_element(postproc_flow, src_flow); #endif