summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorStephen Sinclair <sinclair@music.mcgill.ca>2013-10-11 01:59:16 +0200
committerStephen Sinclair <sinclair@music.mcgill.ca>2013-10-11 01:59:16 +0200
commitda9b77ef9a50a97f7c1f2e154edb938acff02214 (patch)
tree38dcf95e8df65d3e2c8696eee754dd54856d4e01 /tests
parentbe2eb99b37cd017fcab00c1704f794cb1bc85ee1 (diff)
parent6faf4336eb5952b141e1c239d194f5cd70f0a885 (diff)
Merge 4.0.8 into releases
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.in7
-rwxr-xr-xtests/Windows/rtaudio.dsw12
-rwxr-xr-xtests/Windows/teststops.dsp162
-rw-r--r--tests/duplex.cpp2
-rw-r--r--tests/playraw.cpp6
-rw-r--r--tests/playsaw.cpp52
-rw-r--r--tests/testall.cpp2
-rw-r--r--tests/teststops.cpp266
8 files changed, 487 insertions, 22 deletions
diff --git a/tests/Makefile.in b/tests/Makefile.in
index 6947676..fbca16b 100644
--- a/tests/Makefile.in
+++ b/tests/Makefile.in
@@ -1,7 +1,7 @@
### Do not edit -- Generated by 'configure --with-whatever' from Makefile.in
### RtAudio tests Makefile - for various flavors of unix and MinGW
-PROGRAMS = audioprobe playsaw playraw record duplex testall
+PROGRAMS = audioprobe playsaw playraw record duplex testall teststops
RM = /bin/rm
SRC_PATH = ..
INCLUDE = ..
@@ -42,6 +42,9 @@ duplex : duplex.cpp $(OBJECTS)
testall : testall.cpp $(OBJECTS)
$(CC) $(CFLAGS) $(DEFS) -o testall testall.cpp $(OBJECT_PATH)/*.o $(LIBRARY)
+teststops : teststops.cpp $(OBJECTS)
+ $(CC) $(CFLAGS) $(DEFS) -o teststops teststops.cpp $(OBJECT_PATH)/*.o $(LIBRARY)
+
clean :
$(RM) -f $(OBJECT_PATH)/*.o
$(RM) -f $(PROGRAMS)
@@ -49,7 +52,7 @@ clean :
$(RM) -fR *.dSYM
distclean: clean
- $(RM) Makefile
+ $(RM) -f Makefile
strip :
strip $(PROGRAMS)
diff --git a/tests/Windows/rtaudio.dsw b/tests/Windows/rtaudio.dsw
index fe5f324..1869b31 100755
--- a/tests/Windows/rtaudio.dsw
+++ b/tests/Windows/rtaudio.dsw
@@ -75,6 +75,18 @@ Package=<4>
###############################################################################
+Project: "teststops"=.\teststops.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
Global:
Package=<5>
diff --git a/tests/Windows/teststops.dsp b/tests/Windows/teststops.dsp
new file mode 100755
index 0000000..1543bc8
--- /dev/null
+++ b/tests/Windows/teststops.dsp
@@ -0,0 +1,162 @@
+# Microsoft Developer Studio Project File - Name="teststops" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=teststops - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "teststops.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "teststops.mak" CFG="teststops - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "teststops - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "teststops - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "teststops - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "teststops___Win32_Release"
+# PROP BASE Intermediate_Dir "teststops___Win32_Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir ""
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GX /O2 /I "../../" /I "../../include" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__WINDOWS_ASIO__" /D "__WINDOWS_DS__" /YX /FD /c
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib dsound.lib /nologo /subsystem:console /machine:I386
+
+!ELSEIF "$(CFG)" == "teststops - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "teststops___Win32_Debug"
+# PROP BASE Intermediate_Dir "teststops___Win32_Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir ""
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../../" /I "../../include" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "__WINDOWS_ASIO__" /D "__WINDOWS_DS__" /YX /FD /GZ /c
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib dsound.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+
+!ENDIF
+
+# Begin Target
+
+# Name "teststops - Win32 Release"
+# Name "teststops - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=..\..\include\asio.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\include\asiodrivers.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\include\asiolist.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\include\iasiothiscallresolver.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\RtAudio.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\teststops.cpp
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=..\..\include\asio.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\include\asiodrivers.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\include\asiodrvr.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\include\asiolist.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\include\asiosys.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\include\ginclude.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\include\iasiodrv.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\include\iasiothiscallresolver.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\RtAudio.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\RtError.h
+# End Source File
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# End Target
+# End Project
diff --git a/tests/duplex.cpp b/tests/duplex.cpp
index 125b56e..938a7f8 100644
--- a/tests/duplex.cpp
+++ b/tests/duplex.cpp
@@ -53,7 +53,7 @@ int inout( void *outputBuffer, void *inputBuffer, unsigned int nBufferFrames,
// 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;
}
diff --git a/tests/playraw.cpp b/tests/playraw.cpp
index 5a5e7cd..3b7be76 100644
--- a/tests/playraw.cpp
+++ b/tests/playraw.cpp
@@ -26,11 +26,7 @@ typedef signed short MY_TYPE;
#define SCALE 32767.0
/*
-typedef signed long MY_TYPE;
-#define FORMAT RTAUDIO_SINT24
-#define SCALE 8388607.0
-
-typedef signed long MY_TYPE;
+typedef signed int MY_TYPE;
#define FORMAT RTAUDIO_SINT32
#define SCALE 2147483647.0
diff --git a/tests/playsaw.cpp b/tests/playsaw.cpp
index b89d5f9..51f8ad9 100644
--- a/tests/playsaw.cpp
+++ b/tests/playsaw.cpp
@@ -40,22 +40,36 @@ typedef double MY_TYPE;
#define SCALE 1.0
*/
+// Platform-dependent sleep routines.
+#if defined( __WINDOWS_ASIO__ ) || defined( __WINDOWS_DS__ )
+ #include <windows.h>
+ #define SLEEP( milliseconds ) Sleep( (DWORD) milliseconds )
+#else // Unix variants
+ #include <unistd.h>
+ #define SLEEP( milliseconds ) usleep( (unsigned long) (milliseconds * 1000.0) )
+#endif
+
#define BASE_RATE 0.005
#define TIME 1.0
void usage( void ) {
// Error function in case of incorrect command-line
// argument specifications
- std::cout << "\nuseage: playsaw N fs <device> <channelOffset>\n";
+ std::cout << "\nuseage: playsaw N fs <device> <channelOffset> <time>\n";
std::cout << " where N = number of channels,\n";
std::cout << " fs = the sample rate,\n";
std::cout << " device = optional device to use (default = 0),\n";
- std::cout << " and channelOffset = an optional channel offset on the device (default = 0).\n\n";
+ std::cout << " channelOffset = an optional channel offset on the device (default = 0),\n";
+ std::cout << " and time = an optional time duration in seconds (default = no limit).\n\n";
exit( 0 );
}
unsigned int channels;
RtAudio::StreamOptions options;
+unsigned int frameCounter = 0;
+bool checkCount = false;
+unsigned int nFrames = 0;
+const unsigned int callbackReturnValue = 1;
//#define USE_INTERLEAVED
#if defined( USE_INTERLEAVED )
@@ -80,6 +94,8 @@ int saw( void *outputBuffer, void *inputBuffer, unsigned int nBufferFrames,
}
}
+ frameCounter += nBufferFrames;
+ if ( checkCount && ( frameCounter >= nFrames ) ) return callbackReturnValue;
return 0;
}
@@ -106,6 +122,8 @@ int saw( void *outputBuffer, void *inputBuffer, unsigned int nBufferFrames,
}
}
+ frameCounter += nBufferFrames;
+ if ( checkCount && ( frameCounter >= nFrames ) ) return callbackReturnValue;
return 0;
}
#endif
@@ -115,7 +133,7 @@ int main( int argc, char *argv[] )
unsigned int bufferFrames, fs, device = 0, offset = 0;
// minimal command-line checking
- if (argc < 3 || argc > 5 ) usage();
+ if (argc < 3 || argc > 6 ) usage();
RtAudio dac;
if ( dac.getDeviceCount() < 1 ) {
@@ -129,6 +147,9 @@ int main( int argc, char *argv[] )
device = (unsigned int) atoi( argv[3] );
if ( argc > 4 )
offset = (unsigned int) atoi( argv[4] );
+ if ( argc > 5 )
+ nFrames = (unsigned int) (fs * atof( argv[5] ));
+ if ( nFrames > 0 ) checkCount = true;
double *data = (double *) calloc( channels, sizeof( double ) );
@@ -156,17 +177,22 @@ int main( int argc, char *argv[] )
goto cleanup;
}
- char input;
- //std::cout << "Stream latency = " << dac.getStreamLatency() << "\n" << std::endl;
- std::cout << "\nPlaying ... press <enter> to quit (buffer size = " << bufferFrames << ").\n";
- std::cin.get( input );
-
- try {
- // Stop the stream
- dac.stopStream();
+ if ( checkCount ) {
+ while ( dac.isStreamRunning() == true ) SLEEP( 100 );
}
- catch ( RtError& e ) {
- e.printMessage();
+ else {
+ char input;
+ //std::cout << "Stream latency = " << dac.getStreamLatency() << "\n" << std::endl;
+ std::cout << "\nPlaying ... press <enter> to quit (buffer size = " << bufferFrames << ").\n";
+ std::cin.get( input );
+
+ try {
+ // Stop the stream
+ dac.stopStream();
+ }
+ catch ( RtError& e ) {
+ e.printMessage();
+ }
}
cleanup:
diff --git a/tests/testall.cpp b/tests/testall.cpp
index bd9ca74..695488d 100644
--- a/tests/testall.cpp
+++ b/tests/testall.cpp
@@ -86,7 +86,7 @@ int inout( void *outputBuffer, void *inputBuffer, unsigned int nBufferFrames,
// 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;
}
diff --git a/tests/teststops.cpp b/tests/teststops.cpp
new file mode 100644
index 0000000..6122734
--- /dev/null
+++ b/tests/teststops.cpp
@@ -0,0 +1,266 @@
+/******************************************/
+/*
+ teststop.cpp
+ by Gary P. Scavone, 2011
+
+ This program starts and stops an RtAudio
+ stream many times in succession and in
+ different ways to to test its functionality.
+*/
+/******************************************/
+
+#include "RtAudio.h"
+#include <iostream>
+#include <cstdlib>
+#include <cstring>
+#include <cstdio>
+
+#define PULSE_RATE 0.01 // seconds
+#define RUNTIME 0.4 // seconds
+#define PAUSETIME 0.1 // seconds
+#define REPETITIONS 10
+
+// Platform-dependent sleep routines.
+#if defined( __WINDOWS_ASIO__ ) || defined( __WINDOWS_DS__ )
+ #include <windows.h>
+ #define SLEEP( milliseconds ) Sleep( (DWORD) milliseconds )
+#else // Unix variants
+ #include <unistd.h>
+ #define SLEEP( milliseconds ) usleep( (unsigned long) (milliseconds * 1000.0) )
+#endif
+
+void usage( void ) {
+ // Error function in case of incorrect command-line
+ // argument specifications
+ std::cout << "\nuseage: teststops N fs <iDevice> <oDevice> <iChannelOffset> <oChannelOffset>\n";
+ std::cout << " where N = number of channels,\n";
+ std::cout << " fs = the sample rate,\n";
+ std::cout << " iDevice = optional input device to use (default = 0),\n";
+ std::cout << " oDevice = optional output device to use (default = 0),\n";
+ std::cout << " iChannelOffset = an optional input channel offset (default = 0),\n";
+ std::cout << " and oChannelOffset = optional output channel offset (default = 0).\n\n";
+ exit( 0 );
+}
+
+struct MyData {
+ unsigned int channels;
+ unsigned int pulseCount;
+ unsigned int frameCounter;
+ unsigned int nFrames;
+ unsigned int returnValue;
+};
+
+// Interleaved buffers
+int pulse( void *outputBuffer, void *inputBuffer, unsigned int nBufferFrames,
+ double streamTime, RtAudioStreamStatus status, void *mydata )
+{
+ // Write out a pulse signal and ignore the input buffer.
+ unsigned int i, j;
+ float sample;
+ float *buffer = (float *) outputBuffer;
+ MyData *data = (MyData *) mydata;
+
+ if ( status ) std::cout << "Stream over/underflow detected!" << std::endl;
+
+ for ( i=0; i<nBufferFrames; i++ ) {
+ if ( data->frameCounter % data->pulseCount == 0 ) sample = 0.9;
+ else sample = 0.0;
+ for ( j=0; j<data->channels; j++ )
+ *buffer++ = sample;
+
+ data->frameCounter++;
+ }
+
+ if ( data->frameCounter >= data->nFrames )
+ return data->returnValue;
+ else
+ return 0;
+}
+
+int main( int argc, char *argv[] )
+{
+ unsigned int bufferFrames, fs, oDevice = 0, iDevice = 0, iOffset = 0, oOffset = 0;
+ unsigned int runtime, pausetime;
+ char input;
+
+ // minimal command-line checking
+ if (argc < 3 || argc > 7 ) usage();
+
+ RtAudio *adc = new RtAudio();
+ if ( adc->getDeviceCount() < 1 ) {
+ std::cout << "\nNo audio devices found!\n";
+ exit( 1 );
+ }
+
+ MyData mydata;
+ mydata.channels = (unsigned int) atoi( argv[1] );
+ fs = (unsigned int) atoi( argv[2] );
+ if ( argc > 3 )
+ iDevice = (unsigned int) atoi( argv[3] );
+ if ( argc > 4 )
+ oDevice = (unsigned int) atoi(argv[4]);
+ if ( argc > 5 )
+ iOffset = (unsigned int) atoi(argv[5]);
+ if ( argc > 6 )
+ oOffset = (unsigned int) atoi(argv[6]);
+
+ // Let RtAudio print messages to stderr.
+ adc->showWarnings( true );
+
+ runtime = RUNTIME * 1000;
+ pausetime = PAUSETIME * 1000;
+
+ // Set our stream parameters for a duplex stream.
+ bufferFrames = 256;
+ RtAudio::StreamParameters oParams, iParams;
+ oParams.deviceId = oDevice;
+ oParams.nChannels = mydata.channels;
+ oParams.firstChannel = oOffset;
+
+ iParams.deviceId = iDevice;
+ iParams.nChannels = mydata.channels;
+ iParams.firstChannel = iOffset;
+
+ // First, test external stopStream() calls.
+ mydata.pulseCount = PULSE_RATE * fs;
+ mydata.nFrames = 50 * fs;
+ mydata.returnValue = 0;
+ try {
+ adc->openStream( &oParams, &iParams, RTAUDIO_SINT32, fs, &bufferFrames, &pulse, (void *)&mydata );
+
+ std::cout << "Press <enter> to start test.\n";
+ std::cin.get( input );
+
+ for (int i=0; i<REPETITIONS; i++ ) {
+ mydata.frameCounter = 0;
+ adc->startStream();
+ std::cout << "Stream started ... ";
+ SLEEP( runtime );
+ adc->stopStream();
+ std::cout << "stream externally stopped.\n";
+ SLEEP( pausetime );
+ }
+ }
+ catch ( RtError& e ) {
+ e.printMessage();
+ goto cleanup;
+ }
+
+ adc->closeStream();
+
+ // Next, test internal stopStream() calls.
+ mydata.nFrames = (unsigned int) (RUNTIME * fs);
+ mydata.returnValue = 1;
+ try {
+ adc->openStream( &oParams, &iParams, RTAUDIO_SINT32, fs, &bufferFrames, &pulse, (void *)&mydata );
+
+ std::cin.clear();
+ fflush(stdin);
+ std::cout << "\nPress <enter> to continue test.\n";
+ std::cin.get( input );
+
+ for (int i=0; i<REPETITIONS; i++ ) {
+ mydata.frameCounter = 0;
+ adc->startStream();
+ std::cout << "Stream started ... ";
+ while ( adc->isStreamRunning() ) SLEEP( 5 );
+ std::cout << "stream stopped via callback return value = 1.\n";
+ SLEEP( pausetime );
+ }
+ }
+ catch ( RtError& e ) {
+ e.printMessage();
+ goto cleanup;
+ }
+
+ adc->closeStream();
+
+ // Test internal abortStream() calls.
+ mydata.returnValue = 2;
+ try {
+ adc->openStream( &oParams, &iParams, RTAUDIO_SINT32, fs, &bufferFrames, &pulse, (void *)&mydata );
+ std::cin.clear();
+ fflush(stdin);
+ std::cout << "\nPress <enter> to continue test.\n";
+ std::cin.get( input );
+
+ for (int i=0; i<REPETITIONS; i++ ) {
+ mydata.frameCounter = 0;
+ adc->startStream();
+ std::cout << "Stream started ... ";
+ while ( adc->isStreamRunning() ) SLEEP( 5 );
+ std::cout << "stream aborted via callback return value = 2.\n";
+ SLEEP( pausetime );
+ }
+ }
+ catch ( RtError& e ) {
+ e.printMessage();
+ goto cleanup;
+ }
+
+ adc->closeStream();
+
+ // Test consecutive stream re-opening.
+ mydata.returnValue = 0;
+ mydata.nFrames = 50 * fs;
+ try {
+
+ std::cin.clear();
+ fflush(stdin);
+ std::cout << "\nPress <enter> to continue test.\n";
+ std::cin.get( input );
+
+ for (int i=0; i<REPETITIONS; i++ ) {
+ adc->openStream( &oParams, &iParams, RTAUDIO_SINT32, fs, &bufferFrames, &pulse, (void *)&mydata );
+ mydata.frameCounter = 0;
+ adc->startStream();
+ std::cout << "New stream started ... ";
+ SLEEP( runtime );
+ adc->stopStream();
+ adc->closeStream();
+ std::cout << "stream stopped externally and closed.\n";
+ SLEEP( pausetime );
+ }
+ }
+ catch ( RtError& e ) {
+ e.printMessage();
+ goto cleanup;
+ }
+
+ delete adc;
+ adc = 0;
+
+ // Test consecutive RtAudio creating and deletion.
+ try {
+
+ std::cin.clear();
+ fflush(stdin);
+ std::cout << "\nPress <enter> to continue test.\n";
+ std::cin.get( input );
+
+ for (int i=0; i<REPETITIONS; i++ ) {
+ adc = new RtAudio();
+ adc->openStream( &oParams, &iParams, RTAUDIO_SINT32, fs, &bufferFrames, &pulse, (void *)&mydata );
+ mydata.frameCounter = 0;
+ adc->startStream();
+ std::cout << "New instance and stream started ... ";
+ SLEEP( runtime );
+ adc->stopStream();
+ adc->closeStream();
+ delete adc;
+ adc = 0;
+ std::cout << "stream stopped and instance deleted.\n";
+ SLEEP( pausetime );
+ }
+ }
+ catch ( RtError& e ) {
+ e.printMessage();
+ goto cleanup;
+ }
+
+ cleanup:
+ if ( adc && adc->isStreamOpen() ) adc->closeStream();
+ if ( adc ) delete adc;
+
+ return 0;
+}