]> git.saurik.com Git - wxWidgets.git/blobdiff - utils/wxMMedia2/lib/sndwin.cpp
Now wxGIFDecoder always tries to read to the end of the GIF data.
[wxWidgets.git] / utils / wxMMedia2 / lib / sndwin.cpp
index 0d67b5ab890a563e58ea74cfad51d59d682a595c..f09231ee0d6813f096069b4ff95b1014fadd6635 100644 (file)
@@ -2,7 +2,7 @@
 // Name: sndwin.cpp
 // Purpose:
 // Date: 08/11/1999
-// Author: Guilhem Lavaux <lavaux@easynet.fr> (C) 1999
+// Author: Guilhem Lavaux <lavaux@easynet.fr> (C) 1999, 2000
 // CVSID: $Id$
 // --------------------------------------------------------------------------
 #include <wx/wxprec.h>
@@ -59,6 +59,11 @@ wxSoundStreamWin::wxSoundStreamWin()
 
   m_production_started = FALSE;
   m_internal = new wxSoundInternal;
+  if (!m_internal) {
+    m_snderror = wxSOUND_MEMERR;
+    m_internal = NULL;
+    return;
+  }
   m_snderror = wxSOUND_NOERR;
 
   // Setup defaults
@@ -78,11 +83,13 @@ wxSoundStreamWin::wxSoundStreamWin()
 
 wxSoundStreamWin::~wxSoundStreamWin()
 {
-  if (m_production_started)
-    StopProduction();
-  DestroySndWindow();
+  if (m_internal) {
+    if (m_production_started)
+      StopProduction();
+    DestroySndWindow();
 
-  delete m_internal;
+    delete m_internal;
+  }
 }
 
 LRESULT APIENTRY _EXPORT _wxSoundHandlerWndProc(HWND hWnd, UINT message,
@@ -651,6 +658,9 @@ bool wxSoundStreamWin::SetSoundFormat(wxSoundFormatBase& base)
 // -------------------------------------------------------------------------
 bool wxSoundStreamWin::StartProduction(int evt)
 {
+  if (!m_internal)
+    return FALSE;
+
   if ((m_internal->m_output_enabled && (evt & wxSOUND_OUTPUT)) ||
       (m_internal->m_input_enabled && (evt & wxSOUND_INPUT)))
     CloseDevice();
@@ -679,6 +689,9 @@ bool wxSoundStreamWin::StartProduction(int evt)
 // -------------------------------------------------------------------------
 bool wxSoundStreamWin::StopProduction()
 {
+  if (!m_production_started)
+    return FALSE;
+
   m_production_started = FALSE;
   CloseDevice();
   return TRUE;