• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 /**
17  * @addtogroup MultiMedia_AudioCommon
18  * @{
19  *
20  * @brief Provides data types and audio formats required for recording and playing and recording audio.
21  *
22  *
23  * @since 1.0
24  * @version 1.0
25  */
26 
27 /**
28  * @file audio_errors.h
29  *
30  * @brief Declares the <b>audio_errors</b> class to define errors that may occur during audio operations.
31  *
32  *
33  * @since 1.0
34  * @version 1.0
35  */
36 
37 #ifndef AUDIO_ERRORS_H
38 #define AUDIO_ERRORS_H
39 
40 #include <cstdint>
41 
42 namespace OHOS {
43 namespace AudioStandard {
44 constexpr int MODULE_AUDIO = 1;
45 constexpr int SUBSYS_AUDIO = 30;
46 
47 using ErrCode = int32_t;
48 constexpr int SUBSYSTEM_BIT_NUM = 21;
49 constexpr int MODULE_BIT_NUM = 16;
50 
51 constexpr ErrCode ErrCodeOffset(unsigned int subsystem, unsigned int module = 0)
52 {
53     return (subsystem << SUBSYSTEM_BIT_NUM) | (module << MODULE_BIT_NUM);
54 }
55 
56 constexpr int32_t BASE_AUDIO_ERR_OFFSET = -ErrCodeOffset(SUBSYS_AUDIO, MODULE_AUDIO);
57 
58 /** Success */
59 const int32_t  SUCCESS = 0;
60 
61 /** Fail */
62 const int32_t  ERROR = BASE_AUDIO_ERR_OFFSET;
63 
64 /** Status error */
65 const int32_t  ERR_ILLEGAL_STATE = BASE_AUDIO_ERR_OFFSET - 1;
66 
67 /** Invalid parameter */
68 const int32_t  ERR_INVALID_PARAM = BASE_AUDIO_ERR_OFFSET - 2;
69 
70 /** Early media preparation */
71 const int32_t  ERR_EARLY_PREPARE = BASE_AUDIO_ERR_OFFSET - 3;
72 
73 /** Invalid operation */
74 const int32_t  ERR_INVALID_OPERATION = BASE_AUDIO_ERR_OFFSET - 4;
75 
76 /** error operation failed */
77 const int32_t  ERR_OPERATION_FAILED = BASE_AUDIO_ERR_OFFSET - 5;
78 
79 /** Buffer reading failed */
80 const int32_t  ERR_READ_BUFFER = BASE_AUDIO_ERR_OFFSET - 6;
81 
82 /** Buffer writing failed */
83 const int32_t  ERR_WRITE_BUFFER = BASE_AUDIO_ERR_OFFSET - 7;
84 
85 /**  Device not started */
86 const int32_t  ERR_NOT_STARTED = BASE_AUDIO_ERR_OFFSET - 8;
87 
88 /**  Invalid Device handle */
89 const int32_t  ERR_INVALID_HANDLE = BASE_AUDIO_ERR_OFFSET - 9;
90 
91 /**  unsupported operation */
92 const int32_t  ERR_NOT_SUPPORTED = BASE_AUDIO_ERR_OFFSET - 10;
93 
94 /**  unsupported device */
95 const int32_t  ERR_DEVICE_NOT_SUPPORTED = BASE_AUDIO_ERR_OFFSET - 11;
96 
97 /**  write operation failed */
98 const int32_t  ERR_WRITE_FAILED = BASE_AUDIO_ERR_OFFSET - 12;
99 
100 /**  read operation failed */
101 const int32_t  ERR_READ_FAILED = BASE_AUDIO_ERR_OFFSET - 13;
102 
103 /**  device init failed */
104 const int32_t  ERR_DEVICE_INIT = BASE_AUDIO_ERR_OFFSET - 14;
105 
106 /** Invalid data size that has been read */
107 const int32_t  ERR_INVALID_READ = BASE_AUDIO_ERR_OFFSET - 15;
108 
109 /** Invalid data size that has been written */
110 const int32_t  ERR_INVALID_WRITE = BASE_AUDIO_ERR_OFFSET - 16;
111 
112 /** set invalid index < 0 */
113 const int32_t  ERR_INVALID_INDEX = BASE_AUDIO_ERR_OFFSET - 17;
114 
115 /** focus request denied */
116 const int32_t  ERR_FOCUS_DENIED = BASE_AUDIO_ERR_OFFSET - 18;
117 
118 /** incorrect render/capture mode */
119 const int32_t  ERR_INCORRECT_MODE = BASE_AUDIO_ERR_OFFSET - 19;
120 
121 /** Unknown error */
122 const int32_t  ERR_UNKNOWN = BASE_AUDIO_ERR_OFFSET - 200;
123 }  // namespace AudioStandard
124 }  // namespace OHOS
125 #endif  // AUDIO_ERRORS_H
126