summaryrefslogtreecommitdiff
path: root/RtAudio.h
diff options
context:
space:
mode:
authorGary Scavone <gary@music.mcgill.ca>2013-12-27 11:30:37 -0800
committerGary Scavone <gary@music.mcgill.ca>2013-12-27 11:30:37 -0800
commit07c639e41165da70aab5016adf1bf7133a418b31 (patch)
tree23134f770f593643c52f9ca458f06c23fc3d0873 /RtAudio.h
parenta16508efc3f1ce9dee8f8d760ed68626b34881df (diff)
Renamed RtError class to RtAudioError and embedded it in RtAudio.h.
Deleted RtError.h from distribution and renamed all references to RtError in the documentation, test files, and Windows .dsp files. The version number was incremented to 4.1.0 in anticipation of the next release, as this change affects the API.
Diffstat (limited to 'RtAudio.h')
-rw-r--r--RtAudio.h60
1 files changed, 58 insertions, 2 deletions
diff --git a/RtAudio.h b/RtAudio.h
index d78c313..9721905 100644
--- a/RtAudio.h
+++ b/RtAudio.h
@@ -47,10 +47,11 @@
#include <string>
#include <vector>
-#include "RtError.h"
+#include <exception>
+#include <iostream>
// RtAudio version
-static const std::string VERSION( "4.0.12" );
+static const std::string VERSION( "4.1.0pre" );
/*! \typedef typedef unsigned long RtAudioFormat;
\brief RtAudio data format type.
@@ -205,6 +206,7 @@ typedef void (*RtAudioErrorCallback)( RtError::Type type, const std::string &err
//
// **************************************************************** //
+class RtAudioError;
class RtApi;
class RtAudio
@@ -1048,6 +1050,60 @@ public:
#endif
+/************************************************************************/
+/*! \class RtError
+ \brief Exception handling class for RtAudio & RtMidi.
+
+ The RtError class is quite simple but it does allow errors to be
+ "caught" by RtError::Type. See the RtAudio and RtMidi
+ documentation to know which methods can throw an RtError.
+
+*/
+/************************************************************************/
+
+class RtAudioError : public std::exception
+{
+ public:
+ //! Defined RtAudioError types.
+ enum Type {
+ WARNING, /*!< A non-critical error. */
+ DEBUG_WARNING, /*!< A non-critical error which might be useful for debugging. */
+ UNSPECIFIED, /*!< The default, unspecified error type. */
+ NO_DEVICES_FOUND, /*!< No devices found on system. */
+ INVALID_DEVICE, /*!< An invalid device ID was specified. */
+ MEMORY_ERROR, /*!< An error occured during memory allocation. */
+ INVALID_PARAMETER, /*!< An invalid parameter was specified to a function. */
+ INVALID_USE, /*!< The function was called incorrectly. */
+ DRIVER_ERROR, /*!< A system driver error occured. */
+ SYSTEM_ERROR, /*!< A system error occured. */
+ THREAD_ERROR /*!< A thread error occured. */
+ };
+
+ //! The constructor.
+ RtAudioError( const std::string& message, Type type = RtAudioError::UNSPECIFIED ) throw() : message_(message), type_(type) {}
+
+ //! The destructor.
+ virtual ~RtAudioError( void ) throw() {}
+
+ //! Prints thrown error message to stderr.
+ virtual void printMessage( void ) const throw() { std::cerr << '\n' << message_ << "\n\n"; }
+
+ //! Returns the thrown error message type.
+ virtual const Type& getType(void) const throw() { 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(); }
+
+ protected:
+ std::string message_;
+ Type type_;
+};
+
+#endif
+
#endif
// Indentation settings for Vim and Emacs