]> git.saurik.com Git - wxWidgets.git/blobdiff - utils/wxMMedia/sndfrmt.cpp
fixed somebody's poorly done StreamSize-->GetSize transition
[wxWidgets.git] / utils / wxMMedia / sndfrmt.cpp
index a489109d1e2388db27ef61798341980b2e54f4e9..fc9aa77654e3d0ad19c4a08c7476dae40fcea11c 100644 (file)
@@ -1,3 +1,12 @@
+////////////////////////////////////////////////////////////////////////////////
+// Name:       sndfrmt.cpp
+// Purpose:    wxMMedia
+// Author:     Guilhem Lavaux
+// Created:    1998
+// Updated:    December 1998
+// Copyright:  (C) 1997, 1998, Guilhem Lavaux
+// License:    wxWindows license
+////////////////////////////////////////////////////////////////////////////////
 #ifdef __GNUG__
 #pragma implementation "sndfrmt.h"
 #endif
@@ -81,6 +90,7 @@ wxSoundCodec *wxSoundDataFormat::GetCodec()
 
   m_codchange = FALSE;
   m_codec = wxSoundCodec::Get(m_codno);
+  CodecChange();
 
   return m_codec;
 }
@@ -96,12 +106,15 @@ void wxSoundDataFormat::CodecChange()
   case WXSOUND_PCM: {
       wxSoundPcmCodec *pcm_codec = (wxSoundPcmCodec *)codec;
 
-      pcm_codec->SetBits(m_bps);
-      pcm_codec->SetByteOrder(m_byteorder);
-      pcm_codec->SetSign(m_sign);
+      pcm_codec->m_orig_format.SetSampleRate(m_srate);
+      pcm_codec->m_orig_format.SetBps(m_bps);
+      pcm_codec->m_orig_format.SetChannels(m_channels);
+      pcm_codec->m_orig_format.SetByteOrder(m_byteorder);
+      pcm_codec->m_orig_format.SetSign(m_sign);
       break;
     }
   default:
+      codec->InitWith(*this);
       break;
   }
 }
@@ -138,19 +151,19 @@ bool wxSoundDataFormat::operator ==(const wxSoundDataFormat& format) const
 // ----------------------------------------------------------------------------
 
 #include "sndpcm.h"
-//#include "sndadpcm.h"
+#include "sndadpcm.h"
 //#include "sndalaw.h"
 #include "sndmulaw.h"
 
 static wxClassInfo *l_sound_formats[] = {
       NULL,
       CLASSINFO(wxSoundPcmCodec),
-      NULL, //  CLASSINFO(wxSoundAdpcmCodec),
+      CLASSINFO(wxSoundAdpcmCodec),
       NULL,
       NULL,
       NULL,
       NULL, // CLASSINFO(wxSoundAlawCodec),
-      NULL  // CLASSINFO(wxSoundMulawCodec)
+      CLASSINFO(wxSoundMulawCodec)
 };
 
 static int l_nb_formats = WXSIZEOF(l_sound_formats);
@@ -165,6 +178,8 @@ wxSoundCodec::wxSoundCodec()
 
 wxSoundCodec::~wxSoundCodec()
 {
+  if (m_mode != WAITING)
+    ExitMode();
 }
 
 void wxSoundCodec::InitIO(const wxSoundDataFormat& format)
@@ -172,13 +187,13 @@ void wxSoundCodec::InitIO(const wxSoundDataFormat& format)
   m_io_format = format;
 }
 
-void wxSoundCodec::InitMode(int mode)
+void wxSoundCodec::InitMode(ModeType mode)
 {
   wxStreamBuffer *buf_snd;
 
-  m_mode = (mode == 0) ? ENCODING : DECODING;
+  m_mode = mode;
   if (!m_chain_codec) {
-    if (mode == ENCODING) {
+    if (m_mode == ENCODING) {
       m_out_sound = new wxStreamBuffer(*this, wxStreamBuffer::write);
       m_out_sound->SetBufferIO(1024);
     } else {
@@ -219,6 +234,7 @@ void wxSoundCodec::ExitMode()
       m_out_sound = m_chain_codec->GetOutStream();
     }
   }
+  m_mode = WAITING;
 }
 
 bool wxSoundCodec::ChainCodecBefore(wxSoundDataFormat& format)