X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6c5e63761c870ea4918a3fe049f99fce6707b938..6a94433573bab16bcfe85985333323523e4b8517:/utils/wxMMedia2/lib/sndfile.cpp diff --git a/utils/wxMMedia2/lib/sndfile.cpp b/utils/wxMMedia2/lib/sndfile.cpp index 6525d2bbc6..1234726300 100644 --- a/utils/wxMMedia2/lib/sndfile.cpp +++ b/utils/wxMMedia2/lib/sndfile.cpp @@ -16,6 +16,7 @@ #include "sndfile.h" #include "sndcpcm.h" #include "sndulaw.h" +#include "sndg72x.h" // -------------------------------------------------------------------------- // Sound codec router @@ -33,7 +34,7 @@ wxSoundRouterStream::~wxSoundRouterStream() delete m_router; } -wxSoundStream& wxSoundRouterStream::Read(void *buffer, size_t len) +wxSoundStream& wxSoundRouterStream::Read(void *buffer, wxUint32 len) { if (m_router) { m_router->Read(buffer, len); @@ -47,7 +48,7 @@ wxSoundStream& wxSoundRouterStream::Read(void *buffer, size_t len) return *this; } -wxSoundStream& wxSoundRouterStream::Write(const void *buffer, size_t len) +wxSoundStream& wxSoundRouterStream::Write(const void *buffer, wxUint32 len) { if (m_router) { m_router->Write(buffer, len); @@ -82,6 +83,10 @@ bool wxSoundRouterStream::SetSoundFormat(const wxSoundFormatBase& format) m_router = new wxSoundStreamUlaw(*m_sndio); m_router->SetSoundFormat(format); break; + case wxSOUND_G72X: + m_router = new wxSoundStreamG72X(*m_sndio); + m_router->SetSoundFormat(format); + break; } wxSoundStream::SetSoundFormat(m_router->GetSoundFormat()); return TRUE; @@ -158,10 +163,11 @@ bool wxSoundFileStream::Play() if (!PrepareToPlay()) return FALSE; + m_state = wxSOUND_FILE_PLAYING; + if (!StartProduction(wxSOUND_OUTPUT)) return FALSE; - m_state = wxSOUND_FILE_PLAYING; return TRUE; } @@ -175,10 +181,10 @@ bool wxSoundFileStream::Record(unsigned long time) m_len = m_sndformat->GetBytesFromTime(time); + m_state = wxSOUND_FILE_RECORDING; if (!StartProduction(wxSOUND_INPUT)) return FALSE; - m_state = wxSOUND_FILE_RECORDING; return TRUE; } @@ -229,13 +235,13 @@ bool wxSoundFileStream::Resume() return TRUE; } -wxSoundStream& wxSoundFileStream::Read(void *buffer, size_t len) +wxSoundStream& wxSoundFileStream::Read(void *buffer, wxUint32 len) { m_lastcount = GetData(buffer, len); return *this; } -wxSoundStream& wxSoundFileStream::Write(const void *buffer, size_t len) +wxSoundStream& wxSoundFileStream::Write(const void *buffer, wxUint32 len) { m_lastcount = PutData(buffer, len); return *this; @@ -262,33 +268,35 @@ bool wxSoundFileStream::StopProduction() void wxSoundFileStream::OnSoundEvent(int evt) { - size_t len = m_sndio->GetBestSize(); + wxUint32 len = m_sndio->GetBestSize(); char *buffer; - buffer = new char[m_sndio->GetBestSize()]; + buffer = new char[len]; wxSoundStream::OnSoundEvent(evt); - switch(evt) { - case wxSOUND_INPUT: - if (len > m_len) - len = m_len; - - len = m_codec.Read(buffer, len).GetLastAccess(); - PutData(buffer, len); - m_len -= len; - if (m_len == 0) { - Stop(); - return; + while (!m_sndio->QueueFilled()) { + switch(evt) { + case wxSOUND_INPUT: + if (len > m_len) + len = m_len; + + len = m_codec.Read(buffer, len).GetLastAccess(); + PutData(buffer, len); + m_len -= len; + if (m_len == 0) { + Stop(); + return; + } + break; + case wxSOUND_OUTPUT: + len = GetData(buffer, len); + if (len == 0) { + Stop(); + return; + } + m_codec.Write(buffer, len); + break; } - break; - case wxSOUND_OUTPUT: - len = GetData(buffer, len); - if (len == 0) { - Stop(); - return; - } - m_codec.Write(buffer, len); - break; } delete[] buffer; }