gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] gnash backend/sound_handler.h backend/sound_han...


From: Martin Guy
Subject: [Gnash-commit] gnash backend/sound_handler.h backend/sound_han...
Date: Fri, 18 May 2007 13:18:01 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Martin Guy <martinwguy> 07/05/18 13:17:55

Modified files:
        backend        : sound_handler.h sound_handler.cpp 
                         sound_handler_gst.cpp sound_handler_gst.h 
                         sound_handler_sdl.cpp sound_handler_sdl.h 
        testsuite      : sound_handler_test.cpp sound_handler_test.h 
        .              : ChangeLog 

Log message:
                * backend/sound_handler.h,
                  backend/sound_handler.cpp,
                  backend/sound_handler_gst.cpp,
                  backend/sound_handler_gst.h,
                  backend/sound_handler_sdl.cpp,
                  backend/sound_handler_sdl.h,
                  testsuite/sound_handler_test.cpp,
                  testsuite/sound_handler_test.h:
                  convert_raw_samples is now just a static fn of sound_handler::

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/backend/sound_handler.h?cvsroot=gnash&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/gnash/backend/sound_handler.cpp?cvsroot=gnash&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/gnash/backend/sound_handler_gst.cpp?cvsroot=gnash&r1=1.43&r2=1.44
http://cvs.savannah.gnu.org/viewcvs/gnash/backend/sound_handler_gst.h?cvsroot=gnash&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/gnash/backend/sound_handler_sdl.cpp?cvsroot=gnash&r1=1.58&r2=1.59
http://cvs.savannah.gnu.org/viewcvs/gnash/backend/sound_handler_sdl.h?cvsroot=gnash&r1=1.18&r2=1.19
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/sound_handler_test.cpp?cvsroot=gnash&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/sound_handler_test.h?cvsroot=gnash&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.3268&r2=1.3269

Patches:
Index: backend/sound_handler.h
===================================================================
RCS file: /sources/gnash/gnash/backend/sound_handler.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- backend/sound_handler.h     18 May 2007 12:51:47 -0000      1.7
+++ backend/sound_handler.h     18 May 2007 13:17:51 -0000      1.8
@@ -17,7 +17,7 @@
 // 
 //
 
-/* $Id: sound_handler.h,v 1.7 2007/05/18 12:51:47 martinwguy Exp $ */
+/* $Id: sound_handler.h,v 1.8 2007/05/18 13:17:51 martinwguy Exp $ */
 
 /// \page sound_handler_intro Sound handler introduction
 ///
@@ -134,11 +134,11 @@
        virtual void    attach_aux_streamer(aux_streamer_ptr ptr, void* owner) 
= 0;
        virtual void    detach_aux_streamer(void* owner) = 0;
 
-       // Converts input data to the SDL output format.
-       virtual void    convert_raw_data(int16_t** adjusted_data,
+       // Converts audio input data to required sample rate/stereo.
+       static void     convert_raw_data(int16_t** adjusted_data,
                          int* adjusted_size, void* data, int sample_count,
                          int sample_size, int sample_rate, bool stereo,
-                         int m_sample_rate, bool m_stereo) = 0;
+                         int m_sample_rate, bool m_stereo);
 
        virtual ~sound_handler() {};
 };

