]> git.saurik.com Git - wxWidgets.git/blobdiff - contrib/src/mmedia/sndfile.cpp
fix evaluation order bug (patch 1158099)
[wxWidgets.git] / contrib / src / mmedia / sndfile.cpp
index ffe842706eb4fba2b75b29added29bcfd0dda360..05a4acb8b923260f57a8bc09e4712432ba8ca67d 100644 (file)
@@ -4,8 +4,9 @@
 // Date: 08/11/1999
 // Author: Guilhem Lavaux <lavaux@easynet.fr> (C) 1999, 2000
 // CVSID: $Id$
 // Date: 08/11/1999
 // Author: Guilhem Lavaux <lavaux@easynet.fr> (C) 1999, 2000
 // CVSID: $Id$
+// wxWindows licence
 // --------------------------------------------------------------------------
 // --------------------------------------------------------------------------
-#include <wx/wxprec.h>
+#include "wx/wxprec.h"
 
 #ifndef WX_PRECOMP
 #include <wx/defs.h>
 
 #ifndef WX_PRECOMP
 #include <wx/defs.h>
@@ -18,6 +19,7 @@
 #include "wx/mmedia/sndcpcm.h"
 #include "wx/mmedia/sndulaw.h"
 #include "wx/mmedia/sndg72x.h"
 #include "wx/mmedia/sndcpcm.h"
 #include "wx/mmedia/sndulaw.h"
 #include "wx/mmedia/sndg72x.h"
+#include "wx/mmedia/sndmsad.h"
 
 // --------------------------------------------------------------------------
 // Sound codec router
 
 // --------------------------------------------------------------------------
 // Sound codec router
@@ -77,7 +79,7 @@ wxSoundStream& wxSoundRouterStream::Write(const void *buffer, wxUint32 len)
 // sound driver using the specified format. If this fails, it uses personnal
 // codec converters: for the moment there is a PCM converter (PCM to PCM:
 // with optional resampling, ...), an ULAW converter (ULAW to PCM), a G72X
 // sound driver using the specified format. If this fails, it uses personnal
 // codec converters: for the moment there is a PCM converter (PCM to PCM:
 // with optional resampling, ...), an ULAW converter (ULAW to PCM), a G72X
-// converter (G72X to PCM). If nothing works, it returns FALSE.
+// converter (G72X to PCM). If nothing works, it returns false.
 // --------------------------------------------------------------------------
 bool wxSoundRouterStream::SetSoundFormat(const wxSoundFormatBase& format)
 {
 // --------------------------------------------------------------------------
 bool wxSoundRouterStream::SetSoundFormat(const wxSoundFormatBase& format)
 {
@@ -88,12 +90,12 @@ bool wxSoundRouterStream::SetSoundFormat(const wxSoundFormatBase& format)
     if (m_sndio->SetSoundFormat(format)) {
         // We are lucky, it is working.
         wxSoundStream::SetSoundFormat(m_sndio->GetSoundFormat());
     if (m_sndio->SetSoundFormat(format)) {
         // We are lucky, it is working.
         wxSoundStream::SetSoundFormat(m_sndio->GetSoundFormat());
-        return TRUE;
+        return true;
     }
     
     switch(format.GetType()) {
         case wxSOUND_NOFORMAT:
     }
     
     switch(format.GetType()) {
         case wxSOUND_NOFORMAT:
-            return FALSE;
+            return false;
         case wxSOUND_PCM:
             m_router = new wxSoundStreamPcm(*m_sndio);
             m_router->SetSoundFormat(format);
         case wxSOUND_PCM:
             m_router = new wxSoundStreamPcm(*m_sndio);
             m_router->SetSoundFormat(format);
@@ -106,12 +108,16 @@ bool wxSoundRouterStream::SetSoundFormat(const wxSoundFormatBase& format)
             m_router = new wxSoundStreamG72X(*m_sndio);
             m_router->SetSoundFormat(format);
             break;
             m_router = new wxSoundStreamG72X(*m_sndio);
             m_router->SetSoundFormat(format);
             break;
+        case wxSOUND_MSADPCM:
+            m_router = new  wxSoundStreamMSAdpcm(*m_sndio);
+            m_router->SetSoundFormat(format);
+            break;
         default:
         default:
-            return FALSE;
+            return false;
         
     }
     wxSoundStream::SetSoundFormat(m_router->GetSoundFormat());
         
     }
     wxSoundStream::SetSoundFormat(m_router->GetSoundFormat());
-    return TRUE;
+    return true;
 }
 
 // --------------------------------------------------------------------------
 }
 
 // --------------------------------------------------------------------------
