### patch number: 6 ### area: AF/lib/AF and AF/clients/{aplay,arecord} and AF/server/dia ### severity: high ### comments: patch using command "(cd ; patch -p < thisfile)" *** patchlevel.h Wed Mar 3 11:17:37 1993 --- /crl/audio/patchlevel.h Wed Mar 3 10:18:07 1993 *************** *** 1 **** ! #define PATCHLEVEL 5 --- 1 ---- ! #define PATCHLEVEL 6 *** ./AF/server/dia/dispatch.c Wed Feb 10 09:09:55 1993 --- /crl/audio/./AF/server/dia/dispatch.c Fri Feb 26 15:16:05 1993 *************** *** 410,416 **** int nplayed; int samples; int ssize; ! int indian = 1; REQUEST_AT_LEAST_SIZE(aPlaySamplesReq); VERIFY_AC(pAC, stuff->ac, client); --- 410,416 ---- int nplayed; int samples; int ssize; ! int endian = 1; REQUEST_AT_LEAST_SIZE(aPlaySamplesReq); VERIFY_AC(pAC, stuff->ac, client); *************** *** 432,440 **** * it here. Lets see how good a C boolean hacker you are! */ if (((stuff->mask & ABigEndianMask) == ABigEndianMask) ! ^ (*(char *) & indian)) { SwapShorts((short *) &stuff[1], ! stuff->nbytes / ssize); } break; default: --- 432,440 ---- * it here. Lets see how good a C boolean hacker you are! */ if (((stuff->mask & ABigEndianMask) == ABigEndianMask) ! ^ (!(*(char *) & endian))) { SwapShorts((short *) &stuff[1], ! stuff->nbytes / 2); } break; default: *************** *** 460,465 **** --- 460,466 ---- task->p = (pointer) client->cdata; task->ssize = ssize; task->ac = pAC; + task->mask = stuff->mask; memcpy(task->p, ((char *)&stuff[1])+(nplayed*ssize), task->len*ssize); *************** *** 472,482 **** return (client->noClientException); } else { ! reply.type = A_Reply; ! reply.sequenceNumber = client->sequence; ! reply.length = 0; ! reply.time = (*(pAC->aDev->GetTime))(pAC->aDev); ! WriteReplyToClient(client, sizeof(aGetTimeReply), &reply); return(client->noClientException); } --- 473,486 ---- return (client->noClientException); } else { ! if (!(stuff->mask & ANoTimeReplyMask)) { ! reply.type = A_Reply; ! reply.sequenceNumber = client->sequence; ! reply.length = 0; ! reply.time = (*(pAC->aDev->GetTime))(pAC->aDev); ! WriteReplyToClient(client, sizeof(aGetTimeReply), ! &reply); ! } return(client->noClientException); } *************** *** 511,522 **** aGetTimeReply reply; AttendClient(t->client); ! reply.type = A_Reply; ! reply.sequenceNumber = t->client->sequence; ! reply.length = 0; ! reply.time = (*(t->ac->aDev->GetTime))(t->ac->aDev); ! WriteReplyToClient(t->client, sizeof(aGetTimeReply), &reply); } } --- 515,528 ---- aGetTimeReply reply; AttendClient(t->client); ! if(!(t->mask & ANoTimeReplyMask)) { ! reply.type = A_Reply; ! reply.sequenceNumber = t->client->sequence; ! reply.length = 0; ! reply.time = (*(t->ac->aDev->GetTime))(t->ac->aDev); ! WriteReplyToClient(t->client, sizeof(aGetTimeReply), &reply); ! } } } *************** *** 530,536 **** int ssize; int ns,nrecorded; ATime end_time; ! int indian = 1; REQUEST_AT_LEAST_SIZE(aRecordSamplesReq); VERIFY_AC(pAC, stuff->ac, client); --- 536,542 ---- int ssize; int ns,nrecorded; ATime end_time; ! int endian = 1; REQUEST_AT_LEAST_SIZE(aRecordSamplesReq); VERIFY_AC(pAC, stuff->ac, client); *************** *** 598,605 **** * it here. Lets see how good a C boolean hacker you are! */ if ((((stuff->mask & ABigEndianMask) == ABigEndianMask) ! ^ (*(char *) & indian)) & (ssize > 1)) { ! SwapShorts((short *)client->crdata, nrecorded); } (void) WriteToClient(client, nrecorded * ssize, client->crdata); --- 604,611 ---- * it here. Lets see how good a C boolean hacker you are! */ if ((((stuff->mask & ABigEndianMask) == ABigEndianMask) ! ^ (!(*(char *) & endian))) & (ssize > 1)) { ! SwapShorts((short *)client->crdata, nrecorded * ssize / 2); } (void) WriteToClient(client, nrecorded * ssize, client->crdata); *************** *** 613,619 **** { int nrecorded ; ATime current_time; ! int indian = 1; aRecordSamplesReply reply; nrecorded = (t->ac->ops->ConvertRec)(t->time, t->p, t->len, t->ac); --- 619,625 ---- { int nrecorded ; ATime current_time; ! int endian = 1; aRecordSamplesReply reply; nrecorded = (t->ac->ops->ConvertRec)(t->time, t->p, t->len, t->ac); *************** *** 657,665 **** * it here. Lets see how good a C boolean hacker you are! */ if ((((t->mask & ABigEndianMask) == ABigEndianMask) ! ^ (*(char *) & indian)) & (t->ssize > 1)) { SwapShorts((short *)t->client->crdata, ! clen / t->ssize); } (void) WriteToClient(t->client, clen, t->client->crdata); --- 663,671 ---- * it here. Lets see how good a C boolean hacker you are! */ if ((((t->mask & ABigEndianMask) == ABigEndianMask) ! ^ (!(*(char *) & endian))) & (t->ssize > 1)) { SwapShorts((short *)t->client->crdata, ! clen / 2); } (void) WriteToClient(t->client, clen, t->client->crdata); *** ./AF/server/dia/ac.c Mon Feb 8 08:17:02 1993 --- /crl/audio/./AF/server/dia/ac.c Fri Feb 26 13:57:04 1993 *************** *** 156,163 **** return error; } ! /* CreateAC(pDrawable, mask, pval, pStatus) ! creates a default AC for the given drawable, using mask to fill in any non-default values. Returns a pointer to the new AC on success, NULL otherwise. returns status of non-default fields in pStatus --- 156,163 ---- return error; } ! /* CreateAC(client, aDev, mask, pval, pStatus) ! creates a default AC for the given AC, using mask to fill in any non-default values. Returns a pointer to the new AC on success, NULL otherwise. returns status of non-default fields in pStatus *** ./AF/include/audioproto.h Sun Feb 7 18:32:54 1993 --- /crl/audio/./AF/include/audioproto.h Thu Feb 25 13:24:53 1993 *************** *** 1,5 **** /* ! * $Header: /crl/audio/AF/include/RCS/audioproto.h,v 1.31 1993/02/07 23:32:54 stewart Exp $ */ /* Copyright 1990, 1991, 1992, 1993 Digital Equipment Corporation --- 1,5 ---- /* ! * $Header: /crl/audio/AF/include/RCS/audioproto.h,v 1.32 1993/02/25 18:23:41 jg Exp $ */ /* Copyright 1990, 1991, 1992, 1993 Digital Equipment Corporation *************** *** 205,211 **** #define ABigEndianMask (1L << 0) #define ALittleEndianMask 0 #define ABlockMask (1L << 1) ! #define ANoBlockMask 0 /* * Initial connection handshake. --- 205,211 ---- #define ABigEndianMask (1L << 0) #define ALittleEndianMask 0 #define ABlockMask (1L << 1) ! #define ANoTimeReplyMask (1L << 2) /* * Initial connection handshake. *** ./AF/lib/AF/Alibint.h Sun Feb 7 17:12:11 1993 --- /crl/audio/./AF/lib/AF/Alibint.h Fri Feb 26 11:46:28 1993 *************** *** 103,108 **** --- 103,112 ---- #ifndef EPERBATCH #define EPERBATCH 8 /* when batching, how many elements */ #endif + #ifndef CHUNKSIZE /* chuncking size on play and record */ + #define CHUNKSIZE 8192 /* default just under smallest socket + buffering size */ + #endif /* * display flags *** ./AF/lib/AF/Play.c Fri Feb 19 16:58:30 1993 --- /crl/audio/./AF/lib/AF/Play.c Fri Feb 26 11:46:29 1993 *************** *** 51,63 **** PlayChunk( AC ac, ATime startTime, int nbytes, ! unsigned char *buf) #else ! PlayChunk(ac, startTime, nbytes, buf) AC ac; ATime startTime; int nbytes; unsigned char *buf; #endif { register AFAudioConn *aud = ac->connection; --- 51,65 ---- PlayChunk( AC ac, ATime startTime, int nbytes, ! unsigned char *buf, ! ABool gettime) #else ! PlayChunk(ac, startTime, nbytes, buf, gettime) AC ac; ATime startTime; int nbytes; unsigned char *buf; + ABool gettime; #endif { register AFAudioConn *aud = ac->connection; *************** *** 76,83 **** if(ac->attributes.endian == ABigEndian) req->mask |= ABigEndianMask; _ASend(aud, buf, (long) req->nbytes); ! _AReply(aud, (aReply *) &reply, 0, aTrue); UnlockConnection(aud); return(reply.time); } --- 78,86 ---- if(ac->attributes.endian == ABigEndian) req->mask |= ABigEndianMask; + if (!gettime) req->mask |= ANoTimeReplyMask; _ASend(aud, buf, (long) req->nbytes); ! if (gettime) _AReply(aud, (aReply *) &reply, 0, aTrue); UnlockConnection(aud); return(reply.time); } *************** *** 121,133 **** _ADefaultIOError(ac->connection); } nsamples = nbytes / ssize; ! chunk_size = MIN(4000, ac->connection->max_request_size - sz_aPlaySamplesReq) / ssize; while (nsamples > 0) { len = min(chunk_size, nsamples); - dtime = PlayChunk(ac, startTime, len*ssize, buf); nsamples -= len; startTime += len; /* we played that many samples. */ buf += len * ssize; } --- 124,136 ---- _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); nsamples -= len; + dtime = PlayChunk(ac, startTime, len*ssize, buf, (nsamples <= 0)); startTime += len; /* we played that many samples. */ buf += len * ssize; } *** ./AF/lib/AF/Record.c Tue Feb 16 13:03:21 1993 --- /crl/audio/./AF/lib/AF/Record.c Fri Feb 26 11:46:30 1993 *************** *** 132,138 **** _ADefaultIOError(ac->connection); } nsamples = nbytes / ssize; ! chunk_size = MIN(4000, ac->connection->max_request_size - sz_aRecordSamplesReq) / ssize; while (nsamples > 0) { --- 132,138 ---- _ADefaultIOError(ac->connection); } nsamples = nbytes / ssize; ! chunk_size = MIN(CHUNKSIZE, ac->connection->max_request_size - sz_aRecordSamplesReq) / ssize; while (nsamples > 0) { *** ./AF/lib/AF/CreateAC.c Mon Feb 8 09:27:36 1993 --- /crl/audio/./AF/lib/AF/CreateAC.c Fri Feb 26 15:44:10 1993 *************** *** 48,53 **** --- 48,56 ---- #define AllMaskBits (ACRecordGain | ACPlayGain | ACStartTimeout | \ ACEndSilence | ACPreemption | ACEncodingType | ACChannels | ACEndian) + #define ServerMaskBits (ACRecordGain | ACPlayGain | ACStartTimeout | \ + ACEndSilence | ACPreemption) + static AFSetACAttributes initial_AC = { 0, 0, *************** *** 90,98 **** ac->attributes.type = ac->device->playBufType; ac->attributes.channels = ac->device->playNchannels; if (*(char *) &indian) - ac->attributes.endian = ABigEndian; - else ac->attributes.endian = ALittleEndian; req->mask = valuemask; req->device = device; --- 93,101 ---- ac->attributes.type = ac->device->playBufType; ac->attributes.channels = ac->device->playNchannels; if (*(char *) &indian) ac->attributes.endian = ALittleEndian; + else + ac->attributes.endian = ABigEndian; req->mask = valuemask; req->device = device; *************** *** 101,106 **** --- 104,110 ---- _AFProcessACAttributes (aud, ac, (aChangeACAttributesReq *)req, valuemask, attributes); + req->mask &= ServerMaskBits; UnlockConnection(aud); SyncHandle(); return (ac); *** ./AF/clients/aplay/aplay.c Tue Feb 23 08:39:40 1993 --- /crl/audio/./AF/clients/aplay/aplay.c Fri Feb 26 15:38:21 1993 *************** *** 47,53 **** #define DEFAULT_FILE "bob.snd" /* Needs SOUND_PATH */ ! #define BUFSIZE 2048 /* buffer size, in samples */ int flushflag = 0; /* convert data type to sample size. Should this be in the AF include --- 47,53 ---- #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 *************** *** 130,135 **** --- 130,136 ---- int gain; AEncodeType type; unsigned int channels; + int endianflag = 0; device = -1; attributes.preempt = Mix; *************** *** 169,174 **** --- 170,181 ---- } } else if ( strcmp( argv[i], "-f" ) == 0) { flushflag = 1; + } else if ( strcmp( argv[i], "-b" ) == 0) { + attributes.endian = ABigEndian; + endianflag = ACEndian; + } else if ( strcmp( argv[i], "-l" ) == 0) { + attributes.endian = ALittleEndian; + endianflag = ACEndian; } else { filename = argv[i]; } *************** *** 202,208 **** if(device < 0) device = FindDefaultDevice(aud); ! ac = AFCreateAC(aud, device, ACPlayGain, &attributes); srate = ac->device->playSampleFreq; type = ac->device->playBufType; channels = ac->device->playNchannels; --- 209,215 ---- if(device < 0) device = FindDefaultDevice(aud); ! ac = AFCreateAC(aud, device, (ACPlayGain | endianflag), &attributes); srate = ac->device->playSampleFreq; type = ac->device->playBufType; channels = ac->device->playNchannels; *** ./AF/clients/aplay/aplay.man Tue Feb 23 08:39:41 1993 --- /crl/audio/./AF/clients/aplay/aplay.man Fri Feb 26 15:55:59 1993 *************** *** 1,4 **** ! .TH AF 1 "Release 1" "AudioFile Version 1" .SH NAME aplay - An AudioFile play client. .SH SYNOPSIS --- 1,4 ---- ! .TH AF 1 "Release 2" "AudioFile Version 2" .SH NAME aplay - An AudioFile play client. .SH SYNOPSIS *************** *** 9,14 **** --- 9,16 ---- [\fB-g\fP \fIgain\fP] [\fB-f\fP ] [\fB-c\fP] + [\fB-b\fP] + [\fB-l\fP] [\fIfile\fP] .SH DESCRIPTION \fIaplay\fP reads samples from \fIfile\fP, *************** *** 48,53 **** --- 50,65 ---- shipped with the AF kit. This switch depends on the SOUND_PATH environment variable. .TP + .B \-b + .IP + Specifies that for 16 bit data, the bytes are in "Big Endian" byte order + (e.g. Sparc, RIOS, PA). + .TP + .B \-l + .IP + Specifies that for 16 bit data, the bytes are in "Little Endian" byte order + (e.g. Alpha, Intel x86, VAX). + .TP .B \fIfile\fP .IP \fIaplay\fP attempts to read from \fIfile\fP in the current working *************** *** 72,78 **** .SH "SEE ALSO" AudioFile(1), arecord(1) .SH COPYRIGHT ! Copyright 1992, Digital Equipment Corporation. .br See \fIAudioFile(1)\fP for a full statement of rights and permissions. .SH AUTHORS --- 84,90 ---- .SH "SEE ALSO" AudioFile(1), arecord(1) .SH COPYRIGHT ! Copyright 1992, 1993, Digital Equipment Corporation. .br See \fIAudioFile(1)\fP for a full statement of rights and permissions. .SH AUTHORS *** ./AF/clients/arecord/arecord.c Tue Feb 23 08:39:42 1993 --- /crl/audio/./AF/clients/arecord/arecord.c Fri Feb 26 17:44:47 1993 *************** *** 133,138 **** --- 133,140 ---- AEncodeType type; int channels; char *filename=(char *)NULL; + AFSetACAttributes attributes; + int endianflag = 0; float length = -1.0; /* length, in seconds */ float toffset = 0.125; /* start time offset, in seconds */ *************** *** 141,158 **** /* Parse the command line. */ for ( i = 1; i < argc; i++ ) { ! if ( strcmp( argv[i], "-d" ) == 0) ! { if(++i < argc) device = atoi(argv[i]); ! else ! { fprintf(stderr,"%s: missing device\n", argv[0]); exit(1); } } ! else if ( strcmp( argv[i], "-l" ) == 0) ! { if(++i < argc) if (sscanf(argv[i],"%f",&length) != 1) { fprintf(stderr,"%s: missing time length\n", --- 143,157 ---- /* Parse the command line. */ for ( i = 1; i < argc; i++ ) { ! if ( strcmp( argv[i], "-d" ) == 0) { if(++i < argc) device = atoi(argv[i]); ! else { fprintf(stderr,"%s: missing device\n", argv[0]); exit(1); } } ! else if ( strcmp( argv[i], "-l" ) == 0) { if(++i < argc) if (sscanf(argv[i],"%f",&length) != 1) { fprintf(stderr,"%s: missing time length\n", *************** *** 161,168 **** exit(1); } } ! else if ( strcmp( argv[i], "-t" ) == 0) ! { if(++i < argc) if (sscanf(argv[i],"%f",&toffset) != 1) { fprintf(stderr,"%s: missing time offset\n", --- 160,166 ---- exit(1); } } ! else if ( strcmp( argv[i], "-t" ) == 0) { if(++i < argc) if (sscanf(argv[i],"%f",&toffset) != 1) { fprintf(stderr,"%s: missing time offset\n", *************** *** 170,205 **** exit(1); } } ! else if ( strcmp( argv[i], "-silentlevel" ) == 0) ! { if(++i < argc) if (sscanf(argv[i],"%lf",&silent_level) == 1) silent_level_flag = 1; ! else ! { fprintf(stderr,"%s: missing silentlevel\n", argv[0]); exit(1); ! } ! } else if ( strcmp( argv[i], "-printpower" ) == 0) print_power_flag = 1; ! else if ( strcmp( argv[i], "-silenttime" ) == 0) ! { if(++i < argc) if (sscanf(argv[i],"%lf",&silent_time) == 1) silent_time_flag = 1; ! else ! { fprintf(stderr,"%s: missing silenttime\n", argv[0]); exit(1); } } ! else ! { filename = argv[i]; } } --- 168,206 ---- exit(1); } } ! else if ( strcmp( argv[i], "-silentlevel" ) == 0) { if(++i < argc) if (sscanf(argv[i],"%lf",&silent_level) == 1) silent_level_flag = 1; ! else { fprintf(stderr,"%s: missing silentlevel\n", argv[0]); exit(1); ! } ! } ! else if ( strcmp( argv[i], "-b" ) == 0) { ! attributes.endian = ABigEndian; ! endianflag = ACEndian; ! } ! else if ( strcmp( argv[i], "-l" ) == 0) { ! attributes.endian = ALittleEndian; ! endianflag = ACEndian; ! } else if ( strcmp( argv[i], "-printpower" ) == 0) print_power_flag = 1; ! else if ( strcmp( argv[i], "-silenttime" ) == 0) { if(++i < argc) if (sscanf(argv[i],"%lf",&silent_time) == 1) silent_time_flag = 1; ! else { fprintf(stderr,"%s: missing silenttime\n", argv[0]); exit(1); } } ! else { filename = argv[i]; } } *************** *** 232,238 **** if(device < 0) device = FindDefaultDevice(aud); ! ac = AFCreateAC(aud, device, 0, NULL); srate = ac->device->recSampleFreq; type = ac->device->recBufType; channels = ac->device->recNchannels; --- 233,239 ---- if(device < 0) device = FindDefaultDevice(aud); ! ac = AFCreateAC(aud, device, endianflag, &attributes); srate = ac->device->recSampleFreq; type = ac->device->recBufType; channels = ac->device->recNchannels; *** ./AF/clients/arecord/arecord.man Tue Feb 23 08:39:43 1993 --- /crl/audio/./AF/clients/arecord/arecord.man Mon Mar 1 10:49:44 1993 *************** *** 10,15 **** --- 10,17 ---- [\fB-silentlevel\fP \fIlevel (dB)\fP] [\fB-silenttime\fP \fItime\fP] [\fB-printpower] + [\fB-b] + [\fB-l] [\fIfile\fP] .SH DDESCRIPTION .PP *************** *** 16,21 **** --- 18,25 ---- \fIarecord\fP reads samples from the audio server and writes the data to \fIfile\fP, or stdout if \fIfile\fP is not specified. The file will be written in a sample format appropriate for the record device. + By default, the byte order of any 16 bit data will be that of + the host on which arecord is executing. .SH OPTIONS .TP .B \-d \fIdevice\fP *************** *** 44,49 **** --- 48,63 ---- .B \-printpower .IP Print input power level in dBm on stderr every block (8 times a second). + .TP + .B \-b + .IP + Specifies that for 16 bit data, the bytes are in "Big Endian" byte order + (e.g. Sparc, RIOS, PA). + .TP + .B \-l + .IP + Specifies that for 16 bit data, the bytes are in "Little Endian" byte order + (e.g. Alpha, Intel x86, VAX). .TP .B \-t \fItime\fP .IP