1 /* 2 * Copyright (C) 2010 The Android Open Source Project 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 // Trace debugging 18 19 // Always defined, but may be a no-op if trace support is disabled at compile-time 20 extern void slTraceSetEnabled(unsigned enabled); 21 22 #define SL_TRACE_ENTER 0x1 23 #define SL_TRACE_LEAVE_FAILURE 0x2 24 #define SL_TRACE_LEAVE_VOID 0x4 25 #define SL_TRACE_LEAVE_SUCCESS 0x8 26 #define SL_TRACE_LEAVE (SL_TRACE_LEAVE_FAILURE | SL_TRACE_LEAVE_VOID | \ 27 SL_TRACE_LEAVE_SUCCESS) 28 #define SL_TRACE_ALL (SL_TRACE_ENTER | SL_TRACE_LEAVE) 29 #ifndef SL_TRACE_DEFAULT 30 #define SL_TRACE_DEFAULT (SL_TRACE_LEAVE_FAILURE) 31 #endif 32 33 #ifndef USE_TRACE 34 35 #define SL_ENTER_GLOBAL SLresult result; 36 #define SL_LEAVE_GLOBAL return result; 37 #define SL_ENTER_INTERFACE SLresult result; 38 #define SL_LEAVE_INTERFACE return result; 39 #define SL_ENTER_INTERFACE_VOID 40 #define SL_LEAVE_INTERFACE_VOID return; 41 42 #define XA_ENTER_GLOBAL XAresult result; 43 #define XA_LEAVE_GLOBAL return result; 44 #define XA_ENTER_INTERFACE XAresult result; 45 #define XA_LEAVE_INTERFACE return result; 46 47 #else 48 49 extern void slTraceEnterGlobal(const char *function); 50 extern void slTraceLeaveGlobal(const char *function, SLresult result); 51 extern void slTraceEnterInterface(const char *function); 52 extern void slTraceLeaveInterface(const char *function, SLresult result); 53 extern void slTraceEnterInterfaceVoid(const char *function); 54 extern void slTraceLeaveInterfaceVoid(const char *function); 55 #define SL_ENTER_GLOBAL SLresult result; slTraceEnterGlobal(__FUNCTION__); 56 #define SL_LEAVE_GLOBAL slTraceLeaveGlobal(__FUNCTION__, result); return result; 57 #define SL_ENTER_INTERFACE SLresult result; slTraceEnterInterface(__FUNCTION__); 58 #define SL_LEAVE_INTERFACE slTraceLeaveInterface(__FUNCTION__, result); return result; 59 #define SL_ENTER_INTERFACE_VOID slTraceEnterInterfaceVoid(__FUNCTION__); 60 #define SL_LEAVE_INTERFACE_VOID slTraceLeaveInterfaceVoid(__FUNCTION__); return; 61 62 #define XA_ENTER_GLOBAL XAresult result; slTraceEnterGlobal(__FUNCTION__); 63 #define XA_LEAVE_GLOBAL slTraceLeaveGlobal(__FUNCTION__, result); return result; 64 #define XA_ENTER_INTERFACE XAresult result; slTraceEnterInterface(__FUNCTION__); 65 #define XA_LEAVE_INTERFACE slTraceLeaveInterface(__FUNCTION__, result); return result; 66 67 #endif 68