gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog gui/Makefile.am gui/Player.cpp ...


From: Russ Nelson
Subject: [Gnash-commit] gnash ChangeLog gui/Makefile.am gui/Player.cpp ...
Date: Fri, 02 May 2008 20:23:33 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Russ Nelson <nelsonrn>  08/05/02 20:23:33

Modified files:
        .              : ChangeLog 
        gui            : Makefile.am Player.cpp Player.h gnash.cpp 
        libmedia       : sound_handler.h 
        libmedia/ffmpeg: sound_handler_sdl.cpp sound_handler_sdl.h 

Log message:
        * incorporate the rest of Craig Kelley's "dump" gui code.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.6479&r2=1.6480
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/Makefile.am?cvsroot=gnash&r1=1.124&r2=1.125
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/Player.cpp?cvsroot=gnash&r1=1.104&r2=1.105
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/Player.h?cvsroot=gnash&r1=1.29&r2=1.30
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/gnash.cpp?cvsroot=gnash&r1=1.114&r2=1.115
http://cvs.savannah.gnu.org/viewcvs/gnash/libmedia/sound_handler.h?cvsroot=gnash&r1=1.13&r2=1.14
http://cvs.savannah.gnu.org/viewcvs/gnash/libmedia/ffmpeg/sound_handler_sdl.cpp?cvsroot=gnash&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/gnash/libmedia/ffmpeg/sound_handler_sdl.h?cvsroot=gnash&r1=1.4&r2=1.5

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.6479
retrieving revision 1.6480
diff -u -b -r1.6479 -r1.6480
--- ChangeLog   2 May 2008 20:01:35 -0000       1.6479
+++ ChangeLog   2 May 2008 20:23:29 -0000       1.6480
@@ -1,3 +1,7 @@
+2008-05-02 Russ Nelson <address@hidden>
+
+       * incorporate the rest of Craig Kelley's "dump" gui code.
+
 2008-05-02 Sandro Santilli <address@hidden>
 
        * server/movie_root.cpp (cleanupUnloadedListeners): scan again if

Index: gui/Makefile.am
===================================================================
RCS file: /sources/gnash/gnash/gui/Makefile.am,v
retrieving revision 1.124
retrieving revision 1.125
diff -u -b -r1.124 -r1.125
--- gui/Makefile.am     2 May 2008 13:50:39 -0000       1.124
+++ gui/Makefile.am     2 May 2008 20:23:30 -0000       1.125
@@ -16,7 +16,8 @@
 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
 # 
-# build gtk-gnash, kde-gnash, sdl-gnash, fltk-gnash, aqua-gnash, fb-gnash and 
riscos-gnash
+# build gtk-gnash, kde-gnash, sdl-gnash, fltk-gnash, aqua-gnash, fb-gnash, 
riscos-gnash
+# and dump-gnash
 #
 
 AUTOMAKE_OPTIONS = -Wno-portability
@@ -72,6 +73,10 @@
        $(GLIB_LIBS) \
        $(EXPAT_LIBS)
 
+DUMP_CFLAGS =
+
+DUMP_LIBS =
+
 # The following will be filled up later
 GUI_CPPFLAGS = 
 
@@ -225,6 +230,11 @@
 include $(srcdir)/am-frag/hildon.am
 endif
 
+# Build the DUMP gui
+if BUILD_DUMP_GUI
+include $(srcdir)/am-frag/dump.am
+endif
+
 # Build the FB gui
 if BUILD_FB_GUI
 include $(srcdir)/am-frag/fb.am
@@ -235,11 +245,6 @@
 include $(srcdir)/am-frag/riscos.am
 endif
 
-# Build the DUMP gui
-if BUILD_DUMP_GUI
-include $(srcdir)/am-frag/dump.am
-endif
-
 CLEANFILES = klash.moc .configline gnash
 
 bundle: Info.plist

Index: gui/Player.cpp
===================================================================
RCS file: /sources/gnash/gnash/gui/Player.cpp,v
retrieving revision 1.104
retrieving revision 1.105
diff -u -b -r1.104 -r1.105
--- gui/Player.cpp      2 May 2008 14:53:42 -0000       1.104
+++ gui/Player.cpp      2 May 2008 20:23:31 -0000       1.105
@@ -92,6 +92,7 @@
     _fpsDebugTime(0.0),
 #endif
     _hostfd(-1),
+    _audio_dump(NULL),
     _startFullscreen(false)
 {
     init();
@@ -159,12 +160,25 @@
 
 }
 
