Merge pull request #3 from berkus/master
[rtaudio-cdist.git] / tests / duplex.cpp
index f416bad993f268ad9fba52d8f1f5bcf5d266d8ea..291d2aa91eda7a1e8d4d84105d52d80652378465 100644 (file)
 
 #include "RtAudio.h"
 #include <iostream>
+#include <cstdlib>
+#include <cstring>
 
 /*
-typedef signed long  MY_TYPE;
-#define FORMAT RTAUDIO_SINT24
-
-typedef char  MY_TYPE;
+typedef char MY_TYPE;
 #define FORMAT RTAUDIO_SINT8
+*/
 
-typedef signed short  MY_TYPE;
+typedef signed short MY_TYPE;
 #define FORMAT RTAUDIO_SINT16
 
-typedef signed long  MY_TYPE;
+/*
+typedef S24 MY_TYPE;
+#define FORMAT RTAUDIO_SINT24
+
+typedef signed long MY_TYPE;
 #define FORMAT RTAUDIO_SINT32
 
-typedef float  MY_TYPE;
+typedef float MY_TYPE;
 #define FORMAT RTAUDIO_FLOAT32
-*/
 
-typedef double  MY_TYPE;
+typedef double MY_TYPE;
 #define FORMAT RTAUDIO_FLOAT64
+*/
 
 void usage( void ) {
   // Error function in case of incorrect command-line
@@ -44,14 +48,14 @@ void usage( void ) {
   exit( 0 );
 }
 
-int inout( void *outputBuffer, void *inputBuffer, unsigned int nBufferFrames,
-           double streamTime, RtAudioStreamStatus status, void *data )
+int inout( void *outputBuffer, void *inputBuffer, unsigned int /*nBufferFrames*/,
+           double /*streamTime*/, RtAudioStreamStatus status, void *data )
 {
   // Since the number of input and output channels is equal, we can do
   // a simple buffer copy operation here.
   if ( status ) std::cout << "Stream over/underflow detected." << std::endl;
 
-  unsigned long *bytes = (unsigned long *) data;
+  unsigned int *bytes = (unsigned int *) data;
   memcpy( outputBuffer, inputBuffer, *bytes );
   return 0;
 }
@@ -99,7 +103,7 @@ int main( int argc, char *argv[] )
   try {
     adac.openStream( &oParams, &iParams, FORMAT, fs, &bufferFrames, &inout, (void *)&bufferBytes, &options );
   }
-  catch ( RtError& e ) {
+  catch ( RtAudioError& e ) {
     std::cout << '\n' << e.getMessage() << '\n' << std::endl;
     exit( 1 );
   }
@@ -119,7 +123,7 @@ int main( int argc, char *argv[] )
     // Stop the stream.
     adac.stopStream();
   }
-  catch ( RtError& e ) {
+  catch ( RtAudioError& e ) {
     std::cout << '\n' << e.getMessage() << '\n' << std::endl;
     goto cleanup;
   }