#ifndef __PA_MAT_H__
#define __PA_MAT_H__

#include "matrix.h"
#include "mex.h"
#include "portaudio.h"


/*
 * All of the data we need to call the matlab function.  The interface
 * to the matlab function must be:
 * function output = callback(input, framesPerBuffer, time)
 */
typedef struct
{
  char *function;
  int nlhs;
  int nrhs;
  mxArray *plhs[1];
  mxArray *prhs[3];
  int samplesPerInFrame;
  int samplesPerOutFrame;
} paMatData;


void openStream(int nrhs, const mxArray *prhs[]);
void closeStream();
void startStream();
void stopStream();
int okToGo();
int paMatCallback(void *inputBuffer, void *outputBuffer,
		  unsigned long framesPerBuffer,
		  PaTimestamp outTime, void *userData );
void paMatClose();


/* Can only use one stream at a time from matlab */
extern PaStream *matStream;
extern paMatData *data;

#endif
