00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef DRUMSTICK_DRUMSTICKCOMMON_H
00021 #define DRUMSTICK_DRUMSTICKCOMMON_H
00022
00023 #include "macros.h"
00024 #include <qglobal.h>
00025 #include <QString>
00026 #include <QApplication>
00027 #include <QtDebug>
00028
00029 extern "C" {
00030 #include <alsa/asoundlib.h>
00031 }
00032
00041 namespace drumstick {
00042
00046 typedef quint8 MidiByte;
00047
00054 class DRUMSTICK_EXPORT SequencerError
00055 {
00056 public:
00062 SequencerError(QString const& s, int rc) :
00063 m_location(s), m_errCode(rc) {}
00064
00068 virtual ~SequencerError() {}
00069
00074 const QString qstrError() const
00075 {
00076 return QString(snd_strerror(m_errCode));
00077 }
00078
00083 int code() const
00084 {
00085 return m_errCode;
00086 }
00087
00092 const QString& location() const
00093 {
00094 return m_location;
00095 }
00096
00097 private:
00098 QString m_location;
00099 int m_errCode;
00100 };
00101
00110 inline int checkErrorAndThrow(int rc, const char *where)
00111 {
00112 if (rc < 0) {
00113 qDebug() << "Error code:" << rc << "(" << snd_strerror(rc) << ")";
00114 qDebug() << "Location:" << where;
00115 throw SequencerError(QString(where), rc);
00116 }
00117 return rc;
00118 }
00119
00127 inline int checkWarning(int rc, const char *where)
00128 {
00129 if (rc < 0) {
00130 qWarning() << "Exception code:" << rc << "(" << snd_strerror(rc) << ")";
00131 qWarning() << "Location:" << where;
00132 }
00133 return rc;
00134 }
00135
00140 #define CHECK_ERROR(x) (checkErrorAndThrow((x),__PRETTY_FUNCTION__))
00141
00146 #define CHECK_WARNING(x) (checkWarning((x),__PRETTY_FUNCTION__))
00147
00155 const QString LIBRARY_VERSION(SND_LIB_VERSION_STR);
00156
00157 }
00158
00161 #endif