xref: /aosp_15_r20/external/libxaac/encoder/ixheaace_error_handler.h (revision 15dc779a375ca8b5125643b829a8aa4b70d7f451)
1*15dc779aSAndroid Build Coastguard Worker /******************************************************************************
2*15dc779aSAndroid Build Coastguard Worker  *                                                                            *
3*15dc779aSAndroid Build Coastguard Worker  * Copyright (C) 2023 The Android Open Source Project
4*15dc779aSAndroid Build Coastguard Worker  *
5*15dc779aSAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
6*15dc779aSAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
7*15dc779aSAndroid Build Coastguard Worker  * You may obtain a copy of the License at:
8*15dc779aSAndroid Build Coastguard Worker  *
9*15dc779aSAndroid Build Coastguard Worker  * http://www.apache.org/licenses/LICENSE-2.0
10*15dc779aSAndroid Build Coastguard Worker  *
11*15dc779aSAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
12*15dc779aSAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
13*15dc779aSAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14*15dc779aSAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
15*15dc779aSAndroid Build Coastguard Worker  * limitations under the License.
16*15dc779aSAndroid Build Coastguard Worker  *
17*15dc779aSAndroid Build Coastguard Worker  *****************************************************************************
18*15dc779aSAndroid Build Coastguard Worker  * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
19*15dc779aSAndroid Build Coastguard Worker  */
20*15dc779aSAndroid Build Coastguard Worker 
21*15dc779aSAndroid Build Coastguard Worker #pragma once
22*15dc779aSAndroid Build Coastguard Worker #define IA_MAX_ERROR_SUB_CODE (70)
23*15dc779aSAndroid Build Coastguard Worker 
24*15dc779aSAndroid Build Coastguard Worker /* these definitions are used by error handling function         */
25*15dc779aSAndroid Build Coastguard Worker /* the error handler will work on a structure which identifies a */
26*15dc779aSAndroid Build Coastguard Worker /* particular error with a module, context and error_code        */
27*15dc779aSAndroid Build Coastguard Worker /* within error_code, MSB identifies FATAL (1), NONFATAL (0)     */
28*15dc779aSAndroid Build Coastguard Worker /* next 4 ms_bs identify a class of error                        */
29*15dc779aSAndroid Build Coastguard Worker 
30*15dc779aSAndroid Build Coastguard Worker typedef struct {
31*15dc779aSAndroid Build Coastguard Worker   pWORD8 pb_module_name;
32*15dc779aSAndroid Build Coastguard Worker   pWORD8 ppb_class_names[16];
33*15dc779aSAndroid Build Coastguard Worker   WORD8 **ppppb_error_msg_pointers[2][7][20];
34*15dc779aSAndroid Build Coastguard Worker } ia_error_info_struct;
35*15dc779aSAndroid Build Coastguard Worker 
36*15dc779aSAndroid Build Coastguard Worker /* this error handler maps the code generated by a module to a error string */
37*15dc779aSAndroid Build Coastguard Worker /* pb_context is a string to specify where the module broke                 */
38*15dc779aSAndroid Build Coastguard Worker IA_ERRORCODE ia_error_handler(ia_error_info_struct *p_mod_err_info, WORD8 *pb_context,
39*15dc779aSAndroid Build Coastguard Worker                               IA_ERRORCODE code);
40*15dc779aSAndroid Build Coastguard Worker 
41*15dc779aSAndroid Build Coastguard Worker /* the following macro does a line job of returning back to the parent */
42*15dc779aSAndroid Build Coastguard Worker /* in case a fatal error occurs after calling the errorhandler         */
43*15dc779aSAndroid Build Coastguard Worker #define _IA_HANDLE_ERROR(p_mod_err_info, context, e, pv_output) \
44*15dc779aSAndroid Build Coastguard Worker   if ((e) != IA_NO_ERROR) {                                     \
45*15dc779aSAndroid Build Coastguard Worker     ia_error_handler((p_mod_err_info), (context), (e));         \
46*15dc779aSAndroid Build Coastguard Worker     if ((e)&IA_FATAL_ERROR) {                                   \
47*15dc779aSAndroid Build Coastguard Worker       IA_ERRORCODE err = IA_NO_ERROR;                           \
48*15dc779aSAndroid Build Coastguard Worker       err = ixheaace_delete((pVOID)pv_output);                  \
49*15dc779aSAndroid Build Coastguard Worker       if (pstr_in_cfg->pv_drc_cfg) {                            \
50*15dc779aSAndroid Build Coastguard Worker         pv_output->free_xheaace(pstr_in_cfg->pv_drc_cfg);       \
51*15dc779aSAndroid Build Coastguard Worker       }                                                         \
52*15dc779aSAndroid Build Coastguard Worker       if (pstr_drc_cfg_user) {                                  \
53*15dc779aSAndroid Build Coastguard Worker         free_global(pstr_drc_cfg_user);                         \
54*15dc779aSAndroid Build Coastguard Worker         pstr_drc_cfg_user = NULL;                               \
55*15dc779aSAndroid Build Coastguard Worker       }                                                         \
56*15dc779aSAndroid Build Coastguard Worker       if (ia_stsz_size != NULL) {                               \
57*15dc779aSAndroid Build Coastguard Worker         pv_output->free_xheaace(ia_stsz_size);                  \
58*15dc779aSAndroid Build Coastguard Worker         ia_stsz_size = NULL;                                    \
59*15dc779aSAndroid Build Coastguard Worker       }                                                         \
60*15dc779aSAndroid Build Coastguard Worker       if ((err)&IA_FATAL_ERROR) {                               \
61*15dc779aSAndroid Build Coastguard Worker         return (err);                                           \
62*15dc779aSAndroid Build Coastguard Worker       } else {                                                  \
63*15dc779aSAndroid Build Coastguard Worker         return (e);                                             \
64*15dc779aSAndroid Build Coastguard Worker       }                                                         \
65*15dc779aSAndroid Build Coastguard Worker     }                                                           \
66*15dc779aSAndroid Build Coastguard Worker   }
67