gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog libmedia/ffmpeg/sound_handler_s...


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog libmedia/ffmpeg/sound_handler_s...
Date: Thu, 08 May 2008 17:54:53 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  08/05/08 17:54:53

Modified files:
        .              : ChangeLog 
        libmedia/ffmpeg: sound_handler_sdl.cpp sound_handler_sdl.h 

Log message:
        * libmedia/ffmpeg/sound_handler_sdl.cpp: fix default constructor
          to actually construct the object instead of corrupting memory;
          don't heap-allocate WAV and CHK stuff.
        * libmedia/ffmpeg/sound_handler_sdl.h: hide wave-specific code, not
          needed in header.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.6557&r2=1.6558
http://cvs.savannah.gnu.org/viewcvs/gnash/libmedia/ffmpeg/sound_handler_sdl.cpp?cvsroot=gnash&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/gnash/libmedia/ffmpeg/sound_handler_sdl.h?cvsroot=gnash&r1=1.7&r2=1.8

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.6557
retrieving revision 1.6558
diff -u -b -r1.6557 -r1.6558
--- ChangeLog   8 May 2008 17:37:47 -0000       1.6557
+++ ChangeLog   8 May 2008 17:54:52 -0000       1.6558
@@ -1,3 +1,11 @@
+2008-05-08 Sandro Santilli <address@hidden>
+
+       * libmedia/ffmpeg/sound_handler_sdl.cpp: fix default constructor
+         to actually construct the object instead of corrupting memory;
+         don't heap-allocate WAV and CHK stuff.
+       * libmedia/ffmpeg/sound_handler_sdl.h: hide wave-specific code, not
+         needed in header.
+
 2008-05-08 Bastiaan Jacques <address@hidden>
 
        * server/asobj/NetStreamFfmpeg.cpp: Sleep 1 millisecond instead of 1

Index: libmedia/ffmpeg/sound_handler_sdl.cpp
===================================================================
RCS file: /sources/gnash/gnash/libmedia/ffmpeg/sound_handler_sdl.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- libmedia/ffmpeg/sound_handler_sdl.cpp       6 May 2008 13:33:40 -0000       
1.6
+++ libmedia/ffmpeg/sound_handler_sdl.cpp       8 May 2008 17:54:52 -0000       
1.7
@@ -44,6 +44,33 @@
 #include <boost/scoped_array.hpp>
 #include <SDL.h>
 
+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 media {
 
@@ -75,8 +102,11 @@
 }
 
 SDL_sound_handler::SDL_sound_handler()
+       :
+       soundOpened(false),
+       soundsPlaying(0),
+       muted(false)
 {
-    SDL_sound_handler(NULL);
 }
 
 void
@@ -663,49 +693,42 @@
   int i;
   char obuff[80];
  
-  WAV_HDR *wav;
-  CHUNK_HDR *chk;
- 
   // allocate wav header
-  wav = new WAV_HDR;
-  chk = new CHUNK_HDR;
+  WAV_HDR wav;
+  CHUNK_HDR chk;
   
   // setup wav header
   sprintf(obuff,"RIFF");
-  for(i=0;i<4;i++) wav->rID[i] = obuff[i];
+  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];
+  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];
+  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;
+  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;
+  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));
+  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;
+  outfile.write((char *)&chk, sizeof(CHUNK_HDR));
 
 }
 

Index: libmedia/ffmpeg/sound_handler_sdl.h
===================================================================
RCS file: /sources/gnash/gnash/libmedia/ffmpeg/sound_handler_sdl.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- libmedia/ffmpeg/sound_handler_sdl.h 6 May 2008 13:33:40 -0000       1.7
+++ libmedia/ffmpeg/sound_handler_sdl.h 8 May 2008 17:54:53 -0000       1.8
@@ -43,28 +43,6 @@
 #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 {




reply via email to

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