@@ -134,19 +140,19 @@ bool wxSoundRouterStream::StartProduction(int evt)
 {
     if (!m_router) {
         if (m_sndio->StartProduction(evt))
 {
     if (!m_router) {
         if (m_sndio->StartProduction(evt))
-            return TRUE;
+            return true;
         
         m_snderror = m_sndio->GetError();
         m_lastcount = m_sndio->GetLastAccess();
         
         m_snderror = m_sndio->GetError();
         m_lastcount = m_sndio->GetLastAccess();
-        return FALSE;
+        return false;
     }
     
     if (m_router->StartProduction(evt))
     }
     
     if (m_router->StartProduction(evt))
-        return TRUE;
+        return true;
     
     m_snderror = m_router->GetError();
     m_lastcount = m_router->GetLastAccess();
     
     m_snderror = m_router->GetError();
     m_lastcount = m_router->GetLastAccess();
-    return FALSE;
+    return false;
 } 
 
 // --------------------------------------------------------------------------
 } 
 
 // --------------------------------------------------------------------------
@@ -156,19 +162,19 @@ bool wxSoundRouterStream::StopProduction()
 {
     if (!m_router) {
         if (m_sndio->StopProduction())
 {
     if (!m_router) {
         if (m_sndio->StopProduction())
-            return TRUE;
+            return true;
         
         m_snderror = m_sndio->GetError();
         m_lastcount = m_sndio->GetLastAccess();
         
         m_snderror = m_sndio->GetError();
         m_lastcount = m_sndio->GetLastAccess();
-        return FALSE;
+        return false;
     }
     
     if (m_router->StopProduction())
     }
     
     if (m_router->StopProduction())
-        return TRUE;
+        return true;
     
     m_snderror = m_router->GetError();
     m_lastcount = m_router->GetLastAccess();
     
     m_snderror = m_router->GetError();
     m_lastcount = m_router->GetLastAccess();
-    return FALSE;
+    return false;
 }
 
 // --------------------------------------------------------------------------
 }
 
 // --------------------------------------------------------------------------
