X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e8482f24cfc00645607f8526fde38d39e0dcaa63..adb8a71bbc0ba11aad0b417db24f7267a250b6c3:/contrib/src/mmedia/sndwav.cpp?ds=sidebyside diff --git a/contrib/src/mmedia/sndwav.cpp b/contrib/src/mmedia/sndwav.cpp index 7d6d891878..75f5bf9e59 100644 --- a/contrib/src/mmedia/sndwav.cpp +++ b/contrib/src/mmedia/sndwav.cpp @@ -9,7 +9,7 @@ #pragma implementation "sndwav.cpp" #endif -#include +#include "wx/wxprec.h" #ifndef WX_PRECOMP #include "wx/defs.h" @@ -29,6 +29,7 @@ #include "wx/mmedia/sndfile.h" #include "wx/mmedia/sndpcm.h" #include "wx/mmedia/sndg72x.h" +#include "wx/mmedia/sndmsad.h" #include "wx/mmedia/sndwav.h" #define BUILD_SIGNATURE(a,b,c,d) (((wxUint32)a) | (((wxUint32)b) << 8) | (((wxUint32)c) << 16) | (((wxUint32)d) << 24)) @@ -97,9 +98,10 @@ bool wxSoundWave::CanRead() return TRUE; } -bool wxSoundWave::HandleOutputPCM(wxDataInputStream& data, wxUint16 channels, - wxUint32 sample_fq, wxUint32 byte_p_sec, - wxUint16 byte_p_spl, wxUint16 bits_p_spl) +bool wxSoundWave::HandleOutputPCM(wxDataInputStream& WXUNUSED(data), wxUint32 len, + wxUint16 channels, + wxUint32 sample_fq, wxUint32 WXUNUSED(byte_p_sec), + wxUint16 WXUNUSED(byte_p_spl), wxUint16 bits_p_spl) { wxSoundFormatPcm sndformat; @@ -112,12 +114,55 @@ bool wxSoundWave::HandleOutputPCM(wxDataInputStream& data, wxUint16 channels, if (!SetSoundFormat(sndformat)) return FALSE; + m_input->SeekI(len, wxFromCurrent); + return TRUE; } -bool wxSoundWave::HandleOutputG721(wxDataInputStream& data, wxUint16 channels, - wxUint32 sample_fq, wxUint32 byte_p_sec, - wxUint16 byte_p_spl, wxUint16 bits_p_spl) +bool wxSoundWave::HandleOutputMSADPCM(wxDataInputStream& data, wxUint32 len, + wxUint16 channels, + wxUint32 sample_fq, wxUint32 WXUNUSED(byte_p_sec), + wxUint16 WXUNUSED(byte_p_spl), wxUint16 WXUNUSED(bits_p_spl)) +{ + wxSoundFormatMSAdpcm sndformat; + wxInt16 *coefs[2]; + wxUint16 coefs_len, i; + wxUint16 block_size; + + sndformat.SetSampleRate(sample_fq); + sndformat.SetChannels(channels); + + block_size = data.Read16(); + coefs_len = data.Read16(); + + coefs[0] = new wxInt16[coefs_len]; + coefs[1] = new wxInt16[coefs_len]; + + for (i=0;iSeekI(len, wxFromCurrent); + + return TRUE; +} + +bool wxSoundWave::HandleOutputG721(wxDataInputStream& WXUNUSED(data), wxUint32 len, + wxUint16 WXUNUSED(channels), + wxUint32 sample_fq, wxUint32 WXUNUSED(byte_p_sec), + wxUint16 WXUNUSED(byte_p_spl), wxUint16 WXUNUSED(bits_p_spl)) { wxSoundFormatG72X sndformat; @@ -127,6 +172,8 @@ bool wxSoundWave::HandleOutputG721(wxDataInputStream& data, wxUint16 channels, if (!SetSoundFormat(sndformat)) return FALSE; + m_input->SeekI(len, wxFromCurrent); + return TRUE; } @@ -149,6 +196,7 @@ bool wxSoundWave::PrepareToPlay() // "RIFF" len = data.Read32(); + wxUnusedVar(len); FAIL_WITH(m_input->LastRead() != 4, wxSOUND_INVSTRM); // dummy len @@ -173,16 +221,27 @@ bool wxSoundWave::PrepareToPlay() // Get the common parameters data >> format >> channels >> sample_fq >> byte_p_sec >> byte_p_spl >> bits_p_spl; + len -= 16; switch (format) { case 0x01: // PCM - if (!HandleOutputPCM(data, channels, sample_fq, - byte_p_sec, byte_p_spl, bits_p_spl)) + if (!HandleOutputPCM(data, len, channels, sample_fq, + byte_p_sec, byte_p_spl, + bits_p_spl)) + return FALSE; + break; + case 0x02: // MS ADPCM + if (!HandleOutputMSADPCM(data, len, + channels, sample_fq, + byte_p_sec, byte_p_spl, + bits_p_spl)) return FALSE; break; case 0x40: // G721 - if (!HandleOutputG721(data, channels, sample_fq, - byte_p_sec, byte_p_spl, bits_p_spl)) + if (!HandleOutputG721(data, len, + channels, sample_fq, + byte_p_sec, byte_p_spl, + bits_p_spl)) return FALSE; break; default: @@ -344,7 +403,7 @@ bool wxSoundWave::FinishRecording() return TRUE; } -bool wxSoundWave::RepositionStream(wxUint32 position) +bool wxSoundWave::RepositionStream(wxUint32 WXUNUSED(position)) { if (m_base_offset == wxInvalidOffset) return FALSE;