summaryrefslogtreecommitdiff
path: root/tests/playsaw.cpp
diff options
context:
space:
mode:
authorGary Scavone <gary@music.mcgill.ca>2019-07-30 12:26:44 -0400
committerGary Scavone <gary@music.mcgill.ca>2019-07-30 12:26:44 -0400
commit6c7651fd65e2d6d423836cee77a48d1b238b2595 (patch)
tree22f480750f83e3c8b4155bd8557438c4f34da142 /tests/playsaw.cpp
parenta09f92013c020e23bad9fecd2cb7ad8b9dbb4fd6 (diff)
Added new setErrorCallback() function and removed errorCallback argument in openStream(). Also added RtAudioError::Type return value to openStream(), startStream(), stopStream() and abortStream() functions, but only implemented in RtApiCore.
Diffstat (limited to 'tests/playsaw.cpp')
-rw-r--r--tests/playsaw.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/tests/playsaw.cpp b/tests/playsaw.cpp
index beaf714..e875313 100644
--- a/tests/playsaw.cpp
+++ b/tests/playsaw.cpp
@@ -66,8 +66,7 @@ void usage( void ) {
void errorCallback( RtAudioError::Type /*type*/, const std::string &errorText )
{
- // This example error handling function does exactly the same thing
- // as the embedded RtAudio::error() function.
+ // This example error handling function simply outputs the error message to stderr.
std::cerr << "\nerrorCallback: " << errorText << "\n\n";
}
@@ -172,7 +171,9 @@ int main( int argc, char *argv[] )
double *data = (double *) calloc( channels, sizeof( double ) );
- // Let RtAudio print messages to stderr.
+ // Specify our own error callback function and tell RtAudio to
+ // output all messages, even warnings.
+ dac.setErrorCallback( &errorCallback );
dac.showWarnings( true );
// Set our stream parameters for output only.
@@ -191,11 +192,15 @@ int main( int argc, char *argv[] )
options.flags |= RTAUDIO_NONINTERLEAVED;
#endif
- dac.openStream( &oParams, NULL, FORMAT, fs, &bufferFrames, &saw, (void *)data, &options, &errorCallback );
+ // An error in the openStream() function can be detected either by
+ // checking for a non-zero return value OR by a subsequent call to
+ // isStreamOpen().
+ if ( dac.openStream( &oParams, NULL, FORMAT, fs, &bufferFrames, &saw, (void *)data, &options ) )
+ goto cleanup;
if ( dac.isStreamOpen() == false ) goto cleanup;
// Stream is open ... now start it.
- dac.startStream();
+ if ( dac.startStream() ) goto cleanup;
if ( checkCount ) {
while ( dac.isStreamRunning() == true ) SLEEP( 100 );