gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] [SCM] Gnash branch, master, updated. fa25110f10b040fd98eb


From: Sandro Santilli
Subject: [Gnash-commit] [SCM] Gnash branch, master, updated. fa25110f10b040fd98eb4752b0621fc176656e79
Date: Fri, 22 Oct 2010 14:26:03 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Gnash".

The branch, master has been updated
       via  fa25110f10b040fd98eb4752b0621fc176656e79 (commit)
       via  4a53b9e26fa587e391c1605ac56746c22b3501db (commit)
       via  33c0460ac1f4b4bf45e6b62204dd2136b0fcdcef (commit)
       via  f2905fc1c29b30c2a19794d7dff77cb2aecd8588 (commit)
       via  e13fd27aa514d5c8078c6892d43cded19f8c73ba (commit)
       via  2dfd8c31bf2fabf806cf3bb287692cde5a9c78c2 (commit)
      from  e189a1ba2a4fc3b06a7aa9602b8e25b209d98da2 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit//commit/?id=fa25110f10b040fd98eb4752b0621fc176656e79


commit fa25110f10b040fd98eb4752b0621fc176656e79
Author: Sandro Santilli <address@hidden>
Date:   Fri Oct 22 15:26:48 2010 +0200

    Move WAV writing/dumping to base sound_handler class

diff --git a/gui/Player.cpp b/gui/Player.cpp
index e4314c1..c1d87b4 100644
--- a/gui/Player.cpp
+++ b/gui/Player.cpp
@@ -157,14 +157,6 @@ Player::init_logfile()
 
 }
 
-unsigned int
-Player::silentStream(void* /*udata*/, boost::int16_t* stream, unsigned int 
len, bool& atEOF)
-{
-    std::fill(stream, stream+len, 0);
-    atEOF=false;
-    return len;
-}
-
 void
 Player::init_sound()
 {
@@ -173,24 +165,21 @@ Player::init_sound()
         try {
 #ifdef SOUND_SDL
             _soundHandler.reset(sound::create_sound_handler_sdl(
-                        _mediaHandler.get(), _audioDump));
+                        _mediaHandler.get()));
 #elif defined(SOUND_AHI)
             _soundHandler.reset(sound::create_sound_handler_aos4(
-                        _mediaHandler.get(), _audioDump));
+                        _mediaHandler.get()));
 #elif defined(SOUND_MKIT)
             _soundHandler.reset(sound::create_sound_handler_mkit(
-                        _mediaHandler.get(), _audioDump));
+                        _mediaHandler.get()));
 #else
             log_error(_("Sound requested but no sound support compiled in"));
             return;
 #endif
 
             if (! _audioDump.empty()) {
-                // TODO: move this logic into GUI
-                // add a silent stream to the audio pool so that our
-                // output file is homogenous;  we actually want silent
-                // wave data when no sounds are playing on the stage
-                _soundHandler->attach_aux_streamer(silentStream, (void*) this);
+                // TODO: notify tu Gui instead
+                _soundHandler->setAudioDump(_audioDump);
             }
 
         } catch (SoundException& ex) {
diff --git a/libsound/aos4/sound_handler_ahi.cpp 
b/libsound/aos4/sound_handler_ahi.cpp
index ce84aa1..b50e9d9 100644
--- a/libsound/aos4/sound_handler_ahi.cpp
+++ b/libsound/aos4/sound_handler_ahi.cpp
@@ -71,17 +71,6 @@ audioTaskWrapper()
 namespace gnash {
 namespace sound {
 
-AOS4_sound_handler::AOS4_sound_handler(media::MediaHandler* m,
-               const std::string& wavefile)
-    :
-    sound_handler(m, wavefile),
-    _audioOpened(false),
-       _closing(false)
-{
-
-    initAudio();
-}
-
 AOS4_sound_handler::AOS4_sound_handler(media::MediaHandler* m)
     :
     sound_handler(m),
@@ -279,13 +268,6 @@ create_sound_handler_aos4(media::MediaHandler* m)
     return new AOS4_sound_handler(m);
 }
 
-sound_handler*
-create_sound_handler_aos4(media::MediaHandler* m, const std::string& wave_file)
-// Factory.
-{
-    return new AOS4_sound_handler(m, wave_file);
-}
-
 void
 AOS4_sound_handler::fetchSamples(boost::int16_t* to, unsigned int nSamples)
 {
diff --git a/libsound/aos4/sound_handler_ahi.h 
b/libsound/aos4/sound_handler_ahi.h
index 0286fec..ceaad5f 100644
--- a/libsound/aos4/sound_handler_ahi.h
+++ b/libsound/aos4/sound_handler_ahi.h
@@ -22,7 +22,6 @@
 
 #include "sound_handler.h" // for inheritance
 
-#include <string>
 #include <set> // for composition (InputStreams)
 #include <boost/thread/mutex.hpp>
 
@@ -102,8 +101,6 @@ public:
 
     AOS4_sound_handler(media::MediaHandler* m);
 
-    AOS4_sound_handler(media::MediaHandler* m, const std::string& wave_file);
-
     ~AOS4_sound_handler();
 
     // See dox in sound_handler.h
diff --git a/libsound/mkit/sound_handler_mkit.cpp 
b/libsound/mkit/sound_handler_mkit.cpp
index a28b9c4..e91c14d 100644
--- a/libsound/mkit/sound_handler_mkit.cpp
+++ b/libsound/mkit/sound_handler_mkit.cpp
@@ -54,13 +54,6 @@ Mkit_sound_handler::Mkit_sound_handler(media::MediaHandler* 
m)
 {
 }
 
-Mkit_sound_handler::Mkit_sound_handler(media::MediaHandler* m, const 
std::string& wavefile)
-    :
-    sound_handler(m, wavefile),
-    _audioopen(false)
-{
-}
-
 void
 Mkit_sound_handler::openAudio()
 {
@@ -371,23 +364,6 @@ create_sound_handler_mkit(media::MediaHandler* m)
     return new Mkit_sound_handler(m);
 }
 
-sound_handler*
-create_sound_handler_mkit(media::MediaHandler* m, const std::string& wave_file)
-// Factory.
-{
-    return new Mkit_sound_handler(m, wave_file);
-}
-
-
-
-
-
-
-
-
-
-
-
 } // gnash.sound namespace 
 } // namespace gnash
 
diff --git a/libsound/mkit/sound_handler_mkit.h 
b/libsound/mkit/sound_handler_mkit.h
index 1173af3..170e90b 100644
--- a/libsound/mkit/sound_handler_mkit.h
+++ b/libsound/mkit/sound_handler_mkit.h
@@ -22,7 +22,6 @@
 
 #include "sound_handler.h" // for inheritance
 
-#include <string>
 #include <set> // for composition (InputStreams)
 #include <boost/thread/mutex.hpp>
 #include <boost/scoped_ptr.hpp>
@@ -70,8 +69,6 @@ class Mkit_sound_handler : public sound_handler
 public:
     Mkit_sound_handler(media::MediaHandler* m);
 
-    Mkit_sound_handler(media::MediaHandler* m, const std::string& wave_file);
-
     ~Mkit_sound_handler();
 
     // See dox in sound_handler.h
diff --git a/libsound/sdl/sound_handler_sdl.cpp 
b/libsound/sdl/sound_handler_sdl.cpp
index 8cd1341..80af7d6 100644
--- a/libsound/sdl/sound_handler_sdl.cpp
+++ b/libsound/sdl/sound_handler_sdl.cpp
@@ -104,17 +104,6 @@ SDL_sound_handler::closeAudio()
 }
 
 
