Remove 3.0 deprecated API implementation
[platform/core/api/audio-io.git] / include / CAudioIODef.h
1 /*
2  * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef __TIZEN_MEDIA_AUDIO_IO_CAUDIO_DEF_H__
18 #define __TIZEN_MEDIA_AUDIO_IO_CAUDIO_DEF_H__
19
20
21 #ifdef __cplusplus
22
23
24 #include <stdio.h>
25 #include <dlog.h>
26
27 #include "CAudioError.h"
28 #include "CAudioInfo.h"
29 #include "IPulseStreamListener.h"
30 #include "CPulseStreamSpec.h"
31 #include "CPulseAudioClient.h"
32 #include "CAudioIO.h"
33 #include "CAudioInput.h"
34 #include "CAudioOutput.h"
35
36 //#define _AUDIO_IO_DEBUG_TIMING_
37
38 #ifdef LOG_TAG
39 #undef LOG_TAG
40 #endif
41 #define LOG_TAG "TIZEN_N_AUDIO_IO"
42
43 #define AUDIO_IO_LOGD(_fmt_, arg...) do { \
44         LOGI(_fmt_, ##arg);      \
45 } while (0)
46
47 #define AUDIO_IO_LOGW(_fmt_, arg...) do { \
48         LOGW(_fmt_, ##arg);      \
49 } while (0)
50
51 #define AUDIO_IO_LOGE(_fmt_, arg...) do { \
52         LOGE(_fmt_, ##arg);      \
53 } while (0)
54
55 #define _AUDIO_IO_SHELL_COLOR_
56 #ifdef _AUDIO_IO_SHELL_COLOR_
57 #define COLOR_BLACK     "\033[0;30m"
58 #define COLOR_RED       "\033[0;31m"
59 #define COLOR_GREEN     "\033[0;32m"
60 #define COLOR_YELLOW    "\033[0;33m"
61 #define COLOR_BLUE      "\033[0;34m"
62 #define COLOR_MAGENTA   "\033[0;35m"
63 #define COLOR_CYAN      "\033[0;36m"
64 #define COLOR_GRAY      "\033[0;37m"
65 #define COLOR_WHITE     "\033[1;37m"
66 #define COLOR_END       "\033[0m"
67 #else
68 #define COLOR_BLACK
69 #define COLOR_RED
70 #define COLOR_GREEN
71 #define COLOR_BLUE
72 #define COLOR_YELLOW
73 #define COLOR_MAGENTA
74 #define COLOR_CYAN
75 #define COLOR_WHITE
76 #define COLOR_END
77 #endif
78
79
80 #define RET_ERROR(_x_)              do {return CAudioError((_x_), __FILE__, __func__, __LINE__);} while(0)
81 #define RET_ERROR_MSG(_x_, _msg_)   do {return CAudioError((_x_), (_msg_), __FILE__, __func__, __LINE__);} while(0)
82
83 #define RET_ERROR_MSG_FORMAT(_x_, _format_, ...) do {                     \
84     char _msg_[CAudioError::MSG_LENGTH] = {0, };                       \
85     snprintf(_msg_, CAudioError::MSG_LENGTH, _format_, ##__VA_ARGS__); \
86     return CAudioError((_x_), (_msg_), __FILE__, __func__, __LINE__);  \
87 } while (0)
88
89
90 #define THROW_ERROR(_x_)            do {throw  CAudioError((_x_), __FILE__, __func__, __LINE__);} while (0)
91 #define THROW_ERROR_MSG(_x_, _msg_) do {throw  CAudioError((_x_), (_msg_), __FILE__, __func__, __LINE__);} while (0)
92
93 #define THROW_ERROR_MSG_FORMAT(_x_, _format_, ...) do {                   \
94     char _msg_[CAudioError::MSG_LENGTH] = {0, };                       \
95     snprintf(_msg_, CAudioError::MSG_LENGTH, _format_, ##__VA_ARGS__); \
96     throw CAudioError((_x_), (_msg_), __FILE__,  __func__, __LINE__);  \
97 } while (0)
98
99 #define VALID_POINTER_START(_x_) { \
100     if ((_x_) != NULL) {
101 #define VALID_POINTER_END } \
102 }
103
104 #define SAFE_DELETE(_x_)   do {if ((_x_)) {delete (_x_); (_x_) = NULL;}} while (0)
105 #define SAFE_FINALIZE(_x_) do {if ((_x_)) {(_x_)->finalize();}} while (0)
106 #define SAFE_REMOVE(_x_)   do {if ((_x_)) {(_x_)->finalize(); delete (_x_); (_x_) = NULL;}} while (0)
107
108 #define DEFAULT_PERIOD_SIZE 50
109
110 #endif
111 #endif /* __TIZEN_MEDIA_AUDIO_IO_CAUDIO_DEF_H__ */