]> git.saurik.com Git - wxWidgets.git/blobdiff - contrib/samples/mmedia/mmbman.cpp
Re-adding setup0.h for OpenWatcom makefile build.
[wxWidgets.git] / contrib / samples / mmedia / mmbman.cpp
index fbb30965a56ef689974eaee33c7514ea1873c47b..ab4f5c8c5477e8465dfa0fbefa9ed853833292b1 100644 (file)
@@ -10,7 +10,7 @@
 /////////////////////////////////////////////////////////////////////////////
 
 #ifdef __GNUG__
 /////////////////////////////////////////////////////////////////////////////
 
 #ifdef __GNUG__
-  #pragma implementation "mmbman.cpp"
+  #pragma implementation "mmbman.h"
 #endif
 
 // ----------------------------------------------------------------------------
 #endif
 
 // ----------------------------------------------------------------------------
@@ -25,7 +25,7 @@
 #endif
 
 // for all others, include the necessary headers (this file is usually all you
 #endif
 
 // for all others, include the necessary headers (this file is usually all you
-// need because it includes almost all "standard" wxWindows headers
+// need because it includes almost all "standard" wxWidgets headers
 #ifndef WX_PRECOMP
     #include "wx/wx.h"
 #endif
 #ifndef WX_PRECOMP
     #include "wx/wx.h"
 #endif
