Mantis - Squeak
Viewing Issue Advanced Details
871 Sound major always 02-09-05 01:46 04-28-05 19:32
johnmci  
 
normal  
assigned 3.9  
open  
none    
none  
0000871: unix sound plugin produces sharp noise under certain conditions.
I compiled sqUnixSoundMacOSX.c under the carbon VM and shipped as mac vm 3.8.6b5. Bert reported a problem of a sharp loud noise at various times. If for example draging an item out of the toolbox, then back in and hold the cursor down for extended periods while doing this. Dropping the item back in the toolbox does result in a beep (as expected).
The Problem code is

static OSStatus bufferDataProc(AudioConverterRef inAudioConverter, UInt32 *ioDataSize, void **outData, void *context)
{
  Stream *s= (Stream *)context;
  Buffer *b= s->buffer;
  char *p1, *p2;
  int n1, n2;
  Buffer_getOutputPointers(b, &p1, &n1, &p2, &n2);
  if (!n1)
    {
      static char empty[256];
      *ioDataSize= min(256, *ioDataSize);
      *outData= (void *)empty;
# if (DEBUG)
      putchar('-'); fflush(stdout);
# endif
    }

where you attempt to pass back an address to a local storage area (perhaps on the stack) that is not been initialized to zero. This then is processed by coreaudio resulting in a loud unwanted sound.

Notes
(0001141)
johnmci   
02-09-05 01:54   
I'l will note I would like to assign to Ian, but he's not listed as a person in Mantis.

One solution would be to create a file variable (static) assign the first element to zero, the C standards say the other 255 elements will get filled with 0. The use that variable when passing back zeros to process.

char empty[256] = { 0 };


  if (!n1)
    {
      *ioDataSize= min(256, *ioDataSize);
      *outData= (void *)empty;
# if (DEBUG)
      putchar('-'); fflush(stdout);
# endif
    }