X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=tests%2Fduplex.cpp;h=494e5ad7ab121e6ffa1ac98537d064af20c2c9f2;hb=33444d65018dda0912552a53e5e0b3836468d9a9;hp=125b56e2d12c827a0b04e3bbb0ee931254319ec7;hpb=ad768de27c78093a6000a4f00d1baeca8ca5ce37;p=rtaudio.git diff --git a/tests/duplex.cpp b/tests/duplex.cpp index 125b56e..494e5ad 100644 --- a/tests/duplex.cpp +++ b/tests/duplex.cpp @@ -14,24 +14,26 @@ #include /* -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 @@ -46,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; } @@ -95,19 +97,23 @@ int main( int argc, char *argv[] ) oParams.nChannels = channels; oParams.firstChannel = oOffset; + if ( iDevice == 0 ) + iParams.deviceId = adac.getDefaultInputDevice(); + if ( oDevice == 0 ) + oParams.deviceId = adac.getDefaultOutputDevice(); + RtAudio::StreamOptions options; //options.flags |= RTAUDIO_NONINTERLEAVED; + bufferBytes = bufferFrames * channels * sizeof( MY_TYPE ); 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 ); } - bufferBytes = bufferFrames * channels * sizeof( MY_TYPE ); - // Test RtAudio functionality for reporting latency. std::cout << "\nStream latency = " << adac.getStreamLatency() << " frames" << std::endl; @@ -121,7 +127,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; }