**--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"
+ ])
+ ;;
+
+ *)
+
+ UNIX_THREAD="gtk/threadno.cpp"
+
+ dnl For glibc 2 users who have the old libc 5 too
- dnl pthread_create is always available in pthread but it seems not to be
- dnl the case for pthread_setcanceltype.
+ 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, [
+ 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
// ---------------------------------------------------------------------------
typedef enum {
- wxStream_NOERROR,
- wxStream_EOF
+ wxStream_NOERROR = 0,
+ wxStream_EOF,
+ wxStream_WRITE_ERR,
+ wxStream_READ_ERR
} wxStreamError;
class WXDLLEXPORT wxStreamBase {
#pragma implementation "serbase.h"
#endif
+#ifdef wxUSE_SERIAL
+
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
for (i=0;i<n;i++)
table->hash_table[i] = (wxList *)s.GetChild();
}
+
+#endif
// 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),
{
char *b_start;
- wxDELETE(m_buffer_start);
+ if (m_destroybuf)
+ wxDELETEA(m_buffer_start);
if (!bufsize) {
m_buffer_start = NULL;
}
if (!GetDataLeft() && !FlushBuffer()) {
- m_stream->m_lasterror = wxStream_EOF;
+ CHECK_ERROR(wxStream_READ_ERR);
return;
}
}
if (!GetDataLeft()) {
- m_stream->m_lasterror = wxStream_EOF;
+ CHECK_ERROR(wxStream_READ_ERR);
return 0;
}
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
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 {
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);
}
{
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;
/////////////////////////////////////////////////////////////////////////////
// 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$
/////////////////////////////////////////////////////////////////////////////
// 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$
#include "wx/wx.h"
#endif
#include <wx/stream.h>
-#include <wx/fstream.h>
+#include <wx/wfstream.h>
#include <wx/mstream.h>
#include "mmfile.h"
}
wxFragmentBuffer::wxFragBufPtr *wxFragmentBuffer::FindFreeBuffer(
- wxFragBufPtr *list, wxUint8 max_queue)
+ xFragBufPtr *list, wxUint8 max_queue)
{
if (!list)
return NULL;
wxFragBufPtr *ptr;
char *raw_buf;
wxUint32 rawbuf_size;
+ wxSoundCodec *codec = buf->GetCurrentCodec();
if (!m_iodrv->OnSetupDriver(*buf, wxSND_OUTPUT))
return FALSE;
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);
// 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);
}
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;
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))
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;
}
node = ptr->buffers->First();
}
- ptr->ptr = 0;
+ ptr->sndbuf->ResetBuffer();
ptr->state = wxBUFFER_FREE;
}
wxFragBufPtr *m_lstoptrs, *m_lstiptrs;
///
bool m_buf2free, m_dontq, m_freeing;
+ ///
+ wxSoundDataFormat m_drvformat;
public:
///
wxFragmentBuffer(wxSound& io_drv);
#include "sndsnd.h"
#include "sndfrmt.h"
#include "sndpcm.h"
-#include <dmalloc.h>
// ----------------------------------------------------------------------------
// 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);
return NULL;
if (m_codchange)
- wxDELETEA(m_codec);
+ wxDELETE(m_codec);
if (m_codec)
return m_codec;
m_in_sound = NULL;
m_out_sound = NULL;
m_init = TRUE;
+ m_chain_codec = NULL;
}
wxSoundCodec::~wxSoundCodec()
#endif
#include <wx/object.h>
+#include <wx/stream.h>
class wxSndBuffer;
class wxSoundDataFormat {
public:
wxSoundDataFormat();
+ wxSoundDataFormat(const wxSoundDataFormat& format);
~wxSoundDataFormat();
void SetSampleRate(int srate) { m_srate = srate; }
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;
InitMode(DECODING);
- while (!Good()) {
+ while (!StreamOk()) {
smp = ulaw2linear(m_in_sound->GetChar());
#ifdef USE_BE_MACH
m_out_sound->PutChar((smp & 0xff00) >> 8);
InitMode(ENCODING);
- while (!Good()) {
+ while (!StreamOk()) {
#ifdef USE_BE_MACH
smp = ((unsigned short)m_in_sound->GetChar()) << 8;
smp |= m_in_sound->GetChar() & 0xff;
#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;
}
#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);
}
}
#include <unistd.h>
#include <fcntl.h>
#include <time.h>
-#include <dmalloc.h>
#include "wx/app.h"
#include "wx/utils.h"
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);
#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"
#pragma implementation "wave.h"
#endif
-#include <wx/fstream.h>
+#include <wx/wfstream.h>
#include "wave.h"
wxWave::wxWave()