Arduino AudioKit HAL
audio_error.h
1 /*
2  * ESPRESSIF MIT License
3  *
4  * Copyright (c) 2018 <ESPRESSIF SYSTEMS (SHANGHAI) PTE LTD>
5  *
6  * Permission is hereby granted for use on all ESPRESSIF SYSTEMS products, in which case,
7  * it is free of charge, to any person obtaining a copy of this software and associated
8  * documentation files (the "Software"), to deal in the Software without restriction, including
9  * without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  * and/or sell copies of the Software, and to permit persons to whom the Software is furnished
11  * to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in all copies or
14  * substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22  *
23  */
24 
25 
26 #ifndef _AUDIO_ERROR_H_
27 #define _AUDIO_ERROR_H_
28 
29 #ifdef ESP32
30 #include "esp_err.h"
31 #else
32 typedef int esp_err_t;
33 
34 /* Definitions for error constants. */
35 #define ESP_OK 0 /*!< esp_err_t value indicating success (no error) */
36 #define ESP_FAIL -1 /*!< Generic esp_err_t code indicating failure */
37 #define ESP_ERR_INVALID_ARG 1
38 #endif
39 
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43 
44 
45 #ifndef __FILENAME__
46 #define __FILENAME__ __FILE__
47 #endif
48 
49 #define ESP_ERR_ADF_BASE 0x80000 /*!< Starting number of ESP-ADF error codes */
50 
51 /*
52  * ESP-ADF error code field start from 0x80000, end of the -1.
53  * The whole area is divided into series independent modules.
54  * The range of each module is 0x1000.
55  * //////////////////////////////////////////////////////////
56  * ESP-Audio module starting on 0x81000;
57  *
58  */
59 
60 
61 #define ESP_ERR_ADF_NO_ERROR ESP_OK
62 #define ESP_ERR_ADF_NO_FAIL ESP_FAIL
63 
64 #define ESP_ERR_ADF_UNKNOWN ESP_ERR_ADF_BASE + 0
65 #define ESP_ERR_ADF_ALREADY_EXISTS ESP_ERR_ADF_BASE + 1
66 #define ESP_ERR_ADF_MEMORY_LACK ESP_ERR_ADF_BASE + 2
67 #define ESP_ERR_ADF_INVALID_URI ESP_ERR_ADF_BASE + 3
68 #define ESP_ERR_ADF_INVALID_PATH ESP_ERR_ADF_BASE + 4
69 #define ESP_ERR_ADF_INVALID_PARAMETER ESP_ERR_ADF_BASE + 5
70 #define ESP_ERR_ADF_NOT_READY ESP_ERR_ADF_BASE + 6
71 #define ESP_ERR_ADF_NOT_SUPPORT ESP_ERR_ADF_BASE + 7
72 #define ESP_ERR_ADF_NOT_FOUND ESP_ERR_ADF_BASE + 8
73 #define ESP_ERR_ADF_TIMEOUT ESP_ERR_ADF_BASE + 9
74 #define ESP_ERR_ADF_INITIALIZED ESP_ERR_ADF_BASE + 10
75 #define ESP_ERR_ADF_UNINITIALIZED ESP_ERR_ADF_BASE + 11
76 
77 
78 
79 #define AUDIO_CHECK(TAG, a, action, msg) if (!(a)) { \
80  KIT_LOGE("%s:%d (%s): %s", __FILENAME__, __LINE__, __FUNCTION__, msg); \
81  action; \
82  }
83 
84 #define AUDIO_MEM_CHECK(TAG, a, action) AUDIO_CHECK(TAG, a, action, "Memory exhausted")
85 
86 #define AUDIO_NULL_CHECK(TAG, a, action) AUDIO_CHECK(TAG, a, action, "Got NULL Pointer")
87 
88 #define AUDIO_ERROR(TAG, str) KIT_LOGE("%s:%d (%s): %s", __FILENAME__, __LINE__, __FUNCTION__, str)
89 
90 #define ESP_EXISTS (ESP_OK + 1)
91 
92 #ifdef __cplusplus
93 }
94 #endif
95 
96 #endif