summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt15
-rw-r--r--RtAudio.cpp164
-rw-r--r--RtAudio.h63
-rw-r--r--contrib/python/pyrtaudio/rtaudiomodule.cpp50
-rw-r--r--contrib/python/pyrtaudio/setup.py3
-rw-r--r--doc/doxygen/compiling.txt2
-rw-r--r--doc/doxygen/probe.txt1
-rw-r--r--tests/duplex.cpp3
-rw-r--r--tests/testall.cpp2
-rw-r--r--tests/teststops.cpp8
10 files changed, 208 insertions, 103 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9de6a85..812d4d3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -44,7 +44,8 @@ elseif (UNIX AND NOT APPLE)
if (AUDIO_LINUX_PULSE)
find_library(PULSE_LIB pulse)
find_library(PULSESIMPLE_LIB pulse-simple)
- list(APPEND LINKLIBS ${PULSE_LIB} ${PULSESIMPLE_LIB})
+ find_package(Threads REQUIRED CMAKE_THREAD_PREFER_PTHREAD)
+ list(APPEND LINKLIBS ${PULSE_LIB} ${PULSESIMPLE_LIB} ${CMAKE_THREAD_LIBS_INIT})
add_definitions(-D__LINUX_PULSE__)
message(STATUS "Using Linux PulseAudio")
endif (AUDIO_LINUX_PULSE)
@@ -124,3 +125,15 @@ if (BUILD_TESTING)
add_subdirectory(tests)
endif (BUILD_TESTING)
+install(TARGETS rtaudio
+ LIBRARY DESTINATION lib
+ ARCHIVE DESTINATION lib
+ RUNTIME DESTINATION bin)
+
+install(
+ FILES RtAudio.h
+ DESTINATION include)
+
+install(
+ FILES rtaudio.pc
+ DESTINATION lib/pkgconfig)
diff --git a/RtAudio.cpp b/RtAudio.cpp
index d41c408..0b952f0 100644
--- a/RtAudio.cpp
+++ b/RtAudio.cpp
@@ -1,4 +1,4 @@
-/************************************************************************/
+/************************************************************************/
/*! \class RtAudio
\brief Realtime audio i/o C++ classes.
@@ -45,6 +45,7 @@
#include <cstdlib>
#include <cstring>
#include <climits>
+#include <cmath>
#include <algorithm>
// Static variable definitions.
@@ -92,12 +93,12 @@ const unsigned int RtApi::SAMPLE_RATES[] = {
//
// *************************************************** //
-std::string RtAudio :: getVersion( void ) throw()
+std::string RtAudio :: getVersion( void )
{
return RTAUDIO_VERSION;
}
-void RtAudio :: getCompiledApi( std::vector<RtAudio::Api> &apis ) throw()
+void RtAudio :: getCompiledApi( std::vector<RtAudio::Api> &apis )
{
apis.clear();
@@ -209,7 +210,7 @@ RtAudio :: RtAudio( RtAudio::Api api )
throw( RtAudioError( errorText, RtAudioError::UNSPECIFIED ) );
}
-RtAudio :: ~RtAudio() throw()
+RtAudio :: ~RtAudio()
{
if ( rtapi_ )
delete rtapi_;
@@ -427,6 +428,9 @@ void RtApi :: setStreamTime( double time )
if ( time >= 0.0 )
stream_.streamTime = time;
+#if defined( HAVE_GETTIMEOFDAY )
+ gettimeofday( &stream_.lastTickTimestamp, NULL );
+#endif
}
unsigned int RtApi :: getStreamSampleRate( void )
@@ -3861,8 +3865,7 @@ private:
// In order to satisfy WASAPI's buffer requirements, we need a means of converting sample rate
// between HW and the user. The convertBufferWasapi function is used to perform this conversion
// between HwIn->UserIn and UserOut->HwOut during the stream callback loop.
-// This sample rate converter favors speed over quality, and works best with conversions between
-// one rate and its multiple.
+// This sample rate converter works best with conversions between one rate and its multiple.
void convertBufferWasapi( char* outBuffer,
const char* inBuffer,
const unsigned int& channelCount,
@@ -3874,40 +3877,129 @@ void convertBufferWasapi( char* outBuffer,
{
// calculate the new outSampleCount and relative sampleStep
float sampleRatio = ( float ) outSampleRate / inSampleRate;
+ float sampleRatioInv = ( float ) 1 / sampleRatio;
float sampleStep = 1.0f / sampleRatio;
float inSampleFraction = 0.0f;
- outSampleCount = ( unsigned int ) roundf( inSampleCount * sampleRatio );
+ outSampleCount = ( unsigned int ) std::roundf( inSampleCount * sampleRatio );
- // frame-by-frame, copy each relative input sample into it's corresponding output sample
- for ( unsigned int outSample = 0; outSample < outSampleCount; outSample++ )
+ // if inSampleRate is a multiple of outSampleRate (or vice versa) there's no need to interpolate
+ if ( floor( sampleRatio ) == sampleRatio || floor( sampleRatioInv ) == sampleRatioInv )
{
- unsigned int inSample = ( unsigned int ) inSampleFraction;
-
- switch ( format )
+ // frame-by-frame, copy each relative input sample into it's corresponding output sample
+ for ( unsigned int outSample = 0; outSample < outSampleCount; outSample++ )
{
- case RTAUDIO_SINT8:
- memcpy( &( ( char* ) outBuffer )[ outSample * channelCount ], &( ( char* ) inBuffer )[ inSample * channelCount ], channelCount * sizeof( char ) );
- break;
- case RTAUDIO_SINT16:
- memcpy( &( ( short* ) outBuffer )[ outSample * channelCount ], &( ( short* ) inBuffer )[ inSample * channelCount ], channelCount * sizeof( short ) );
- break;
- case RTAUDIO_SINT24:
- memcpy( &( ( S24* ) outBuffer )[ outSample * channelCount ], &( ( S24* ) inBuffer )[ inSample * channelCount ], channelCount * sizeof( S24 ) );
- break;
- case RTAUDIO_SINT32:
- memcpy( &( ( int* ) outBuffer )[ outSample * channelCount ], &( ( int* ) inBuffer )[ inSample * channelCount ], channelCount * sizeof( int ) );
- break;
- case RTAUDIO_FLOAT32:
- memcpy( &( ( float* ) outBuffer )[ outSample * channelCount ], &( ( float* ) inBuffer )[ inSample * channelCount ], channelCount * sizeof( float ) );
- break;
- case RTAUDIO_FLOAT64:
- memcpy( &( ( double* ) outBuffer )[ outSample * channelCount ], &( ( double* ) inBuffer )[ inSample * channelCount ], channelCount * sizeof( double ) );
- break;
+ unsigned int inSample = ( unsigned int ) inSampleFraction;
+
+ switch ( format )
+ {
+ case RTAUDIO_SINT8:
+ memcpy( &( ( char* ) outBuffer )[ outSample * channelCount ], &( ( char* ) inBuffer )[ inSample * channelCount ], channelCount * sizeof( char ) );
+ break;
+ case RTAUDIO_SINT16:
+ memcpy( &( ( short* ) outBuffer )[ outSample * channelCount ], &( ( short* ) inBuffer )[ inSample * channelCount ], channelCount * sizeof( short ) );
+ break;
+ case RTAUDIO_SINT24:
+ memcpy( &( ( S24* ) outBuffer )[ outSample * channelCount ], &( ( S24* ) inBuffer )[ inSample * channelCount ], channelCount * sizeof( S24 ) );
+ break;
+ case RTAUDIO_SINT32:
+ memcpy( &( ( int* ) outBuffer )[ outSample * channelCount ], &( ( int* ) inBuffer )[ inSample * channelCount ], channelCount * sizeof( int ) );
+ break;
+ case RTAUDIO_FLOAT32:
+ memcpy( &( ( float* ) outBuffer )[ outSample * channelCount ], &( ( float* ) inBuffer )[ inSample * channelCount ], channelCount * sizeof( float ) );
+ break;
+ case RTAUDIO_FLOAT64:
+ memcpy( &( ( double* ) outBuffer )[ outSample * channelCount ], &( ( double* ) inBuffer )[ inSample * channelCount ], channelCount * sizeof( double ) );
+ break;
+ }
+
+ // jump to next in sample
+ inSampleFraction += sampleStep;
}
+ }
+ else // else interpolate
+ {
+ // frame-by-frame, copy each relative input sample into it's corresponding output sample
+ for ( unsigned int outSample = 0; outSample < outSampleCount; outSample++ )
+ {
+ unsigned int inSample = ( unsigned int ) inSampleFraction;
+ float inSampleDec = inSampleFraction - inSample;
+ unsigned int frameInSample = inSample * channelCount;
+ unsigned int frameOutSample = outSample * channelCount;
- // jump to next in sample
- inSampleFraction += sampleStep;
+ switch ( format )
+ {
+ case RTAUDIO_SINT8:
+ {
+ for ( unsigned int channel = 0; channel < channelCount; channel++ )
+ {
+ char fromSample = ( ( char* ) inBuffer )[ frameInSample + channel ];
+ char toSample = ( ( char* ) inBuffer )[ frameInSample + channelCount + channel ];
+ char sampleDiff = ( char ) ( ( toSample - fromSample ) * inSampleDec );
+ ( ( char* ) outBuffer )[ frameOutSample + channel ] = fromSample + sampleDiff;
+ }
+ break;
+ }
+ case RTAUDIO_SINT16:
+ {
+ for ( unsigned int channel = 0; channel < channelCount; channel++ )
+ {
+ short fromSample = ( ( short* ) inBuffer )[ frameInSample + channel ];
+ short toSample = ( ( short* ) inBuffer )[ frameInSample + channelCount + channel ];
+ short sampleDiff = ( short ) ( ( toSample - fromSample ) * inSampleDec );
+ ( ( short* ) outBuffer )[ frameOutSample + channel ] = fromSample + sampleDiff;
+ }
+ break;
+ }
+ case RTAUDIO_SINT24:
+ {
+ for ( unsigned int channel = 0; channel < channelCount; channel++ )
+ {
+ int fromSample = ( ( S24* ) inBuffer )[ frameInSample + channel ].asInt();
+ int toSample = ( ( S24* ) inBuffer )[ frameInSample + channelCount + channel ].asInt();
+ int sampleDiff = ( int ) ( ( toSample - fromSample ) * inSampleDec );
+ ( ( S24* ) outBuffer )[ frameOutSample + channel ] = fromSample + sampleDiff;
+ }
+ break;
+ }
+ case RTAUDIO_SINT32:
+ {
+ for ( unsigned int channel = 0; channel < channelCount; channel++ )
+ {
+ int fromSample = ( ( int* ) inBuffer )[ frameInSample + channel ];
+ int toSample = ( ( int* ) inBuffer )[ frameInSample + channelCount + channel ];
+ int sampleDiff = ( int ) ( ( toSample - fromSample ) * inSampleDec );
+ ( ( int* ) outBuffer )[ frameOutSample + channel ] = fromSample + sampleDiff;
+ }
+ break;
+ }
+ case RTAUDIO_FLOAT32:
+ {
+ for ( unsigned int channel = 0; channel < channelCount; channel++ )
+ {
+ float fromSample = ( ( float* ) inBuffer )[ frameInSample + channel ];
+ float toSample = ( ( float* ) inBuffer )[ frameInSample + channelCount + channel ];
+ float sampleDiff = ( toSample - fromSample ) * inSampleDec;
+ ( ( float* ) outBuffer )[ frameOutSample + channel ] = fromSample + sampleDiff;
+ }
+ break;
+ }
+ case RTAUDIO_FLOAT64:
+ {
+ for ( unsigned int channel = 0; channel < channelCount; channel++ )
+ {
+ double fromSample = ( ( double* ) inBuffer )[ frameInSample + channel ];
+ double toSample = ( ( double* ) inBuffer )[ frameInSample + channelCount + channel ];
+ double sampleDiff = ( toSample - fromSample ) * inSampleDec;
+ ( ( double* ) outBuffer )[ frameOutSample + channel ] = fromSample + sampleDiff;
+ }
+ break;
+ }
+ }
+
+ // jump to next in sample
+ inSampleFraction += sampleStep;
+ }
}
}
@@ -5197,6 +5289,8 @@ Exit:
// Various revisions for RtAudio 4.0 by Gary Scavone, April 2007
// Changed device query structure for RtAudio 4.0.7, January 2010
+#include <mmsystem.h>
+#include <mmreg.h>
#include <dsound.h>
#include <assert.h>
#include <algorithm>
@@ -5277,8 +5371,8 @@ RtApiDs :: RtApiDs()
RtApiDs :: ~RtApiDs()
{
- if ( coInitialized_ ) CoUninitialize(); // balanced call.
if ( stream_.state != STREAM_CLOSED ) closeStream();
+ if ( coInitialized_ ) CoUninitialize(); // balanced call.
}
// The DirectSound default output is always the first device.
@@ -8697,8 +8791,10 @@ RtAudio::DeviceInfo RtApiOss :: getDeviceInfo( unsigned int device )
info.nativeFormats |= RTAUDIO_SINT8;
if ( mask & AFMT_S32_LE || mask & AFMT_S32_BE )
info.nativeFormats |= RTAUDIO_SINT32;
+#ifdef AFMT_FLOAT
if ( mask & AFMT_FLOAT )
info.nativeFormats |= RTAUDIO_FLOAT32;
+#endif
if ( mask & AFMT_S24_LE || mask & AFMT_S24_BE )
info.nativeFormats |= RTAUDIO_SINT24;
@@ -9025,7 +9121,7 @@ bool RtApiOss :: probeDeviceOpen( unsigned int device, StreamMode mode, unsigned
}
// Verify the sample rate setup worked.
- if ( abs( srate - sampleRate ) > 100 ) {
+ if ( abs( srate - (int)sampleRate ) > 100 ) {
close( fd );
errorStream_ << "RtApiOss::probeDeviceOpen: device (" << ainfo.name << ") does not support sample rate (" << sampleRate << ").";
errorText_ = errorStream_.str();
diff --git a/RtAudio.h b/RtAudio.h
index dea39f0..21c16a3 100644
--- a/RtAudio.h
+++ b/RtAudio.h
@@ -49,7 +49,7 @@
#include <string>
#include <vector>
-#include <exception>
+#include <stdexcept>
#include <iostream>
/*! \typedef typedef unsigned long RtAudioFormat;
@@ -200,7 +200,7 @@ typedef int (*RtAudioCallback)( void *outputBuffer, void *inputBuffer,
*/
/************************************************************************/
-class RtAudioError : public std::exception
+class RtAudioError : public std::runtime_error
{
public:
//! Defined RtAudioError types.
@@ -219,25 +219,22 @@ class RtAudioError : public std::exception
};
//! The constructor.
- RtAudioError( const std::string& message, Type type = RtAudioError::UNSPECIFIED ) throw() : message_(message), type_(type) {}
-
- //! The destructor.
- virtual ~RtAudioError( void ) throw() {}
+ RtAudioError( const std::string& message,
+ Type type = RtAudioError::UNSPECIFIED )
+ : std::runtime_error(message), type_(type) {}
//! Prints thrown error message to stderr.
- virtual void printMessage( void ) const throw() { std::cerr << '\n' << message_ << "\n\n"; }
+ virtual void printMessage( void ) const
+ { std::cerr << '\n' << what() << "\n\n"; }
//! Returns the thrown error message type.
- virtual const Type& getType(void) const throw() { return type_; }
+ virtual const Type& getType(void) const { return type_; }
//! Returns the thrown error message string.
- virtual const std::string& getMessage(void) const throw() { return message_; }
-
- //! Returns the thrown error message as a c-style string.
- virtual const char* what( void ) const throw() { return message_.c_str(); }
+ virtual const std::string getMessage(void) const
+ { return std::string(what()); }
protected:
- std::string message_;
Type type_;
};
@@ -380,7 +377,7 @@ class RtAudio
};
//! A static function to determine the current RtAudio version.
- static std::string getVersion( void ) throw();
+ static std::string getVersion( void );
//! A static function to determine the available compiled audio APIs.
/*!
@@ -388,7 +385,7 @@ class RtAudio
the enumerated list values. Note that there can be more than one
API compiled for certain operating systems.
*/
- static void getCompiledApi( std::vector<RtAudio::Api> &apis ) throw();
+ static void getCompiledApi( std::vector<RtAudio::Api> &apis );
//! The class constructor.
/*!
@@ -406,10 +403,10 @@ class RtAudio
If a stream is running or open, it will be stopped and closed
automatically.
*/
- ~RtAudio() throw();
+ ~RtAudio();
//! Returns the audio API specifier for the current instance of RtAudio.
- RtAudio::Api getCurrentApi( void ) throw();
+ RtAudio::Api getCurrentApi( void );
//! A public function that queries for the number of audio devices available.
/*!
@@ -417,7 +414,7 @@ class RtAudio
is called, thus supporting devices connected \e after instantiation. If
a system error occurs during processing, a warning will be issued.
*/
- unsigned int getDeviceCount( void ) throw();
+ unsigned int getDeviceCount( void );
//! Return an RtAudio::DeviceInfo structure for a specified device number.
/*!
@@ -440,7 +437,7 @@ class RtAudio
client's responsibility to verify that a device is available
before attempting to open a stream.
*/
- unsigned int getDefaultOutputDevice( void ) throw();
+ unsigned int getDefaultOutputDevice( void );
//! A function that returns the index of the default input device.
/*!
@@ -450,7 +447,7 @@ class RtAudio
client's responsibility to verify that a device is available
before attempting to open a stream.
*/
- unsigned int getDefaultInputDevice( void ) throw();
+ unsigned int getDefaultInputDevice( void );
//! A public function for opening a stream with the specified parameters.
/*!
@@ -503,7 +500,7 @@ class RtAudio
If a stream is not open, this function issues a warning and
returns (no exception is thrown).
*/
- void closeStream( void ) throw();
+ void closeStream( void );
//! A function that starts a stream.
/*!
@@ -533,10 +530,10 @@ class RtAudio
void abortStream( void );
//! Returns true if a stream is open and false if not.
- bool isStreamOpen( void ) const throw();
+ bool isStreamOpen( void ) const;
//! Returns true if the stream is running and false if it is stopped or not open.
- bool isStreamRunning( void ) const throw();
+ bool isStreamRunning( void ) const;
//! Returns the number of elapsed seconds since the stream was started.
/*!
@@ -570,7 +567,7 @@ class RtAudio
unsigned int getStreamSampleRate( void );
//! Specify whether warning messages should be printed to stderr.
- void showWarnings( bool value = true ) throw();
+ void showWarnings( bool value = true );
protected:
@@ -621,7 +618,7 @@ struct CallbackInfo {
// Default constructor.
CallbackInfo()
- :object(0), callback(0), userData(0), errorCallback(0), apiInfo(0), isRunning(false), doRealtime(false) {}
+ :object(0), callback(0), userData(0), errorCallback(0), apiInfo(0), isRunning(false), doRealtime(false), priority(0) {}
};
// **************************************************************** //
@@ -829,22 +826,22 @@ protected:
//
// **************************************************************** //
-inline RtAudio::Api RtAudio :: getCurrentApi( void ) throw() { return rtapi_->getCurrentApi(); }
-inline unsigned int RtAudio :: getDeviceCount( void ) throw() { return rtapi_->getDeviceCount(); }
+inline RtAudio::Api RtAudio :: getCurrentApi( void ) { return rtapi_->getCurrentApi(); }
+inline unsigned int RtAudio :: getDeviceCount( void ) { return rtapi_->getDeviceCount(); }
inline RtAudio::DeviceInfo RtAudio :: getDeviceInfo( unsigned int device ) { return rtapi_->getDeviceInfo( device ); }
-inline unsigned int RtAudio :: getDefaultInputDevice( void ) throw() { return rtapi_->getDefaultInputDevice(); }
-inline unsigned int RtAudio :: getDefaultOutputDevice( void ) throw() { return rtapi_->getDefaultOutputDevice(); }
-inline void RtAudio :: closeStream( void ) throw() { return rtapi_->closeStream(); }
+inline unsigned int RtAudio :: getDefaultInputDevice( void ) { return rtapi_->getDefaultInputDevice(); }
+inline unsigned int RtAudio :: getDefaultOutputDevice( void ) { return rtapi_->getDefaultOutputDevice(); }
+inline void RtAudio :: closeStream( void ) { return rtapi_->closeStream(); }
inline void RtAudio :: startStream( void ) { return rtapi_->startStream(); }
inline void RtAudio :: stopStream( void ) { return rtapi_->stopStream(); }
inline void RtAudio :: abortStream( void ) { return rtapi_->abortStream(); }
-inline bool RtAudio :: isStreamOpen( void ) const throw() { return rtapi_->isStreamOpen(); }
-inline bool RtAudio :: isStreamRunning( void ) const throw() { return rtapi_->isStreamRunning(); }
+inline bool RtAudio :: isStreamOpen( void ) const { return rtapi_->isStreamOpen(); }
+inline bool RtAudio :: isStreamRunning( void ) const { return rtapi_->isStreamRunning(); }
inline long RtAudio :: getStreamLatency( void ) { return rtapi_->getStreamLatency(); }
inline unsigned int RtAudio :: getStreamSampleRate( void ) { return rtapi_->getStreamSampleRate(); }
inline double RtAudio :: getStreamTime( void ) { return rtapi_->getStreamTime(); }
inline void RtAudio :: setStreamTime( double time ) { return rtapi_->setStreamTime( time ); }
-inline void RtAudio :: showWarnings( bool value ) throw() { rtapi_->showWarnings( value ); }
+inline void RtAudio :: showWarnings( bool value ) { rtapi_->showWarnings( value ); }
// RtApi Subclass prototypes.
diff --git a/contrib/python/pyrtaudio/rtaudiomodule.cpp b/contrib/python/pyrtaudio/rtaudiomodule.cpp
index 40a87e5..93d3c73 100644
--- a/contrib/python/pyrtaudio/rtaudiomodule.cpp
+++ b/contrib/python/pyrtaudio/rtaudiomodule.cpp
@@ -48,7 +48,7 @@ extern "C" {
PyObject *callback_func;
} PyRtAudio;
- static PyObject *RtAudioError;
+ static PyObject *RtAudioErrorException;
static int callback(void *outputBuffer, void *inputBuffer, unsigned int nBufferFrames,
double streamTime, RtAudioStreamStatus status, void *data )
@@ -151,9 +151,9 @@ extern "C" {
else if(!strcmp(api, "directsound"))
self->dac = new RtAudio(RtAudio::WINDOWS_DS);
}
- catch (RtError &error) {
- PyErr_SetString(RtAudioError, error.getMessage().c_str());
- Py_INCREF(RtAudioError);
+ catch (RtAudioError &error) {
+ PyErr_SetString(RtAudioErrorException, error.getMessage().c_str());
+ Py_INCREF(RtAudioErrorException);
return NULL;
}
@@ -261,9 +261,9 @@ extern "C" {
self->dac->closeStream();
self->dac->openStream(&oParams, &iParams, self->_format, fs, &bf, &callback, self, &options);
}
- catch ( RtError& error ) {
- PyErr_SetString(RtAudioError, error.getMessage().c_str());
- Py_INCREF(RtAudioError);
+ catch ( RtAudioError& error ) {
+ PyErr_SetString(RtAudioErrorException, error.getMessage().c_str());
+ Py_INCREF(RtAudioErrorException);
return NULL;
}
@@ -281,9 +281,9 @@ extern "C" {
self->dac->closeStream();
Py_CLEAR(self->callback_func);
}
- catch(RtError &error) {
- PyErr_SetString(RtAudioError, error.getMessage().c_str());
- Py_INCREF(RtAudioError);
+ catch(RtAudioError &error) {
+ PyErr_SetString(RtAudioErrorException, error.getMessage().c_str());
+ Py_INCREF(RtAudioErrorException);
return NULL;
}
@@ -297,9 +297,9 @@ extern "C" {
try {
self->dac->startStream();
}
- catch(RtError &error) {
- PyErr_SetString(RtAudioError, error.getMessage().c_str());
- Py_INCREF(RtAudioError);
+ catch(RtAudioError &error) {
+ PyErr_SetString(RtAudioErrorException, error.getMessage().c_str());
+ Py_INCREF(RtAudioErrorException);
return NULL;
}
@@ -315,9 +315,9 @@ extern "C" {
try {
self->dac->stopStream();
}
- catch(RtError &error) {
- PyErr_SetString(RtAudioError, error.getMessage().c_str());
- Py_INCREF(RtAudioError);
+ catch(RtAudioError &error) {
+ PyErr_SetString(RtAudioErrorException, error.getMessage().c_str());
+ Py_INCREF(RtAudioErrorException);
return NULL;
}
@@ -332,9 +332,9 @@ extern "C" {
try {
self->dac->abortStream();
}
- catch(RtError &error) {
- PyErr_SetString(RtAudioError, error.getMessage().c_str());
- Py_INCREF(RtAudioError);
+ catch(RtAudioError &error) {
+ PyErr_SetString(RtAudioErrorException, error.getMessage().c_str());
+ Py_INCREF(RtAudioErrorException);
return NULL;
}
Py_RETURN_NONE;
@@ -430,9 +430,9 @@ extern "C" {
return info_dict;
}
- catch(RtError &error) {
- PyErr_SetString(RtAudioError, error.getMessage().c_str());
- Py_INCREF(RtAudioError);
+ catch(RtAudioError &error) {
+ PyErr_SetString(RtAudioErrorException, error.getMessage().c_str());
+ Py_INCREF(RtAudioErrorException);
return NULL;
}
}
@@ -598,8 +598,8 @@ extern "C" {
Py_INCREF(&RtAudio_type);
PyModule_AddObject(module, "RtAudio", (PyObject *)&RtAudio_type);
- RtAudioError = PyErr_NewException("rtaudio.RtError", NULL, NULL);
- Py_INCREF(RtAudioError);
- PyModule_AddObject(module, "RtError", RtAudioError);
+ RtAudioErrorException = PyErr_NewException("rtaudio.RtError", NULL, NULL);
+ Py_INCREF(RtAudioErrorException);
+ PyModule_AddObject(module, "RtError", RtAudioErrorException);
}
}
diff --git a/contrib/python/pyrtaudio/setup.py b/contrib/python/pyrtaudio/setup.py
index 6ad0d4a..a942f3b 100644
--- a/contrib/python/pyrtaudio/setup.py
+++ b/contrib/python/pyrtaudio/setup.py
@@ -18,8 +18,7 @@ sources = ['rtaudiomodule.cpp', '../../../RtAudio.cpp']
if OSNAME == 'Linux':
define_macros=[("__LINUX_ALSA__", ''),
- ('__LINUX_JACK__', ''),
- ('__LINUX_OSS__', '')]
+ ('__LINUX_JACK__', '')]
libraries = ['asound', 'jack', 'pthread']
elif OSNAME == 'Darwin':
diff --git a/doc/doxygen/compiling.txt b/doc/doxygen/compiling.txt
index 15f45b0..29dcbd4 100644
--- a/doc/doxygen/compiling.txt
+++ b/doc/doxygen/compiling.txt
@@ -57,7 +57,7 @@ In order to compile RtAudio for a specific OS and audio API, it is necessary to
<TD>RtApiCore</TD>
<TD>__MACOSX_CORE__</TD>
<TD><TT>pthread, CoreAudio</TT></TD>
- <TD><TT>g++ -Wall -D__MACOSX_CORE__ -o audioprobe audioprobe.cpp RtAudio.cpp -framework CoreAudio -lpthread</TT></TD>
+ <TD><TT>g++ -Wall -D__MACOSX_CORE__ -o audioprobe audioprobe.cpp RtAudio.cpp -framework CoreAudio -framework CoreFoundation -lpthread</TT></TD>
</TR>
<TR>
<TD>Windows</TD>
diff --git a/doc/doxygen/probe.txt b/doc/doxygen/probe.txt
index 653955b..975ff0e 100644
--- a/doc/doxygen/probe.txt
+++ b/doc/doxygen/probe.txt
@@ -45,6 +45,7 @@ The RtAudio::DeviceInfo structure is defined in RtAudio.h and provides a variety
bool isDefaultOutput; // true if this is the default output device.
bool isDefaultInput; // true if this is the default input device.
std::vector<unsigned int> sampleRates; // Supported sample rates.
+ unsigned int preferredSampleRate; // Preferred sample rate, eg. for WASAPI the system sample rate.
RtAudioFormat nativeFormats; // Bit mask of supported data formats.
};
\endcode
diff --git a/tests/duplex.cpp b/tests/duplex.cpp
index 06462f2..494e5ad 100644
--- a/tests/duplex.cpp
+++ b/tests/duplex.cpp
@@ -105,6 +105,7 @@ int main( int argc, char *argv[] )
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 );
}
@@ -113,8 +114,6 @@ int main( int argc, char *argv[] )
exit( 1 );
}
- bufferBytes = bufferFrames * channels * sizeof( MY_TYPE );
-
// Test RtAudio functionality for reporting latency.
std::cout << "\nStream latency = " << adac.getStreamLatency() << " frames" << std::endl;
diff --git a/tests/testall.cpp b/tests/testall.cpp
index 419f27b..b94ce69 100644
--- a/tests/testall.cpp
+++ b/tests/testall.cpp
@@ -66,7 +66,7 @@ int sawni( void *outputBuffer, void * /*inputBuffer*/, unsigned int nBufferFrame
if ( status )
std::cout << "Stream underflow detected!" << std::endl;
- float increment;
+ double increment;
for ( j=0; j<channels; j++ ) {
increment = BASE_RATE * (j+1+(j*0.1));
for ( i=0; i<nBufferFrames; i++ ) {
diff --git a/tests/teststops.cpp b/tests/teststops.cpp
index e24c064..6159b88 100644
--- a/tests/teststops.cpp
+++ b/tests/teststops.cpp
@@ -63,7 +63,7 @@ int pulse( void *outputBuffer, void * /*inputBuffer*/, unsigned int nBufferFrame
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;
+ if ( data->frameCounter % data->pulseCount == 0 ) sample = 0.9f;
else sample = 0.0;
for ( j=0; j<data->channels; j++ )
*buffer++ = sample;
@@ -107,8 +107,8 @@ int main( int argc, char *argv[] )
// Let RtAudio print messages to stderr.
adc->showWarnings( true );
- runtime = RUNTIME * 1000;
- pausetime = PAUSETIME * 1000;
+ runtime = static_cast<unsigned int>(RUNTIME * 1000);
+ pausetime = static_cast<unsigned int>(PAUSETIME * 1000);
// Set our stream parameters for a duplex stream.
bufferFrames = 512;
@@ -127,7 +127,7 @@ int main( int argc, char *argv[] )
oParams.deviceId = adc->getDefaultOutputDevice();
// First, test external stopStream() calls.
- mydata.pulseCount = PULSE_RATE * fs;
+ mydata.pulseCount = static_cast<unsigned int>(PULSE_RATE * fs);
mydata.nFrames = 50 * fs;
mydata.returnValue = 0;
try {