+
+ data.BigEndianOrdered(TRUE);
+
+ FAIL_WITH(m_input->Read(&signature, 4).LastRead() != 4, wxSOUND_INVSTRM);
+ FAIL_WITH(wxUINT32_SWAP_ON_BE(signature) != FORM_SIGNATURE, wxSOUND_INVSTRM);
+ // "FORM"
+
+ len = data.Read32();
+ FAIL_WITH(m_input->LastRead() != 4, wxSOUND_INVSTRM);
+ // dummy len
+
+ FAIL_WITH(m_input->Read(&signature, 4).LastRead() != 4, wxSOUND_INVSTRM);
+ FAIL_WITH(
+ wxUINT32_SWAP_ON_BE(signature) != AIFF_SIGNATURE &&
+ wxUINT32_SWAP_ON_BE(signature) != AIFC_SIGNATURE, wxSOUND_INVSTRM);
+ // "AIFF" / "AIFC"
+
+ end_headers = FALSE;
+ while (!end_headers) {
+ FAIL_WITH(m_input->Read(&signature, 4).LastRead() != 4, wxSOUND_INVSTRM);
+
+ len = data.Read32();
+ FAIL_WITH(m_input->LastRead() != 4, wxSOUND_INVSTRM);
+
+ switch (wxUINT32_SWAP_ON_BE(signature)) {
+ case COMM_SIGNATURE: { // "COMM"
+ wxUint16 channels, bps;
+ wxUint32 num_samples;
+ double srate;
+ wxSoundFormatPcm sndformat;
+
+ data >> channels >> num_samples >> bps >> srate;
+
+ sndformat.SetSampleRate((wxUint32) srate);
+ sndformat.SetBPS(bps);
+ sndformat.SetChannels(channels);
+ sndformat.Signed(FALSE);
+ sndformat.SetOrder(wxBIG_ENDIAN);
+
+ if (!SetSoundFormat(sndformat))
+ return FALSE;
+ m_input->SeekI(len-18, wxFromCurrent);
+ break;
+ }
+ case SSND_SIGNATURE: { // "SSND"
+ data >> ssnd;
+ // m_input->SeekI(4, wxFromCurrent); // Pass an INT32
+ // m_input->SeekI(len-4, wxFromCurrent); // Pass the rest
+ m_input->SeekI(ssnd + 4, wxFromCurrent);
+ m_base_offset = m_input->TellI();
+ FinishPreparation(len - 8);
+ end_headers = TRUE;
+ break;
+ }
+ default:
+ m_input->SeekI(len, wxFromCurrent);
+ break;
+ }