Index: backend/sound_handler.cpp
===================================================================
RCS file: /sources/gnash/gnash/backend/sound_handler.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- backend/sound_handler.cpp   27 Feb 2007 09:54:48 -0000      1.2
+++ backend/sound_handler.cpp   18 May 2007 13:17:51 -0000      1.3
@@ -19,6 +19,71 @@
 
 namespace gnash {
 
+// VERY crude sample-rate conversion.
+// Converts input data to output format.
+// sample_size
+
+void sound_handler::convert_raw_data(
+       int16_t** adjusted_data,
+       int* adjusted_size,
+       void* data,
+       int sample_count,       // A stereo pair counts as one
+       int sample_size,        // Should now always == 2
+       // sample_rate and stereo are those of the incoming sample
+       int sample_rate, 
+       bool stereo,
+       // m_sample_rate, m_stereo are the format we must convert to.
+       int m_sample_rate,
+       bool m_stereo)
+{
+       // simple hack to handle dup'ing mono to stereo
+       if ( !stereo && m_stereo)
+       {
+               sample_rate >>= 1;
+       }
+
+       // simple hack to lose half the samples to get mono from stereo
+       // Unfortunately, this gives two copies of the left channel.
+       if ( stereo && !m_stereo)
+       {
+               sample_rate <<= 1;
+       }
+
+       // Brain-dead sample-rate conversion: duplicate or
+       // skip input samples an integral number of times.
+       int     inc = 1;        // increment
+       int     dup = 1;        // duplicate
+       if (sample_rate > m_sample_rate)
+       {
+               inc = sample_rate / m_sample_rate;
+       }
+       else if (sample_rate < m_sample_rate)
+       {
+               dup = m_sample_rate / sample_rate;
+       }
+
+       int     output_sample_count = (sample_count * dup * (stereo ? 2 : 1)) / 
inc;
+       int16_t*        out_data = new int16_t[output_sample_count];
+       *adjusted_data = out_data;
+       *adjusted_size = output_sample_count * 2;       // 2 bytes per sample
+
+       if (inc == 1 && dup == 1) {
+               // Speed up no-op case
+               memcpy(out_data, data, output_sample_count * sizeof(int16_t));
+       } else {
+               // crude sample rate conversion.
+               int16_t*        in = (int16_t*) data;
+               for (int i = 0; i < output_sample_count; i += dup)
+               {
+                       int16_t val = *in;
+                       for (int j = 0; j < dup; j++)
+                       {
+                               *out_data++ = val;
+                       }
+                       in += inc;
+               }
+       }
+}
 
 
 } // namespace gnash

Index: backend/sound_handler_gst.cpp
===================================================================
RCS file: /sources/gnash/gnash/backend/sound_handler_gst.cpp,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -b -r1.43 -r1.44
--- backend/sound_handler_gst.cpp       18 May 2007 12:51:47 -0000      1.43
+++ backend/sound_handler_gst.cpp       18 May 2007 13:17:51 -0000      1.44
@@ -20,7 +20,7 @@
 // Based on sound_handler_sdl.cpp by Thatcher Ulrich http://tulrich.com 2003
 // which has been donated to the Public Domain.
 
-/* $Id: sound_handler_gst.cpp,v 1.43 2007/05/18 12:51:47 martinwguy Exp $ */
+/* $Id: sound_handler_gst.cpp,v 1.44 2007/05/18 13:17:51 martinwguy Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -575,20 +575,6 @@
        gnash::log_unimpl(__PRETTY_FUNCTION__);
 }
 
-void GST_sound_handler::convert_raw_data(
-       int16_t** /*adjusted_data*/,
-       int* /*adjusted_size*/,
-       void* /*data*/,
-       int /*sample_count*/,
-       int /*sample_size*/,
-       int /*sample_rate*/,
-       bool /*stereo*/,
-       int /*m_sample_rate*/,
-       bool /*m_stereo*/)
-{
-       gnash::log_unimpl(__PRETTY_FUNCTION__);
-}
-
 gnash::sound_handler*  gnash::create_sound_handler_gst()
 // Factory.
 {

Index: backend/sound_handler_gst.h
===================================================================
RCS file: /sources/gnash/gnash/backend/sound_handler_gst.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- backend/sound_handler_gst.h 18 May 2007 12:51:47 -0000      1.3
+++ backend/sound_handler_gst.h 18 May 2007 13:17:51 -0000      1.4
@@ -152,12 +152,6 @@
 
        virtual void    attach_aux_streamer(aux_streamer_ptr ptr, void* owner); 
//vv
        virtual void    detach_aux_streamer(void* owner);       //vv
-
-       /// Converts input data to the SDL output format.
-       virtual void    convert_raw_data(int16_t** adjusted_data,
-                         int* adjusted_size, void* data, int sample_count,
-                         int sample_size, int sample_rate, bool stereo,
-                         int m_sample_rate, bool m_stereo);
 };
 
 #endif // SOUND_HANDLER_GST_H

