xref: /illumos-gate/usr/src/cmd/audio/utilities/AudioError.cc (revision ddb365bfc9e868ad24ccdcb0dc91af18b10df082)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright (c) 1993-2001 by Sun Microsystems, Inc.
24  * All rights reserved.
25  */
26 
27 #include <string.h>
28 #include <AudioError.h>
29 
30 
31 // class Audio methods
32 
33 // Convert error code to string
34 char *AudioError::
35 msg()
36 {
37 	if (code == AUDIO_NOERROR)
38 		return (char *)("");
39 	if (code == AUDIO_UNIXERROR) {
40 		if (sys == 0) {
41 			sys = errno;
42 		}
43 		if (sys >= 0) {
44 			return (strerror(sys));
45 		} else {
46 			return (_MGET_("Unknown UNIX error"));
47 		}
48 	}
49 
50 	// XXX - these must jive with what's in audio_errno.h
51 	switch (code) {
52 	case 0:				/* AUDIO_SUCCESS = 0 */
53 		return (_MGET_("Audio operation successful"));
54 	case 1:				/* AUDIO_ERR_BADHDR = 1 */
55 		return (_MGET_("Invalid audio header"));
56 	case 2:				/* AUDIO_ERR_BADFILEHDR = 2 */
57 		return (_MGET_("Invalid audio file header"));
58 	case 3:				/* AUDIO_ERR_BADARG = 3 */
59 		return (_MGET_("Invalid argument or value"));
60 	case 4:				/* AUDIO_ERR_NOEFFECT = 4 */
61 		return (_MGET_("Audio operation not performed"));
62 	case 5:				/* AUDIO_ERR_ENCODING = 5 */
63 		return (_MGET_("Unknown audio encoding format"));
64 	case 6:				/* AUDIO_ERR_INTERRUPTED = 6 */
65 		return (_MGET_("Audio operation interrupted"));
66 	case 7:				/* AUDIO_EOF = 7 */
67 		return (_MGET_("Audio end-of-file"));
68 	case 8:				/* AUDIO_ERR_HDRINVAL = 8 */
69 		return (_MGET_("Unsupported audio data format"));
70 	case 9:				/* AUDIO_ERR_PRECISION = 9 */
71 		return (_MGET_("Unsupported audio data precision"));
72 	case 10:			/* AUDIO_ERR_NOTDEVICE = 10 */
73 		return (_MGET_("Not an audio device"));
74 	case 11:			/* AUDIO_ERR_DEVICEBUSY = 11 */
75 		return (_MGET_("Audio device is busy"));
76 	case 12:			/* AUDIO_ERR_BADFRAME = 12 */
77 		return (_MGET_("Partial sample frame"));
78 	case 13:			/* AUDIO_ERR_FORMATLOCK = 13 */
79 		return (_MGET_("Audio format cannot be changed"));
80 	case 14:			/* AUDIO_ERR_DEVOVERFLOW = 14 */
81 		return (_MGET_("Audio device overrun"));
82 	default:
83 		return (_MGET_("Unknown audio error"));
84 	}
85 }
86