git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1258 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Guilhem Lavaux
1998-12-23 18:16:19 +00:00
parent e0253070f5
commit 926c550dc5
17 changed files with 142 additions and 116 deletions

View File

@@ -1417,35 +1417,49 @@ AC_OVERRIDES(threads,threads,
**--without-threads Force disabling threads, **--without-threads Force disabling threads,
wxUSE_THREADS) wxUSE_THREADS)
dnl AC_ARG_WITH(threads,
dnl [**--without-threads Force disabling threads ],
dnl [wxUSE_THREADS="$withval"])
if test "$wxUSE_THREADS" = "1"; then if test "$wxUSE_THREADS" = "1"; then
UNIX_THREAD="gtk/threadno.cpp"
dnl For glibc 2 users who have the old libc 5 too case "$os" in
solaris*)
AC_CHECK_LIB(pthread-0.7, pthread_create, [ AC_CHECK_LIB(thread, thr_create, [
UNIX_THREAD="gtk/threadpsx.cpp" UNIX_THREAD="gtk/threadsol.cpp"
THREADS_LINK="-lpthread-0.7" THREADS_LINK="-lthread"
],[ ])
AC_CHECK_HEADER(sys/prctl.h, [ ;;
UNIX_THREAD="gtk/threadsgi.cpp"
])
dnl pthread_create is always available in pthread but it seems not to be *)
dnl the case for pthread_setcanceltype.
UNIX_THREAD="gtk/threadno.cpp"
AC_CHECK_LIB(pthread, pthread_setcanceltype, [ dnl For glibc 2 users who have the old libc 5 too
AC_CHECK_LIB(pthread-0.7, pthread_create, [
UNIX_THREAD="gtk/threadpsx.cpp"
THREADS_LINK="-lpthread-0.7"
],[
AC_CHECK_HEADER(sys/prctl.h, [
UNIX_THREAD="gtk/threadsgi.cpp"
])
dnl pthread_create is always available in pthread but it seems not to be
dnl the case for pthread_setcanceltype.
AC_CHECK_LIB(pthread, pthread_setcanceltype, [
UNIX_THREAD="gtk/threadpsx.cpp" UNIX_THREAD="gtk/threadpsx.cpp"
THREADS_LINK="-lpthread" THREADS_LINK="-lpthread"
])
]) ])
]) AC_CHECK_LIB(pthreads, pthread_setcanceltype, [
AC_CHECK_LIB(pthreads, pthread_setcanceltype, [ UNIX_THREAD="gtk/threadpsx.cpp"
UNIX_THREAD="gtk/threadpsx.cpp" THREADS_LINK="-lpthreads"
THREADS_LINK="-lpthreads" ])
])
AC_CHECK_LIB(posix4, printf, [
THREADS_LINK="$THREADS_LINK -lposix4"
]);;
esac
fi fi
if test "$wxUSE_MOTIF" = "1"; then if test "$wxUSE_MOTIF" = "1"; then

View File

