X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/15e8daecf594d38a57bc750f58de0ea33b79f4ee..19b44116d5c04181f9a20f92546cff26405ed115:/contrib/src/mmedia/sndesd.cpp?ds=sidebyside diff --git a/contrib/src/mmedia/sndesd.cpp b/contrib/src/mmedia/sndesd.cpp index e3d6860253..f7c74b7c07 100644 --- a/contrib/src/mmedia/sndesd.cpp +++ b/contrib/src/mmedia/sndesd.cpp @@ -20,8 +20,6 @@ #pragma hdrstop #endif -#ifdef HAVE_ESD_H - // -------------------------------------------------------------------------- // MMedia headers // -------------------------------------------------------------------------- @@ -34,6 +32,7 @@ // System headers // -------------------------------------------------------------------------- +#ifdef HAVE_ESD_H #include #include #include @@ -41,10 +40,11 @@ #ifdef __WXGTK__ #include #endif +#endif // -------------------------------------------------------------------------- -#define MY_ESD_NAME "wxWindows/wxSoundStreamESD" +#define MY_ESD_NAME "wxWidgets/wxSoundStreamESD" // -------------------------------------------------------------------------- // wxSoundStreamESD: ESD sound driver @@ -55,10 +55,14 @@ 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 = FALSE; + m_esd_ok = false; if (hostname.IsNull()) m_fd_output = esd_play_stream(ESD_PLAY | ESD_STREAM, 22050, @@ -82,17 +86,20 @@ wxSoundStreamESD::wxSoundStreamESD(const wxString& hostname) // Initialize some variable m_snderror = wxSOUND_NOERROR; - m_esd_stop = TRUE; - m_q_filled = TRUE; - m_esd_ok = TRUE; + m_esd_stop = true; + m_q_filled = true; + 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 } // -------------------------------------------------------------------------- @@ -101,6 +108,10 @@ wxSoundStreamESD::~wxSoundStreamESD() wxSoundStream& wxSoundStreamESD::Read(void *buffer, wxUint32 len) { +#ifndef HAVE_ESD_H + m_snderror = wxSOUND_INVDEV; + return *this; +#else int ret; if (m_esd_stop) { @@ -116,6 +127,7 @@ wxSoundStream& wxSoundStreamESD::Read(void *buffer, wxUint32 len) m_snderror = wxSOUND_NOERROR; return *this; +#endif // defined HAVE_ESD_H } // -------------------------------------------------------------------------- @@ -123,6 +135,10 @@ wxSoundStream& wxSoundStreamESD::Read(void *buffer, wxUint32 len) // -------------------------------------------------------------------------- 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) { @@ -138,9 +154,10 @@ wxSoundStream& wxSoundStreamESD::Write(const void *buffer, wxUint32 len) else m_snderror = wxSOUND_NOERROR; - m_q_filled = TRUE; + m_q_filled = true; return *this; +#endif // defined HAVE_ESD_H } // -------------------------------------------------------------------------- @@ -149,16 +166,20 @@ wxSoundStream& wxSoundStreamESD::Write(const void *buffer, wxUint32 len) // -------------------------------------------------------------------------- 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) { m_snderror = wxSOUND_INVFRMT; - return FALSE; + return false; } if (!m_esd_ok) { m_snderror = wxSOUND_INVDEV; - return FALSE; + return false; } if (m_sndformat) @@ -167,7 +188,7 @@ bool wxSoundStreamESD::SetSoundFormat(const wxSoundFormatBase& format) m_sndformat = format.Clone(); if (!m_sndformat) { m_snderror = wxSOUND_MEMERROR; - return FALSE; + return false; } pcm_format = (wxSoundFormatPcm *)m_sndformat; @@ -177,16 +198,17 @@ bool wxSoundStreamESD::SetSoundFormat(const wxSoundFormatBase& format) m_snderror = wxSOUND_NOERROR; if (*pcm_format != format) { m_snderror = wxSOUND_NOEXACT; - return FALSE; + return false; } - return TRUE; + 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) { @@ -212,7 +234,7 @@ static void _wxSound_OSS_CBack(gpointer data, int source, // -------------------------------------------------------------------------- void wxSoundStreamESD::WakeUpEvt(int evt) { - m_q_filled = FALSE; + m_q_filled = false; OnSoundEvent(evt); } @@ -221,12 +243,16 @@ void wxSoundStreamESD::WakeUpEvt(int evt) // -------------------------------------------------------------------------- bool wxSoundStreamESD::StartProduction(int evt) { +#ifndef HAVE_ESD_H + m_snderror = wxSOUND_INVDEV; + return false; +#else wxSoundFormatPcm *pcm; int flag = 0; if (!m_esd_ok) { m_snderror = wxSOUND_INVDEV; - return FALSE; + return false; } if (!m_esd_stop) @@ -260,10 +286,11 @@ bool wxSoundStreamESD::StartProduction(int evt) } #endif - m_esd_stop = FALSE; - m_q_filled = FALSE; + m_esd_stop = false; + m_q_filled = false; - return TRUE; + return true; +#endif // defined HAVE_ESD_H } // -------------------------------------------------------------------------- @@ -271,8 +298,12 @@ bool wxSoundStreamESD::StartProduction(int evt) // -------------------------------------------------------------------------- bool wxSoundStreamESD::StopProduction() { +#ifndef HAVE_ESD_H + m_snderror = wxSOUND_INVDEV; + return false; +#else if (m_esd_stop) - return FALSE; + return false; if (m_fd_input != -1) { esd_close(m_fd_input); @@ -289,9 +320,10 @@ bool wxSoundStreamESD::StopProduction() m_fd_input = -1; m_fd_output= -1; - m_esd_stop = TRUE; - m_q_filled = TRUE; - return TRUE; + m_esd_stop = true; + m_q_filled = true; + return true; +#endif // defined HAVE_ESD_H } // @@ -299,6 +331,10 @@ bool wxSoundStreamESD::StopProduction() // 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 @@ -314,10 +350,10 @@ void wxSoundStreamESD::DetectBest(wxSoundFormatPcm *pcm) best_pcm.SetBPS(8); best_pcm.SetOrder(wxLITTLE_ENDIAN); - best_pcm.Signed(TRUE); + best_pcm.Signed(true); // Finally recopy the new format *pcm = best_pcm; +#endif // defined HAVE_ESD_H } -#endif // HAVE_ESD_H