Index: backend/sound_handler_sdl.cpp
===================================================================
RCS file: /sources/gnash/gnash/backend/sound_handler_sdl.cpp,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -b -r1.58 -r1.59
--- backend/sound_handler_sdl.cpp       18 May 2007 12:51:47 -0000      1.58
+++ backend/sound_handler_sdl.cpp       18 May 2007 13:17:51 -0000      1.59
@@ -18,7 +18,7 @@
 // Based on sound_handler_sdl.cpp by Thatcher Ulrich http://tulrich.com 2003
 // which has been donated to the Public Domain.
 
-// $Id: sound_handler_sdl.cpp,v 1.58 2007/05/18 12:51:47 martinwguy Exp $
+// $Id: sound_handler_sdl.cpp,v 1.59 2007/05/18 13:17:51 martinwguy Exp $
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -525,73 +525,6 @@
        m_aux_streamer.erase(owner);
 }
 
-void SDL_sound_handler::convert_raw_data(
-       int16_t** adjusted_data,
-       int* adjusted_size,
-       void* data,
-       int sample_count,
-       int sample_size,
-       // stereo, sample_rate are those of the incoming sample
-       int sample_rate, 
-       bool stereo,
-       // m_stereo etc are the format we must convert to.
-       int m_sample_rate,
-       bool m_stereo)
-// VERY crude sample-rate & sample-size conversion.  Converts
-// input data to the SDL output format (SAMPLE_RATE,
-// stereo, 16-bit native endianness)
-{
-       assert(sample_size == 2);
-
-       // simple hack to handle dup'ing mono to stereo
-       if ( !stereo && m_stereo)
-       {
-               sample_rate >>= 1;
-       }
-
-       // simple hack to lose half the samples to get mono from stereo
-       // Unfortunately, this gives two copies of the left channel.
-       if ( stereo && !m_stereo)
-       {
-               sample_rate <<= 1;
-       }
-
-       // Brain-dead sample-rate conversion: duplicate or
-       // skip input samples an integral number of times.
-       int     inc = 1;        // increment
-       int     dup = 1;        // duplicate
-       if (sample_rate > m_sample_rate)
-       {
-               inc = sample_rate / m_sample_rate;
-       }
-       else if (sample_rate < m_sample_rate)
-       {
-               dup = m_sample_rate / sample_rate;
-       }
-
-       int     output_sample_count = (sample_count * dup * (stereo ? 2 : 1)) / 
inc;
-       int16_t*        out_data = new int16_t[output_sample_count];
-       *adjusted_data = out_data;
-       *adjusted_size = output_sample_count * 2;       // 2 bytes per sample
-
-       if (inc == 1 && dup == 1) {
-               // Speed up no-op case
-               memcpy(out_data, data, output_sample_count * sizeof(int16_t));
-       } else {
-               // crude sample rate conversion.
-               int16_t*        in = (int16_t*) data;
-               for (int i = 0; i < output_sample_count; i += dup)
-               {
-                       int16_t val = *in;
-                       for (int j = 0; j < dup; j++)
-                       {
-                               *out_data++ = val;
-                       }
-                       in += inc;
-               }
-       }
-}
-
 
 gnash::sound_handler*  gnash::create_sound_handler_sdl()
 // Factory.

Index: backend/sound_handler_sdl.h
===================================================================
RCS file: /sources/gnash/gnash/backend/sound_handler_sdl.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- backend/sound_handler_sdl.h 18 May 2007 12:51:47 -0000      1.18
+++ backend/sound_handler_sdl.h 18 May 2007 13:17:51 -0000      1.19
@@ -14,7 +14,7 @@
 // along with this program; if not, write to the Free Software
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
-// $Id: sound_handler_sdl.h,v 1.18 2007/05/18 12:51:47 martinwguy Exp $
+// $Id: sound_handler_sdl.h,v 1.19 2007/05/18 13:17:51 martinwguy Exp $
 
 #ifndef SOUND_HANDLER_SDL_H
 #define SOUND_HANDLER_SDL_H