@@ -114,8 +114,10 @@ class WXDLLEXPORT wxStreamBuffer {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
typedef enum { typedef enum {
wxStream_NOERROR, wxStream_NOERROR = 0,
wxStream_EOF wxStream_EOF,
wxStream_WRITE_ERR,
wxStream_READ_ERR
} wxStreamError; } wxStreamError;
class WXDLLEXPORT wxStreamBase { class WXDLLEXPORT wxStreamBase {

View File

@@ -13,6 +13,8 @@
#pragma implementation "serbase.h" #pragma implementation "serbase.h"
#endif #endif
#ifdef wxUSE_SERIAL
// For compilers that support precompilation, includes "wx.h". // For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h" #include "wx/wxprec.h"
@@ -118,3 +120,5 @@ void WXSERIAL(wxHashTable)::LoadObject(wxObjectInputStream& s)
for (i=0;i<n;i++) for (i=0;i<n;i++)
table->hash_table[i] = (wxList *)s.GetChild(); table->hash_table[i] = (wxList *)s.GetChild();
} }
#endif

View File

@@ -30,6 +30,10 @@
// wxStreamBuffer // wxStreamBuffer
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#define CHECK_ERROR(err) \
if (m_stream->m_lasterror == wxStream_NOERROR) \
m_stream->m_lasterror = err
wxStreamBuffer::wxStreamBuffer(wxStreamBase& stream, BufMode mode) wxStreamBuffer::wxStreamBuffer(wxStreamBase& stream, BufMode mode)
: m_buffer_start(NULL), m_buffer_end(NULL), m_buffer_pos(NULL), : m_buffer_start(NULL), m_buffer_end(NULL), m_buffer_pos(NULL),
m_buffer_size(0), m_fixed(TRUE), m_flushable(TRUE), m_stream(&stream), m_buffer_size(0), m_fixed(TRUE), m_flushable(TRUE), m_stream(&stream),
@@ -107,7 +111,8 @@ void wxStreamBuffer::SetBufferIO(size_t bufsize)
{ {
char *b_start; char *b_start;
wxDELETE(m_buffer_start); if (m_destroybuf)
wxDELETEA(m_buffer_start);
if (!bufsize) { if (!bufsize) {
m_buffer_start = NULL; m_buffer_start = NULL;
@@ -233,7 +238,7 @@ void wxStreamBuffer::PutChar(char c)
} }
if (!GetDataLeft() && !FlushBuffer()) { if (!GetDataLeft() && !FlushBuffer()) {
m_stream->m_lasterror = wxStream_EOF; CHECK_ERROR(wxStream_READ_ERR);
return; return;
} }
@@ -253,7 +258,7 @@ char wxStreamBuffer::GetChar()
} }
if (!GetDataLeft()) { if (!GetDataLeft()) {
m_stream->m_lasterror = wxStream_EOF; CHECK_ERROR(wxStream_READ_ERR);
return 0; return 0;
} }
@@ -277,9 +282,8 @@ size_t wxStreamBuffer::Read(void *buffer, size_t size)
buffer = (void *)((char *)buffer+m_stream->m_lastcount); buffer = (void *)((char *)buffer+m_stream->m_lastcount);
if (!m_buffer_size) { if (!m_buffer_size)
return (m_stream->m_lastcount += m_stream->OnSysRead(buffer, size)); return (m_stream->m_lastcount += m_stream->OnSysRead(buffer, size));
}
// ----------------- // -----------------
// Buffering enabled // Buffering enabled
@@ -297,8 +301,7 @@ size_t wxStreamBuffer::Read(void *buffer, size_t size)
buffer = (char *)buffer + buf_left; // ANSI C++ violation. buffer = (char *)buffer + buf_left; // ANSI C++ violation.
if (!FillBuffer()) { if (!FillBuffer()) {
if (m_stream->m_lasterror == wxStream_NOERROR) CHECK_ERROR(wxStream_READ_ERR);
m_stream->m_lasterror = wxStream_EOF;
return (m_stream->m_lastcount = orig_size-size); return (m_stream->m_lastcount = orig_size-size);
} }
} else { } else {
@@ -352,8 +355,7 @@ size_t wxStreamBuffer::Write(const void *buffer, size_t size)
buffer = (char *)buffer + buf_left; // ANSI C++ violation. buffer = (char *)buffer + buf_left; // ANSI C++ violation.
if (!FlushBuffer()) { if (!FlushBuffer()) {
if (m_stream->m_lasterror == wxStream_NOERROR) CHECK_ERROR(wxStream_WRITE_ERR);
m_stream->m_lasterror = wxStream_EOF;
return (m_stream->m_lastcount = orig_size-size); return (m_stream->m_lastcount = orig_size-size);
} }
@@ -373,10 +375,12 @@ size_t wxStreamBuffer::Write(wxStreamBuffer *sbuf)
{ {
char buf[BUF_TEMP_SIZE]; char buf[BUF_TEMP_SIZE];
size_t s = 0, bytes_count = BUF_TEMP_SIZE; size_t s = 0, bytes_count = BUF_TEMP_SIZE;
size_t s_size;
while (bytes_count == BUF_TEMP_SIZE) { while (bytes_count == BUF_TEMP_SIZE) {
if (m_stream->StreamSize() < bytes_count) s_size = (sbuf->GetDataLeft() < GetDataLeft()) ? sbuf->GetDataLeft() : GetDataLeft();
bytes_count = m_stream->StreamSize(); if (s_size < bytes_count)
bytes_count = s_size;
bytes_count = sbuf->Read(buf, bytes_count); bytes_count = sbuf->Read(buf, bytes_count);
bytes_count = Write(buf, bytes_count); bytes_count = Write(buf, bytes_count);
s += bytes_count; s += bytes_count;

View File

@@ -1,7 +1,7 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: thread.cpp // Name: thread.cpp
// Purpose: No thread support // Purpose: Solaris thread support
// Author: Original from Wolfram Gloger/Guilhem Lavaux // Author: Guilhem Lavaux
// Modified by: // Modified by:
// Created: 04/22/98 // Created: 04/22/98
// RCS-ID: $Id$ // RCS-ID: $Id$

View File

@@ -1,7 +1,7 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: thread.cpp // Name: thread.cpp
// Purpose: No thread support // Purpose: Solaris thread support
// Author: Original from Wolfram Gloger/Guilhem Lavaux // Author: Guilhem Lavaux
// Modified by: // Modified by:
// Created: 04/22/98 // Created: 04/22/98
// RCS-ID: $Id$ // RCS-ID: $Id$

View File

@@ -16,7 +16,7 @@
#include "wx/wx.h" #include "wx/wx.h"
#endif #endif
#include <wx/stream.h> #include <wx/stream.h>
#include <wx/fstream.h> #include <wx/wfstream.h>
#include <wx/mstream.h> #include <wx/mstream.h>
#include "mmfile.h" #include "mmfile.h"

View File

@@ -53,7 +53,7 @@ void wxFragmentBuffer::AbortBuffer(wxSndBuffer *buf)
} }
wxFragmentBuffer::wxFragBufPtr *wxFragmentBuffer::FindFreeBuffer( wxFragmentBuffer::wxFragBufPtr *wxFragmentBuffer::FindFreeBuffer(
wxFragBufPtr *list, wxUint8 max_queue) xFragBufPtr *list, wxUint8 max_queue)
{ {
if (!list) if (!list)
return NULL; return NULL;
@@ -71,6 +71,7 @@ bool wxFragmentBuffer::NotifyOutputBuffer(wxSndBuffer *buf)
wxFragBufPtr *ptr; wxFragBufPtr *ptr;
char *raw_buf; char *raw_buf;
wxUint32 rawbuf_size; wxUint32 rawbuf_size;
wxSoundCodec *codec = buf->GetCurrentCodec();
if (!m_iodrv->OnSetupDriver(*buf, wxSND_OUTPUT)) if (!m_iodrv->OnSetupDriver(*buf, wxSND_OUTPUT))
return FALSE; return FALSE;
@@ -82,15 +83,14 @@ bool wxFragmentBuffer::NotifyOutputBuffer(wxSndBuffer *buf)
if (!ptr) if (!ptr)
return FALSE; return FALSE;
// Find the end of the buffer codec->SetOutStream(ptr->sndbuf);
raw_buf = ptr->data + ptr->ptr; codec->InitIO(m_drvformat);
rawbuf_size = ptr->size - ptr->ptr;
// Fill it up // Fill it up
buf->OnNeedOutputData(raw_buf, rawbuf_size); codec->Decode();
// No data to fill the buffer: dequeue the current wxSndBuffer // No data to fill the buffer: dequeue the current wxSndBuffer
if (!rawbuf_size) { if (!codec->Available()) {
if (buf->IsNotSet(wxSND_KEEPQUEUED)) { if (buf->IsNotSet(wxSND_KEEPQUEUED)) {
buf->Set(wxSND_UNQUEUEING); buf->Set(wxSND_UNQUEUEING);
m_iodrv->m_buffers.DeleteObject(buf); m_iodrv->m_buffers.DeleteObject(buf);
@@ -101,10 +101,8 @@ bool wxFragmentBuffer::NotifyOutputBuffer(wxSndBuffer *buf)
// Data: append it to the list // Data: append it to the list
ptr->buffers->Append(buf); ptr->buffers->Append(buf);
ptr->ptr += rawbuf_size;
// Output buffer full: send it to the driver // Output buffer full: send it to the driver
if (ptr->ptr == ptr->size) { if (ptr->sndbuf->GetDataLeft()) {
ptr->state = wxBUFFER_FFILLED; ptr->state = wxBUFFER_FFILLED;
OnBufferFilled(ptr, wxSND_OUTPUT); OnBufferFilled(ptr, wxSND_OUTPUT);
} }
@@ -113,18 +111,19 @@ bool wxFragmentBuffer::NotifyOutputBuffer(wxSndBuffer *buf)
bool wxFragmentBuffer::NotifyInputBuffer(wxSndBuffer *buf) bool wxFragmentBuffer::NotifyInputBuffer(wxSndBuffer *buf)
{ {
wxFragBufPtr *ptr; /*
char *raw_buf; wxFragBufPtr *ptr;
wxUint32 rawbuf_size; char *raw_buf;
wxUint32 rawbuf_size;
if (!m_iodrv->OnSetupDriver(*buf, wxSND_INPUT))
return FALSE; if (!m_iodrv->OnSetupDriver(*buf, wxSND_INPUT))
while (1) {
ptr = FindFreeBuffer(m_lstiptrs, m_maxiq);
if (!ptr)
return FALSE; return FALSE;
while (1) {
ptr = FindFreeBuffer(m_lstiptrs, m_maxiq);
if (!ptr)
return FALSE;
raw_buf = ptr->data + ptr->ptr; raw_buf = ptr->data + ptr->ptr;
rawbuf_size = ptr->size - ptr->ptr; rawbuf_size = ptr->size - ptr->ptr;
@@ -137,7 +136,6 @@ bool wxFragmentBuffer::NotifyInputBuffer(wxSndBuffer *buf)
m_iodrv->m_buffers.DeleteObject(buf); m_iodrv->m_buffers.DeleteObject(buf);
} }
// Get data now when there isn't anymore buffer in the queue
if (!LastBuffer() && ptr->ptr) { if (!LastBuffer() && ptr->ptr) {
ptr->state = wxBUFFER_FFILLED; ptr->state = wxBUFFER_FFILLED;
if (!OnBufferFilled(ptr, wxSND_INPUT)) if (!OnBufferFilled(ptr, wxSND_INPUT))
@@ -149,13 +147,15 @@ bool wxFragmentBuffer::NotifyInputBuffer(wxSndBuffer *buf)
ptr->ptr += rawbuf_size; ptr->ptr += rawbuf_size;
// Input buffer full => get data
if (ptr->ptr == ptr->size) { if (ptr->ptr == ptr->size) {
ptr->state = wxBUFFER_FFILLED; ptr->state = wxBUFFER_FFILLED;
if (!OnBufferFilled(ptr, wxSND_INPUT)) if (!OnBufferFilled(ptr, wxSND_INPUT))
return FALSE; return FALSE;
} }
} }
*/
return TRUE; return TRUE;
} }
@@ -213,7 +213,7 @@ void wxFragmentBuffer::ClearBuffer(wxFragBufPtr *ptr)
node = ptr->buffers->First(); node = ptr->buffers->First();
} }
ptr->ptr = 0; ptr->sndbuf->ResetBuffer();
ptr->state = wxBUFFER_FREE; ptr->state = wxBUFFER_FREE;
} }

View File

@@ -54,6 +54,8 @@ protected:
wxFragBufPtr *m_lstoptrs, *m_lstiptrs; wxFragBufPtr *m_lstoptrs, *m_lstiptrs;
/// ///
bool m_buf2free, m_dontq, m_freeing; bool m_buf2free, m_dontq, m_freeing;
///
wxSoundDataFormat m_drvformat;
public: public:
/// ///
wxFragmentBuffer(wxSound& io_drv); wxFragmentBuffer(wxSound& io_drv);

View File

@@ -4,7 +4,6 @@
#include "sndsnd.h" #include "sndsnd.h"
#include "sndfrmt.h" #include "sndfrmt.h"
#include "sndpcm.h" #include "sndpcm.h"
#include <dmalloc.h>
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxSoundDataFormat // wxSoundDataFormat
@@ -21,6 +20,19 @@ wxSoundDataFormat::wxSoundDataFormat()
m_codcreate = TRUE; m_codcreate = TRUE;
} }
wxSoundDataFormat::wxSoundDataFormat(const wxSoundDataFormat& format)
{
m_srate = format.m_srate;
m_bps = format.m_bps;
m_channels = format.m_channels;
m_codno = format.m_codno;
m_sign = format.m_sign;
m_byteorder = format.m_byteorder;
m_codchange = FALSE;
m_codcreate = TRUE;
m_codec = NULL;
}
wxSoundDataFormat::~wxSoundDataFormat() wxSoundDataFormat::~wxSoundDataFormat()
{ {
wxDELETE(m_codec); wxDELETE(m_codec);
@@ -62,7 +74,7 @@ wxSoundCodec *wxSoundDataFormat::GetCodec()
return NULL; return NULL;
if (m_codchange) if (m_codchange)
wxDELETEA(m_codec); wxDELETE(m_codec);
if (m_codec) if (m_codec)
return m_codec; return m_codec;
@@ -148,6 +160,7 @@ wxSoundCodec::wxSoundCodec()
m_in_sound = NULL; m_in_sound = NULL;
m_out_sound = NULL; m_out_sound = NULL;
m_init = TRUE; m_init = TRUE;
m_chain_codec = NULL;
} }
wxSoundCodec::~wxSoundCodec() wxSoundCodec::~wxSoundCodec()

View File

@@ -6,6 +6,7 @@
#endif #endif
#include <wx/object.h> #include <wx/object.h>
#include <wx/stream.h>
class wxSndBuffer; class wxSndBuffer;
@@ -19,6 +20,7 @@ class wxSoundCodec;
class wxSoundDataFormat { class wxSoundDataFormat {
public: public:
wxSoundDataFormat(); wxSoundDataFormat();
wxSoundDataFormat(const wxSoundDataFormat& format);
~wxSoundDataFormat(); ~wxSoundDataFormat();
void SetSampleRate(int srate) { m_srate = srate; } void SetSampleRate(int srate) { m_srate = srate; }
@@ -78,7 +80,9 @@ class wxSoundCodec : public wxObject, public wxStreamBase {
inline wxStreamBuffer *GetInStream() const { return m_in_sound; } inline wxStreamBuffer *GetInStream() const { return m_in_sound; }
inline wxStreamBuffer *GetOutStream() const { return m_out_sound; } inline wxStreamBuffer *GetOutStream() const { return m_out_sound; }
inline bool Good() const { return (m_in_sound->Stream()->LastError() == wxStream_NOERROR) && (m_out_sound->Stream()->LastError() == wxStream_NOERROR); } inline bool StreamOk() const
{ return (m_in_sound->Stream()->LastError() == wxStream_NOERROR) &&
(m_out_sound->Stream()->LastError() == wxStream_NOERROR); }
virtual size_t GetByteRate() const = 0; virtual size_t GetByteRate() const = 0;
virtual wxSoundDataFormat GetPreferredFormat(int codec = 0) const = 0; virtual wxSoundDataFormat GetPreferredFormat(int codec = 0) const = 0;

View File

@@ -27,7 +27,7 @@ void wxSoundMulawCodec::Decode()
InitMode(DECODING); InitMode(DECODING);
while (!Good()) { while (!StreamOk()) {
smp = ulaw2linear(m_in_sound->GetChar()); smp = ulaw2linear(m_in_sound->GetChar());
#ifdef USE_BE_MACH #ifdef USE_BE_MACH
m_out_sound->PutChar((smp & 0xff00) >> 8); m_out_sound->PutChar((smp & 0xff00) >> 8);
@@ -50,7 +50,7 @@ void wxSoundMulawCodec::Encode()
InitMode(ENCODING); InitMode(ENCODING);
while (!Good()) { while (!StreamOk()) {
#ifdef USE_BE_MACH #ifdef USE_BE_MACH
smp = ((unsigned short)m_in_sound->GetChar()) << 8; smp = ((unsigned short)m_in_sound->GetChar()) << 8;
smp |= m_in_sound->GetChar() & 0xff; smp |= m_in_sound->GetChar() & 0xff;

View File

@@ -3,7 +3,6 @@
#endif #endif
#include "sndsnd.h" #include "sndsnd.h"
#include "sndpcm.h" #include "sndpcm.h"
#include <dmalloc.h>
#define WX_BIG_ENDIAN 0 #define WX_BIG_ENDIAN 0
@@ -11,8 +10,7 @@ wxSoundPcmCodec::wxSoundPcmCodec()
: wxSoundCodec() : wxSoundCodec()
{ {
m_orig_format.SetCodecCreate(FALSE); m_orig_format.SetCodecCreate(FALSE);
m_orig_format.SetCodecNo(1); m_orig_format.SetCodecNo(WXSOUND_PCM);
m_char_bool = FALSE;
} }
wxSoundPcmCodec::~wxSoundPcmCodec() wxSoundPcmCodec::~wxSoundPcmCodec()
@@ -31,7 +29,6 @@ wxSoundDataFormat wxSoundPcmCodec::GetPreferredFormat(int codec) const
wxSoundDataFormat prefFormat; wxSoundDataFormat prefFormat;
prefFormat = m_orig_format; prefFormat = m_orig_format;
prefFormat.SetCodecNo(WXSOUND_PCM);
return prefFormat; return prefFormat;
} }
@@ -69,20 +66,16 @@ void wxSoundPcmCodec::Decode()
#define GET() (m_in_sound->GetChar()) #define GET() (m_in_sound->GetChar())
#define PUT(c) (m_out_sound->PutChar(c)) #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() void wxSoundPcmCodec::InputSign8()
{ {
unsigned char signer = 0; unsigned char signer = 0;
wxStreamBase *in = m_out_sound->Stream(), *out = m_in_sound->Stream();
if (m_io_format.GetSign() != m_orig_format.GetSign()) if (m_io_format.GetSign() != m_orig_format.GetSign())
signer = 128; signer = 128;
while (IN_ERROR() && OUT_ERROR()) while (StreamOk())
PUT(GET() + signer); PUT(GET() + signer);
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@@ -91,9 +84,8 @@ void wxSoundPcmCodec::InputSign8()
void wxSoundPcmCodec::InputSwapAndSign16() void wxSoundPcmCodec::InputSwapAndSign16()
{ {
unsigned short signer1 = 0, signer2 = 0; 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()); 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.GetSign() != m_orig_format.GetSign()) {
if (m_io_format.GetByteOrder() == wxSND_SAMPLE_LE) if (m_io_format.GetByteOrder() == wxSND_SAMPLE_LE)
@@ -103,22 +95,23 @@ void wxSoundPcmCodec::InputSwapAndSign16()
} }
if (swap) { if (swap) {
while (IN_ERROR() && OUT_ERROR()) { while (StreamOk()) {
temp = GET() ^ signer1; temp = GET();
PUT(GET() ^ signer2); temp2 = GET();
if (OUT_ERROR()) { PUT(temp2 ^ signer2);
m_char_bool = TRUE; if (!StreamOk()) {
m_char_stack = temp; m_in_sound->WriteBack(temp);
m_in_sound->WriteBack(temp2);
break; break;
} }
PUT(temp); PUT(temp ^ signer1);
} }
} else { } else {
while (IN_ERROR() && OUT_ERROR()) { while (StreamOk()) {
PUT(GET() ^ signer1); temp = GET();
if (OUT_ERROR()) { PUT(temp ^ signer1);
m_char_bool = TRUE; if (!StreamOk()) {
m_char_stack = temp; m_in_sound->WriteBack(temp);
break; break;
} }
PUT(GET() ^ signer2); PUT(GET() ^ signer2);
@@ -132,13 +125,12 @@ void wxSoundPcmCodec::InputSwapAndSign16()
void wxSoundPcmCodec::OutputSign8() void wxSoundPcmCodec::OutputSign8()
{ {
wxStreamBase *in = m_out_sound->Stream(), *out = m_in_sound->Stream();
unsigned char signer = 0; unsigned char signer = 0;
if (m_io_format.GetSign() != m_orig_format.GetSign()) if (m_io_format.GetSign() != m_orig_format.GetSign())
signer = 128; signer = 128;
while (IN_ERROR() && OUT_ERROR()) while (StreamOk())
PUT((char)(GET() + signer)); PUT((char)(GET() + signer));
} }
@@ -148,14 +140,7 @@ void wxSoundPcmCodec::OutputSwapAndSign16()
{ {
bool swap = (m_io_format.GetByteOrder() != m_orig_format.GetByteOrder()); bool swap = (m_io_format.GetByteOrder() != m_orig_format.GetByteOrder());
unsigned short signer1 = 0, signer2 = 0; unsigned short signer1 = 0, signer2 = 0;
char temp; register char temp, temp2;
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;
}
if (m_io_format.GetSign() != m_orig_format.GetSign()) if (m_io_format.GetSign() != m_orig_format.GetSign())
if (m_io_format.GetByteOrder() == wxSND_SAMPLE_LE) if (m_io_format.GetByteOrder() == wxSND_SAMPLE_LE)
@@ -164,25 +149,27 @@ void wxSoundPcmCodec::OutputSwapAndSign16()
signer2 = 0x80; signer2 = 0x80;
if (swap) { if (swap) {
while (IN_ERROR()) { while (StreamOk()) {
temp = GET(); temp = GET();
PUT(GET() ^ signer1); temp2 = GET();
if (OUT_ERROR()) { PUT(temp2 ^ signer1);
m_char_stack = temp ^ signer2; if (!StreamOk()) {
m_char_bool = TRUE; m_in_sound->WriteBack(temp);
m_in_sound->WriteBack(temp2);
break; break;
} }
PUT(temp ^ signer2); PUT(temp ^ signer2);
} }
} else { } else {
while (IN_ERROR()) { while (StreamOk()) {
PUT(GET() ^ signer1); temp = GET();
if (!OUT_ERROR()) { temp2 = GET();
m_char_stack = GET() ^ signer2; PUT(temp ^ signer1);
m_char_bool = TRUE; if (!StreamOk()) {
m_in_sound->WriteBack(temp);
break; break;
} }
PUT(GET() ^ signer2); PUT(temp2 ^ signer2);
} }
} }

View File

@@ -16,7 +16,6 @@
#include <unistd.h> #include <unistd.h>
#include <fcntl.h> #include <fcntl.h>
#include <time.h> #include <time.h>
#include <dmalloc.h>
#include "wx/app.h" #include "wx/app.h"
#include "wx/utils.h" #include "wx/utils.h"

View File

@@ -86,9 +86,6 @@ wxUint32 wxSndWavCodec::PrepareToPlay()
if (!riff_codec.FindChunk("data")) if (!riff_codec.FindChunk("data"))
return 0; return 0;
m_sndformat.SetSampleRate(wav_hdr.sample_fq);
m_sndformat.SetBps(wav_hdr.bits_p_spl);
m_sndformat.SetChannels(wav_hdr.channels);
m_sndmode = wxSND_OUTPUT; m_sndmode = wxSND_OUTPUT;
ChangeCodec(wav_hdr.format); ChangeCodec(wav_hdr.format);

View File

@@ -10,7 +10,7 @@
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation "vidbase.h" #pragma implementation "vidbase.h"
#endif #endif
#include <wx/fstream.h> #include <wx/wfstream.h>
#include "vidbase.h" #include "vidbase.h"
#ifdef WX_PRECOMP #ifdef WX_PRECOMP
#include "wx_prec.h" #include "wx_prec.h"

View File

@@ -12,7 +12,7 @@
#pragma implementation "wave.h" #pragma implementation "wave.h"
#endif #endif
#include <wx/fstream.h> #include <wx/wfstream.h>
#include "wave.h" #include "wave.h"
wxWave::wxWave() wxWave::wxWave()