]>
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
;
56 m_istream
->Read(temp_buf
, 4);
61 m_mmerror
= wxMMFILE_INVALID
;
65 #define READ_BE_32(i) \
66 m_istream->Read(temp_buf, 4); \
67 i = (unsigned long)temp_buf[0] << 24; \
68 i |= (unsigned long)temp_buf[1] << 16; \
69 i |= (unsigned long)temp_buf[2] << 8; \
70 i |= (unsigned long)temp_buf[3];
78 m_sndformat
.SetSampleRate(srate
);
79 m_sndformat
.SetChannels(ch_count
);
82 ChangeCodec(WXSOUND_ULAW
);
85 ChangeCodec(WXSOUND_PCM
);
86 m_sndformat
.SetByteOrder(wxSND_SAMPLE_LE
);
87 m_sndformat
.SetSign(wxSND_SAMPLE_SIGNED
);
90 ChangeCodec(WXSOUND_PCM
);
91 m_sndformat
.SetByteOrder(wxSND_SAMPLE_LE
);
92 m_sndformat
.SetSign(wxSND_SAMPLE_SIGNED
);
95 ChangeCodec(WXSOUND_ADPCM
);
101 bool wxSndAuCodec::OnNeedData(char *buf
, wxUint32 size
)
103 return m_istream
->Read(buf
, size
).LastError();
106 bool wxSndAuCodec::OnWriteData(char *buf
, wxUint32 size
)
108 return m_ostream
->Write(buf
, size
).LastError();
111 bool wxSndAuCodec::PrepareToRecord(wxUint32 file_size
)