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,
wxUSE_THREADS)
dnl AC_ARG_WITH(threads,
dnl [**--without-threads Force disabling threads ],
dnl [wxUSE_THREADS="$withval"])
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, [
UNIX_THREAD="gtk/threadpsx.cpp"
THREADS_LINK="-lpthread-0.7"
],[
AC_CHECK_HEADER(sys/prctl.h, [
UNIX_THREAD="gtk/threadsgi.cpp"
])
AC_CHECK_LIB(thread, thr_create, [
UNIX_THREAD="gtk/threadsol.cpp"
THREADS_LINK="-lthread"
])
;;
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"
THREADS_LINK="-lpthread"
])
])
])
AC_CHECK_LIB(pthreads, pthread_setcanceltype, [
UNIX_THREAD="gtk/threadpsx.cpp"
THREADS_LINK="-lpthreads"
])
AC_CHECK_LIB(pthreads, pthread_setcanceltype, [
UNIX_THREAD="gtk/threadpsx.cpp"
THREADS_LINK="-lpthreads"
])
AC_CHECK_LIB(posix4, printf, [
THREADS_LINK="$THREADS_LINK -lposix4"
]);;
esac
fi
if test "$wxUSE_MOTIF" = "1"; then

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -4,7 +4,6 @@
#include "sndsnd.h"
#include "sndfrmt.h"
#include "sndpcm.h"
#include <dmalloc.h>
// ----------------------------------------------------------------------------
// wxSoundDataFormat
@ -21,6 +20,19 @@ wxSoundDataFormat::wxSoundDataFormat()
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()
{
wxDELETE(m_codec);
@ -62,7 +74,7 @@ wxSoundCodec *wxSoundDataFormat::GetCodec()
return NULL;
if (m_codchange)
wxDELETEA(m_codec);
wxDELETE(m_codec);
if (m_codec)
return m_codec;
@ -148,6 +160,7 @@ wxSoundCodec::wxSoundCodec()
m_in_sound = NULL;
m_out_sound = NULL;
m_init = TRUE;
m_chain_codec = NULL;
}
wxSoundCodec::~wxSoundCodec()

View File

@ -6,6 +6,7 @@
#endif
#include <wx/object.h>
#include <wx/stream.h>
class wxSndBuffer;
@ -19,6 +20,7 @@ class wxSoundCodec;
class wxSoundDataFormat {
public:
wxSoundDataFormat();
wxSoundDataFormat(const wxSoundDataFormat& format);
~wxSoundDataFormat();
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 *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 wxSoundDataFormat GetPreferredFormat(int codec = 0) const = 0;

View File

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

View File

@ -3,7 +3,6 @@
#endif
#include "sndsnd.h"
#include "sndpcm.h"
#include <dmalloc.h>
#define WX_BIG_ENDIAN 0
@ -11,8 +10,7 @@ wxSoundPcmCodec::wxSoundPcmCodec()
: wxSoundCodec()
{
m_orig_format.SetCodecCreate(FALSE);
m_orig_format.SetCodecNo(1);
m_char_bool = FALSE;
m_orig_format.SetCodecNo(WXSOUND_PCM);
}
wxSoundPcmCodec::~wxSoundPcmCodec()
@ -31,7 +29,6 @@ wxSoundDataFormat wxSoundPcmCodec::GetPreferredFormat(int codec) const
wxSoundDataFormat prefFormat;
prefFormat = m_orig_format;
prefFormat.SetCodecNo(WXSOUND_PCM);
return prefFormat;
}
@ -69,20 +66,16 @@ void wxSoundPcmCodec::Decode()
#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);
}
// ---------------------------------------------------------------------------
@ -91,9 +84,8 @@ void wxSoundPcmCodec::InputSign8()
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)
@ -103,22 +95,23 @@ void wxSoundPcmCodec::InputSwapAndSign16()
}
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);
@ -132,13 +125,12 @@ void wxSoundPcmCodec::InputSwapAndSign16()
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));
}
@ -148,14 +140,7 @@ void wxSoundPcmCodec::OutputSwapAndSign16()
{
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)
@ -164,25 +149,27 @@ void wxSoundPcmCodec::OutputSwapAndSign16()
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);
}
}

View File

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

View File

@ -86,9 +86,6 @@ wxUint32 wxSndWavCodec::PrepareToPlay()
if (!riff_codec.FindChunk("data"))
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;
ChangeCodec(wav_hdr.format);

View File

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

View File

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