X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/526ddb13e289be62ee1926c265138c0dea36fa56..0185cd097844887c308a81fbd137676086ae8580:/utils/wxMMedia2/lib/sndaiff.cpp?ds=sidebyside diff --git a/utils/wxMMedia2/lib/sndaiff.cpp b/utils/wxMMedia2/lib/sndaiff.cpp index 8c53872a94..674141f653 100644 --- a/utils/wxMMedia2/lib/sndaiff.cpp +++ b/utils/wxMMedia2/lib/sndaiff.cpp @@ -9,7 +9,8 @@ #pragma implementation "sndaiff.cpp" #endif -#include +#include + #include #include #include @@ -41,6 +42,44 @@ wxSoundAiff::~wxSoundAiff() { } +bool wxSoundAiff::CanRead() +{ + wxUint32 signature1, signature2, len; + + if (m_input->Read(&signature1, 4).LastRead() != 4) + return FALSE; + + if (wxUINT32_SWAP_ON_BE(signature1) != FORM_SIGNATURE) { + m_input->Ungetch(&signature1, 4); + return FALSE; + } + + m_input->Read(&len, 4); + if (m_input->LastRead() != 4) { + m_input->Ungetch(&len, m_input->LastRead()); + m_input->Ungetch(&signature1, 4); + return FALSE; + } + + if (m_input->Read(&signature2, 4).LastRead() != 4) { + m_input->Ungetch(&signature2, m_input->LastRead()); + m_input->Ungetch(&len, 4); + m_input->Ungetch(&signature1, 4); + return FALSE; + } + + m_input->Ungetch(&signature2, 4); + m_input->Ungetch(&len, 4); + m_input->Ungetch(&signature1, 4); + + if ( + wxUINT32_SWAP_ON_BE(signature2) != AIFF_SIGNATURE && + wxUINT32_SWAP_ON_BE(signature2) != AIFC_SIGNATURE) + return FALSE; + + return TRUE; +} + #define FAIL_WITH(condition, err) if (condition) { m_snderror = err; return FALSE; } bool wxSoundAiff::PrepareToPlay() @@ -89,7 +128,7 @@ bool wxSoundAiff::PrepareToPlay() sndformat.SetSampleRate((wxUint32) srate); sndformat.SetBPS(bps); sndformat.SetChannels(channels); - sndformat.Signed(TRUE); + sndformat.Signed(FALSE); sndformat.SetOrder(wxBIG_ENDIAN); if (!SetSoundFormat(sndformat)) @@ -115,20 +154,22 @@ bool wxSoundAiff::PrepareToPlay() bool wxSoundAiff::PrepareToRecord(unsigned long time) { + // TODO return FALSE; } bool wxSoundAiff::FinishRecording() { + // TODO return FALSE; } -size_t wxSoundAiff::GetData(void *buffer, size_t len) +wxUint32 wxSoundAiff::GetData(void *buffer, wxUint32 len) { return m_input->Read(buffer, len).LastRead(); } -size_t wxSoundAiff::PutData(const void *buffer, size_t len) +wxUint32 wxSoundAiff::PutData(const void *buffer, wxUint32 len) { return m_output->Write(buffer, len).LastWrite(); }