1 | /* GStreamer |
---|
2 | * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu> |
---|
3 | * 2000 Wim Taymans <wtay@chello.be> |
---|
4 | * |
---|
5 | * gsttrace.h: Header for tracing functions (depracated) |
---|
6 | * |
---|
7 | * This library is free software; you can redistribute it and/or |
---|
8 | * modify it under the terms of the GNU Library General Public |
---|
9 | * License as published by the Free Software Foundation; either |
---|
10 | * version 2 of the License, or (at your option) any later version. |
---|
11 | * |
---|
12 | * This library is distributed in the hope that it will be useful, |
---|
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
15 | * Library General Public License for more details. |
---|
16 | * |
---|
17 | * You should have received a copy of the GNU Library General Public |
---|
18 | * License along with this library; if not, write to the |
---|
19 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
---|
20 | * Boston, MA 02111-1307, USA. |
---|
21 | */ |
---|
22 | |
---|
23 | |
---|
24 | #ifndef __GST_TRACE_H__ |
---|
25 | #define __GST_TRACE_H__ |
---|
26 | |
---|
27 | #include <glib.h> |
---|
28 | |
---|
29 | G_BEGIN_DECLS |
---|
30 | |
---|
31 | #ifndef GST_DISABLE_TRACE |
---|
32 | |
---|
33 | typedef struct _GstTrace GstTrace; |
---|
34 | typedef struct _GstTraceEntry GstTraceEntry; |
---|
35 | |
---|
36 | struct _GstTrace { |
---|
37 | /* where this trace is going */ |
---|
38 | gchar *filename; |
---|
39 | int fd; |
---|
40 | |
---|
41 | /* current buffer, size, head offset */ |
---|
42 | GstTraceEntry *buf; |
---|
43 | gint bufsize; |
---|
44 | gint bufoffset; |
---|
45 | }; |
---|
46 | |
---|
47 | struct _GstTraceEntry { |
---|
48 | gint64 timestamp; |
---|
49 | guint32 sequence; |
---|
50 | guint32 data; |
---|
51 | gchar message[112]; |
---|
52 | }; |
---|
53 | |
---|
54 | |
---|
55 | |
---|
56 | GstTrace* gst_trace_new (gchar *filename, gint size); |
---|
57 | |
---|
58 | void gst_trace_destroy (GstTrace *trace); |
---|
59 | void gst_trace_flush (GstTrace *trace); |
---|
60 | void gst_trace_text_flush (GstTrace *trace); |
---|
61 | #define gst_trace_get_size(trace) ((trace)->bufsize) |
---|
62 | #define gst_trace_get_offset(trace) ((trace)->bufoffset) |
---|
63 | #define gst_trace_get_remaining(trace) ((trace)->bufsize - (trace)->bufoffset) |
---|
64 | void gst_trace_set_default (GstTrace *trace); |
---|
65 | |
---|
66 | void _gst_trace_add_entry (GstTrace *trace, guint32 seq, |
---|
67 | guint32 data, gchar *msg); |
---|
68 | |
---|
69 | void gst_trace_read_tsc (gint64 *dst); |
---|
70 | |
---|
71 | |
---|
72 | typedef enum |
---|
73 | { |
---|
74 | GST_ALLOC_TRACE_LIVE = (1 << 0), |
---|
75 | GST_ALLOC_TRACE_MEM_LIVE = (1 << 1) |
---|
76 | } GstAllocTraceFlags; |
---|
77 | |
---|
78 | typedef struct _GstAllocTrace GstAllocTrace; |
---|
79 | |
---|
80 | struct _GstAllocTrace { |
---|
81 | gchar *name; |
---|
82 | gint flags; |
---|
83 | |
---|
84 | gint live; |
---|
85 | GSList *mem_live; |
---|
86 | }; |
---|
87 | |
---|
88 | gboolean gst_alloc_trace_available (void); |
---|
89 | G_CONST_RETURN GList* gst_alloc_trace_list (void); |
---|
90 | GstAllocTrace* _gst_alloc_trace_register (const gchar *name); |
---|
91 | |
---|
92 | int gst_alloc_trace_live_all (void); |
---|
93 | void gst_alloc_trace_print_all (void); |
---|
94 | void gst_alloc_trace_set_flags_all (GstAllocTraceFlags flags); |
---|
95 | |
---|
96 | GstAllocTrace* gst_alloc_trace_get (const gchar *name); |
---|
97 | void gst_alloc_trace_print (const GstAllocTrace *trace); |
---|
98 | void gst_alloc_trace_set_flags (GstAllocTrace *trace, GstAllocTraceFlags flags); |
---|
99 | |
---|
100 | |
---|
101 | #ifndef GST_DISABLE_ALLOC_TRACE |
---|
102 | #define gst_alloc_trace_register(name) _gst_alloc_trace_register (name); |
---|
103 | #define gst_alloc_trace_new(trace, mem) \ |
---|
104 | G_STMT_START { \ |
---|
105 | if ((trace)->flags & GST_ALLOC_TRACE_LIVE) \ |
---|
106 | (trace)->live++; \ |
---|
107 | if ((trace)->flags & GST_ALLOC_TRACE_MEM_LIVE) \ |
---|
108 | (trace)->mem_live = \ |
---|
109 | g_slist_prepend ((trace)->mem_live, mem); \ |
---|
110 | } G_STMT_END |
---|
111 | |
---|
112 | #define gst_alloc_trace_free(trace, mem) \ |
---|
113 | G_STMT_START { \ |
---|
114 | if ((trace)->flags & GST_ALLOC_TRACE_LIVE) \ |
---|
115 | (trace)->live--; \ |
---|
116 | if ((trace)->flags & GST_ALLOC_TRACE_MEM_LIVE) \ |
---|
117 | (trace)->mem_live = \ |
---|
118 | g_slist_remove ((trace)->mem_live, mem); \ |
---|
119 | } G_STMT_END |
---|
120 | |
---|
121 | #else |
---|
122 | #define gst_alloc_trace_register(name) (NULL) |
---|
123 | #define gst_alloc_trace_new(trace, mem) |
---|
124 | #define gst_alloc_trace_free(trace, mem) |
---|
125 | #endif |
---|
126 | |
---|
127 | |
---|
128 | extern gint _gst_trace_on; |
---|
129 | #define gst_trace_add_entry(trace,seq,data,msg) \ |
---|
130 | if (_gst_trace_on) { \ |
---|
131 | _gst_trace_add_entry(trace,(guint32)seq,(guint32)data,msg); \ |
---|
132 | } |
---|
133 | |
---|
134 | #else /* GST_DISABLE_TRACE */ |
---|
135 | |
---|
136 | #if defined _GNUC_ && _GNUC_ >= 3 |
---|
137 | #pragma GCC poison gst_trace_new |
---|
138 | #pragma GCC poison gst_trace_destroy |
---|
139 | #pragma GCC poison gst_trace_flush |
---|
140 | #pragma GCC poison gst_trace_text_flush |
---|
141 | #pragma GCC poison gst_trace_get_size |
---|
142 | #pragma GCC poison gst_trace_get_offset |
---|
143 | #pragma GCC poison gst_trace_get_remaining |
---|
144 | #pragma GCC poison gst_trace_set_default |
---|
145 | #pragma GCC poison _gst_trace_add_entry |
---|
146 | #pragma GCC poison gst_trace_read_tsc |
---|
147 | #pragma GCC poison gst_trace_add_entry |
---|
148 | #endif |
---|
149 | |
---|
150 | #define gst_alloc_trace_register(name) |
---|
151 | #define gst_alloc_trace_new(trace, mem) |
---|
152 | #define gst_alloc_trace_free(trace, mem) |
---|
153 | |
---|
154 | #define gst_alloc_trace_available() (FALSE) |
---|
155 | #define gst_alloc_trace_list() (NULL) |
---|
156 | #define _gst_alloc_trace_register(name) (NULL) |
---|
157 | |
---|
158 | #define gst_alloc_trace_print_all() |
---|
159 | #define gst_alloc_trace_set_flags_all(flags) |
---|
160 | |
---|
161 | #define gst_alloc_trace_get(name) (NULL) |
---|
162 | #define gst_alloc_trace_print(trace) |
---|
163 | #define gst_alloc_trace_set_flags(trace,flags) |
---|
164 | |
---|
165 | #define gst_trace_add_entry(trace,seq,data,msg) |
---|
166 | |
---|
167 | #endif /* GST_DISABLE_TRACE */ |
---|
168 | |
---|
169 | G_END_DECLS |
---|
170 | |
---|
171 | #endif /* __GST_TRACE_H__ */ |
---|