--- a/SoundStream.st Wed Dec 23 16:09:58 1998 +0100
+++ b/SoundStream.st Wed Dec 23 16:40:09 1998 +0100
@@ -1410,6 +1410,7 @@
}
if (!t_pDSBuffer || !t_pDirectSound) {
+ fprintf(stderr, "SoundStream not open!\n");
RETURN (0);
}
t_cbBufOffset = __intVal(__INST(cbBufOffset));
@@ -1422,12 +1423,14 @@
// Should be playing, right?
hr = IDirectSoundBuffer_GetStatus(t_pDSBuffer, &status );
if (!(status && DSBSTATUS_PLAYING)) {
- printf("Buffer not playing!\n");
+ fprintf(stderr, "Buffer not playing!\n");
+ RETURN (0);
}
// Sleep until we have enough room in buffer.
hr = IDirectSoundBuffer_GetCurrentPosition(t_pDSBuffer, &playPos, &safePos );
if( hr != DS_OK ) {
+ fprintf(stderr, "Cannot get position!\n");
RETURN (0);
}
if( playPos < t_cbBufOffset ) playPos += t_cbBufSize;
@@ -1445,6 +1448,7 @@
// Wake up, find out where we are now
hr = IDirectSoundBuffer_GetCurrentPosition(t_pDSBuffer, &playPos, &safePos );
if( hr != DS_OK ) {
+ fprintf(stderr, "Cannot get position!\n");
RETURN (0);
}
if( playPos < t_cbBufOffset ) playPos += t_cbBufSize; // unwrap offset
@@ -1463,7 +1467,7 @@
}
__INST(cbBufOffset) = __MKSMALLINT(t_cbBufOffset);
- RETURN (0);
+ RETURN (count);
}
#endif /* WIN32 */
@@ -1727,7 +1731,7 @@
__INST(cbBufOffset) = __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)) {
+ if ((result = IDirectSoundBuffer_Play(t_pDSBuffer, 0, 0, DSBPLAY_LOOPING) != DS_OK)) {
fprintf(stderr,"SoundStream: couldn't play sound buffer!\n");
IDirectSoundBuffer_Stop(t_pDSBuffer);
IDirectSoundBuffer_Stop(t_pDSPrimeBuffer);
@@ -1755,13 +1759,13 @@
tuneTone
audioFormat == #S16 ifTrue:[
- ^ self tuneTone16:440
+ ^ self tuneTone16:440
].
audioFormat == #U16 ifTrue:[
- ^ self tuneTone16:440
+ ^ self tuneTone16:440
].
audioFormat == #MU_LAW ifTrue:[
- ^ self tuneToneMU:440
+ ^ self tuneToneMU:440
].
self tuneTone:440
@@ -1791,18 +1795,18 @@
scale := freq * 2 * (Float pi).
1 to:numSamples do:[:i |
- val := (scale * i / numSamples) sin.
- val := (val * 16r7FFF) rounded bitAnd:16rFFFF.
- audioFormat == #U16 ifTrue:[
- val := val + 32768
- ].
- buffer at:i put:val
+ val := (scale * i / numSamples) sin.
+ val := (val * 16r7FFF) rounded bitAnd:16rFFFF.
+ audioFormat == #U16 ifTrue:[
+ val := val + 32768
+ ].
+ buffer at:i put:val
].
oldFormat := audioFormat.
self setAudioFormat:#S16.
1 to:3 do:[:s |
- self nextPutBytes:(numSamples*2) from:buffer startingAt:1
+ self nextPutBytes:(numSamples*2) from:buffer startingAt:1
].
self setAudioFormat:oldFormat.
@@ -1910,5 +1914,5 @@
!SoundStream class methodsFor:'documentation'!
version
-^ '$Header: /cvs/stx/stx/libbasic2/SoundStream.st,v 1.36 1998-12-23 15:09:58 cg Exp $'! !
+^ '$Header: /cvs/stx/stx/libbasic2/SoundStream.st,v 1.37 1998-12-23 15:40:09 cg Exp $'! !
SoundStream initialize!