]>
git.saurik.com Git - wxWidgets.git/blob - utils/wxMMedia/sndau.cpp
1 // /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxMMedia Sun Audio File Codec
4 // Author: Guilhem Lavaux
7 // Copyright: (C) 1998, Guilhem Lavaux
8 // License: wxWindows license
9 // /////////////////////////////////////////////////////////////////////////////
11 #pragma implementation "sndau.h"
18 #define AU_ISDN_ULAW 1
19 #define AU_PCM_8BITS 2
20 #define AU_PCM_16BITS 3
23 wxSndAuCodec::wxSndAuCodec()
28 wxSndAuCodec::wxSndAuCodec(wxInputStream
& s
, bool preload
, bool seekable
)
29 : wxSndFileCodec(s
, preload
, seekable
)
33 wxSndAuCodec::wxSndAuCodec(wxOutputStream
& s
, bool seekable
)
34 : wxSndFileCodec(s
, seekable
)
38 wxSndAuCodec::wxSndAuCodec(const wxString
& fname
)
39 : wxSndFileCodec(fname
)
43 wxSndAuCodec::~wxSndAuCodec()
47 wxUint32
wxSndAuCodec::PrepareToPlay()
51 int offset
, srate
, codec
, ch_count
;
54 m_istream
->Read(temp_buf
, 4);
59 m_mmerror
= wxMMFILE_INVALID
;
63 #define READ_BE_32(i) \
64 m_istream->Read(temp_buf, 4); \
65 i = (unsigned long)temp_buf[0] << 24; \
66 i |= (unsigned long)temp_buf[1] << 16; \
67 i |= (unsigned long)temp_buf[2] << 8; \
68 i |= (unsigned long)temp_buf[3];
76 m_sndformat
.SetSampleRate(srate
);
77 m_sndformat
.SetChannels(ch_count
);
80 ChangeCodec(WXSOUND_ULAW
);
83 ChangeCodec(WXSOUND_PCM
);
84 m_sndformat
.SetByteOrder(wxSND_SAMPLE_LE
);
85 m_sndformat
.SetSign(wxSND_SAMPLE_SIGNED
);
88 ChangeCodec(WXSOUND_PCM
);
89 m_sndformat
.SetByteOrder(wxSND_SAMPLE_LE
);
90 m_sndformat
.SetSign(wxSND_SAMPLE_SIGNED
);
93 ChangeCodec(WXSOUND_ADPCM
);
99 bool wxSndAuCodec::OnNeedData(char *buf
, wxUint32 size
)
101 return m_istream
->Read(buf
, size
).LastError();
104 bool wxSndAuCodec::OnWriteData(char *buf
, wxUint32 size
)
106 return m_ostream
->Write(buf
, size
).LastError();
109 bool wxSndAuCodec::PrepareToRecord(wxUint32 file_size
)