#endif
#include "sndsnd.h"
#include "sndpcm.h"
-#include <dmalloc.h>
#define WX_BIG_ENDIAN 0
: wxSoundCodec()
{
m_orig_format.SetCodecCreate(FALSE);
- m_orig_format.SetCodecNo(1);
- m_char_bool = FALSE;
+ m_orig_format.SetCodecNo(WXSOUND_PCM);
}
wxSoundPcmCodec::~wxSoundPcmCodec()
wxSoundDataFormat prefFormat;
prefFormat = m_orig_format;
- prefFormat.SetCodecNo(WXSOUND_PCM);
return prefFormat;
}
void wxSoundPcmCodec::Decode()
{
- InitMode(DECODING);
if (m_io_format == m_orig_format) {
CopyToOutput();
- ExitMode();
return;
}
default:
break;
}
- ExitMode();
}
// ---------------------------------------------------------------------------
#define GET() (m_in_sound->GetChar())
#define PUT(c) (m_out_sound->PutChar(c))
-#define OUT_ERROR() (out->LastError() == wxStream_NOERROR)
-#define IN_ERROR() (in->LastError() == wxStream_NOERROR)
void wxSoundPcmCodec::InputSign8()
{
unsigned char signer = 0;
- wxStreamBase *in = m_out_sound->Stream(), *out = m_in_sound->Stream();
if (m_io_format.GetSign() != m_orig_format.GetSign())
signer = 128;
- while (IN_ERROR() && OUT_ERROR())
+ while (StreamOk())
PUT(GET() + signer);
-
}
// ---------------------------------------------------------------------------
void wxSoundPcmCodec::InputSwapAndSign16()
{
unsigned short signer1 = 0, signer2 = 0;
- wxStreamBase *in = m_out_sound->Stream(), *out = m_in_sound->Stream();
bool swap = (m_io_format.GetByteOrder() != m_orig_format.GetByteOrder());
- char temp;
+ register char temp, temp2;
if (m_io_format.GetSign() != m_orig_format.GetSign()) {
if (m_io_format.GetByteOrder() == wxSND_SAMPLE_LE)
}
if (swap) {
- while (IN_ERROR() && OUT_ERROR()) {
- temp = GET() ^ signer1;
- PUT(GET() ^ signer2);
- if (OUT_ERROR()) {
- m_char_bool = TRUE;
- m_char_stack = temp;
+ while (StreamOk()) {
+ temp = GET();
+ temp2 = GET();
+ PUT(temp2 ^ signer2);
+ if (!StreamOk()) {
+ m_in_sound->WriteBack(temp);
+ m_in_sound->WriteBack(temp2);
break;
}
- PUT(temp);
+ PUT(temp ^ signer1);
}
} else {
- while (IN_ERROR() && OUT_ERROR()) {
- PUT(GET() ^ signer1);
- if (OUT_ERROR()) {
- m_char_bool = TRUE;
- m_char_stack = temp;
+ while (StreamOk()) {
+ temp = GET();
+ PUT(temp ^ signer1);
+ if (!StreamOk()) {
+ m_in_sound->WriteBack(temp);
break;
}
PUT(GET() ^ signer2);
void wxSoundPcmCodec::OutputSign8()
{
- wxStreamBase *in = m_out_sound->Stream(), *out = m_in_sound->Stream();
unsigned char signer = 0;
if (m_io_format.GetSign() != m_orig_format.GetSign())
signer = 128;
- while (IN_ERROR() && OUT_ERROR())
+ while (StreamOk())
PUT((char)(GET() + signer));
}
{
bool swap = (m_io_format.GetByteOrder() != m_orig_format.GetByteOrder());
unsigned short signer1 = 0, signer2 = 0;
- char temp;
- wxStreamBase *in = m_out_sound->Stream(), *out = m_in_sound->Stream();
-
- if (m_char_bool) {
- PUT(GET());
- PUT(m_char_stack);
- m_char_bool = FALSE;
- }
+ register char temp, temp2;
if (m_io_format.GetSign() != m_orig_format.GetSign())
if (m_io_format.GetByteOrder() == wxSND_SAMPLE_LE)
signer2 = 0x80;
if (swap) {
- while (IN_ERROR()) {
+ while (StreamOk()) {
temp = GET();
- PUT(GET() ^ signer1);
- if (OUT_ERROR()) {
- m_char_stack = temp ^ signer2;
- m_char_bool = TRUE;
+ temp2 = GET();
+ PUT(temp2 ^ signer1);
+ if (!StreamOk()) {
+ m_in_sound->WriteBack(temp);
+ m_in_sound->WriteBack(temp2);
break;
}
PUT(temp ^ signer2);
}
} else {
- while (IN_ERROR()) {
- PUT(GET() ^ signer1);
- if (!OUT_ERROR()) {
- m_char_stack = GET() ^ signer2;
- m_char_bool = TRUE;
+ while (StreamOk()) {
+ temp = GET();
+ temp2 = GET();
+ PUT(temp ^ signer1);
+ if (!StreamOk()) {
+ m_in_sound->WriteBack(temp);
break;
}
- PUT(GET() ^ signer2);
+ PUT(temp2 ^ signer2);
}
}
void wxSoundPcmCodec::Encode()
{
- InitMode(ENCODING);
if (m_io_format == m_orig_format) {
CopyToOutput();
- ExitMode();
return;
}
default:
break;
}
- ExitMode();
}