@@ -72,29 +72,29 @@ class MMBoardSoundFile: public MMBoardFile {
 public:
     MMBoardSoundFile(const wxString& filename);
     ~MMBoardSoundFile();
 public:
     MMBoardSoundFile(const wxString& filename);
     ~MMBoardSoundFile();
-    
+
     bool NeedWindow();
     bool NeedWindow();
-    
+
     void SetWindow(wxWindow *window);
     void SetWindow(wxWindow *window);
-    
+
     void Play();
     void Pause();
     void Resume();
     void Stop();
     void Play();
     void Pause();
     void Resume();
     void Stop();
-    
+
     MMBoardTime GetPosition();
     MMBoardTime GetLength();
     void SetPosition(MMBoardTime btime);
     MMBoardTime GetPosition();
     MMBoardTime GetLength();
     void SetPosition(MMBoardTime btime);
-    
+
     bool IsStopped();
     bool IsPaused();
     bool IsStopped();
     bool IsPaused();
-    
+
     wxString GetStringType();
     wxString GetStringInformation();
     wxString GetStringType();
     wxString GetStringInformation();
-    
+
 protected:
     wxSoundFileStream *GetDecoder();
 protected:
     wxSoundFileStream *GetDecoder();
-    
+
     wxSoundStream *m_output_stream;
     wxInputStream *m_input_stream;
     wxSoundFileStream *m_file_stream;
     wxSoundStream *m_output_stream;
     wxInputStream *m_input_stream;
     wxSoundFileStream *m_file_stream;
@@ -107,26 +107,26 @@ class MMBoardVideoFile: public MMBoardFile {
 public:
     MMBoardVideoFile(const wxString& filename);
     ~MMBoardVideoFile();
 public:
     MMBoardVideoFile(const wxString& filename);
     ~MMBoardVideoFile();
-    
+
     bool NeedWindow();
     bool NeedWindow();
-    
+
     void SetWindow(wxWindow *window);
     void SetWindow(wxWindow *window);
-    
+
     void Play();
     void Pause();
     void Resume();
     void Stop();
     void Play();
     void Pause();
     void Resume();
     void Stop();
-    
+
     MMBoardTime GetPosition();
     MMBoardTime GetLength();
     void SetPosition(MMBoardTime btime);
     MMBoardTime GetPosition();
     MMBoardTime GetLength();
     void SetPosition(MMBoardTime btime);
-    
+
     bool IsStopped();
     bool IsPaused();
     bool IsStopped();
     bool IsPaused();
-    
+
     wxString GetStringType();
     wxString GetStringInformation();
     wxString GetStringType();
     wxString GetStringInformation();
-    
+
 protected:
     wxWindow *m_output_window;
     wxVideoBaseDriver *m_video_driver;
 protected:
     wxWindow *m_output_window;
     wxVideoBaseDriver *m_video_driver;
@@ -148,14 +148,14 @@ MMBoardSoundFile::MMBoardSoundFile(const wxString& filename)
 {
     m_input_stream = new wxFileInputStream(filename);
     m_output_stream = MMBoardManager::OpenSoundStream();
 {
     m_input_stream = new wxFileInputStream(filename);
     m_output_stream = MMBoardManager::OpenSoundStream();
-    
+
     m_file_stream = GetDecoder();
     m_file_stream = GetDecoder();
-    
+
     if (!m_file_stream) {
         SetError(MMBoard_UnknownFile);
         return;
     }
     if (!m_file_stream) {
         SetError(MMBoard_UnknownFile);
         return;
     }
-    
+
     // Compute length
     wxUint32 length, seconds;
 
     // Compute length
     wxUint32 length, seconds;
 
@@ -177,25 +177,25 @@ MMBoardSoundFile::~MMBoardSoundFile()
 wxSoundFileStream *MMBoardSoundFile::GetDecoder()
 {
     wxSoundFileStream *f_stream;
 wxSoundFileStream *MMBoardSoundFile::GetDecoder()
 {
     wxSoundFileStream *f_stream;
-    
+
     // First, we try a Wave decoder
     f_stream = new wxSoundWave(*m_input_stream, *m_output_stream);
     m_file_type = MMBoard_WAVE;
     if (f_stream->CanRead())
         return f_stream;
     delete f_stream;
     // First, we try a Wave decoder
     f_stream = new wxSoundWave(*m_input_stream, *m_output_stream);
     m_file_type = MMBoard_WAVE;
     if (f_stream->CanRead())
         return f_stream;
     delete f_stream;
-    
+
     // Then, a AIFF decoder
     f_stream = new wxSoundAiff(*m_input_stream, *m_output_stream);
     m_file_type = MMBoard_AIFF;
     if (f_stream->CanRead())
         return f_stream;
     delete f_stream;
     // Then, a AIFF decoder
     f_stream = new wxSoundAiff(*m_input_stream, *m_output_stream);
     m_file_type = MMBoard_AIFF;
     if (f_stream->CanRead())
         return f_stream;
     delete f_stream;
-    
+
     m_file_type = MMBoard_UNKNOWNTYPE;
     m_file_type = MMBoard_UNKNOWNTYPE;
-    
+
     // TODO: automate
     // TODO: automate
-    
+
     return NULL;
 }
 
     return NULL;
 }
 
@@ -218,17 +218,17 @@ MMBoardTime MMBoardSoundFile::GetPosition()
 {
     wxUint32 length, seconds;
     MMBoardTime file_time;
 {
     wxUint32 length, seconds;
     MMBoardTime file_time;
-    
+
     file_time.seconds = file_time.minutes = file_time.hours = 0;
     if (m_file_stream->IsStopped())
         return file_time;
     file_time.seconds = file_time.minutes = file_time.hours = 0;
     if (m_file_stream->IsStopped())
         return file_time;
-    
+
     length = m_file_stream->GetPosition();
     seconds = m_file_stream->GetSoundFormat().GetTimeFromBytes(length);
     file_time.seconds = seconds % 60;
     file_time.minutes = (seconds / 60) % 60;
     file_time.hours   = seconds / 3600;
     length = m_file_stream->GetPosition();
     seconds = m_file_stream->GetSoundFormat().GetTimeFromBytes(length);
     file_time.seconds = seconds % 60;
     file_time.minutes = (seconds / 60) % 60;
     file_time.hours   = seconds / 3600;
-    
+
     return file_time;
 }
 
     return file_time;
 }
 
@@ -245,7 +245,7 @@ void MMBoardSoundFile::SetPosition(MMBoardTime btime)
 
 bool MMBoardSoundFile::NeedWindow()
 {
 
 bool MMBoardSoundFile::NeedWindow()
 {
-    return FALSE;
+    return false;
 }
 
 void MMBoardSoundFile::SetWindow(wxWindow *WXUNUSED(window))
 }
 
 void MMBoardSoundFile::SetWindow(wxWindow *WXUNUSED(window))
@@ -302,25 +302,25 @@ wxString MMBoardSoundFile::GetStringInformation()
 {
     wxString info;
     wxSoundFormatBase *format;
 {
     wxString info;
     wxSoundFormatBase *format;
-    
+
     format = &(m_file_stream->GetSoundFormat());
     format = &(m_file_stream->GetSoundFormat());
-    
+
     info = wxT("Data encoding: ");
     switch (format->GetType()) {
     case wxSOUND_PCM: {
         wxSoundFormatPcm *pcm_format = (wxSoundFormatPcm *)format;
     info = wxT("Data encoding: ");
     switch (format->GetType()) {
     case wxSOUND_PCM: {
         wxSoundFormatPcm *pcm_format = (wxSoundFormatPcm *)format;
-      
-       info += wxString::Format(wxT("PCM %s %s\n"),
+
+    info += wxString::Format(wxT("PCM %s %s\n"),
                                  pcm_format->Signed() ? wxT("signed") : wxT("unsigned"),
                                  pcm_format->GetOrder() == wxLITTLE_ENDIAN ? wxT("little endian") : wxT("big endian"));
                                  pcm_format->Signed() ? wxT("signed") : wxT("unsigned"),
                                  pcm_format->GetOrder() == wxLITTLE_ENDIAN ? wxT("little endian") : wxT("big endian"));
-       info += wxString::Format(wxT("Sampling rate: %d\n")
-                                wxT("Bits per sample: %d\n")
-                                wxT("Number of channels: %d\n"),
-                                pcm_format->GetSampleRate(),
-                                pcm_format->GetBPS(),
-                                pcm_format->GetChannels());
-       
-       break;
+    info += wxString::Format(wxT("Sampling rate: %d\n")
+                 wxT("Bits per sample: %d\n")
+                 wxT("Number of channels: %d\n"),
+                 pcm_format->GetSampleRate(),
+                 pcm_format->GetBPS(),
+                 pcm_format->GetChannels());
+
+    break;
     }
     case wxSOUND_MSADPCM: {
         wxSoundFormatMSAdpcm *adpcm_format = (wxSoundFormatMSAdpcm *)format;
     }
     case wxSOUND_MSADPCM: {
         wxSoundFormatMSAdpcm *adpcm_format = (wxSoundFormatMSAdpcm *)format;
@@ -334,13 +334,13 @@ wxString MMBoardSoundFile::GetStringInformation()
     }
     case wxSOUND_ULAW: {
         wxSoundFormatUlaw *ulaw_format = (wxSoundFormatUlaw *)format;
     }
     case wxSOUND_ULAW: {
         wxSoundFormatUlaw *ulaw_format = (wxSoundFormatUlaw *)format;
-       info += wxT("ULAW\n");
-       info += wxString::Format(wxT("Sampling rate: %d\n"), ulaw_format->GetSampleRate());
-       break;
+        info += wxT("ULAW\n");
+        info += wxString::Format(wxT("Sampling rate: %d\n"), ulaw_format->GetSampleRate());
+        break;
     }
     default:
         info += wxT("Unknown");
     }
     default:
         info += wxT("Unknown");
-       break;
+        break;
     }
     return info;
 }
     }
     return info;
 }
@@ -354,12 +354,15 @@ wxString MMBoardSoundFile::GetStringInformation()
 MMBoardVideoFile::MMBoardVideoFile(const wxString& filename)
 {
     m_output_window = NULL;
 MMBoardVideoFile::MMBoardVideoFile(const wxString& filename)
 {
     m_output_window = NULL;
-  
-#if defined(__UNIX__)
+
+#if defined(__UNIX__) && !defined(__CYGWIN__)
     m_video_driver = new wxVideoXANIM(filename);
     m_video_driver = new wxVideoXANIM(filename);
-#elif defined(__WIN32__)
+#elif defined(__WINDOWS__) && !defined(__MINGW32__) && !defined(__WATCOMC__) && !defined(__CYGWIN__)
+    // versions of Open Watcom and MinGW tested against this source does not
+    // deliver "digitalv.h" required in this feature
     m_video_driver = new wxVideoWindows(filename);
 #else
     m_video_driver = new wxVideoWindows(filename);
 #else
+    wxUnusedVar(filename);
     m_video_driver = NULL;
     SetError(MMBoard_UnknownFile);
 #endif
     m_video_driver = NULL;
     SetError(MMBoard_UnknownFile);
 #endif
@@ -373,7 +376,7 @@ MMBoardVideoFile::~MMBoardVideoFile()
 
 bool MMBoardVideoFile::NeedWindow()
 {
 
 bool MMBoardVideoFile::NeedWindow()
 {
-    return TRUE;
+    return true;
 }
 
 void MMBoardVideoFile::SetWindow(wxWindow *window)
 }
 
 void MMBoardVideoFile::SetWindow(wxWindow *window)
@@ -423,7 +426,7 @@ MMBoardTime MMBoardVideoFile::GetLength()
     int frameTime;
 
     frameTime = (int)( m_video_driver->GetNbFrames() / m_video_driver->GetFrameRate());
     int frameTime;
 
     frameTime = (int)( m_video_driver->GetNbFrames() / m_video_driver->GetFrameRate());
-    
+
     btime.seconds = frameTime % 60;
     btime.minutes = (frameTime / 60) % 60;
     btime.hours   = frameTime / 3600;
     btime.seconds = frameTime % 60;
     btime.minutes = (frameTime / 60) % 60;
     btime.hours   = frameTime / 3600;
@@ -507,7 +510,10 @@ DECLARE_APP(MMBoardApp)
 
 wxSoundStream *MMBoardManager::OpenSoundStream()
 {
 
 wxSoundStream *MMBoardManager::OpenSoundStream()
 {
-#ifdef __UNIX__
+#ifdef __WIN32__
+  if ((wxGetApp().m_caps & MM_SOUND_WIN) != 0)
+    return new wxSoundStreamWin();
+#elif __UNIX__
   if ((wxGetApp().m_caps & MM_SOUND_ESD) != 0)
     return new wxSoundStreamESD();
 
   if ((wxGetApp().m_caps & MM_SOUND_ESD) != 0)
     return new wxSoundStreamESD();
 
@@ -515,11 +521,6 @@ wxSoundStream *MMBoardManager::OpenSoundStream()
     return new wxSoundStreamOSS();
 #endif
 
     return new wxSoundStreamOSS();
 #endif
 
-#ifdef __WIN32__
-  if ((wxGetApp().m_caps & MM_SOUND_WIN) != 0)
-    return new wxSoundStreamWin();
-#endif
-
   wxMessageBox(_T("You are trying to open a multimedia but you have not devices"), _T("Error"), wxOK | wxICON_ERROR, NULL);
 
   return NULL;
   wxMessageBox(_T("You are trying to open a multimedia but you have not devices"), _T("Error"), wxOK | wxICON_ERROR, NULL);
 
   return NULL;