### patch number: 22
### area:	libAF, aplay, arecord.
### severity:	low.
### comments: 	patch using command "(cd <audio_root> ; patch -p < thisfile)"
###             Changes to blocking sizes.

*** ./patchlevel.h	Wed Mar  3 16:02:55 1993
--- /crl/audio/./patchlevel.h	Fri Mar  5 11:30:15 1993
***************
*** 1 ****
! #define       PATCHLEVEL      21
--- 1 ----
! #define	PATCHLEVEL	22
*** ./AF/lib/AF/Play.c	Wed Mar  3 11:33:13 1993
--- /crl/audio/./AF/lib/AF/Play.c	Thu Mar 25 11:06:04 1993
***************
*** 124,131 ****
                  _ADefaultIOError(ac->connection);
      }
      nsamples = nbytes / ssize;
!     chunk_size = MIN(CHUNKSIZE, ac->connection->max_request_size - sz_aPlaySamplesReq) 
! 			/ ssize;
  
      while (nsamples > 0) {
  	    len = min(chunk_size, nsamples);
--- 124,131 ----
                  _ADefaultIOError(ac->connection);
      }
      nsamples = nbytes / ssize;
!     chunk_size = (MIN(CHUNKSIZE, ac->connection->max_request_size)
! 			- sz_aPlaySamplesReq) / ssize;
  
      while (nsamples > 0) {
  	    len = min(chunk_size, nsamples);
*** ./AF/lib/AF/Record.c	Wed Mar  3 11:33:13 1993
--- /crl/audio/./AF/lib/AF/Record.c	Thu Mar 25 11:07:09 1993
***************
*** 132,139 ****
  		_ADefaultIOError(ac->connection);
      }
      nsamples = nbytes / ssize;
!     chunk_size = MIN(CHUNKSIZE, ac->connection->max_request_size - sz_aRecordSamplesReq) 
! 			/ ssize;
  
      while (nsamples > 0) {
  	    len = min(chunk_size / ssize, nsamples);
--- 132,139 ----
  		_ADefaultIOError(ac->connection);
      }
      nsamples = nbytes / ssize;
!     chunk_size = (MIN(CHUNKSIZE, ac->connection->max_request_size)
! 			 - sz_aRecordSamplesReq) / ssize;
  
      while (nsamples > 0) {
  	    len = min(chunk_size / ssize, nsamples);
*** ./AF/clients/aplay/aplay.c	Wed Mar  3 11:33:14 1993
--- /crl/audio/./AF/clients/aplay/aplay.c	Thu Mar 25 15:08:59 1993
***************
*** 47,54 ****
  
  #define DEFAULT_FILE "bob.snd"	/* Needs SOUND_PATH */
  
! #define BUFSIZE  16384			/* buffer size, in samples */
  int flushflag = 0;
  
  /* convert data type to sample size.  Should this be in the AF include
     file somewhere for everyone to use?  See the type encodings in 'audio.h'
--- 47,55 ----
  
  #define DEFAULT_FILE "bob.snd"	/* Needs SOUND_PATH */
  
! #define BUFSIZE  2.0			/* buffer size, in seconds */
  int flushflag = 0;
+ int bufsize;				/* buffer size, in seconds */
  
  /* convert data type to sample size.  Should this be in the AF include
     file somewhere for everyone to use?  See the type encodings in 'audio.h'
***************
*** 214,227 ****
      type = ac->device->playBufType;
      channels = ac->device->playNchannels;
      ssize = sample_sizes[type] * channels;
  
  /* allocate play buffer */
!     if((buf = malloc(BUFSIZE*ssize)) == NULL) {
  	fprintf(stderr, "Couldn't allocate play buffer\n");
  	exit(1);
      }
  
!     if((nbytes = read(fd, buf, BUFSIZE*ssize)) <= 0) 
  	exit(0);
  
      old_handler = signal(SIGINT, handle_int);
--- 215,229 ----
      type = ac->device->playBufType;
      channels = ac->device->playNchannels;
      ssize = sample_sizes[type] * channels;
+     bufsize = srate * BUFSIZE;
  
  /* allocate play buffer */
!     if((buf = malloc(bufsize*ssize)) == NULL) {
  	fprintf(stderr, "Couldn't allocate play buffer\n");
  	exit(1);
      }
  
!     if((nbytes = read(fd, buf, bufsize*ssize)) <= 0) 
  	exit(0);
  
      old_handler = signal(SIGINT, handle_int);
***************
*** 235,244 ****
  	t += nsamples;
  	/* AF holds samples from nact to t */
  	if (int_flag) break;
!     } while ( (nbytes = read(fd, buf, BUFSIZE*ssize)) != 0);
      if (int_flag)
      {
!       AFSilence(ac->device->playBufType, buf, BUFSIZE*ssize);
        attributes.preempt = 1;
        AFChangeACAttributes(ac, ACPreemption, &attributes);
        while (nact < t)
--- 237,246 ----
  	t += nsamples;
  	/* AF holds samples from nact to t */
  	if (int_flag) break;
!     } while ( (nbytes = read(fd, buf, bufsize*ssize)) != 0);
      if (int_flag)
      {
!       AFSilence(ac->device->playBufType, buf, bufsize*ssize);
        attributes.preempt = 1;
        AFChangeACAttributes(ac, ACPreemption, &attributes);
        while (nact < t)
*** ./AF/clients/arecord/arecord.c	Fri Mar  5 17:04:26 1993
--- /crl/audio/./AF/clients/arecord/arecord.c	Thu Mar 25 15:11:24 1993
***************
*** 49,56 ****
  #endif
  #include <math.h>
  
! #define BUFSIZE  2048			/* buffer size, in samples */
  #define	MSTOTICKS(x)	((x)<<3)
  
  extern float power_ulaw_table[];
  double silent_time, silent_level;
--- 49,57 ----
  #endif
  #include <math.h>
  
! #define BUFSIZE  0.5			/* buffer size, in seconds */
  #define	MSTOTICKS(x)	((x)<<3)
+ int bufsize;				/* buffer size, in samples */
  
  extern float power_ulaw_table[];
  double silent_time, silent_level;
***************
*** 244,252 ****
  	ssize = sample_sizes[type] * channels;
  	if(length >= 0)
  		nsamples = srate * length;
  
  /* allocate record buffer */
! 	if((buf = (unsigned char *)malloc(BUFSIZE*ssize)) == NULL) {
   		fprintf(stderr, "Couldn't allocate record buffer\n");
  		exit(1);
  	}
--- 245,254 ----
  	ssize = sample_sizes[type] * channels;
  	if(length >= 0)
  		nsamples = srate * length;
+ 	bufsize = BUFSIZE * srate;
  
  /* allocate record buffer */
! 	if((buf = (unsigned char *)malloc(bufsize*ssize)) == NULL) {
   		fprintf(stderr, "Couldn't allocate record buffer\n");
  		exit(1);
  	}
***************
*** 253,259 ****
  
  	t = AFGetTime(ac) + (toffset * srate);
  	while (nsamples > 0) {
! 		int nb = (nsamples > BUFSIZE) ? BUFSIZE : nsamples;
  
  		AFRecordSamples(ac, t, nb * ssize, buf, ABlock);
  		pow = power(buf, nb);
--- 255,261 ----
  
  	t = AFGetTime(ac) + (toffset * srate);
  	while (nsamples > 0) {
! 		int nb = (nsamples > bufsize) ? bufsize : nsamples;
  
  		AFRecordSamples(ac, t, nb * ssize, buf, ABlock);
  		pow = power(buf, nb);