-SDL_sound_handler::SDL_sound_handler(media::MediaHandler* m,
-        const std::string& wavefile)
-    :
-    sound_handler(m, wavefile),
-    _audioOpened(false)
-{
-
-    initAudio();
-
-}
-
 SDL_sound_handler::SDL_sound_handler(media::MediaHandler* m)
     :
     sound_handler(m),
@@ -235,12 +224,6 @@ create_sound_handler_sdl(media::MediaHandler* m)
     return new SDL_sound_handler(m);
 }
 
-sound_handler*
-create_sound_handler_sdl(media::MediaHandler* m, const std::string& wave_file)
-{
-    return new SDL_sound_handler(m, wave_file);
-}
-
 void
 SDL_sound_handler::fetchSamples(boost::int16_t* to, unsigned int nSamples)
 {
diff --git a/libsound/sdl/sound_handler_sdl.h b/libsound/sdl/sound_handler_sdl.h
index 4c094f1..b0f060b 100644
--- a/libsound/sdl/sound_handler_sdl.h
+++ b/libsound/sdl/sound_handler_sdl.h
@@ -24,7 +24,6 @@
 
 #include "sound_handler.h" // for inheritance
 
-#include <string>
 #include <set> // for composition (InputStreams)
 #include <SDL_audio.h>
 #include <boost/thread/mutex.hpp>
@@ -91,8 +90,6 @@ public:
 
     SDL_sound_handler(media::MediaHandler* m);
 
-    SDL_sound_handler(media::MediaHandler* m, const std::string& wave_file);
-
     ~SDL_sound_handler();
 
     // See dox in sound_handler.h
diff --git a/libsound/sound_handler.cpp b/libsound/sound_handler.cpp
index 474c75b..4493d42 100644
--- a/libsound/sound_handler.cpp
+++ b/libsound/sound_handler.cpp
@@ -34,6 +34,18 @@
 // Debug samples fetching
 //#define GNASH_DEBUG_SAMPLES_FETCHING 1
 
+namespace {
+
+unsigned int silentStream(void*, boost::int16_t* stream, unsigned int len, 
bool& atEOF)
+{
+    std::fill(stream, stream+len, 0);
+    atEOF=false;
+    return len;
+}
+
+}
+
+
 namespace gnash {
 namespace sound {
 
@@ -561,7 +573,7 @@ sound_handler::fetchSamples (boost::int16_t* to, unsigned 
int nSamples)
     }
 #endif
 
-    if ( isPaused() ) return;
+    if ( isPaused() ) return; // should we write wav file anyway ?
 
     float finalVolumeFact = getFinalVolume()/100.0;
 
@@ -620,6 +632,25 @@ sound_handler::fetchSamples (boost::int16_t* to, unsigned 
int nSamples)
     }
 }
 
