SoundStream.st
changeset 1839 c10cd58ec334
parent 1583 a45ac92afbc8
child 1853 b9c4a09bfc6a
--- a/SoundStream.st	Thu Jan 18 16:16:27 2007 +0100
+++ b/SoundStream.st	Wed Jan 24 16:12:17 2007 +0100
@@ -220,7 +220,7 @@
 #endif /* WIN32 */
 
 #ifdef DEBUG_SOUND
-# define DPRINTF(x) printf x
+# define DPRINTF(x) console_printf x
 #else
 # define DPRINTF(x) /* as nothing */
 #endif
@@ -1211,7 +1211,7 @@
 		__fmt = AUDIO_FORMAT_ALAW;
 # endif
 	    } else {
-		fprintf(stderr, "bad format: %s\n", __stringVal(sym));
+		console_fprintf(stderr, "bad format: %s\n", __stringVal(sym));
 		goto bad;
 	    }
 	}
@@ -1224,15 +1224,15 @@
 		__INST(audioFormat) = sym;
 		RETURN (self);
 	    } else {
-		/* fprintf(stderr, "want: %x; got: %x\n", __fmtWant, __fmt); */
+		/* console_fprintf(stderr, "want: %x; got: %x\n", __fmtWant, __fmt); */
 	    }
 	} else {
-		/* fprintf(stderr, "got err-ret from setFmp %x\n", __fmt); */
+		/* console_fprintf(stderr, "got err-ret from setFmp %x\n", __fmt); */
 	}
 # else
 #  ifdef AUDIO_SET_DATA_FORMAT /* hpux */
 	if (ioctl (f, AUDIO_SET_DATA_FORMAT, __fmt)) {
-	    /* fprintf(stderr, "got err-ret from AUDIO_SET_DATA_FORMAT\n"); */
+	    /* console_fprintf(stderr, "got err-ret from AUDIO_SET_DATA_FORMAT\n"); */
 	}
 #  endif
 # endif /* SNDCTL_DSP_SETFMT */
@@ -1295,7 +1295,7 @@
 #  else
 #   ifdef AUDIO_SET_CHANNELS /* hpux */
 	if (ioctl (f, AUDIO_SET_CHANNELS, __nCh)) {
-	    /* fprintf(stderr, "got err-ret from AUDIO_SET_CHANNELS\n"); */
+	    /* console_fprintf(stderr, "got err-ret from AUDIO_SET_CHANNELS\n"); */
 	    __INST(numberOfChannels) = nChannels;
 	    RETURN (self);
 	}
@@ -1342,7 +1342,7 @@
 # endif
 # ifdef AUDIO_SET_CHANNELS /* hpux */
 	if (ioctl (f, AUDIO_SET_TXBUFSIZE, __blockSize)) {
-	    /* fprintf(stderr, "got err-ret from AUDIO_SET_TXBUFSIZE\n"); */
+	    /* console_fprintf(stderr, "got err-ret from AUDIO_SET_TXBUFSIZE\n"); */
 	    /* __INST(blockSize) = blockSize; */
 	    RETURN (self);
 	}
