OSDN Git Service

gas/opcodes: blackfin: move dsp mac func defines to common header
[pf3gnuchains/sourceware.git] / winsup / cygwin / fhandler_dsp.cc
index 249fa77..9095ba5 100644 (file)
@@ -1,6 +1,6 @@
 /* Fhandler_dev_dsp: code to emulate OSS sound model /dev/dsp
 
-   Copyright 2001, 2002, 2003, 2004 Red Hat, Inc
+   Copyright 2001, 2002, 2003, 2004, 2008 Red Hat, Inc
 
    Written by Andy Younger (andy@snoogie.demon.co.uk)
    Extended by Gerd Spalink (Gerd.Spalink@t-online.de)
@@ -13,10 +13,7 @@ Cygwin license.  Please consult the file "CYGWIN_LICENSE" for
 details. */
 
 #include "winsup.h"
-#include <stdio.h>
-#include <windows.h>
 #include <sys/soundcard.h>
-#include <mmsystem.h>
 #include "cygerrno.h"
 #include "security.h"
 #include "path.h"
@@ -1000,7 +997,7 @@ fhandler_dev_dsp::open (int flags, mode_t mode)
 #define IS_WRITE() ((get_flags() & O_ACCMODE) != O_RDONLY)
 #define IS_READ() ((get_flags() & O_ACCMODE) != O_WRONLY)
 
-int
+ssize_t __stdcall
 fhandler_dev_dsp::write (const void *ptr, size_t len)
 {
   debug_printf ("ptr=%08x len=%d", ptr, len);
@@ -1010,24 +1007,25 @@ fhandler_dev_dsp::write (const void *ptr, size_t len)
   int len_s = len;
   const char *ptr_s = static_cast <const char *> (ptr);
 
-  if (!audio_out_)
-    if (IS_WRITE ())
-      {
-       debug_printf ("Allocating");
-       if (!(audio_out_ = new Audio_out))
-         return -1;
+  if (audio_out_)
+    /* nothing to do */;
+  else if (IS_WRITE ())
+    {
+      debug_printf ("Allocating");
+      if (!(audio_out_ = new Audio_out))
+       return -1;
 
-       /* check for wave file & get parameters & skip header if possible. */
+      /* check for wave file & get parameters & skip header if possible. */
 
-       if (audio_out_->parsewav (ptr_s, len_s,
-                                 audiofreq_, audiobits_, audiochannels_))
-         debug_printf ("=> ptr_s=%08x len_s=%d", ptr_s, len_s);
-      }
-    else
-      {
-       set_errno (EBADF); // device was opened for read?
-       return -1;
-      }
+      if (audio_out_->parsewav (ptr_s, len_s,
+                               audiofreq_, audiobits_, audiochannels_))
+       debug_printf ("=> ptr_s=%08x len_s=%d", ptr_s, len_s);
+    }
+  else
+    {
+      set_errno (EBADF); // device was opened for read?
+      return -1;
+    }
 
   /* Open audio device properly with callbacks.
      Private parameters were set in call to parsewav.
@@ -1049,23 +1047,24 @@ fhandler_dev_dsp::read (void *ptr, size_t& len)
   if ((fhandler_dev_dsp *) archetype != this)
     return ((fhandler_dev_dsp *)archetype)->read(ptr, len);
 
-  if (!audio_in_)
-    if (IS_READ ())
-      {
-       debug_printf ("Allocating");
-       if (!(audio_in_ = new Audio_in))
-         {
-           len = (size_t)-1;
-           return;
-         }
-       audio_in_->setconvert (audioformat_);
-      }
-    else
-      {
-       len = (size_t)-1;
-       set_errno (EBADF); // device was opened for write?
-       return;
-      }
+  if (audio_in_)
+    /* nothing to do */;
+  else if (IS_READ ())
+    {
+      debug_printf ("Allocating");
+      if (!(audio_in_ = new Audio_in))
+       {
+         len = (size_t)-1;
+         return;
+       }
+      audio_in_->setconvert (audioformat_);
+    }
+  else
+    {
+      len = (size_t)-1;
+      set_errno (EBADF); // device was opened for write?
+      return;
+    }
 
   /* Open audio device properly with callbacks.
      This is a noop when there are successive reads in the same process */