Exemplo n.º 1
0
void write_depth_png_netstring(FILE *file) {
  Buffer *buffer = Buffer_create();
  Image *image = Image_create(320, 240);

  Image_downsample(kinect_depth_image, image);

  if (Image_get_png(image, buffer)) {
    fprintf(file, "%lu:", buffer->size);
    Buffer_write(buffer, file);
    fputc(',', file);
  }

  Image_destroy(image);
  Buffer_destroy(buffer);
}
Exemplo n.º 2
0
// shipin from device (usually 512 frames at 44k1).  this is asynchronous and
// runs (implicitly) in its own thread.
// 
static OSStatus ioProcInput(AudioDeviceID	    device,
			    const AudioTimeStamp  *currentTime,
			    const AudioBufferList *inputData,
			    const AudioTimeStamp  *inputTime,
			    AudioBufferList	   *outputData,	// io param
			    const AudioTimeStamp  *outputTime,
			    void		   *context)
{
  Stream *s= (Stream *)context;
  Buffer *b= s->buffer;
  int     n= Buffer_free(b);
  if (n >= inputData->mBuffers[0].mDataByteSize)
    Buffer_write(b, inputData->mBuffers[0].mData, inputData->mBuffers[0].mDataByteSize);
  if (Buffer_avail(b) >= s->imgBufSize)
    ioProcSignal(s->semaphore);		// restart SoundRecorder
  return kAudioHardwareNoError;
}
Exemplo n.º 3
0
// play (exactly) frameCount of samples (and no less, since the result is
// ignored).
// 
static sqInt sound_PlaySamplesFromAtLength(sqInt frameCount, sqInt arrayIndex, sqInt startIndex)
{
  if (output)
    {
      int byteCount= frameCount * SqueakFrameSize;
      if (Buffer_free(output->buffer) >= byteCount)
	{
	  Buffer_write(output->buffer,
		       pointerForOop(arrayIndex) + (startIndex * SqueakFrameSize),
		       byteCount);
	  return frameCount;
	}
      return 0;
    }
  success(false);
  return 8192;
}
Exemplo n.º 4
0
  int sound_PlaySamplesFromAtLength(int frameCount, int arrayIndex, int startIndex)
{
  if (output)
    {
      int byteCount= frameCount * SqueakFrameSize;
      if (Buffer_free(output->buffer) >= byteCount)
	{
	  Buffer_write(output->buffer,
		       (char *)arrayIndex + (startIndex * SqueakFrameSize),
		       byteCount);
	  return frameCount;
	}
      return 0;
    }
  success(false);
  return 8192;
}