source: roaraudio/libroarpulse/error.c @ 4960:60cdebcb83ef

Last change on this file since 4960:60cdebcb83ef was 4960:60cdebcb83ef, checked in by phi, 8 years ago

some updates for pulseaudio emulation, converted libroarpulse-simple fully to VS API

File size: 4.7 KB
Line 
1//error.c:
2
3/*
4 *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010-2011
5 *  The code (may) include prototypes and comments (and maybe
6 *  other code fragements) from libpulse*. They are mostly copyrighted by:
7 *  Lennart Poettering <poettering@users.sourceforge.net> and
8 *  Pierre Ossman <drzeus@drzeus.cx>
9 *
10 *  This file is part of libroarpulse a part of RoarAudio,
11 *  a cross-platform sound system for both, home and professional use.
12 *  See README for details.
13 *
14 *  This file is free software; you can redistribute it and/or modify
15 *  it under the terms of the GNU General Public License version 3
16 *  as published by the Free Software Foundation.
17 *
18 *  RoarAudio is distributed in the hope that it will be useful,
19 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
20 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21 *  GNU General Public License for more details.
22 *
23 *  You should have received a copy of the GNU General Public License
24 *  along with this software; see the file COPYING.  If not, write to
25 *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
26 *  Boston, MA 02110-1301, USA.
27 *
28 *  NOTE for everyone want's to change something and send patches:
29 *  read README and HACKING! There a addition information on
30 *  the license of this document you need to read before you send
31 *  any patches.
32 *
33 *  NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc
34 *  or libpulse*:
35 *  The libs libroaresd, libroararts and libroarpulse link this libroar
36 *  and are therefore GPL. Because of this it may be illigal to use
37 *  them with any software that uses libesd, libartsc or libpulse*.
38 */
39
40#include <libroarpulse/libroarpulse.h>
41
42
43static const struct {
44 int error;
45 int ra_error;
46 const char * name;
47} _roar_pa_errors[] = {
48 {PA_OK,                       ROAR_ERROR_NONE,   "OK"                             },
49 {PA_ERR_ACCESS,               ROAR_ERROR_PERM,   "Access denied"                  },
50 {PA_ERR_COMMAND,              ROAR_ERROR_BADRQC, "Unknown command"                },
51 {PA_ERR_INVALID,              ROAR_ERROR_INVAL,  "Invalid argument"               },
52 {PA_ERR_EXIST,                ROAR_ERROR_EXIST,  "Entity exists"                  },
53 {PA_ERR_NOENTITY,             ROAR_ERROR_NOENT,  "No such entity"                 },
54 {PA_ERR_CONNECTIONREFUSED,    ROAR_ERROR_CONNREFUSED, "Connection refused"             },
55 {PA_ERR_PROTOCOL,             ROAR_ERROR_PROTO,  "Protocol error"                 },
56 {PA_ERR_TIMEOUT,              ROAR_ERROR_TIMEDOUT, "Timeout"                        },
57 {PA_ERR_AUTHKEY,              ROAR_ERROR_PERM,   "No authorization key"           },
58 {PA_ERR_INTERNAL,             ROAR_ERROR_UNKNOWN, "Internal error"                 },
59 {PA_ERR_CONNECTIONTERMINATED, ROAR_ERROR_IO,     "Connection terminated"          },
60 {PA_ERR_KILLED,               ROAR_ERROR_IO,     "Entity killed"                  },
61 {PA_ERR_INVALIDSERVER,        ROAR_ERROR_INVAL,  "Invalid server"                 },
62 {PA_ERR_MODINITFAILED,        ROAR_ERROR_BADLIB, "Module initalization failed"    },
63 {PA_ERR_BADSTATE,             ROAR_ERROR_INVAL,  "Bad state"                      },
64 {PA_ERR_NODATA,               ROAR_ERROR_NODATA, "No data"                        },
65 {PA_ERR_VERSION,              ROAR_ERROR_NSVERSION, "Incompatible protocol version"  },
66 {PA_ERR_TOOLARGE,             ROAR_ERROR_RANGE,  "Too large"                      },
67#ifdef PA_ERR_NOTSUPPORTED
68 {PA_ERR_NOTSUPPORTED,         ROAR_ERROR_NOTSUP, "Not supported"},
69#endif
70#ifdef PA_ERR_UNKNOWN
71 {PA_ERR_UNKNOWN,              ROAR_ERROR_UNKNOWN, "Unknown error code"},
72#endif
73#ifdef PA_ERR_NOEXTENSION
74 {PA_ERR_UNKNOWN,              ROAR_ERROR_NOENT,  "No such extension"},
75#endif
76#ifdef PA_ERR_OBSOLETE
77 {PA_ERR_OBSOLETE,             ROAR_ERROR_NOSYS,  "Obsolete functionality"},
78#endif
79#ifdef PA_ERR_NOTIMPLEMENTED
80 {PA_ERR_NOTIMPLEMENTED,       ROAR_ERROR_NOSYS,  "Missing implementation"},
81#endif
82#ifdef PA_ERR_FORKED
83 {PA_ERR_FORKED,               ROAR_ERROR_INVAL,  "Client forked"},
84#endif
85#ifdef PA_ERR_IO
86 {PA_ERR_IO,                   ROAR_ERROR_IO,     "Input/Output error"},
87#endif
88#ifdef PA_ERR_BUSY
89 {PA_ERR_BUSY,                 ROAR_ERROR_BUSY,   "Device or resource busy"},
90#endif
91 {PA_ERR_MAX,                  ROAR_ERROR_UNKNOWN, "MAX"                            },
92 {-1, ROAR_ERROR_UNKNOWN, NULL}
93};
94
95const char * pa_strerror(int error) {
96 int i;
97
98 for (i = 0; _roar_pa_errors[i].name != NULL; i++)
99  if ( _roar_pa_errors[i].error == error )
100   return _roar_pa_errors[i].name;
101
102 return NULL;
103}
104
105int roar_pa_raerror2paerror(int error) {
106 int i;
107
108 for (i = 0; _roar_pa_errors[i].name != NULL; i++)
109  if ( _roar_pa_errors[i].ra_error == error )
110   return _roar_pa_errors[i].error;
111
112 return PA_ERR_INVALID;
113}
114
115//ll
Note: See TracBrowser for help on using the repository browser.