gtkIOStream  1.7.0
GTK+ << C++ IOStream operators for GTK+. Now with ORBing, numerical computation, audio client and more ...
ALSADebug.H
Go to the documentation of this file.
1 /* Copyright 2000-2018 Matt Flax <flatmax@flatmax.org>
2  This file is part of GTK+ IOStream class set
3 
4  GTK+ IOStream is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8 
9  GTK+ IOStream is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You have received a copy of the GNU General Public License
15  along with GTK+ IOStream
16 */
17 #ifndef ALSADEBUG_H
18 #define ALSADEBUG_H
19 
20 #include <iostream>
21 #include <Debug.H>
22 #include <alsa/asoundlib.h>
23 
24 namespace ALSA {
25  #define ALSA_PCM_NOT_OPEN_ERROR -1+ALSA_ERROR_OFFSET
26  #define ALSA_UNKNOWN_READ_ERROR -2+ALSA_ERROR_OFFSET
27  #define ALSA_FULLDUPLEX_PROCESS_ERROR -3+ALSA_ERROR_OFFSET
28  #define ALSA_FRAME_MISMATCH_ERROR -4+ALSA_ERROR_OFFSET
29  #define ALSA_NO_CHANNELS_ERROR -5+ALSA_ERROR_OFFSET
30  #define ALSA_YOUR_PROCESS_FN_ERROR -6+ALSA_ERROR_OFFSET
31  #define ALSA_FORMAT_MISMATCH_ERROR -7+ALSA_ERROR_OFFSET
32  #define ALSA_MIXER_NOT_OPEN_ERROR -8+ALSA_ERROR_OFFSET
33  #define ALSA_MIXER_QUERY_ERROR -9+ALSA_ERROR_OFFSET
34  #define ALSA_MIXER_FIND_ELEMENT_ERROR -10+ALSA_ERROR_OFFSET
35  #define ALSA_MIXER_WRONG_ELEMENT_ERROR -11+ALSA_ERROR_OFFSET
36  #define ALSA_MIXER_NO_CHANNEL_ERROR -12+ALSA_ERROR_OFFSET
37  #define ALSA_MIXER_NO_PLAYBACK_VOL_ERROR -13+ALSA_ERROR_OFFSET
38  #define ALSA_MIXER_NO_CAPTURE_VOL_ERROR -13+ALSA_ERROR_OFFSET
39  class ALSADebug : public Debug {
40  public:
41  ALSADebug(void) {
42  #ifndef NDEBUG
43  errors[ALSA_PCM_NOT_OPEN_ERROR]=std::string("The pcm device isn't open, open first.");
44  errors[ALSA_UNKNOWN_READ_ERROR]=std::string("Tried to read but couldn't for an unknown reason.");
45  errors[ALSA_FULLDUPLEX_PROCESS_ERROR]=std::string("Tried to execute your process function, but it returned error.");
46  errors[ALSA_FRAME_MISMATCH_ERROR]=std::string("Frame size mismatch. ");
47  errors[ALSA_NO_CHANNELS_ERROR]=std::string("No channels found. ");
48  errors[ALSA_YOUR_PROCESS_FN_ERROR]=std::string("Your process function returned error. ");
49  errors[ALSA_FORMAT_MISMATCH_ERROR]=std::string("The bits in the words don't match. ");
50  errors[ALSA_MIXER_NOT_OPEN_ERROR]=std::string("The mixer device isn't open, open first.");
51  errors[ALSA_MIXER_QUERY_ERROR]=std::string("The mixer query failed.");
52  errors[ALSA_MIXER_FIND_ELEMENT_ERROR]=std::string("Failed to find the element.");
53  errors[ALSA_MIXER_WRONG_ELEMENT_ERROR]=std::string("The two mixer elements are different.");
54  errors[ALSA_MIXER_NO_CHANNEL_ERROR]=std::string("That channel couldn't be found.");
55  errors[ALSA_MIXER_NO_PLAYBACK_VOL_ERROR]=std::string("That mixer element doesn't have a playback vol control.");
56  errors[ALSA_MIXER_NO_CAPTURE_VOL_ERROR]=std::string("That mixer element doesn't have a capture vol control.");
57 
58  #endif
59  }
60 
61  virtual int evaluateError(int errorNum) {
62  std::cout<<errorNum<<std::endl;
63  if (errorNum>MAX_ERROR_OFFSET || errorNum<MIN_ERROR_OFFSET){
64  fprintf(stderr, "%s ", snd_strerror(errorNum));
65  return errorNum;
66  }
67  return Debug::evaluateError(errorNum);
68  }
69 
70  virtual int evaluateError(int errorNum, std::string append) {
71  return Debug::evaluateError(errorNum, append);
72  }
73 
78  bool noChannelError(int val){ return val==ALSA_MIXER_NO_CHANNEL_ERROR;}
79  };
80 }
81 #endif // ALSADEBUG_H
ALSADebug(void)
Definition: ALSADebug.H:41
#define ALSA_FRAME_MISMATCH_ERROR
error when frame sizes are incorrect
Definition: ALSADebug.H:28
#define ALSA_MIXER_NOT_OPEN_ERROR
error when mixer pointer is null
Definition: ALSADebug.H:32
#define MAX_ERROR_OFFSET
The lowest debug error magnitude from gtkiostream.
Definition: Debug.H:97
#define ALSA_FORMAT_MISMATCH_ERROR
error when comparing bits sizes of two words
Definition: ALSADebug.H:31
virtual int evaluateError(int errorNum)
Definition: Debug.H:132
Definition: ALSA.H:26
#define ALSA_YOUR_PROCESS_FN_ERROR
error when calling the user&#39;s process function
Definition: ALSADebug.H:30
#define ALSA_MIXER_NO_CHANNEL_ERROR
error when we can&#39;t find the prescribed channel
Definition: ALSADebug.H:36
virtual int evaluateError(int errorNum)
Definition: ALSADebug.H:61
virtual int evaluateError(int errorNum, std::string append)
Definition: ALSADebug.H:70
#define ALSA_MIXER_QUERY_ERROR
error when attempting to query the mixer
Definition: ALSADebug.H:33
#define ALSA_PCM_NOT_OPEN_ERROR
error when pcm pointer is null
Definition: ALSADebug.H:25
#define ALSA_MIXER_NO_CAPTURE_VOL_ERROR
error this mixer element is not a playback element
Definition: ALSADebug.H:38
#define ALSA_MIXER_FIND_ELEMENT_ERROR
error when trying to find a mixer element
Definition: ALSADebug.H:34
#define ALSA_MIXER_NO_PLAYBACK_VOL_ERROR
error this mixer element is not a playback element
Definition: ALSADebug.H:37
#define MIN_ERROR_OFFSET
The highest debug error magnitude from gtkiostream.
Definition: Debug.H:98
#define ALSA_NO_CHANNELS_ERROR
error when channel cnt is zero
Definition: ALSADebug.H:29
#define ALSA_UNKNOWN_READ_ERROR
error when reading and an unknown code is retured
Definition: ALSADebug.H:26
#define ALSA_MIXER_WRONG_ELEMENT_ERROR
error when comparing two mixer elements.
Definition: ALSADebug.H:35
bool noChannelError(int val)
Definition: ALSADebug.H:78
#define ALSA_FULLDUPLEX_PROCESS_ERROR
error when processing the full duplex method.
Definition: ALSADebug.H:27
gtkIOStream: /tmp/gtkiostream/include/ALSA/ALSADebug.H Source File
GTK+ IOStream  Beta