git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1258
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
17 files changed:
**--without-threads Force disabling threads,
wxUSE_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
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"
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
fi
if test "$wxUSE_MOTIF" = "1"; then
// ---------------------------------------------------------------------------
typedef enum {
// ---------------------------------------------------------------------------
typedef enum {
- wxStream_NOERROR,
- wxStream_EOF
+ wxStream_NOERROR = 0,
+ wxStream_EOF,
+ wxStream_WRITE_ERR,
+ wxStream_READ_ERR
} wxStreamError;
class WXDLLEXPORT wxStreamBase {
} wxStreamError;
class WXDLLEXPORT wxStreamBase {
#pragma implementation "serbase.h"
#endif
#pragma implementation "serbase.h"
#endif
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
// 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();
}
for (i=0;i<n;i++)
table->hash_table[i] = (wxList *)s.GetChild();
}
// wxStreamBuffer
// ----------------------------------------------------------------------------
// 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),
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),
- wxDELETE(m_buffer_start);
+ if (m_destroybuf)
+ wxDELETEA(m_buffer_start);
if (!bufsize) {
m_buffer_start = NULL;
if (!bufsize) {
m_buffer_start = NULL;
}
if (!GetDataLeft() && !FlushBuffer()) {
}
if (!GetDataLeft() && !FlushBuffer()) {
- m_stream->m_lasterror = wxStream_EOF;
+ CHECK_ERROR(wxStream_READ_ERR);
- m_stream->m_lasterror = wxStream_EOF;
+ CHECK_ERROR(wxStream_READ_ERR);
buffer = (void *)((char *)buffer+m_stream->m_lastcount);
buffer = (void *)((char *)buffer+m_stream->m_lastcount);
return (m_stream->m_lastcount += m_stream->OnSysRead(buffer, size));
return (m_stream->m_lastcount += m_stream->OnSysRead(buffer, size));
// -----------------
// Buffering enabled
// -----------------
// Buffering enabled
buffer = (char *)buffer + buf_left; // ANSI C++ violation.
if (!FillBuffer()) {
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 {
return (m_stream->m_lastcount = orig_size-size);
}
} else {
buffer = (char *)buffer + buf_left; // ANSI C++ violation.
if (!FlushBuffer()) {
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);
}
return (m_stream->m_lastcount = orig_size-size);
}
{
char buf[BUF_TEMP_SIZE];
size_t s = 0, bytes_count = BUF_TEMP_SIZE;
{
char buf[BUF_TEMP_SIZE];
size_t s = 0, bytes_count = BUF_TEMP_SIZE;
while (bytes_count == BUF_TEMP_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;
bytes_count = sbuf->Read(buf, bytes_count);
bytes_count = Write(buf, bytes_count);
s += bytes_count;
/////////////////////////////////////////////////////////////////////////////
// Name: thread.cpp
/////////////////////////////////////////////////////////////////////////////
// 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$
// Modified by:
// Created: 04/22/98
// RCS-ID: $Id$
/////////////////////////////////////////////////////////////////////////////
// Name: thread.cpp
/////////////////////////////////////////////////////////////////////////////
// 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$
// Modified by:
// Created: 04/22/98
// RCS-ID: $Id$
#include "wx/wx.h"
#endif
#include <wx/stream.h>
#include "wx/wx.h"
#endif
#include <wx/stream.h>
+#include <wx/wfstream.h>
#include <wx/mstream.h>
#include "mmfile.h"
#include <wx/mstream.h>
#include "mmfile.h"
}
wxFragmentBuffer::wxFragBufPtr *wxFragmentBuffer::FindFreeBuffer(
}
wxFragmentBuffer::wxFragBufPtr *wxFragmentBuffer::FindFreeBuffer(
- wxFragBufPtr *list, wxUint8 max_queue)
+ xFragBufPtr *list, wxUint8 max_queue)
{
if (!list)
return NULL;
{
if (!list)
return NULL;
wxFragBufPtr *ptr;
char *raw_buf;
wxUint32 rawbuf_size;
wxFragBufPtr *ptr;
char *raw_buf;
wxUint32 rawbuf_size;
+ wxSoundCodec *codec = buf->GetCurrentCodec();
if (!m_iodrv->OnSetupDriver(*buf, wxSND_OUTPUT))
return FALSE;
if (!m_iodrv->OnSetupDriver(*buf, wxSND_OUTPUT))
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);
- buf->OnNeedOutputData(raw_buf, rawbuf_size);
// No data to fill the buffer: dequeue the current wxSndBuffer
// No data to fill the buffer: dequeue the current wxSndBuffer
+ if (!codec->Available()) {
if (buf->IsNotSet(wxSND_KEEPQUEUED)) {
buf->Set(wxSND_UNQUEUEING);
m_iodrv->m_buffers.DeleteObject(buf);
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);
// Data: append it to the list
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;
OnBufferFilled(ptr, wxSND_OUTPUT);
}
ptr->state = wxBUFFER_FFILLED;
OnBufferFilled(ptr, wxSND_OUTPUT);
}
bool wxFragmentBuffer::NotifyInputBuffer(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))
+ while (1) {
+ ptr = FindFreeBuffer(m_lstiptrs, m_maxiq);
+ if (!ptr)
+ return FALSE;
+
raw_buf = ptr->data + ptr->ptr;
rawbuf_size = ptr->size - ptr->ptr;
raw_buf = ptr->data + ptr->ptr;
rawbuf_size = ptr->size - ptr->ptr;
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) {
ptr->state = wxBUFFER_FFILLED;
if (!OnBufferFilled(ptr, wxSND_INPUT))
if (!LastBuffer() && ptr->ptr) {
ptr->state = wxBUFFER_FFILLED;
if (!OnBufferFilled(ptr, wxSND_INPUT))
- // Input buffer full => get data
if (ptr->ptr == ptr->size) {
ptr->state = wxBUFFER_FFILLED;
if (!OnBufferFilled(ptr, wxSND_INPUT))
return FALSE;
}
}
if (ptr->ptr == ptr->size) {
ptr->state = wxBUFFER_FFILLED;
if (!OnBufferFilled(ptr, wxSND_INPUT))
return FALSE;
}
}
node = ptr->buffers->First();
}
node = ptr->buffers->First();
}
+ ptr->sndbuf->ResetBuffer();
ptr->state = wxBUFFER_FREE;
}
ptr->state = wxBUFFER_FREE;
}
wxFragBufPtr *m_lstoptrs, *m_lstiptrs;
///
bool m_buf2free, m_dontq, m_freeing;
wxFragBufPtr *m_lstoptrs, *m_lstiptrs;
///
bool m_buf2free, m_dontq, m_freeing;
+ ///
+ wxSoundDataFormat m_drvformat;
public:
///
wxFragmentBuffer(wxSound& io_drv);
public:
///
wxFragmentBuffer(wxSound& io_drv);
#include "sndsnd.h"
#include "sndfrmt.h"
#include "sndpcm.h"
#include "sndsnd.h"
#include "sndfrmt.h"
#include "sndpcm.h"
// ----------------------------------------------------------------------------
// wxSoundDataFormat
// ----------------------------------------------------------------------------
// wxSoundDataFormat
+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);
wxSoundDataFormat::~wxSoundDataFormat()
{
wxDELETE(m_codec);
return NULL;
if (m_codchange)
return NULL;
if (m_codchange)
if (m_codec)
return m_codec;
if (m_codec)
return m_codec;
m_in_sound = NULL;
m_out_sound = NULL;
m_init = TRUE;
m_in_sound = NULL;
m_out_sound = NULL;
m_init = TRUE;
}
wxSoundCodec::~wxSoundCodec()
}
wxSoundCodec::~wxSoundCodec()
#endif
#include <wx/object.h>
#endif
#include <wx/object.h>
class wxSoundDataFormat {
public:
wxSoundDataFormat();
class wxSoundDataFormat {
public:
wxSoundDataFormat();
+ wxSoundDataFormat(const wxSoundDataFormat& format);
~wxSoundDataFormat();
void SetSampleRate(int srate) { m_srate = srate; }
~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 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;
virtual size_t GetByteRate() const = 0;
virtual wxSoundDataFormat GetPreferredFormat(int codec = 0) const = 0;
smp = ulaw2linear(m_in_sound->GetChar());
#ifdef USE_BE_MACH
m_out_sound->PutChar((smp & 0xff00) >> 8);
smp = ulaw2linear(m_in_sound->GetChar());
#ifdef USE_BE_MACH
m_out_sound->PutChar((smp & 0xff00) >> 8);
#ifdef USE_BE_MACH
smp = ((unsigned short)m_in_sound->GetChar()) << 8;
smp |= m_in_sound->GetChar() & 0xff;
#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"
#endif
#include "sndsnd.h"
#include "sndpcm.h"
: wxSoundCodec()
{
m_orig_format.SetCodecCreate(FALSE);
: wxSoundCodec()
{
m_orig_format.SetCodecCreate(FALSE);
- m_orig_format.SetCodecNo(1);
- m_char_bool = FALSE;
+ m_orig_format.SetCodecNo(WXSOUND_PCM);
}
wxSoundPcmCodec::~wxSoundPcmCodec()
}
wxSoundPcmCodec::~wxSoundPcmCodec()
wxSoundDataFormat prefFormat;
prefFormat = m_orig_format;
wxSoundDataFormat prefFormat;
prefFormat = m_orig_format;
- prefFormat.SetCodecNo(WXSOUND_PCM);
#define GET() (m_in_sound->GetChar())
#define PUT(c) (m_out_sound->PutChar(c))
#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;
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;
if (m_io_format.GetSign() != m_orig_format.GetSign())
signer = 128;
- while (IN_ERROR() && OUT_ERROR())
}
// ---------------------------------------------------------------------------
}
// ---------------------------------------------------------------------------
void wxSoundPcmCodec::InputSwapAndSign16()
{
unsigned short signer1 = 0, signer2 = 0;
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());
bool swap = (m_io_format.GetByteOrder() != m_orig_format.GetByteOrder());
+ register char temp, temp2;
if (m_io_format.GetSign() != m_orig_format.GetSign()) {
if (m_io_format.GetByteOrder() == wxSND_SAMPLE_LE)
if (m_io_format.GetSign() != m_orig_format.GetSign()) {
if (m_io_format.GetByteOrder() == wxSND_SAMPLE_LE)
- 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);
- 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);
break;
}
PUT(GET() ^ signer2);
void wxSoundPcmCodec::OutputSign8()
{
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;
unsigned char signer = 0;
if (m_io_format.GetSign() != m_orig_format.GetSign())
signer = 128;
- while (IN_ERROR() && OUT_ERROR())
PUT((char)(GET() + signer));
}
PUT((char)(GET() + signer));
}
{
bool swap = (m_io_format.GetByteOrder() != m_orig_format.GetByteOrder());
unsigned short signer1 = 0, signer2 = 0;
{
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)
if (m_io_format.GetSign() != m_orig_format.GetSign())
if (m_io_format.GetByteOrder() == wxSND_SAMPLE_LE)
signer2 = 0x80;
if (swap) {
signer2 = 0x80;
if (swap) {
- 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 {
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);
#include <unistd.h>
#include <fcntl.h>
#include <time.h>
#include <unistd.h>
#include <fcntl.h>
#include <time.h>
#include "wx/app.h"
#include "wx/utils.h"
#include "wx/app.h"
#include "wx/utils.h"
if (!riff_codec.FindChunk("data"))
return 0;
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);
m_sndmode = wxSND_OUTPUT;
ChangeCodec(wav_hdr.format);
#ifdef __GNUG__
#pragma implementation "vidbase.h"
#endif
#ifdef __GNUG__
#pragma implementation "vidbase.h"
#endif
+#include <wx/wfstream.h>
#include "vidbase.h"
#ifdef WX_PRECOMP
#include "wx_prec.h"
#include "vidbase.h"
#ifdef WX_PRECOMP
#include "wx_prec.h"
#pragma implementation "wave.h"
#endif
#pragma implementation "wave.h"
#endif
+#include <wx/wfstream.h>
#include "wave.h"
wxWave::wxWave()
#include "wave.h"
wxWave::wxWave()