+/*public*/
+void
+sound_handler::setAudioDump(const std::string& wavefile)
+{
+    bool wasDumping = (_wavWriter.get() != 0);
+
+    if (!wavefile.empty()) {
+        _wavWriter.reset(new WAVWriter(wavefile));
+    }
+
+    // TODO: just avoid pausing instead ...
+    if ( ! wasDumping ) {
+        // add a silent stream to the audio pool so that our
+        // output file is homogenous;  we actually want silent
+        // wave data when no sounds are playing on the stage
+        attach_aux_streamer(silentStream, (void*) this);
+    }
+}
+
 /*private*/
 void
 sound_handler::unplugCompletedInputStreams()
diff --git a/libsound/sound_handler.h b/libsound/sound_handler.h
index eb54ae8..9907c7b 100644
--- a/libsound/sound_handler.h
+++ b/libsound/sound_handler.h
@@ -439,6 +439,14 @@ public:
     virtual void mix(boost::int16_t* outSamples, boost::int16_t* inSamples,
                 unsigned int nSamples, float volume) = 0;
 
+
+    /// Request to dump audio to the given filename
+    //
+    /// Every call to this function starts recording
+    /// to a new file, closing any existing other dump.
+    ///
+    void setAudioDump(const std::string& wavefile);
+
 protected:
 
 
@@ -455,22 +463,6 @@ protected:
     {
     }
 
-    sound_handler(media::MediaHandler* m, const std::string& wavefile)
-        :
-        _soundsStarted(0),
-        _soundsStopped(0),
-        _paused(false),
-        _muted(false),
-        _volume(100),
-        _sounds(),
-        _inputStreams(),
-        _mediaHandler(m)
-    {
-        if (!wavefile.empty()) {
-            _wavWriter.reset(new WAVWriter(wavefile));
-        }
-    }
-
     /// Plug an InputStream to the mixer
     //
     /// @param in
@@ -593,25 +585,12 @@ private:
 #ifdef SOUND_SDL
 /// @throw a SoundException if fails to initialize audio card.
 DSOEXPORT sound_handler* create_sound_handler_sdl(media::MediaHandler* m);
-
-/// @throw a SoundException if fails to initialize audio card.
-DSOEXPORT sound_handler* create_sound_handler_sdl(media::MediaHandler* m,
-        const std::string& wave_file);
 #elif defined(SOUND_AHI)
 /// @throw a SoundException if fails to initialize audio card.
 DSOEXPORT sound_handler* create_sound_handler_aos4(media::MediaHandler* m);
-
-/// @throw a SoundException if fails to initialize audio card.
-DSOEXPORT sound_handler* create_sound_handler_aos4(media::MediaHandler* m,
-        const std::string& wave_file);
-
 #elif defined(SOUND_MKIT)
 /// @throw a SoundException if fails to create node.
 DSOEXPORT sound_handler* create_sound_handler_mkit(media::MediaHandler* m);
-
-/// @throw a SoundException if fails to create node.
-DSOEXPORT sound_handler* create_sound_handler_mkit(media::MediaHandler* m,
-        const std::string& wave_file);
 #endif
 
 } // gnash.sound namespace 

http://git.savannah.gnu.org/cgit//commit/?id=4a53b9e26fa587e391c1605ac56746c22b3501db


commit 4a53b9e26fa587e391c1605ac56746c22b3501db
Author: Sandro Santilli <address@hidden>
Date:   Fri Oct 22 14:58:26 2010 +0200

    file_stream need be in base class only

diff --git a/libsound/aos4/sound_handler_ahi.h 
b/libsound/aos4/sound_handler_ahi.h
index 764f9a8..0286fec 100644
--- a/libsound/aos4/sound_handler_ahi.h
+++ b/libsound/aos4/sound_handler_ahi.h
@@ -24,7 +24,6 @@
 
 #include <string>
 #include <set> // for composition (InputStreams)
-#include <fstream> // for composition (file_stream)
 #include <boost/thread/mutex.hpp>
 
 #include <proto/dos.h>
@@ -93,12 +92,6 @@ private:
     /// Mutex protecting _muted (defined in base class)
     mutable boost::mutex _mutedMutex;
 
-    /// File stream for dump file
-    //
-    /// TODO: move to base class ?
-    ///
-    std::ofstream file_stream;
-
     // See dox in sound_handler.h
     void mix(boost::int16_t* outSamples, boost::int16_t* inSamples,
                 unsigned int nSamples, float volume);