+bool
+Player::silent_stream(void* /*udata*/, boost::uint8_t* stream, int len)
+{
+    memset((void*)stream, 0, len);
+    return true;
+}
+
 void
 Player::init_sound()
 {
     if (_doSound) {
 #ifdef SOUND_SDL
-        _sound_handler.reset( gnash::media::create_sound_handler_sdl() );
+        _sound_handler.reset( 
gnash::media::create_sound_handler_sdl(_audio_dump) );
+        if (_audio_dump != NULL) {
+            // 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
+            _sound_handler->attach_aux_streamer(silent_stream, (void*) this);
+        }
 #elif defined(SOUND_GST)
         _sound_handler.reset( gnash::media::create_sound_handler_gst() );
 #else

Index: gui/Player.h
===================================================================
RCS file: /sources/gnash/gnash/gui/Player.h,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -b -r1.29 -r1.30
--- gui/Player.h        28 Mar 2008 16:23:07 -0000      1.29
+++ gui/Player.h        2 May 2008 20:23:31 -0000       1.30
@@ -134,10 +134,25 @@
            _startFullscreen = x;
        }
        
+        void setAudioDumpfile(const char* filespec) {
+            _audio_dump = filespec;
+        }
+       
 private:
 
        void init();
 
+       /// This aux streamer returns a silent audio stream
+       ///
+       /// @param udata
+       ///     Pointer to user-specific data
+       /// @param stream
+       ///     Buffer into which method will put data
+       /// @param len
+       ///     Requested amount of data to put
+       /// @return success
+       static bool silent_stream(void* udata, boost::uint8_t* stream, int len);
+        
        void init_sound();
 
        void init_logfile();
@@ -215,6 +230,8 @@
        // (Or what did you think it meant?)
        bool _startFullscreen;
 
+        const char* _audio_dump;
+
 };
 
  

Index: gui/gnash.cpp
===================================================================
RCS file: /sources/gnash/gnash/gui/gnash.cpp,v
retrieving revision 1.114
retrieving revision 1.115
diff -u -b -r1.114 -r1.115
--- gui/gnash.cpp       27 Apr 2008 17:20:30 -0000      1.114
+++ gui/gnash.cpp       2 May 2008 20:23:31 -0000       1.115
@@ -97,6 +97,8 @@
 #if VERBOSE_PARSE
     << _("  -vp                      Be (very) verbose about parsing") << endl
 #endif
+    << _("  -A <file>                Audio dump file (wave format)") << endl
+    << _("  -D <file>                Video dump file (only valid with 
dump-gnash)") << endl
     << _("  -x,  --xid <ID>          X11 Window ID for display") << endl
     << _("  -w,  --writelog          Produce the disk based debug log") << endl
     << _("  -j,  --width <width>     Set window width") << endl
@@ -202,6 +204,7 @@
         { 'V', "version",       Arg_parser::no  },        
         { 'f', "debug-fps",     Arg_parser::yes },        
         { 'F', "fd",            Arg_parser::yes },
+        { 'A', "dump",          Arg_parser::yes },
         {   0, 0,               Arg_parser::no  }
     };
 
@@ -378,6 +381,12 @@
                    case 0:
                        infiles.push_back(parser.argument(i));
                        break;
+                case 'A':
+                {
+                    std::string fn = parser.argument(i);
+                    player.setAudioDumpfile(fn.c_str());
+                    break;
+                }
                }
            }
            catch (Arg_parser::ArgParserException &e)

Index: libmedia/sound_handler.h
===================================================================
RCS file: /sources/gnash/gnash/libmedia/sound_handler.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- libmedia/sound_handler.h    28 Mar 2008 16:23:07 -0000      1.13
+++ libmedia/sound_handler.h    2 May 2008 20:23:32 -0000       1.14
@@ -435,7 +435,7 @@
 };
 
 // TODO: move to appropriate specific sound handlers
-DSOEXPORT sound_handler*       create_sound_handler_sdl();
+DSOEXPORT sound_handler*       create_sound_handler_sdl(char* wave_file);
 DSOEXPORT sound_handler*       create_sound_handler_gst();
        
 

Index: libmedia/ffmpeg/sound_handler_sdl.cpp
===================================================================
RCS file: /sources/gnash/gnash/libmedia/ffmpeg/sound_handler_sdl.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- libmedia/ffmpeg/sound_handler_sdl.cpp       5 Mar 2008 03:55:54 -0000       
1.3
+++ libmedia/ffmpeg/sound_handler_sdl.cpp       2 May 2008 20:23:32 -0000       
1.4
@@ -47,7 +47,7 @@
 namespace gnash {
 namespace media {
 
-SDL_sound_handler::SDL_sound_handler()
+SDL_sound_handler::SDL_sound_handler(char* wave_file)
        : soundOpened(false),
                soundsPlaying(0),
                muted(false)
@@ -59,6 +59,29 @@
        audioSpec.callback = SDL_sound_handler::sdl_audio_callback;
        audioSpec.userdata = this;
        audioSpec.samples = 2048;               //512 - not enough for  
videostream
+
+        file_output = NULL;
+        file_stream = NULL;
+
+       if (wave_file != NULL) {
+            file_output = wave_file;
+           file_stream = new std::ofstream();
+           file_stream->open(file_output);
+           if (file_stream->fail()) {
+                std::cerr << "Unable to write file '" << file_output << "'\n";
+                exit(1);
+           } else {
+                write_wave_header(file_stream);
+                std::cout << "# Created 44100 16Mhz stereo wave file:" << 
std::endl <<
+                    "AUDIOFILE=" << file_output << std::endl;
+           }
+        }
+
+}
+
+SDL_sound_handler::SDL_sound_handler()
+{
+    SDL_sound_handler(NULL);
 }
 
 void
@@ -84,6 +107,10 @@
 {
        delete_all_sounds();
        if (soundOpened) SDL_CloseAudio();
+       if ((file_stream != NULL) && (file_stream->is_open())) {
+         file_stream->close();
+       }
+
 }
 
 
@@ -513,6 +540,13 @@
        return new SDL_sound_handler;
 }
 