@@ -1376,7 +1376,7 @@
 # if defined(SNDCTL_DSP_SPEED)
 	if (ioctl(f, SNDCTL_DSP_SPEED, &__rate) >= 0) {
 	    if (__rate != __rateWant) {
-		fprintf(stderr, "SoundStream [warning]: actual rate is %d\n", __rate);
+		console_fprintf(stderr, "SoundStream [warning]: actual rate is %d\n", __rate);
 		hz = __MKSMALLINT(__rate);
 	    }
 	    __INST(sampleRate) = hz;
@@ -1386,7 +1386,7 @@
 #  if defined(SOUND_PCM_WRITE_RATE)
 	if (ioctl(f, SOUND_PCM_WRITE_RATE, &__rate) >= 0) {
 	    if (__rate != __rateWant) {
-		fprintf(stderr, "SoundStream [warning]: actual rate is %d\n", __rate);
+		console_fprintf(stderr, "SoundStream [warning]: actual rate is %d\n", __rate);
 		hz = __MKSMALLINT(__rate);
 	    }
 	    __INST(sampleRate) = hz;
@@ -1395,7 +1395,7 @@
 #  else
 #   ifdef AUDIO_SET_SAMPLE_RATE /* hpux */
 	if (ioctl (f, AUDIO_SET_SAMPLE_RATE, __rate)) {
-	    /* fprintf(stderr, "got err-ret from AUDIO_SET_SAMPLE_RATE\n"); */
+	    /* console_fprintf(stderr, "got err-ret from AUDIO_SET_SAMPLE_RATE\n"); */
 	    __INST(sampleRate) = hz;
 	    RETURN (self);
 	}
@@ -1625,7 +1625,7 @@
 
 	/* Close the device */
 	if ((r = waveOutClose(t_waveHandle)) != 0) {
-	    printf("waveOutClose\n");
+	    console_printf("waveOutClose\n");
 	    RETURN(self);
 	}
 
@@ -1792,13 +1792,13 @@
 # endif
 			__BEGIN_INTERRUPTABLE__
 			__END_INTERRUPTABLE__
-/* printf("SoundStream: read %d bytes\n", n); */
+/* console_printf("SoundStream: read %d bytes\n", n); */
 			if (n > 0) {
 			    offs += n;
 			    cnt -= n;
 			} else {
 			    if (n < 0) {
-				fprintf(stderr, "read error: %d\n", __threadErrno);
+				console_fprintf(stderr, "read error: %d\n", __threadErrno);
 				RETURN (count);
 			    }
 			}
@@ -1887,7 +1887,7 @@
     }
 
     if (!t_pDSBuffer || !t_pDirectSound) {
-	fprintf(stderr, "SoundStream not open!\n");
+	console_fprintf(stderr, "SoundStream not open!\n");
 	RETURN (0);
     }
     t_cbBufOffset = __intVal(__INST(bufferOffset));
@@ -1900,14 +1900,14 @@
     // Should be playing, right?
     hr = IDirectSoundBuffer_GetStatus(t_pDSBuffer, &status );
     if (!(status && DSBSTATUS_PLAYING)) {
-	fprintf(stderr, "Buffer not playing!\n");
+	console_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");
+	console_fprintf(stderr, "Cannot get position!\n");
 	RETURN (0);
     }
     if( playPos < t_cbBufOffset ) playPos += t_cbBufSize;
@@ -1925,7 +1925,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");
+	    console_fprintf(stderr, "Cannot get position!\n");
 	    RETURN (0);
 	}
 	if( playPos < t_cbBufOffset ) playPos += t_cbBufSize; // unwrap offset
@@ -1986,7 +1986,7 @@
 	    LeaveCriticalSection(&free_list_lock);
 	    r = waveOutUnprepareHeader(t_waveHandle, &bp->hdr, sizeof(WAVEHDR));
 	    if (r != 0) {
-		printf("waveOutUnprepareHeader\n");
+		console_printf("waveOutUnprepareHeader\n");
 		RETURN(self);
 	    }
 	}
@@ -1999,7 +1999,7 @@
 	bp->hdr.dwLoops = 0;
 	r = waveOutPrepareHeader(t_waveHandle, &bp->hdr, sizeof(WAVEHDR));
 	if (r != 0) {
-	    printf("waveOutPrepareHeader\n");
+	    console_printf("waveOutPrepareHeader\n");
 	    RETURN(self);
 	}
 	for (i = 0; i < len; i++) {
@@ -2007,7 +2007,7 @@
 	}
 	r = waveOutWrite(t_waveHandle, &bp->hdr, sizeof(WAVEHDR));
 	if (r != 0) {
-	    printf("waveOutWrite\n");
+	    console_printf("waveOutWrite\n");
 	    RETURN(self);
 	}
 	buf += len;
@@ -2067,7 +2067,7 @@
 			    cnt -= n;
 			} else {
 			    if (n < 0) {
-				fprintf(stderr, "write error: %d\n", __threadErrno);
+				console_fprintf(stderr, "write error: %d\n", __threadErrno);
 				RETURN (count);
 			    }
 			}
@@ -2172,7 +2172,7 @@
 
     /* Create the DS object */
     if ((result = DirectSoundCreate(NULL, &t_pDirectSound, NULL)) != DS_OK) {
-	fprintf(stderr,"SoundStream: Cannot open default sound device!!\n");
+	console_fprintf(stderr,"SoundStream: Cannot open default sound device!!\n");
 	goto out;
     }
 