@@ -212,13 +212,6 @@
 
        virtual void    attach_aux_streamer(aux_streamer_ptr ptr, void* owner); 
//vv
        virtual void    detach_aux_streamer(void* owner);       //vv
-
-       /// Converts input data to the SDL output format.
-       virtual void    convert_raw_data(int16_t** adjusted_data,
-                         int* adjusted_size, void* data, int sample_count,
-                         int sample_size, int sample_rate, bool stereo,
-                         int m_sample_rate, bool m_stereo);
-
 };
 
 

Index: testsuite/sound_handler_test.cpp
===================================================================
RCS file: /sources/gnash/gnash/testsuite/sound_handler_test.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- testsuite/sound_handler_test.cpp    18 May 2007 12:51:47 -0000      1.6
+++ testsuite/sound_handler_test.cpp    18 May 2007 13:17:51 -0000      1.7
@@ -15,7 +15,7 @@
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 //
 
-// $Id: sound_handler_test.cpp,v 1.6 2007/05/18 12:51:47 martinwguy Exp $
+// $Id: sound_handler_test.cpp,v 1.7 2007/05/18 13:17:51 martinwguy Exp $
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -372,21 +372,6 @@
 
 }
 
-void TEST_sound_handler::convert_raw_data(
-       int16_t** /*adjusted_data*/,
-       int* /*adjusted_size*/,
-       void* /*data*/,
-       int /*sample_count*/,
-       int /*sample_size*/,
-       int /*sample_rate*/,
-       bool /*stereo*/,
-       int /*m_sample_rate*/,
-       bool /*m_stereo*/)
-{
-       gnash::log_msg("%s: unimplemented \n", __PRETTY_FUNCTION__);
-}
-
-
 gnash::sound_handler*  gnash::create_sound_handler_test()
 // Factory.
 {

Index: testsuite/sound_handler_test.h
===================================================================
RCS file: /sources/gnash/gnash/testsuite/sound_handler_test.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- testsuite/sound_handler_test.h      18 May 2007 12:51:47 -0000      1.3
+++ testsuite/sound_handler_test.h      18 May 2007 13:17:51 -0000      1.4
@@ -14,7 +14,7 @@
 // along with this program; if not, write to the Free Software
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
-// $Id: sound_handler_test.h,v 1.3 2007/05/18 12:51:47 martinwguy Exp $
+// $Id: sound_handler_test.h,v 1.4 2007/05/18 13:17:51 martinwguy Exp $
 
 #ifndef SOUND_HANDLER_TEST_H
 #define SOUND_HANDLER_TEST_H
@@ -172,12 +172,6 @@
        virtual void    attach_aux_streamer(aux_streamer_ptr ptr, void* owner); 
//vv
        virtual void    detach_aux_streamer(void* owner);       //vv
 
-       /// Converts input data to the SDL output format.
-       virtual void    convert_raw_data(int16_t** adjusted_data,
-                         int* adjusted_size, void* data, int sample_count,
-                         int sample_size, int sample_rate, bool stereo,
-                         int m_sample_rate, bool m_stereo);
-
        /// Special test-fuction. Reports how many times this sound has been 
started
        int test_times_started(int sound_handle);
 

Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.3268
retrieving revision 1.3269
diff -u -b -r1.3268 -r1.3269
--- ChangeLog   18 May 2007 12:59:52 -0000      1.3268
+++ ChangeLog   18 May 2007 13:17:53 -0000      1.3269
@@ -40,6 +40,15 @@
          testsuite/sound_handler_test.h,
          server/asobj/SoundMad.cpp:
          Add two params to convert_raw_data so that it is SDL-independent
+       * backend/sound_handler.h,
+         backend/sound_handler.cpp,
+         backend/sound_handler_gst.cpp,
+         backend/sound_handler_gst.h,
+         backend/sound_handler_sdl.cpp,
+         backend/sound_handler_sdl.h,
+         testsuite/sound_handler_test.cpp,
+         testsuite/sound_handler_test.h:
+         convert_raw_samples is now just a static fn of sound_handler::
 
 2007-05-17  Rob Savoye  <address@hidden>
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]