#pragma hdrstop
 #endif
 
-#ifdef HAVE_ESD_H
-
 // --------------------------------------------------------------------------
 // MMedia headers
 // --------------------------------------------------------------------------
 // System headers
 // --------------------------------------------------------------------------
 
+#ifdef HAVE_ESD_H
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <unistd.h>
 #ifdef __WXGTK__
 #include <gdk/gdk.h>
 #endif
+#endif
 
 // --------------------------------------------------------------------------
 
 
 wxSoundStreamESD::wxSoundStreamESD(const wxString& hostname)
 {
+#ifndef HAVE_ESD_H
+    m_snderror = wxSOUND_INVDEV;
+    return;
+#else
     wxSoundFormatPcm pcm_default;
     
     // First, we make some basic test: is there ESD on this computer ?
     m_esd_ok   = TRUE;
     m_fd_output= -1;
     m_fd_input = -1;
+#endif // defined HAVE_ESD_H
 }
 
 wxSoundStreamESD::~wxSoundStreamESD()
 {
+#ifdef HAVE_ESD_H
     if (!m_esd_stop)
         StopProduction();
+#endif // defined HAVE_ESD_H
 }
 
 // --------------------------------------------------------------------------
 
 wxSoundStream& wxSoundStreamESD::Read(void *buffer, wxUint32 len)
 {
+#ifndef HAVE_ESD_H
+    m_snderror = wxSOUND_INVDEV;
+    return *this;
+#else
     int ret;
     
     if (m_esd_stop) {
         m_snderror = wxSOUND_NOERROR;
     
     return *this;
+#endif // defined HAVE_ESD_H
 }
 
 // --------------------------------------------------------------------------
 // --------------------------------------------------------------------------
 wxSoundStream& wxSoundStreamESD::Write(const void *buffer, wxUint32 len)
 {
+#ifndef HAVE_ESD_H
+    m_snderror = wxSOUND_INVDEV;
+    return *this;
+#else
     int ret;
 
     if (m_esd_stop) {
     m_q_filled = TRUE;
     
     return *this;
+#endif // defined HAVE_ESD_H
 }
 
 // --------------------------------------------------------------------------
 // --------------------------------------------------------------------------
 bool wxSoundStreamESD::SetSoundFormat(const wxSoundFormatBase& format)
 {
+#ifndef HAVE_ESD_H
+    m_snderror = wxSOUND_INVDEV;
+    return FALSE;
+#else
     wxSoundFormatPcm *pcm_format;
     
     if (format.GetType() != wxSOUND_PCM) {
         return FALSE;
     }
     return TRUE;
+#endif // defined HAVE_ESD_H
 }
 
 // --------------------------------------------------------------------------
 // _wxSound_OSS_CBack (internal): it is called when the driver (ESD) is
 // ready for a next buffer.
 // --------------------------------------------------------------------------
-#ifdef __WXGTK__
+#if defined(__WXGTK__) && defined(HAVE_ESD_H)
 static void _wxSound_OSS_CBack(gpointer data, int source,
                                GdkInputCondition condition)
 {
 // --------------------------------------------------------------------------
 bool wxSoundStreamESD::StartProduction(int evt)
 {
+#ifndef HAVE_ESD_H
+    m_snderror = wxSOUND_INVDEV;
+    return FALSE;
+#else
     wxSoundFormatPcm *pcm;
     int flag = 0;
 
     m_q_filled = FALSE;
     
     return TRUE;
+#endif // defined HAVE_ESD_H
 }
 
 // --------------------------------------------------------------------------
 // --------------------------------------------------------------------------
 bool wxSoundStreamESD::StopProduction()
 {
+#ifndef HAVE_ESD_H
+    m_snderror = wxSOUND_INVDEV;
+    return FALSE;
+#else
     if (m_esd_stop)
         return FALSE;
     
     m_esd_stop = TRUE;
     m_q_filled = TRUE;
     return TRUE;
+#endif // defined HAVE_ESD_H
 }
 
 //
 //
 void wxSoundStreamESD::DetectBest(wxSoundFormatPcm *pcm)
 {
+#ifndef HAVE_ESD_H
+    m_snderror = wxSOUND_INVDEV;
+    return;
+#else
     wxSoundFormatPcm best_pcm;
 
     // We change neither the number of channels nor the sample rate
     
     // Finally recopy the new format
     *pcm = best_pcm;
+#endif // defined HAVE_ESD_H
 }
 
-#endif // HAVE_ESD_H