[vlc-devel] commit: Fluidsynth: output PCM if there is no FPU ( Rémi Denis-Courmont )

git version control git at videolan.org
Tue Sep 1 20:38:07 CEST 2009


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Sep  1 21:37:26 2009 +0300| [fcf032cbd54063e65287cbbe94524311827cc3e2] | committer: Rémi Denis-Courmont 

Fluidsynth: output PCM if there is no FPU

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=fcf032cbd54063e65287cbbe94524311827cc3e2
---

 modules/codec/fluidsynth.c |   39 +++++++++++++++++++++++++++------------
 1 files changed, 27 insertions(+), 12 deletions(-)

diff --git a/modules/codec/fluidsynth.c b/modules/codec/fluidsynth.c
index aa31abe..22ef5bf 100644
--- a/modules/codec/fluidsynth.c
+++ b/modules/codec/fluidsynth.c
@@ -59,6 +59,7 @@ struct decoder_sys_t
     fluid_settings_t *settings;
     fluid_synth_t    *synth;
     int               soundfont;
+    bool              fixed;
     date_t            end_date;
 };
 
@@ -81,15 +82,6 @@ static int Open (vlc_object_t *p_this)
         return VLC_EGENERIC;
     }
 
-    p_dec->fmt_out.i_cat = AUDIO_ES;
-    p_dec->fmt_out.audio.i_rate = 44100;
-    p_dec->fmt_out.audio.i_channels = 2;
-    p_dec->fmt_out.audio.i_original_channels =
-    p_dec->fmt_out.audio.i_physical_channels =
-        AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT;
-    p_dec->fmt_out.i_codec = VLC_CODEC_FL32;
-    p_dec->fmt_out.audio.i_bitspersample = 32;
-
     p_dec->pf_decode_audio = DecodeBlock;
     p_sys = p_dec->p_sys = malloc (sizeof (*p_sys));
     if (p_sys == NULL)
@@ -110,6 +102,24 @@ static int Open (vlc_object_t *p_this)
         return VLC_EGENERIC;
     }
 
+    p_dec->fmt_out.i_cat = AUDIO_ES;
+    p_dec->fmt_out.audio.i_rate = 44100;
+    p_dec->fmt_out.audio.i_channels = 2;
+    p_dec->fmt_out.audio.i_original_channels =
+    p_dec->fmt_out.audio.i_physical_channels =
+        AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT;
+    if (vlc_CPU () & CPU_CAPABILITY_FPU)
+    {
+        p_dec->fmt_out.i_codec = VLC_CODEC_FL32;
+        p_dec->fmt_out.audio.i_bitspersample = 32;
+        p_sys->fixed = false;
+    }
+    else
+    {
+        p_dec->fmt_out.i_codec = VLC_CODEC_S16N;
+        p_dec->fmt_out.audio.i_bitspersample = 16;
+        p_sys->fixed = true;
+    }
     date_Init (&p_sys->end_date, p_dec->fmt_out.audio.i_rate, 1);
     date_Set (&p_sys->end_date, 0);
 
@@ -188,9 +198,14 @@ static aout_buffer_t *DecodeBlock (decoder_t *p_dec, block_t **pp_block)
 
     p_out->start_date = date_Get (&p_sys->end_date );
     p_out->end_date   = date_Increment (&p_sys->end_date, samples);
-    fluid_synth_write_float (p_sys->synth, samples,
-                             p_out->p_buffer, 0, 2,
-                             p_out->p_buffer, 1, 2);
+    if (!p_sys->fixed)
+        fluid_synth_write_float (p_sys->synth, samples,
+                                 p_out->p_buffer, 0, 2,
+                                 p_out->p_buffer, 1, 2);
+    else
+        fluid_synth_write_s16 (p_sys->synth, samples,
+                               (int16_t *)p_out->p_buffer, 0, 2,
+                               (int16_t *)p_out->p_buffer, 1, 2);
 drop:
     block_Release (p_block);
     return p_out;




More information about the vlc-devel mailing list