diff --git a/libsound/mkit/sound_handler_mkit.h 
b/libsound/mkit/sound_handler_mkit.h
index 101f172..1173af3 100644
--- a/libsound/mkit/sound_handler_mkit.h
+++ b/libsound/mkit/sound_handler_mkit.h
@@ -24,7 +24,6 @@
 
 #include <string>
 #include <set> // for composition (InputStreams)
-#include <fstream> // for composition (file_stream)
 #include <boost/thread/mutex.hpp>
 #include <boost/scoped_ptr.hpp>
 
@@ -62,12 +61,6 @@ class Mkit_sound_handler : public sound_handler
     /// Mutex protecting _muted (defined in base class)
     mutable boost::mutex _mutedMutex;
 
-    /// File stream for dump file
-    //
-    /// TODO: move to base class ?
-    ///
-    std::ofstream file_stream;
-
     // See dox in sound_handler.h
     void mix(boost::int16_t* outSamples, boost::int16_t* inSamples,
                 unsigned int nSamples, float volume);

http://git.savannah.gnu.org/cgit//commit/?id=33c0460ac1f4b4bf45e6b62204dd2136b0fcdcef


commit 33c0460ac1f4b4bf45e6b62204dd2136b0fcdcef
Author: Sandro Santilli <address@hidden>
Date:   Fri Oct 22 14:49:02 2010 +0200

    Move audio dump writing to base sound_handler class

diff --git a/libsound/aos4/sound_handler_ahi.cpp 
b/libsound/aos4/sound_handler_ahi.cpp
index 5b0c95c..ce84aa1 100644
--- a/libsound/aos4/sound_handler_ahi.cpp
+++ b/libsound/aos4/sound_handler_ahi.cpp
@@ -68,58 +68,18 @@ audioTaskWrapper()
        return obj->audioTask();
 }
 
