This is the mail archive of the cygwin-patches@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Fix to discard wave header properly


This patch fixes the following problem: If .wav files are copied
to /dev/dsp, the wave header is played as PCM audio.
After the patch, discarding the wave header works properly.
I also got rid of one type cast. The cast in the call to
parsewav prevented the call by reference to work properly.

Gerd

ChangeLog

2004-03-23  Gerd Spalink  <Gerd.Spalink@t-online.de>

	* fhandler_dsp.cc (fhandler_dev_dsp::write): Remove type
	cast from argument to audio_out_->parsewav() to make reference
	work properly. Now .wav file headers are properly discarded.


Index: fhandler_dsp.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/fhandler_dsp.cc,v
retrieving revision 1.31
diff -p -u -r1.31 fhandler_dsp.cc
--- fhandler_dsp.cc     23 Mar 2004 11:05:56 -0000      1.31
+++ fhandler_dsp.cc     23 Mar 2004 22:15:10 -0000
@@ -1098,7 +1098,9 @@ fhandler_dev_dsp::open (int flags, mode_
 int
 fhandler_dev_dsp::write (const void *ptr, size_t len)
 {
-  int len_s = len;
+  int len_s = len;
+  const char *ptr_s = static_cast <const char *> (ptr);
+
   debug_printf ("ptr=%08x len=%d", ptr, len);
   if (!audio_out_)
     {
@@ -1109,9 +1111,10 @@ fhandler_dev_dsp::write (const void *ptr
   if (audio_out_->getOwner () == 0L)
     { // No owner yet, lets do it
       // check for wave file & get parameters & skip header if possible.
-      if (audio_out_->parsewav ((const char *) ptr, len_s,
+      if (audio_out_->parsewav (ptr_s, len_s,
                                audiofreq_, audiobits_, audiochannels_))
        { // update our format conversion
+         debug_printf ("=> ptr_s=%08x len_s=%d", ptr_s, len_s);
          audioformat_ = ((audiobits_ == 8) ? AFMT_U8 : AFMT_S16_LE);
          audio_out_->setformat (audioformat_);
        }
@@ -1123,7 +1126,7 @@ fhandler_dev_dsp::write (const void *ptr
        }
     }

-  audio_out_->write ((char *)ptr, len_s);
+  audio_out_->write (ptr_s, len_s);
   return len;
 }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]