+sound_handler*
+create_sound_handler_sdl(char* wave_file)
+// Factory.
+{
+       return new SDL_sound_handler(wave_file);
+}
+
 // Pointer handling and checking functions
 boost::uint8_t*
 active_sound::get_raw_data_ptr(unsigned long int pos)
@@ -629,6 +663,59 @@
 }
 
 
+// write a wave header, using the current audioSpec settings
+void SDL_sound_handler::write_wave_header(std::ofstream *outfile)
+{
+
+  int i;
+  char obuff[80];
+ 
+  WAV_HDR *wav;
+  CHUNK_HDR *chk;
+ 
+  // allocate wav header
+  wav = new WAV_HDR;
+  chk = new CHUNK_HDR;
+  
+  // setup wav header
+  sprintf(obuff,"RIFF");
+  for(i=0;i<4;i++) wav->rID[i] = obuff[i];
+ 
+  sprintf(obuff,"WAVE");
+  for(i=0;i<4;i++) wav->wID[i] = obuff[i];
+  
+  sprintf(obuff,"fmt ");
+  for(i=0;i<4;i++) wav->fId[i] = obuff[i];
+ 
+  wav->nBitsPerSample = ((audioSpec.format == AUDIO_S16SYS) ? 16 : 0);
+  wav->nSamplesPerSec = audioSpec.freq;
+  wav->nAvgBytesPerSec = audioSpec.freq;
+  wav->nAvgBytesPerSec *= wav->nBitsPerSample / 8;
+  wav->nAvgBytesPerSec *= audioSpec.channels;
+  wav->nChannels = audioSpec.channels;
+    
+  wav->pcm_header_len = 16;
+  wav->wFormatTag = 1;
+  wav->rLen = sizeof(WAV_HDR) + sizeof(CHUNK_HDR);
+  wav->nBlockAlign = audioSpec.channels * wav->nBitsPerSample / 8;
+
+  // setup chunk header
+  sprintf(obuff,"data");
+  for(i=0;i<4;i++) chk->dId[i] = obuff[i];
+  chk->dLen = 0;
+ 
+  /* write riff/wav header */
+  outfile->write((char *)wav,sizeof(WAV_HDR));
+ 
+  /* write chunk header */
+  outfile->write((char *)chk,sizeof(CHUNK_HDR));
+ 
+  // be polite
+  if(wav!=NULL) delete wav;
+  if(chk!=NULL) delete chk;
+
+}
+
 // Callback invoked by the SDL audio thread.
 void SDL_sound_handler::sdl_audio_callback (void *udata, Uint8 *stream, int 
buffer_length_in)
 {
@@ -652,6 +739,7 @@
        // If nothing to play there is no reason to play
        // Is this a potential deadlock problem?
        if (handler->soundsPlaying == 0 && handler->m_aux_streamer.size() == 0) 
{
+            std::cout << "Pausing Audio now...\n";
                SDL_PauseAudio(1);
                return;
        }
@@ -814,8 +902,20 @@
                } // active sounds loop
        } // existing sounds loop
 
+       // 
+       // WRITE CONTENTS OF stream TO FILE
+       //
+       if (handler->file_stream != NULL) {
+            handler->file_stream->write((char*) stream, buffer_length_in);
+            // now, mute all audio
+            memset ((void*) stream, 0, buffer_length_in);
+       }
+
+
+
 }
 
+
 } // gnash.media namespace 
 } // namespace gnash
 

Index: libmedia/ffmpeg/sound_handler_sdl.h
===================================================================
RCS file: /sources/gnash/gnash/libmedia/ffmpeg/sound_handler_sdl.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- libmedia/ffmpeg/sound_handler_sdl.h 22 Mar 2008 02:35:24 -0000      1.4
+++ libmedia/ffmpeg/sound_handler_sdl.h 2 May 2008 20:23:33 -0000       1.5
@@ -43,6 +43,29 @@
 #include <boost/bind.hpp>
 #include <boost/thread/mutex.hpp>
 
+// 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;
+
 namespace gnash {
 namespace media {
 
@@ -312,9 +335,19 @@
        // stop and delete all sounds
        void delete_all_sounds();
 
+       /// File name for dump file
+       char* file_output;
+
+        /// File stream for dump file
+       std::ofstream* file_stream;
+
+       // write a .WAV file header
+       void write_wave_header(std::ofstream *outfile);
+
 public:
        SDL_sound_handler();
-       virtual ~SDL_sound_handler();
+       SDL_sound_handler(char* wave_file);
+       ~SDL_sound_handler();
 
        /// Called to create a sound.
        virtual int     create_sound(void* data, unsigned int data_bytes, 
std::auto_ptr<SoundInfo> sinfo);




reply via email to

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