-namespace { // anonymous
-
-// Header of a wave file
-// http://ftp.iptel.org/pub/sems/doc/full/current/wav__hdr_8c-source.html
-typedef struct{
-     char rID[4];            // 'RIFF'
-     long int rLen;
-     char wID[4];            // 'WAVE'
-     char fId[4];            // 'fmt '
-     long int pcm_header_len;   // varies...
-     short int wFormatTag;
-     short int nChannels;      // 1,2 for stereo data is (l,r) pairs
-     long int nSamplesPerSec;
-     long int nAvgBytesPerSec;
-     short int nBlockAlign;
-     short int nBitsPerSample;
-} WAV_HDR;
-
-// Chunk of wave file
-// http://ftp.iptel.org/pub/sems/doc/full/current/wav__hdr_8c-source.html
-typedef struct{
-    char dId[4];            // 'data' or 'fact'
-    long int dLen;
-} CHUNK_HDR;
-
-} // end of anonymous namespace
-
 namespace gnash {
 namespace sound {
 
 AOS4_sound_handler::AOS4_sound_handler(media::MediaHandler* m,
                const std::string& wavefile)
     :
-    sound_handler(m),
+    sound_handler(m, wavefile),
     _audioOpened(false),
        _closing(false)
 {
 
     initAudio();
-
-    if (! wavefile.empty() ) {
-        file_stream.open(wavefile.c_str());
-        if (file_stream.fail()) {
-            std::cerr << "Unable to write file '" << wavefile << std::endl;
-            exit(EXIT_FAILURE);
-        } else {
-                write_wave_header(file_stream);
-                std::cout << "# Created 44100 16Mhz stereo wave file:" << 
std::endl <<
-                    "AUDIOFILE=" << wavefile << std::endl;
-        }
-    }
-
 }
 
 AOS4_sound_handler::AOS4_sound_handler(media::MediaHandler* m)
@@ -327,43 +287,6 @@ create_sound_handler_aos4(media::MediaHandler* m, const 
std::string& wave_file)
 }
 
 void
-AOS4_sound_handler::write_wave_header(std::ofstream& outfile)
-{
-
-  // allocate wav header
-  WAV_HDR wav;
-  CHUNK_HDR chk;
-
-  // setup wav header
-  std::strncpy(wav.rID, "RIFF", 4);
-  std::strncpy(wav.wID, "WAVE", 4);
-  std::strncpy(wav.fId, "fmt ", 4);
-
-  wav.nBitsPerSample = 16;
-  wav.nSamplesPerSec = 44100;
-  wav.nAvgBytesPerSec = 44100;
-  wav.nAvgBytesPerSec *= wav.nBitsPerSample / 8;
-  wav.nAvgBytesPerSec *= 2;
-  wav.nChannels = 2;
-
-  wav.pcm_header_len = 16;
-  wav.wFormatTag = 1;
-  wav.rLen = sizeof(WAV_HDR) + sizeof(CHUNK_HDR);
-  wav.nBlockAlign = 2 * wav.nBitsPerSample / 8;
-
-  // setup chunk header
-  std::strncpy(chk.dId, "data", 4);
-  chk.dLen = 0;
-
-  /* write riff/wav header */
-  outfile.write((char *)&wav, sizeof(WAV_HDR));
-
-  /* write chunk header */
-  outfile.write((char *)&chk, sizeof(CHUNK_HDR));
-
-}
-
-void
 AOS4_sound_handler::fetchSamples(boost::int16_t* to, unsigned int nSamples)
 {
        if (!_closing)
@@ -379,19 +302,6 @@ AOS4_sound_handler::fetchSamples(boost::int16_t* to, 
unsigned int nSamples)
                else            
                        return;
                
-           // TODO: move this to base class !
-       if (file_stream)
-           {
-           // NOTE: if muted, the samples will be silent already
-               boost::uint8_t* stream = reinterpret_cast<boost::uint8_t*>(to);
-               unsigned int len = nSamples*2;
-
-           file_stream.write((char*) stream, len);
-
-               // now, mute all audio
-               std::fill(to, to+nSamples, 0);
-       }
-
                //memcpy(BufferPointer, inSamples, nBytes);
                memcpy(BufferPointer, to, nSamples*2);
 
diff --git a/libsound/aos4/sound_handler_ahi.h 
b/libsound/aos4/sound_handler_ahi.h
index c70431f..764f9a8 100644
--- a/libsound/aos4/sound_handler_ahi.h
+++ b/libsound/aos4/sound_handler_ahi.h
@@ -99,9 +99,6 @@ private:
     ///
     std::ofstream file_stream;
 
-    // write a .WAV file header
-    void write_wave_header(std::ofstream& outfile);
-
     // See dox in sound_handler.h
     void mix(boost::int16_t* outSamples, boost::int16_t* inSamples,
                 unsigned int nSamples, float volume);
diff --git a/libsound/mkit/sound_handler_mkit.cpp 
b/libsound/mkit/sound_handler_mkit.cpp
index ff9b91e..a28b9c4 100644
--- a/libsound/mkit/sound_handler_mkit.cpp
+++ b/libsound/mkit/sound_handler_mkit.cpp
@@ -43,33 +43,6 @@
 #define ADJUST_VOLUME(s, v)    (s = (s*v)/MIX_MAXVOLUME)
 #define ADJUST_VOLUME_U8(s, v)    (s = (((s-128)*v)/MIX_MAXVOLUME)+128)
 
-namespace { // anonymous
-
-// Header of a wave file
-// http://ftp.iptel.org/pub/sems/doc/full/current/wav__hdr_8c-source.html
-typedef struct{
-     char rID[4];            // 'RIFF'
-     long int rLen;        
-     char wID[4];            // 'WAVE'
-     char fId[4];            // 'fmt '
-     long int pcm_header_len;   // varies...
-     short int wFormatTag;
-     short int nChannels;      // 1,2 for stereo data is (l,r) pairs
-     long int nSamplesPerSec;
-     long int nAvgBytesPerSec;
-     short int nBlockAlign;      
-     short int nBitsPerSample;
-} WAV_HDR;
-
-// Chunk of wave file
-// http://ftp.iptel.org/pub/sems/doc/full/current/wav__hdr_8c-source.html
-typedef struct{
-    char dId[4];            // 'data' or 'fact'
-    long int dLen;
-} CHUNK_HDR;
-
-} // end of anonymous namespace
-
 
 namespace gnash {
 namespace sound {
@@ -83,20 +56,9 @@ Mkit_sound_handler::Mkit_sound_handler(media::MediaHandler* 
m)
 
 Mkit_sound_handler::Mkit_sound_handler(media::MediaHandler* m, const 
std::string& wavefile)
     :
-    sound_handler(m),
+    sound_handler(m, wavefile),
     _audioopen(false)
 {
-    if (! wavefile.empty() ) {
-        file_stream.open(wavefile.c_str());
-        if (file_stream.fail()) {
-            std::cerr << "Unable to write file '" << wavefile << std::endl;
-            exit(EXIT_FAILURE);
-        } else {
-                write_wave_header(file_stream);
-                std::cout << "# Created 44100 16Mhz stereo wave file:" << 
std::endl <<
-                    "AUDIOFILE=" << wavefile << std::endl;
-        }
-    }
 }
 
 void
@@ -145,43 +107,6 @@ Mkit_sound_handler::~Mkit_sound_handler()
     if (file_stream) file_stream.close();
 }
 
-// write a wave header, using the current audioSpec settings
-void
-Mkit_sound_handler::write_wave_header(std::ofstream& outfile)
-{
-    // allocate wav header
-    WAV_HDR wav;
-    CHUNK_HDR chk;
-
-    // setup wav header
-    std::strncpy(wav.rID, "RIFF", 4);
-    std::strncpy(wav.wID, "WAVE", 4);
-    std::strncpy(wav.fId, "fmt ", 4);
-
-    wav.nBitsPerSample = 16;
-    wav.nSamplesPerSec = 44100;
-    wav.nAvgBytesPerSec = 44100;
-    wav.nAvgBytesPerSec *= wav.nBitsPerSample / 8;
-    wav.nAvgBytesPerSec *= 2;
-    wav.nChannels = 2;
-
-    wav.pcm_header_len = 16;
-    wav.wFormatTag = 1;
-    wav.rLen = sizeof(WAV_HDR) + sizeof(CHUNK_HDR);
-    wav.nBlockAlign = 2 * wav.nBitsPerSample / 8;
-
-    // setup chunk header
-    std::strncpy(chk.dId, "data", 4);
-    chk.dLen = 0;
-
-    /* write riff/wav header */
-    outfile.write((char *)&wav, sizeof(WAV_HDR));
-
-    /* write chunk header */
-    outfile.write((char *)&chk, sizeof(CHUNK_HDR));
-
-}
-
 void
 Mkit_sound_handler::FillNextBuffer(void *cookie, void *buffer, size_t size,
         const media_raw_audio_format &format)
diff --git a/libsound/mkit/sound_handler_mkit.h 
b/libsound/mkit/sound_handler_mkit.h
index defdec9..101f172 100644
--- a/libsound/mkit/sound_handler_mkit.h
+++ b/libsound/mkit/sound_handler_mkit.h
@@ -68,9 +68,6 @@ class Mkit_sound_handler : public sound_handler
     ///
     std::ofstream file_stream;
 
-    // write a .WAV file header
-    void write_wave_header(std::ofstream& outfile);
-
     // See dox in sound_handler.h
     void mix(boost::int16_t* outSamples, boost::int16_t* inSamples,
                 unsigned int nSamples, float volume);
diff --git a/libsound/sdl/sound_handler_sdl.cpp 
b/libsound/sdl/sound_handler_sdl.cpp
index eeac697..8cd1341 100644
--- a/libsound/sdl/sound_handler_sdl.cpp
+++ b/libsound/sdl/sound_handler_sdl.cpp
@@ -107,16 +107,12 @@ SDL_sound_handler::closeAudio()
 SDL_sound_handler::SDL_sound_handler(media::MediaHandler* m,
         const std::string& wavefile)
     :
-    sound_handler(m),
+    sound_handler(m, wavefile),
     _audioOpened(false)
 {
 
     initAudio();
 
-    if (!wavefile.empty()) {
-       _wavWriter.reset(new WAVWriter(wavefile));
-    }
-
 }
 
 SDL_sound_handler::SDL_sound_handler(media::MediaHandler* m)
@@ -251,15 +247,6 @@ SDL_sound_handler::fetchSamples(boost::int16_t* to, 
unsigned int nSamples)
     boost::mutex::scoped_lock lock(_mutex);
     sound_handler::fetchSamples(to, nSamples);
 
-    // TODO: move this to base class !
-    if (_wavWriter.get())
-    {
-       _wavWriter->pushSamples(to, nSamples);
-
-        // now, mute all audio
-        std::fill(to, to+nSamples, 0);
-    }
-
     // If nothing is left to play there is no reason to keep polling.
     if ( ! hasInputStreams() )
     {
diff --git a/libsound/sdl/sound_handler_sdl.h b/libsound/sdl/sound_handler_sdl.h
index b7efb69..4c094f1 100644
--- a/libsound/sdl/sound_handler_sdl.h
+++ b/libsound/sdl/sound_handler_sdl.h
@@ -23,13 +23,11 @@
 
 
 #include "sound_handler.h" // for inheritance
-#include "WAVWriter.h" // for dtor visibility 
 
 #include <string>
 #include <set> // for composition (InputStreams)
 #include <SDL_audio.h>
 #include <boost/thread/mutex.hpp>
-#include <boost/scoped_ptr.hpp>
 
 // Forward declarations
 namespace gnash {
@@ -51,8 +49,6 @@ private:
     /// The SDL_audio specs
     SDL_AudioSpec audioSpec;
 
-    boost::scoped_ptr<WAVWriter> _wavWriter;
-
     /// Initialize audio card
     void initAudio();
 
diff --git a/libsound/sound_handler.cpp b/libsound/sound_handler.cpp
index 4b5f333..474c75b 100644
--- a/libsound/sound_handler.cpp
+++ b/libsound/sound_handler.cpp
@@ -603,6 +603,15 @@ sound_handler::fetchSamples (boost::int16_t* to, unsigned 
int nSamples)
         unplugCompletedInputStreams();
     }
 
+    // TODO: move this to base class !
+    if (_wavWriter.get())
+    {
+        _wavWriter->pushSamples(to, nSamples);
+
+        // now, mute all audio
+        std::fill(to, to+nSamples, 0);
+    }
+
     // Now, after having "consumed" all sounds, blank out
     // the buffer if muted..
     if ( is_muted() )
diff --git a/libsound/sound_handler.h b/libsound/sound_handler.h
index 39aa964..eb54ae8 100644
--- a/libsound/sound_handler.h
+++ b/libsound/sound_handler.h
@@ -33,6 +33,7 @@
 #include "MediaHandler.h" // for inlined ctor
 #include "SoundEnvelope.h" // for SoundEnvelopes typedef
 #include "AuxStream.h" // for aux_stramer_ptr typedef
+#include "WAVWriter.h" // for dtor visibility 
 
 #include <string>
 #include <vector>
@@ -41,6 +42,7 @@
 #include <cstring>
 #include <limits>
 #include <set> // for composition
+#include <boost/scoped_ptr.hpp>
 
 namespace gnash {
     namespace media {
@@ -453,6 +455,22 @@ protected:
     {
     }
 
+    sound_handler(media::MediaHandler* m, const std::string& wavefile)
+        :
+        _soundsStarted(0),
+        _soundsStopped(0),
+        _paused(false),
+        _muted(false),
+        _volume(100),
+        _sounds(),
+        _inputStreams(),
+        _mediaHandler(m)
+    {
+        if (!wavefile.empty()) {
+            _wavWriter.reset(new WAVWriter(wavefile));
+        }
+    }
+
     /// Plug an InputStream to the mixer
     //
     /// @param in
@@ -566,6 +584,8 @@ private:
     unsigned int swfToOutSamples(const media::SoundInfo& sinfo,
                                           unsigned int swfSamples);
 
+    boost::scoped_ptr<WAVWriter> _wavWriter;
+
 };
 
 // TODO: move to appropriate specific sound handlers

http://git.savannah.gnu.org/cgit//commit/?id=f2905fc1c29b30c2a19794d7dff77cb2aecd8588


commit f2905fc1c29b30c2a19794d7dff77cb2aecd8588
Merge: e13fd27 e189a1b
Author: Sandro Santilli <address@hidden>
Date:   Fri Oct 22 14:29:11 2010 +0200

    Merge branch 'master' of ssh://address@hidden/srv/git/gnash


http://git.savannah.gnu.org/cgit//commit/?id=e13fd27aa514d5c8078c6892d43cded19f8c73ba


commit e13fd27aa514d5c8078c6892d43cded19f8c73ba
Author: Sandro Santilli <address@hidden>
Date:   Thu Oct 21 23:59:16 2010 +0200

    Add audioDump string to gui. Currently gui is the hosting application, so 
it make sense for it to know what's the final audio sink (as it knows the final 
rendering output).

diff --git a/gui/gui.h b/gui/gui.h
index 3d1be39..bbe83c6 100644
--- a/gui/gui.h
+++ b/gui/gui.h
@@ -476,6 +476,11 @@ public:
     /// Set the stage to advance/display
     void setStage(movie_root* stage);
 
+    /// Set the name of a file to dump audio to
+    void setAudioDump(const std::string& fname) {
+        _audioDump = fname;
+    }
+
     /// The root movie, or "Stage"
     movie_root* getStage() { return _stage; };
     
@@ -591,6 +596,9 @@ protected:
     /// Counter to keep track of frame advances
     unsigned long _advances;
 
+    /// Name of a file to dump audio to
+    std::string _audioDump;
+
     /// Called by Gui::stop().  This can be used by GUIs to implement pause
     /// widgets (so that resuming a stopped animation is more user-friendly)
     virtual void stopHook() {}

http://git.savannah.gnu.org/cgit//commit/?id=2dfd8c31bf2fabf806cf3bb287692cde5a9c78c2


commit 2dfd8c31bf2fabf806cf3bb287692cde5a9c78c2
Author: Sandro Santilli <address@hidden>
Date:   Thu Oct 21 23:57:27 2010 +0200

    Make sound_handler::mix public and a pure virtual (mixing ain't so easy). 
Allow passing a sound_handler to NullSoundHandler for use to mix.

diff --git a/libsound/NullSoundHandler.h b/libsound/NullSoundHandler.h
index e5a8fe1..6874110 100644
--- a/libsound/NullSoundHandler.h
+++ b/libsound/NullSoundHandler.h
@@ -23,6 +23,7 @@
 
 #include "sound_handler.h" // for inheritance
 #include "dsodefs.h" // for DSOEXPORT
+#include <boost/shared_ptr.hpp> 
 
 namespace gnash {
 
@@ -36,7 +37,27 @@ namespace sound {
 class DSOEXPORT NullSoundHandler : public sound_handler
 {
 public:
-    NullSoundHandler(media::MediaHandler* m) : sound_handler(m) {}
+
+    boost::shared_ptr<sound_handler> _mixer;
+
+    NullSoundHandler(media::MediaHandler* m, boost::shared_ptr<sound_handler> 
mixer=boost::shared_ptr<sound_handler>((sound_handler*)0))
+        :
+        sound_handler(m),
+        _mixer(mixer)
+    {}
+
+    // If a _mixer was given, let it do the mixing!
+    void mix(boost::int16_t* outSamples, boost::int16_t* inSamples,
+                unsigned int nSamples, float volume)
+    {
+        if ( _mixer ) _mixer->mix(outSamples, inSamples, nSamples, volume);
+        else {
+            // cheating, just copy input to output, which in NO WAY
+            // can be considered "mixing"
+            std::copy(outSamples, outSamples+nSamples, inSamples);
+        }
+    }
+
 
 };
        
diff --git a/libsound/sound_handler.cpp b/libsound/sound_handler.cpp
index a55b112..4b5f333 100644
--- a/libsound/sound_handler.cpp
+++ b/libsound/sound_handler.cpp
@@ -669,15 +669,6 @@ sound_handler::hasInputStreams() const
     return !_inputStreams.empty();
 }
 
-void
-sound_handler::mix(boost::int16_t* outSamples, boost::int16_t* inSamples,
-                unsigned int nSamples, float /*volume*/)
-{
-    /// @todo implement a better mixer !
-    // cheating, just copy input to output!
-    std::copy(outSamples, outSamples+nSamples, inSamples);
-}
-
 bool
 sound_handler::is_muted() const
 {
diff --git a/libsound/sound_handler.h b/libsound/sound_handler.h
index 3bfc62f..39aa964 100644
--- a/libsound/sound_handler.h
+++ b/libsound/sound_handler.h
@@ -409,6 +409,34 @@ public:
     ///
     virtual void fetchSamples(boost::int16_t* to, unsigned int nSamples);
 
+    /// Mix nSamples from inSamples to outSamples, with given volume
+    //
+    /// @param outSamples
+    ///     The output samples buffer, to mix to.
+    ///     Must be big enough to contain nSamples.
+    ///     Can be larger.
+    ///
+    /// @param inSamples
+    ///     The input samples buffer, to mix in.
+    ///     It is non-const as this method *is* allowed
+    ///     to mess with content, for example to apply
+    ///     volume.
+    ///     TODO: why not applying volume upstream ?!
+    ///
+    /// @param nSamples
+    ///     The amount of samples to mix in.
+    ///
+    /// @param volume
+    ///     The volume to apply to input samples, as a fraction (0..1)
+    ///
+    /// TODO: this interface says nothing about how many channels we're
+    ///       going to mix. It should, to be a sane interface.
+    ///       Maybe, a Mixer instance should be created, initialized
+    ///       with number of channels, at each fetching.
+    ///
+    virtual void mix(boost::int16_t* outSamples, boost::int16_t* inSamples,
+                unsigned int nSamples, float volume) = 0;
+
 protected:
 
 
@@ -438,34 +466,6 @@ protected:
     /// Does the mixer have input streams ?
     bool hasInputStreams() const;
 
-    /// Mix nSamples from inSamples to outSamples, with given volume
-    //
-    /// @param outSamples
-    ///     The output samples buffer, to mix to.
-    ///     Must be big enough to contain nSamples.
-    ///     Can be larger.
-    ///
-    /// @param inSamples
-    ///     The input samples buffer, to mix in.
-    ///     It is non-const as this method *is* allowed
-    ///     to mess with content, for example to apply
-    ///     volume.
-    ///     TODO: why not applying volume upstream ?!
-    ///
-    /// @param nSamples
-    ///     The amount of samples to mix in.
-    ///
-    /// @param volume
-    ///     The volume to apply to input samples, as a fraction (0..1)
-    ///
-    /// TODO: this interface says nothing about how many channels we're
-    ///       going to mix. It should, to be a sane interface.
-    ///       Maybe, a Mixer instance should be created, initialized
-    ///       with number of channels, at each fetching.
-    ///
-    virtual void mix(boost::int16_t* outSamples, boost::int16_t* inSamples,
-                unsigned int nSamples, float volume);
-
 private:
 
     /// Special test-member. Stores count of started sounds.

-----------------------------------------------------------------------

Summary of changes:
 gui/Player.cpp                       |   21 ++-----
 gui/gui.h                            |    8 +++
 libsound/NullSoundHandler.h          |   23 +++++++-
 libsound/aos4/sound_handler_ahi.cpp  |  108 ----------------------------------
 libsound/aos4/sound_handler_ahi.h    |   13 ----
 libsound/mkit/sound_handler_mkit.cpp |   99 -------------------------------
 libsound/mkit/sound_handler_mkit.h   |   13 ----
 libsound/sdl/sound_handler_sdl.cpp   |   30 ---------
 libsound/sdl/sound_handler_sdl.h     |    7 --
 libsound/sound_handler.cpp           |   51 +++++++++++++---
 libsound/sound_handler.h             |   81 +++++++++++++-------------
 11 files changed, 116 insertions(+), 338 deletions(-)


hooks/post-receive
-- 
Gnash



reply via email to

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