@@ -182,7 +188,7 @@ wxSoundFileStream::wxSoundFileStream(wxInputStream& stream,
 {
     m_length = 0;
     m_bytes_left = 0;
 {
     m_length = 0;
     m_bytes_left = 0;
-    m_prepared = FALSE;
+    m_prepared = false;
 }
 
 wxSoundFileStream::wxSoundFileStream(wxOutputStream& stream,
 }
 
 wxSoundFileStream::wxSoundFileStream(wxOutputStream& stream,
@@ -192,7 +198,7 @@ wxSoundFileStream::wxSoundFileStream(wxOutputStream& stream,
 {
   m_length = 0;
   m_bytes_left = 0;
 {
   m_length = 0;
   m_bytes_left = 0;
-  m_prepared = FALSE;
+  m_prepared = false;
 }
 
 wxSoundFileStream::~wxSoundFileStream()
 }
 
 wxSoundFileStream::~wxSoundFileStream()
@@ -204,51 +210,51 @@ wxSoundFileStream::~wxSoundFileStream()
 bool wxSoundFileStream::Play()
 {
   if (m_state != wxSOUND_FILE_STOPPED)
 bool wxSoundFileStream::Play()
 {
   if (m_state != wxSOUND_FILE_STOPPED)
-    return FALSE;
+    return false;
 
   if (!m_prepared)
     if (!PrepareToPlay())
 
   if (!m_prepared)
     if (!PrepareToPlay())
-      return FALSE;
+      return false;
 
   m_state = wxSOUND_FILE_PLAYING;
 
   if (!StartProduction(wxSOUND_OUTPUT))
 
   m_state = wxSOUND_FILE_PLAYING;
 
   if (!StartProduction(wxSOUND_OUTPUT))
-    return FALSE;
+    return false;
 
 
-  return TRUE;
+  return true;
 }
 
 bool wxSoundFileStream::Record(wxUint32 time)
 {
   if (m_state != wxSOUND_FILE_STOPPED)
 }
 
 bool wxSoundFileStream::Record(wxUint32 time)
 {
   if (m_state != wxSOUND_FILE_STOPPED)
-    return FALSE;
+    return false;
 
   if (!PrepareToRecord(time))
 
   if (!PrepareToRecord(time))
-    return FALSE;
+    return false;
 
   FinishPreparation(m_sndformat->GetBytesFromTime(time));
 
   m_state = wxSOUND_FILE_RECORDING;
   if (!StartProduction(wxSOUND_INPUT))
 
   FinishPreparation(m_sndformat->GetBytesFromTime(time));
 
   m_state = wxSOUND_FILE_RECORDING;
   if (!StartProduction(wxSOUND_INPUT))
-    return FALSE;
+    return false;
 
 
-  return TRUE;
+  return true;
 }
 
 bool wxSoundFileStream::Stop()
 {
   if (m_state == wxSOUND_FILE_STOPPED)
 }
 
 bool wxSoundFileStream::Stop()
 {
   if (m_state == wxSOUND_FILE_STOPPED)
-    return FALSE;
+    return false;
 
   if (!StopProduction())
 
   if (!StopProduction())
-    return FALSE;
+    return false;
 
 
-  m_prepared = FALSE;
+  m_prepared = false;
 
   if (m_state == wxSOUND_FILE_RECORDING)
     if (!FinishRecording()) {
       m_state = wxSOUND_FILE_STOPPED;
 
   if (m_state == wxSOUND_FILE_RECORDING)
     if (!FinishRecording()) {
       m_state = wxSOUND_FILE_STOPPED;
-      return FALSE;
+      return false;
     }
 
   if (m_input)
     }
 
   if (m_input)
@@ -258,35 +264,35 @@ bool wxSoundFileStream::Stop()
     m_output->SeekO(0, wxFromStart);
  
   m_state = wxSOUND_FILE_STOPPED;
     m_output->SeekO(0, wxFromStart);
  
   m_state = wxSOUND_FILE_STOPPED;
-  return TRUE;
+  return true;
 }
 
 bool wxSoundFileStream::Pause()
 {
   if (m_state == wxSOUND_FILE_PAUSED || m_state == wxSOUND_FILE_STOPPED)
 }
 
 bool wxSoundFileStream::Pause()
 {
   if (m_state == wxSOUND_FILE_PAUSED || m_state == wxSOUND_FILE_STOPPED)
-    return FALSE;
+    return false;
 
   if (!StopProduction())
 
   if (!StopProduction())
-    return FALSE;
+    return false;
 
   m_oldstate = m_state;
   m_state = wxSOUND_FILE_PAUSED;
 
   m_oldstate = m_state;
   m_state = wxSOUND_FILE_PAUSED;
-  return TRUE;
+  return true;
 }
 
 bool wxSoundFileStream::Resume()
 {
   if (m_state == wxSOUND_FILE_PLAYING || m_state == wxSOUND_FILE_RECORDING ||
       m_state == wxSOUND_FILE_STOPPED)
 }
 
 bool wxSoundFileStream::Resume()
 {
   if (m_state == wxSOUND_FILE_PLAYING || m_state == wxSOUND_FILE_RECORDING ||
       m_state == wxSOUND_FILE_STOPPED)
-    return FALSE;
+    return false;
 
   if (!StartProduction( (m_oldstate == wxSOUND_FILE_PLAYING) ?
                              wxSOUND_OUTPUT : wxSOUND_INPUT))
 
   if (!StartProduction( (m_oldstate == wxSOUND_FILE_PLAYING) ?
                              wxSOUND_OUTPUT : wxSOUND_INPUT))
-    return FALSE;
+    return false;
 
   m_state = m_oldstate;
 
 
   m_state = m_oldstate;
 
-  return TRUE;
+  return true;
 }
 
 wxSoundStream& wxSoundFileStream::Read(void *buffer, wxUint32 len)
 }
 
 wxSoundStream& wxSoundFileStream::Read(void *buffer, wxUint32 len)
@@ -316,9 +322,9 @@ bool wxSoundFileStream::StartProduction(int evt)
   m_sndio->SetEventHandler(this);
 
   if (!m_codec.StartProduction(evt))
   m_sndio->SetEventHandler(this);
 
   if (!m_codec.StartProduction(evt))
-    return FALSE;
+    return false;
 
 
-  return TRUE;
+  return true;
 }
 
 bool wxSoundFileStream::StopProduction()
 }
 
 bool wxSoundFileStream::StopProduction()
@@ -329,7 +335,7 @@ bool wxSoundFileStream::StopProduction()
 void wxSoundFileStream::FinishPreparation(wxUint32 len)
 {
   m_bytes_left = m_length = len;
 void wxSoundFileStream::FinishPreparation(wxUint32 len)
 {
   m_bytes_left = m_length = len;
-  m_prepared = TRUE;
+  m_prepared = true;
 }
 
 wxString wxSoundFileStream::GetCodecName() const
 }
 
 wxString wxSoundFileStream::GetCodecName() const