HulaLoop
Simple cross-platform audio loopback and recording.
HulaAudioError.h
Go to the documentation of this file.
1 #ifndef HL_AUDIO_ERROR_H
2 #define HL_AUDIO_ERROR_H
3 
4 #include <cstdio>
5 #include <iostream>
6 
7 #include "HulaVersion.h"
8 
25 /******************************************************************************
26  *
27  * Collection of global information for HulaLoop
28  *
29 ******************************************************************************/
30 
34 #define HL_PRINT_PREFIX "[HulaLoop] "
35 
39 #define HL_ERROR_PREFIX "[HulaLoop] "
40 
44 #define hlDebug() \
45  if (HL_NO_DEBUG_OUTPUT) {} \
46  else std::cerr << HL_PRINT_PREFIX
47 
51 #define hlDebugf(...) \
52  if (HL_NO_DEBUG_OUTPUT) {} \
53  else fprintf(stderr, HL_PRINT_PREFIX __VA_ARGS__);
54 
55 /******************************************************************************
56  *
57  * Collection of error codes and exceptions for hlaudio
58  *
59 ******************************************************************************/
60 
61 // OSAudio error messages
62 #define HL_OS_INIT_CODE -1
63 #define HL_OS_INIT_MSG "Could not initialize OS audio module!"
64 
65 #define HL_PA_INIT_CODE -2
66 #define HL_PA_INIT_MSG "Could not initialize Port Audio!"
67 
68 #define HL_PA_GET_DEVICES_CODE -3
69 #define HL_PA_GET_DEVICES_MSG "Could not fetch Port Audio devices!"
70 
71 #define HL_PA_OPEN_STREAM_CODE -4
72 #define HL_PA_OPEN_STREAM_MSG "Could not open Port Audio device stream!"
73 
74 #define HL_PA_CLOSE_STREAM_CODE -5
75 #define HL_PA_CLOSE_STREAM_MSG "Could not close Port Audio device stream!"
76 
77 #define HL_DEVICE_NOT_FOUND_CODE -6
78 #define HL_DEVICE_NOT_FOUND_MSG "Device not found!"
79 
80 #define HL_CHECK_PARAMS_CODE -7
81 #define HL_CHECK_PARAMS_MSG "The specified sample rate or format is invalid!"
82 
83 #define HL_PA_DEVICE_READ_STREAM_CODE -8
84 #define HL_PA_DEVICE_READ_STREAM_MSG "Error during read from device stream!"
85 
86 // OSXAudio error messages
87 #define HL_OSX_DAEMON_INIT_CODE -9
88 #define HL_OSX_DAEMON_INIT_MSG "Could not start hulaloop-osx-daemon process!"
89 
90 #define HL_OSX_DAEMON_CRASH_CODE -10
91 #define HL_OSX_DAEMON_CRASH_MSG "The hulaloop-osx-daemon process crashed!"
92 
93 #define HL_OSX_PGREP_CODE -11
94 #define HL_OSX_PGREP_MSG "Could not start pgrep process!"
95 
96 #define HL_OSX_EXEPATH_CODE -12
97 #define HL_OSX_EXEPATH_MSG "Could not retrieve path to current executable!"
98 
99 #define HL_OSX_EXEPATH_TRIM_CODE -13
100 #define HL_OSX_EXEPATH_TRIM_MSG "Could not trim executable name from install path!"
101 
102 // LinuxAudio error messages
103 #define HL_LINUX_OPEN_DEVICE_CODE -14
104 #define HL_LINUX_OPEN_DEVICE_MSG "Could not open ALSA audio device!"
105 
106 #define HL_LINUX_ALSA_CLOSE_STREAM_CODE -15
107 #define HL_LINUX_ALSA_CLOSE_STREAM_MSG "Could not close ALSA device stream!"
108 
109 #define HL_LINUX_SET_PARAMS_CODE -16
110 #define HL_LINUX_SET_PARAMS_MSG "Could not set ALSA device params!"
111 
112 // WindowsAudio error messages
113 #define HL_WIN_GET_DEVICES_CODE -17
114 #define HL_WIN_GET_DEVICES_MSG "Could not fetch WASAPI audio devices!"
115 
116 #define HL_WIN_OPEN_STREAM_CODE -18
117 #define HL_WIN_OPEN_STREAM_MSG "Could not open WASAPI device stream!"
118 
119 // HulaRingBuffer error messages
120 #define HL_RB_ALLOC_BUFFER_CODE -19
121 #define HL_RB_ALLOC_BUFFER_MSG "Could not allocate ring buffer!"
122 
123 #define HL_RB_INIT_BUFFER_CODE -20
124 #define HL_RB_INIT_BUFFER_MSG "Could not initialize ring buffer! Perhaps the size is not power of 2?"
125 
126 namespace hula
127 {
132 
133  private:
134  int errorCode;
135  std::string msg;
136 
137  public:
141  AudioException(int errorCode, const std::string &msg)
142  {
143  this->errorCode = errorCode;
144  this->msg = msg;
145  }
146 
152  const std::string getMessage() const
153  {
154  return msg;
155  }
156 
162  int getErrorCode() const
163  {
164  return errorCode;
165  }
166  };
167 }
168 
169 #endif // END HL_AUDIO_ERROR_H
const std::string getMessage() const
This method returns the error message that corresponds to the error code.
Definition: HulaAudioError.h:152
Exception class for the control module and higher.
Definition: HulaAudioError.h:131
Wrapper around translation functions for Qt.
Definition: Controller.h:10
int getErrorCode() const
This method returns the error code.
Definition: HulaAudioError.h:162
AudioException(int errorCode, const std::string &msg)
Constructor of AudioException.
Definition: HulaAudioError.h:141