@@ -2195,7 +2195,7 @@
     /* Create the primary DS buffer */
     if ((result = IDirectSound_CreateSoundBuffer(t_pDirectSound, &primarydsbDesc,
 						 &t_pDSPrimeBuffer, NULL)) != DS_OK) {
-	fprintf(stderr,"SoundStream: Cannot get the primary DS buffer address!\n");
+	console_fprintf(stderr,"SoundStream: Cannot get the primary DS buffer address!\n");
 	IDirectSound_Release(t_pDirectSound);
 	goto out;
     }
@@ -2203,7 +2203,7 @@
     /* 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) {
-	fprintf(stderr,"SoundStream: Cannot set the primary DS buffer to proper sound format (%x) (%d)!\n", result, result);
+	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);
@@ -2223,7 +2223,7 @@
 
     /* Create the secondary DS buffer */
     if ((result = IDirectSound_CreateSoundBuffer(t_pDirectSound, &dsbdDesc, &t_pDSBuffer, NULL)) != DS_OK) {
-	fprintf(stderr,"SoundStream: couldn't create sound buffer!\n");
+	console_fprintf(stderr,"SoundStream: couldn't create sound buffer!\n");
 	IDirectSoundBuffer_Stop(t_pDSPrimeBuffer);
 	IDirectSoundBuffer_Release(t_pDSPrimeBuffer);
 	IDirectSound_Release(t_pDirectSound);
@@ -2233,7 +2233,7 @@
     /* Lock the DS buffer */
     if ((result = IDirectSoundBuffer_Lock(t_pDSBuffer, 0, t_cbBufSize, (LPLPVOID)&pDSBuffData,
 					  &dwDataLen, NULL, NULL, 0)) != DS_OK) {
-	fprintf(stderr,"SoundStream: couldn't lock sound buffer!\n");
+	console_fprintf(stderr,"SoundStream: couldn't lock sound buffer!\n");
 	IDirectSoundBuffer_Stop(t_pDSBuffer);
 	IDirectSoundBuffer_Stop(t_pDSPrimeBuffer);
 	IDirectSoundBuffer_Release(t_pDSPrimeBuffer);
@@ -2246,7 +2246,7 @@
 
     /* Unlock the DS buffer */
     if ((result = IDirectSoundBuffer_Unlock(t_pDSBuffer, pDSBuffData, dwDataLen, NULL, 0)) != DS_OK) {
-	fprintf(stderr,"SoundStream: couldn't unlock sound buffer!\n");
+	console_fprintf(stderr,"SoundStream: couldn't unlock sound buffer!\n");
 	IDirectSoundBuffer_Stop(t_pDSBuffer);
 	IDirectSoundBuffer_Stop(t_pDSPrimeBuffer);
 	IDirectSoundBuffer_Release(t_pDSPrimeBuffer);
@@ -2258,7 +2258,7 @@
 
     /* Start the buffer playback */
     if ((result = IDirectSoundBuffer_Play(t_pDSBuffer, 0, 0, DSBPLAY_LOOPING) != DS_OK)) {
-	fprintf(stderr,"SoundStream: couldn't play sound buffer!\n");
+	console_fprintf(stderr,"SoundStream: couldn't play sound buffer!\n");
 	IDirectSoundBuffer_Stop(t_pDSBuffer);
 	IDirectSoundBuffer_Stop(t_pDSPrimeBuffer);
 	IDirectSoundBuffer_Release(t_pDSPrimeBuffer);
@@ -2304,7 +2304,7 @@
 		    0,
 		    CALLBACK_FUNCTION);
     if (r != 0) {
-	printf("waveOutOpen\n");
+	console_printf("waveOutOpen\n");
 	ok = false;
 	goto out;
     }
@@ -2387,7 +2387,7 @@
 
 	      if (ioctl(__fd, SNDCTL_DSP_SETTRIGGER, &enable_bits) == -1)
 	      {
-		  fprintf(stderr, "can't request synchronous start of fullduplex operation");
+		  console_fprintf(stderr, "can't request synchronous start of fullduplex operation");
 	      }
 	  }
 # endif
@@ -2687,7 +2687,7 @@
 !SoundStream class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic2/SoundStream.st,v 1.68 2005-12-22 16:55:51 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic2/SoundStream.st,v 1.69 2007-01-24 15:12:16 cg Exp $'
 ! !
 
 SoundStream initialize!