--- a/SerialPort.st Mon Sep 03 21:58:34 2012 +0200
+++ b/SerialPort.st Mon Sep 03 22:23:42 2012 +0200
@@ -26,10 +26,16 @@
#ifdef WIN32
+/* this is to catch uses of those - there should be none */
# undef __BEGIN_INTERRUPTABLE__
# undef __END_INTERRUPTABLE__
-# define __BEGIN_INTERRUPTABLE__ ..
-# define __END_INTERRUPTABLE__ ..
+# ifdef __TCC__
+# define __BEGIN_INTERRUPTABLE__ xxxx
+# define __END_INTERRUPTABLE__ yyyy
+# else
+# define __BEGIN_INTERRUPTABLE__ ..
+# define __END_INTERRUPTABLE__ ..
+# endif
# define WRAP_STDIO
@@ -305,36 +311,36 @@
t = __INST(handle);
if (t != nil) {
- FILE *fp;
+ FILE *fp;
- __INST(handle) = nil;
- fp = __FILEVal(t);
+ __INST(handle) = nil;
+ fp = __FILEVal(t);
#ifdef WIN32
- {
- int ret;
- SERIALPORT port;
+ {
+ int ret;
+ SERIALPORT port;
- port = PORT_FROM_FILE(fp);
+ port = PORT_FROM_FILE(fp);
# ifdef xxxDO_WRAP_CALLS
- do {
- __threadErrno = 0;
- ret = STX_C_CALL1("fclose", fclose, fp);
- } while ((ret < 0) && (__threadErrno == EINTR));
+ do {
+ __threadErrno = 0;
+ ret = STX_C_CALL1("fclose", fclose, fp);
+ } while ((ret < 0) && (__threadErrno == EINTR));
- do {
- __threadErrno = 0;
- ret = STX_WSA_CALL1("CloseHandle", CloseHandle, port);
- } while ((ret < 0) && (__threadErrno == EINTR));
+ do {
+ __threadErrno = 0;
+ ret = STX_WSA_CALL1("CloseHandle", CloseHandle, port);
+ } while ((ret < 0) && (__threadErrno == EINTR));
# else
- fclose(fp);
- /* In WIN32, apparently the fclose() does not close the SerialPort hadle,
- * so we have to do it here!
- */
- CloseHandle(port);
+ fclose(fp);
+ /* In WIN32, apparently the fclose() does not close the SerialPort hadle,
+ * so we have to do it here!
+ */
+ CloseHandle(port);
# endif /* DO_WRAP_CALLS */
- }
-#else
- fclose(fp);
+ }
+#else
+ fclose(fp);
#endif
}
%}
@@ -348,20 +354,20 @@
|errorSymbol errorNumber|
handle notNil ifTrue:[
- ^ self errorAlreadyOpen
+ ^ self errorAlreadyOpen
].
%{
FILE *fp;
SERIALPORT port;
char *__portName;
int __setBaudRate = 1,
- __setDataBits = 1,
- __setXOnChar = 1,
- __setXOffChar = 1,
- __setInFlowCtrl = 1,
- __setOutFlowCtrl = 1,
- __setStopBits = 1,
- __setParityType = 1;
+ __setDataBits = 1,
+ __setXOnChar = 1,
+ __setXOffChar = 1,
+ __setInFlowCtrl = 1,
+ __setOutFlowCtrl = 1,
+ __setStopBits = 1,
+ __setParityType = 1;
int __baudRate, __dataBits;
int __xOnChar, __xOffChar;
int __inFlowCtrl, __outFlowCtrl;
@@ -382,119 +388,119 @@
# define PARITY_NONE 3
if (__isStringLike(__INST(portName))) {
- __portName = __stringVal(__INST(portName));
+ __portName = __stringVal(__INST(portName));
} else {
- errorSymbol = @symbol(portName);
- goto getOutOfhere;
+ errorSymbol = @symbol(portName);
+ goto getOutOfhere;
}
if (__isSmallInteger(__INST(baudRate))) {
- __baudRate = __intVal(__INST(baudRate));
+ __baudRate = __intVal(__INST(baudRate));
} else if (__INST(baudRate) == nil) {
- __setBaudRate = 0;
+ __setBaudRate = 0;
} else {
- errorSymbol = @symbol(baudRate);
- goto getOutOfhere;
+ errorSymbol = @symbol(baudRate);
+ goto getOutOfhere;
}
if (__isSmallInteger(__INST(dataBits))) {
- __dataBits = __intVal(__INST(dataBits));
+ __dataBits = __intVal(__INST(dataBits));
} else if (__INST(dataBits) == nil) {
- __setDataBits = 0;
+ __setDataBits = 0;
} else {
- errorSymbol = @symbol(dataBits);
- goto getOutOfhere;
+ errorSymbol = @symbol(dataBits);
+ goto getOutOfhere;
}
if (__isSmallInteger(__INST(xOnChar))) {
- __xOnChar = __intVal(__INST(xOnChar));
+ __xOnChar = __intVal(__INST(xOnChar));
} else if (__isCharacter(__INST(xOnChar))) {
- __xOnChar = __intVal(_characterVal(__INST(xOnChar)));
+ __xOnChar = __intVal(_characterVal(__INST(xOnChar)));
} else if (__INST(xOnChar) == nil) {
- __setXOnChar = 0;
+ __setXOnChar = 0;
} else {
- errorSymbol = @symbol(xOnChar);
- goto getOutOfhere;
+ errorSymbol = @symbol(xOnChar);
+ goto getOutOfhere;
}
if (__isSmallInteger(__INST(xOffChar))) {
- __xOffChar = __intVal(__INST(xOffChar));
+ __xOffChar = __intVal(__INST(xOffChar));
} else if (__isCharacter(__INST(xOffChar))) {
- __xOffChar = __intVal(__characterVal(__INST(xOffChar)));
+ __xOffChar = __intVal(__characterVal(__INST(xOffChar)));
} else if (__INST(xOffChar) == nil) {
- __setXOffChar = 0;
+ __setXOffChar = 0;
} else {
- errorSymbol = @symbol(xOffChar);
- goto getOutOfhere;
+ errorSymbol = @symbol(xOffChar);
+ goto getOutOfhere;
}
if (__INST(inFlowCtrlType) == @symbol(xOnOff)) {
- __inFlowCtrl = FLOW_XONOFF;
+ __inFlowCtrl = FLOW_XONOFF;
} else if (__INST(inFlowCtrlType) == @symbol(hardware)) {
- __inFlowCtrl = FLOW_HARDWARE;
+ __inFlowCtrl = FLOW_HARDWARE;
} else if (__INST(inFlowCtrlType) == @symbol(none)) {
- __inFlowCtrl = FLOW_NONE;
+ __inFlowCtrl = FLOW_NONE;
} else if (__INST(inFlowCtrlType) == nil) {
- __setInFlowCtrl = 0;
+ __setInFlowCtrl = 0;
} else {
- errorSymbol = @symbol(inFlowCtrlType);
- goto getOutOfhere;
+ errorSymbol = @symbol(inFlowCtrlType);
+ goto getOutOfhere;
}
if (__INST(outFlowCtrlType) == @symbol(xOnOff)) {
- __outFlowCtrl = FLOW_XONOFF;
+ __outFlowCtrl = FLOW_XONOFF;
} else if (__INST(outFlowCtrlType) == @symbol(hardware)) {
- __outFlowCtrl = FLOW_HARDWARE;
+ __outFlowCtrl = FLOW_HARDWARE;
} else if (__INST(outFlowCtrlType) == @symbol(none)) {
- __outFlowCtrl = FLOW_NONE;
+ __outFlowCtrl = FLOW_NONE;
} else if (__INST(outFlowCtrlType) == nil) {
- __setOutFlowCtrl = 0;
+ __setOutFlowCtrl = 0;
} else {
- errorSymbol = @symbol(outFlowCtrlType);
- goto getOutOfhere;
+ errorSymbol = @symbol(outFlowCtrlType);
+ goto getOutOfhere;
}
if (__INST(stopBitsType) == @symbol(stop1)) {
- __stopBits = STOP_1;
+ __stopBits = STOP_1;
} else if (__INST(stopBitsType) == @symbol(stop2)) {
- __stopBits = STOP_2;
+ __stopBits = STOP_2;
} else if (__INST(stopBitsType) == @symbol(stop1_5)) {
- __stopBits = STOP_1_5;
+ __stopBits = STOP_1_5;
} else if (__INST(stopBitsType) == nil) {
- __setStopBits = 0;
+ __setStopBits = 0;
} else {
- errorSymbol = @symbol(stopBitsType);
- goto getOutOfhere;
+ errorSymbol = @symbol(stopBitsType);
+ goto getOutOfhere;
}
if (__INST(parityType) == @symbol(odd)) {
- __parityType = PARITY_ODD;
+ __parityType = PARITY_ODD;
} else if (__INST(parityType) == @symbol(even)) {
- __parityType = PARITY_EVEN;
+ __parityType = PARITY_EVEN;
} else if (__INST(parityType) == @symbol(none)) {
- __parityType = PARITY_NONE;
+ __parityType = PARITY_NONE;
} else if (__INST(parityType) == nil) {
- __setParityType = 0;
+ __setParityType = 0;
} else {
- errorSymbol = @symbol(parityType);
- goto getOutOfhere;
+ errorSymbol = @symbol(parityType);
+ goto getOutOfhere;
}
#ifdef WIN32
port = CreateFile(__portName,
- GENERIC_READ | GENERIC_WRITE,
- 0, /* comm devices must be opened with exclusive access */
- NULL, /* no security attrs */
- OPEN_EXISTING, /* comm devices must use OPEN_EXISTING */
- 0, /* no overlapped I/O */
- NULL /* hTemplate must be NULL for comm devices */
- );
+ GENERIC_READ | GENERIC_WRITE,
+ 0, /* comm devices must be opened with exclusive access */
+ NULL, /* no security attrs */
+ OPEN_EXISTING, /* comm devices must use OPEN_EXISTING */
+ 0, /* no overlapped I/O */
+ NULL /* hTemplate must be NULL for comm devices */
+ );
if (port == INVALID_HANDLE_VALUE) {
- console_fprintf(stderr, "Win32OS [info]: serial port open failed\n");
- errorNumber = __mkSmallInteger( __WIN32_ERR(GetLastError()) );
- errorSymbol = @symbol(openFailed);
- goto getOutOfhere;
+ console_fprintf(stderr, "Win32OS [info]: serial port open failed\n");
+ errorNumber = __mkSmallInteger( __WIN32_ERR(GetLastError()) );
+ errorSymbol = @symbol(openFailed);
+ goto getOutOfhere;
}
/* Flush the driver */
@@ -522,48 +528,48 @@
if (__setXOffChar) dcb.XoffChar = __xOffChar;
if (__setStopBits) {
- /* set stop bits */
- switch(__stopBits) {
- case STOP_1_5: dcb.StopBits = 1; break; /* 1.5 stop bits */
- case STOP_1: dcb.StopBits = 0; break; /* 1 stop bit */
- case STOP_2: dcb.StopBits = 2; break; /* 2 stop bits */
- default:
- errorSymbol = @symbol(stopBits);
- goto errExit;
- }
+ /* set stop bits */
+ switch(__stopBits) {
+ case STOP_1_5: dcb.StopBits = 1; break; /* 1.5 stop bits */
+ case STOP_1: dcb.StopBits = 0; break; /* 1 stop bit */
+ case STOP_2: dcb.StopBits = 2; break; /* 2 stop bits */
+ default:
+ errorSymbol = @symbol(stopBits);
+ goto errExit;
+ }
}
if (__setParityType) {
- /* set parity */
- switch(__parityType) {
- case PARITY_NONE: dcb.Parity = NOPARITY; break;
- case PARITY_ODD: dcb.Parity = ODDPARITY; break;
- case PARITY_EVEN: dcb.Parity = EVENPARITY; break;
- default:
- errorSymbol = @symbol(parityType);
- goto errExit;
- }
+ /* set parity */
+ switch(__parityType) {
+ case PARITY_NONE: dcb.Parity = NOPARITY; break;
+ case PARITY_ODD: dcb.Parity = ODDPARITY; break;
+ case PARITY_EVEN: dcb.Parity = EVENPARITY; break;
+ default:
+ errorSymbol = @symbol(parityType);
+ goto errExit;
+ }
}
if (__setInFlowCtrl) {
- /* set control flow */
- dcb.fInX = FALSE;
- dcb.fDtrControl = FALSE;
- if (__inFlowCtrl == FLOW_XONOFF) dcb.fInX = TRUE; /* XOn/XOff handshaking */
- if (__inFlowCtrl == FLOW_HARDWARE) dcb.fDtrControl = TRUE; /* hardware handshaking */
+ /* set control flow */
+ dcb.fInX = FALSE;
+ dcb.fDtrControl = FALSE;
+ if (__inFlowCtrl == FLOW_XONOFF) dcb.fInX = TRUE; /* XOn/XOff handshaking */
+ if (__inFlowCtrl == FLOW_HARDWARE) dcb.fDtrControl = TRUE; /* hardware handshaking */
}
if (__setOutFlowCtrl) {
- dcb.fOutX = FALSE;
- dcb.fOutxCtsFlow = FALSE;
+ dcb.fOutX = FALSE;
+ dcb.fOutxCtsFlow = FALSE;
- if (__outFlowCtrl == FLOW_XONOFF) dcb.fOutX = TRUE; /* XOn/XOff handshaking */
- if (__outFlowCtrl == FLOW_HARDWARE) dcb.fOutxCtsFlow = TRUE; /* hardware handshaking */
+ if (__outFlowCtrl == FLOW_XONOFF) dcb.fOutX = TRUE; /* XOn/XOff handshaking */
+ if (__outFlowCtrl == FLOW_HARDWARE) dcb.fOutxCtsFlow = TRUE; /* hardware handshaking */
}
if (! SetCommState(port, &dcb)) {
- console_fprintf(stderr, "Win32OS [info]: serial port comm-setup failed\n");
- errorNumber = __mkSmallInteger( __WIN32_ERR(GetLastError()) );
- goto errExit;
+ console_fprintf(stderr, "Win32OS [info]: serial port comm-setup failed\n");
+ errorNumber = __mkSmallInteger( __WIN32_ERR(GetLastError()) );
+ goto errExit;
}
# endif /* WIN32 */
@@ -572,31 +578,31 @@
*/
# ifdef WIN32
{
- int _fd;
- __stxWrapApiEnterCritical();
- _fd = _open_osfhandle((long)port, 0);
- fp = fdopen(_fd, "r+");
- __stxWrapApiLeaveCritical();
+ int _fd;
+ __stxWrapApiEnterCritical();
+ _fd = _open_osfhandle((long)port, 0);
+ fp = fdopen(_fd, "r+");
+ __stxWrapApiLeaveCritical();
}
# else
fp = fdopen(port, "r+");
# endif
if (! fp) {
- console_fprintf(stderr, "Win32OS [info]: fdopen failed\n");
- errorNumber = __MKSMALLINT(errno);
+ console_fprintf(stderr, "Win32OS [info]: fdopen failed\n");
+ errorNumber = __MKSMALLINT(errno);
errExit: ;
# ifdef WIN32
- CloseHandle(port);
+ CloseHandle(port);
# endif
- goto getOutOfhere;
+ goto getOutOfhere;
}
{
- OBJ t;
+ OBJ t;
- t = __MKEXTERNALADDRESS(fp);
- __INST(handle) = t;
- __STORE(self, t);
+ t = __MKEXTERNALADDRESS(fp);
+ __INST(handle) = t;
+ __STORE(self, t);
}
getOutOfhere: ;
@@ -613,13 +619,13 @@
%}.
"all ok?"
handle notNil ifTrue:[
- Lobby register:self.
+ Lobby register:self.
] ifFalse:[
- errorNumber isNil ifTrue:[
- self error:'invalid argument(s)'.
- ] ifFalse:[
- ((OperatingSystem errorHolderForNumber:errorNumber) parameter:portName) reportError
- ].
+ errorNumber isNil ifTrue:[
+ self error:'invalid argument(s)'.
+ ] ifFalse:[
+ ((OperatingSystem errorHolderForNumber:errorNumber) parameter:portName) reportError
+ ].
].
"Modified: / 05-08-2011 / 14:14:08 / cg"
@@ -646,9 +652,9 @@
!SerialPort class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic2/SerialPort.st,v 1.19 2012-07-19 17:36:36 stefan Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic2/SerialPort.st,v 1.20 2012-09-03 20:23:42 cg Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libbasic2/SerialPort.st,v 1.19 2012-07-19 17:36:36 stefan Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic2/SerialPort.st,v 1.20 2012-09-03 20:23:42 cg Exp $'
! !
--- a/Socket.st Mon Sep 03 21:58:34 2012 +0200
+++ b/Socket.st Mon Sep 03 22:23:42 2012 +0200
@@ -28,10 +28,16 @@
#ifdef WIN32
+/* this is to catch uses of those - there should be none */
# undef __BEGIN_INTERRUPTABLE__
# undef __END_INTERRUPTABLE__
-# define __BEGIN_INTERRUPTABLE__ ..
-# define __END_INTERRUPTABLE__ ..
+# ifdef __TCC__
+# define __BEGIN_INTERRUPTABLE__ xxxx
+# define __END_INTERRUPTABLE__ yyyy
+# else
+# define __BEGIN_INTERRUPTABLE__ ..
+# define __END_INTERRUPTABLE__ ..
+# endif
# define WRAP_STDIO
# define SET_LINGER_WHEN_CREATING_SOCKET
@@ -68,7 +74,7 @@
#include <errno.h>
#ifdef WIN32
-# ifndef __VISUALC__
+# ifdef __BORLANDC__
# include <Ws2tcpip.h>
# endif
#else
@@ -2995,6 +3001,7 @@
].
%{ /* STACK: 32000 */
+#ifndef NO_SOCKET
OBJ fp = __INST(handle);
if (fp != nil) {
@@ -3206,7 +3213,7 @@
ok = ( setsockopt( sock, level, opt, &u, usize) >= 0) ? true : false;
}
argError: ;
-
+#endif /* NO_SOCKET */
%}.
ok isNil ifTrue:[
self primitiveFailed
@@ -4010,9 +4017,9 @@
!Socket class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic2/Socket.st,v 1.268 2012-08-05 16:19:07 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic2/Socket.st,v 1.269 2012-09-03 20:23:42 cg Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libbasic2/Socket.st,v 1.268 2012-08-05 16:19:07 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic2/Socket.st,v 1.269 2012-09-03 20:23:42 cg Exp $'
! !
--- a/SoundStream.st Mon Sep 03 21:58:34 2012 +0200
+++ b/SoundStream.st Mon Sep 03 22:23:42 2012 +0200
@@ -22,8 +22,13 @@
!SoundStream primitiveDefinitions!
%{
+#include "stxOSDefs.h"
+
#ifdef WIN32
-# define xxxUSE_WIN32_DIRECTSOUND
+# ifndef NO_SOUND
+# define xxxUSE_WIN32_DIRECTSOUND
+# define USE_WIN32_WAVESOUND
+# endif
#endif
#ifdef IRIS
@@ -106,12 +111,10 @@
# ifndef O_WRONLY
# include <sys/fcntl.h>
# endif
-
# include <errno.h>
#endif
#ifdef WIN32
-
# define _WIN32
# undef INT
@@ -151,11 +154,11 @@
# define pDSBuffer handle2
# else /* USE WAVE... */
-
-# define WIN32_WAVE
-# define __WaveHandleVal(o) (HWAVEOUT)(__externalAddressVal(o))
-# define MAXBUF 10 /* Maximum number of buffers */
-# define DATALEN 2048 /* Size of wave data buffer */
+# ifdef USE_WIN32_WAVESOUND
+# define WIN32_WAVE
+# define __WaveHandleVal(o) (HWAVEOUT)(__externalAddressVal(o))
+# define MAXBUF 10 /* Maximum number of buffers */
+# define DATALEN 2048 /* Size of wave data buffer */
struct buf {
WAVEHDR hdr; /* Wave data header */
@@ -169,9 +172,10 @@
static int total_buffers = 0; /* Total number of buffers allocated */
static HANDLE free_buffer_event; /* Automatic-reset event triggered whenever */
-# define waveHandle handle1
+# define waveHandle handle1
-# endif
+# endif /* USE_WIN32_WAVESOUND */
+# endif /* USE_WIN32_DIRECTSOUND */
# ifdef __DEF_Array
# define Array __DEF_Array
@@ -2099,33 +2103,33 @@
ALconfig config;
ALport p;
long params[] = {
- AL_INPUT_SOURCE, AL_INPUT_MIC,
- AL_INPUT_RATE, 8000,
- AL_OUTPUT_RATE, 8000,
+ AL_INPUT_SOURCE, AL_INPUT_MIC,
+ AL_INPUT_RATE, 8000,
+ AL_OUTPUT_RATE, 8000,
};
config = ALnewconfig();
if (__INST(numberOfChannels) == __MKSMALLINT(2))
- ALsetchannels(config, AL_STEREO);
+ ALsetchannels(config, AL_STEREO);
else
- ALsetchannels(config, AL_MONO);
+ ALsetchannels(config, AL_MONO);
if (__INST(bitsPerSample) == __MKSMALLINT(16))
- ALsetwidth(config, AL_SAMPLE_16);
+ ALsetwidth(config, AL_SAMPLE_16);
else
- ALsetwidth(config, AL_SAMPLE_8);
+ ALsetwidth(config, AL_SAMPLE_8);
if (__isSmallInteger(__INST(sampleRate)))
- params[3] = params[5] = __intVal(__INST(sampleRate));
+ params[3] = params[5] = __intVal(__INST(sampleRate));
ALsetparams(AL_DEFAULT_DEVICE, params, 6);
p = ALopenport("smallchat", (char *)_stringVal(aMode), config);
if (p) {
- OBJ t;
+ OBJ t;
- t = __MKEXTERNALADDRESS(p); __INST(alPort) = t; __STORE(self, t);
+ t = __MKEXTERNALADDRESS(p); __INST(alPort) = t; __STORE(self, t);
} else {
- __INST(alPort) = nil;
- goto out;
+ __INST(alPort) = nil;
+ goto out;
}
__INST(binary) = true;
@@ -2135,27 +2139,27 @@
*/
config = ALgetconfig(p);
switch (ALgetchannels(config)) {
- default:
- /* cannot happen */
- case AL_MONO:
- __INST(numberOfChannels) = __MKSMALLINT(1);
- break;
- case AL_STEREO:
- __INST(numberOfChannels) = __MKSMALLINT(2);
- break;
+ default:
+ /* cannot happen */
+ case AL_MONO:
+ __INST(numberOfChannels) = __MKSMALLINT(1);
+ break;
+ case AL_STEREO:
+ __INST(numberOfChannels) = __MKSMALLINT(2);
+ break;
}
switch (ALgetwidth(config)) {
- default:
- /* cannot happen */
- case AL_SAMPLE_8:
- __INST(bitsPerSample) = __MKSMALLINT(8);
- break;
- case AL_SAMPLE_16:
- __INST(bitsPerSample) = __MKSMALLINT(16);
- break;
- case AL_SAMPLE_24:
- __INST(bitsPerSample) = __MKSMALLINT(24);
- break;
+ default:
+ /* cannot happen */
+ case AL_SAMPLE_8:
+ __INST(bitsPerSample) = __MKSMALLINT(8);
+ break;
+ case AL_SAMPLE_16:
+ __INST(bitsPerSample) = __MKSMALLINT(16);
+ break;
+ case AL_SAMPLE_24:
+ __INST(bitsPerSample) = __MKSMALLINT(24);
+ break;
}
ALgetparams(AL_DEFAULT_DEVICE, params, 6);
__INST(sampleRate) = __MKSMALLINT(params[3]);
@@ -2179,8 +2183,8 @@
/* Create the DS object */
if ((result = DirectSoundCreate(NULL, &t_pDirectSound, NULL)) != DS_OK) {
- console_fprintf(stderr,"SoundStream: Cannot open default sound device!!\n");
- goto out;
+ console_fprintf(stderr,"SoundStream: Cannot open default sound device!!\n");
+ goto out;
}
/* Define the wave format structure */
@@ -2201,20 +2205,20 @@
/* Create the primary DS buffer */
if ((result = IDirectSound_CreateSoundBuffer(t_pDirectSound, &primarydsbDesc,
- &t_pDSPrimeBuffer, NULL)) != DS_OK) {
- console_fprintf(stderr,"SoundStream: Cannot get the primary DS buffer address!\n");
- IDirectSound_Release(t_pDirectSound);
- goto out;
+ &t_pDSPrimeBuffer, NULL)) != DS_OK) {
+ console_fprintf(stderr,"SoundStream: Cannot get the primary DS buffer address!\n");
+ IDirectSound_Release(t_pDirectSound);
+ goto out;
}
/* Set the primary DS buffer sound format. We have to do this because
the default primary buffer is 8-bit, 22kHz! */
if ((result = IDirectSoundBuffer_SetFormat(t_pDSPrimeBuffer, &wfFormat)) != DS_OK) {
- console_fprintf(stderr,"SoundStream: Cannot set the primary DS buffer to proper sound format (%x) (%d)!\n", result, result);
- IDirectSoundBuffer_Stop(t_pDSPrimeBuffer);
- IDirectSoundBuffer_Release(t_pDSPrimeBuffer);
- IDirectSound_Release(t_pDirectSound);
- goto out;
+ console_fprintf(stderr,"SoundStream: Cannot set the primary DS buffer to proper sound format (%x) (%d)!\n", result, result);
+ IDirectSoundBuffer_Stop(t_pDSPrimeBuffer);
+ IDirectSoundBuffer_Release(t_pDSPrimeBuffer);
+ IDirectSound_Release(t_pDirectSound);
+ goto out;
}
# endif /* 0 */
@@ -2230,22 +2234,22 @@
/* Create the secondary DS buffer */
if ((result = IDirectSound_CreateSoundBuffer(t_pDirectSound, &dsbdDesc, &t_pDSBuffer, NULL)) != DS_OK) {
- console_fprintf(stderr,"SoundStream: couldn't create sound buffer!\n");
- IDirectSoundBuffer_Stop(t_pDSPrimeBuffer);
- IDirectSoundBuffer_Release(t_pDSPrimeBuffer);
- IDirectSound_Release(t_pDirectSound);
- goto out;
+ console_fprintf(stderr,"SoundStream: couldn't create sound buffer!\n");
+ IDirectSoundBuffer_Stop(t_pDSPrimeBuffer);
+ IDirectSoundBuffer_Release(t_pDSPrimeBuffer);
+ IDirectSound_Release(t_pDirectSound);
+ goto out;
}
/* Lock the DS buffer */
if ((result = IDirectSoundBuffer_Lock(t_pDSBuffer, 0, t_cbBufSize, (LPLPVOID)&pDSBuffData,
- &dwDataLen, NULL, NULL, 0)) != DS_OK) {
- console_fprintf(stderr,"SoundStream: couldn't lock sound buffer!\n");
- IDirectSoundBuffer_Stop(t_pDSBuffer);
- IDirectSoundBuffer_Stop(t_pDSPrimeBuffer);
- IDirectSoundBuffer_Release(t_pDSPrimeBuffer);
- IDirectSound_Release(t_pDirectSound);
- goto out;
+ &dwDataLen, NULL, NULL, 0)) != DS_OK) {
+ console_fprintf(stderr,"SoundStream: couldn't lock sound buffer!\n");
+ IDirectSoundBuffer_Stop(t_pDSBuffer);
+ IDirectSoundBuffer_Stop(t_pDSPrimeBuffer);
+ IDirectSoundBuffer_Release(t_pDSPrimeBuffer);
+ IDirectSound_Release(t_pDirectSound);
+ goto out;
}
/* Zero the DS buffer */
@@ -2253,32 +2257,32 @@
/* Unlock the DS buffer */
if ((result = IDirectSoundBuffer_Unlock(t_pDSBuffer, pDSBuffData, dwDataLen, NULL, 0)) != DS_OK) {
- console_fprintf(stderr,"SoundStream: couldn't unlock sound buffer!\n");
- IDirectSoundBuffer_Stop(t_pDSBuffer);
- IDirectSoundBuffer_Stop(t_pDSPrimeBuffer);
- IDirectSoundBuffer_Release(t_pDSPrimeBuffer);
- IDirectSound_Release(t_pDirectSound);
- goto out;
+ console_fprintf(stderr,"SoundStream: couldn't unlock sound buffer!\n");
+ IDirectSoundBuffer_Stop(t_pDSBuffer);
+ IDirectSoundBuffer_Stop(t_pDSPrimeBuffer);
+ IDirectSoundBuffer_Release(t_pDSPrimeBuffer);
+ IDirectSound_Release(t_pDirectSound);
+ goto out;
}
__INST(bufferOffset) = __MKSMALLINT(0); // reset last write position to start of buffer
/* Start the buffer playback */
if ((result = IDirectSoundBuffer_Play(t_pDSBuffer, 0, 0, DSBPLAY_LOOPING) != DS_OK)) {
- console_fprintf(stderr,"SoundStream: couldn't play sound buffer!\n");
- IDirectSoundBuffer_Stop(t_pDSBuffer);
- IDirectSoundBuffer_Stop(t_pDSPrimeBuffer);
- IDirectSoundBuffer_Release(t_pDSPrimeBuffer);
- IDirectSound_Release(t_pDirectSound);
- ok = false;
- goto out;
+ console_fprintf(stderr,"SoundStream: couldn't play sound buffer!\n");
+ IDirectSoundBuffer_Stop(t_pDSBuffer);
+ IDirectSoundBuffer_Stop(t_pDSPrimeBuffer);
+ IDirectSoundBuffer_Release(t_pDSPrimeBuffer);
+ IDirectSound_Release(t_pDirectSound);
+ ok = false;
+ goto out;
}
{
- OBJ t;
+ OBJ t;
- t = __MKEXTERNALADDRESS(t_pDSBuffer); __INST(pDSBuffer) = t; __STORE(self, t);
- t = __MKEXTERNALADDRESS(t_pDirectSound); __INST(pDirectSound) = t; __STORE(self, t);
+ t = __MKEXTERNALADDRESS(t_pDSBuffer); __INST(pDSBuffer) = t; __STORE(self, t);
+ t = __MKEXTERNALADDRESS(t_pDirectSound); __INST(pDirectSound) = t; __STORE(self, t);
}
ok = true;
goto out;
@@ -2293,8 +2297,8 @@
OBJ oWaveHandle;
if ((oWaveHandle = __INST(waveHandle)) != nil) {
- ok = false;
- goto out;
+ ok = false;
+ goto out;
}
waveFormat.wf.wFormatTag = WAVE_FORMAT_PCM;
@@ -2305,15 +2309,15 @@
waveFormat.wf.nAvgBytesPerSec = waveFormat.wf.nSamplesPerSec * waveFormat.wf.nBlockAlign;
r = waveOutOpen(&t_waveHandle,
- WAVE_MAPPER,
- (WAVEFORMAT *)&waveFormat,
- (DWORD)waveCallBack,
- 0,
- CALLBACK_FUNCTION);
+ WAVE_MAPPER,
+ (WAVEFORMAT *)&waveFormat,
+ (DWORD)waveCallBack,
+ 0,
+ CALLBACK_FUNCTION);
if (r != 0) {
- console_printf("waveOutOpen\n");
- ok = false;
- goto out;
+ console_printf("waveOutOpen\n");
+ ok = false;
+ goto out;
}
(void)waveOutReset(t_waveHandle);
@@ -2325,9 +2329,9 @@
total_buffers = 0;
{
- OBJ t;
+ OBJ t;
- t = __MKEXTERNALADDRESS(t_waveHandle); __INST(waveHandle) = t; __STORE(self, t);
+ t = __MKEXTERNALADDRESS(t_waveHandle); __INST(waveHandle) = t; __STORE(self, t);
}
# if 0
@@ -2338,12 +2342,12 @@
* why - DAC
*/
{
- char null[DATALEN];
- int i;
- for (i = 0; i < DATALEN; i++) {
- null[i] = 127;
- }
- audioWrite(null, DATALEN);
+ char null[DATALEN];
+ int i;
+ for (i = 0; i < DATALEN; i++) {
+ null[i] = 127;
+ }
+ audioWrite(null, DATALEN);
}
# endif /* 0 */
ok = true;
@@ -2358,49 +2362,49 @@
FILE *f;
if (strcmp(__stringVal(aMode), "w") == 0) {
- __mode = O_WRONLY;
+ __mode = O_WRONLY;
} else if (strcmp(__stringVal(aMode), "r") == 0) {
- __mode = O_RDONLY;
+ __mode = O_RDONLY;
} else {
- __mode = O_RDWR;
+ __mode = O_RDWR;
}
do {
- __BEGIN_INTERRUPTABLE__
- __fd = open((char *) __stringVal(__INST(pathName)), __mode /* |O_NDELAY */);
- __END_INTERRUPTABLE__
+ __BEGIN_INTERRUPTABLE__
+ __fd = open((char *) __stringVal(__INST(pathName)), __mode /* |O_NDELAY */);
+ __END_INTERRUPTABLE__
} while ((__fd < 0) && (__threadErrno == EINTR));
if (__fd >= 0) {
- /*
- * make it a FILE *
- */
- f = fdopen(__fd, __stringVal(aMode));
- if (! f) {
- __BEGIN_INTERRUPTABLE__
- close(__fd);
- __END_INTERRUPTABLE__
- ok = false;
- goto out;
- }
- setbuf(f, NULL);
- __INST(buffered) = false;
- __INST(handle) = __MKEXTERNALADDRESS(f);
- __STORESELF(handle);
+ /*
+ * make it a FILE *
+ */
+ f = fdopen(__fd, __stringVal(aMode));
+ if (! f) {
+ __BEGIN_INTERRUPTABLE__
+ close(__fd);
+ __END_INTERRUPTABLE__
+ ok = false;
+ goto out;
+ }
+ setbuf(f, NULL);
+ __INST(buffered) = false;
+ __INST(handle) = __MKEXTERNALADDRESS(f);
+ __STORESELF(handle);
#if defined(PCM_ENABLE_OUTPUT) && defined(PCM_ENABLE_INPUT)
# if defined(SNDCTL_DSP_SETTRIGGER)
- if (__mode == O_RDWR) {
- int enable_bits = ~(PCM_ENABLE_OUTPUT|PCM_ENABLE_INPUT);
+ if (__mode == O_RDWR) {
+ int enable_bits = ~(PCM_ENABLE_OUTPUT|PCM_ENABLE_INPUT);
- if (ioctl(__fd, SNDCTL_DSP_SETTRIGGER, &enable_bits) == -1)
- {
- console_fprintf(stderr, "can't request synchronous start of fullduplex operation");
- }
- }
+ if (ioctl(__fd, SNDCTL_DSP_SETTRIGGER, &enable_bits) == -1)
+ {
+ console_fprintf(stderr, "can't request synchronous start of fullduplex operation");
+ }
+ }
# endif
#endif
- ok = true;
- goto out;
+ ok = true;
+ goto out;
}
}
#endif /* DEV_AUDIO */
@@ -2408,14 +2412,14 @@
out:;
%}.
ok == false ifTrue:[
- self openError.
- "not reached"
- ^ nil.
+ self openError.
+ "not reached"
+ ^ nil.
].
ok isNil ifTrue:[
- "its a regular file open (i.e. /dev/audio) "
- ^ super openWithMode:aMode attributes:attributeSpec.
+ "its a regular file open (i.e. /dev/audio) "
+ ^ super openWithMode:aMode attributes:attributeSpec.
].
Lobby register:self.
@@ -2694,11 +2698,11 @@
!SoundStream class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic2/SoundStream.st,v 1.72 2010-02-01 18:19:49 stefan Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic2/SoundStream.st,v 1.73 2012-09-03 20:23:42 cg Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libbasic2/SoundStream.st,v 1.72 2010-02-01 18:19:49 stefan Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic2/SoundStream.st,v 1.73 2012-09-03 20:23:42 cg Exp $'
! !
SoundStream initialize!