changeset 4324:360c934b9330

Automated merge with ssh://hg.atheme.org//hg/audacious
author Eugene Zagidullin <e.asphyx@gmail.com>
date Thu, 13 Mar 2008 01:43:19 +0300
parents 04ade98fafa3 (diff) e960a507509d (current diff)
children 309e8f970517
files
diffstat 2 files changed, 27 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/src/audacious/input.c	Tue Mar 11 20:19:15 2008 +0200
+++ b/src/audacious/input.c	Thu Mar 13 01:43:19 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);
--- a/src/audacious/output.c	Tue Mar 11 20:19:15 2008 +0200
+++ b/src/audacious/output.c	Thu Mar 13 01:43:19 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