]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - glsdk/gstreamer0-10.git/blob - gst/gsttrace.h
gststructure: early out when we know a value cannot be a subset
[glsdk/gstreamer0-10.git] / gst / gsttrace.h
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 (deprecated)
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  */
24 #ifndef __GST_TRACE_H__
25 #define __GST_TRACE_H__
27 #include <glib.h>
29 G_BEGIN_DECLS
31 /**
32  * GstAllocTraceFlags:
33  * @GST_ALLOC_TRACE_NONE: No tracing specified or desired. Since 0.10.36.
34  * @GST_ALLOC_TRACE_LIVE: Trace number of non-freed memory.
35  * @GST_ALLOC_TRACE_MEM_LIVE: Trace pointers of unfreed memory.
36  *
37  * Flags indicating which tracing feature to enable.
38  */
39 typedef enum {
40   GST_ALLOC_TRACE_NONE      = 0,
41   GST_ALLOC_TRACE_LIVE      = (1 << 0),
42   GST_ALLOC_TRACE_MEM_LIVE      = (1 << 1)
43 } GstAllocTraceFlags;
45 typedef struct _GstAllocTrace   GstAllocTrace;
47 /**
48  * GstAllocTrace:
49  * @name: The name of the tracing object
50  * @flags: Flags for this object
51  * @live: counter for live memory
52  * @mem_live: list with pointers to unfreed memory
53  *
54  * The main tracing object
55  */
56 struct _GstAllocTrace {
57   gchar         *name;
58   gint           flags;
60   gint           live;
61   GSList        *mem_live;
62 };
64 #ifndef GST_DISABLE_TRACE
66 typedef struct _GstTrace        GstTrace;
67 typedef struct _GstTraceEntry   GstTraceEntry;
69 /**
70  * GstTrace:
71  *
72  * Opaque #GstTrace structure.
73  */
74 struct _GstTrace {
75   /*< private >*/
76   /* where this trace is going */
77   gchar *filename;
78   int fd;
80   /* current buffer, size, head offset */
81   GstTraceEntry *buf;
82   gint bufsize;
83   gint bufoffset;
84 };
86 struct _GstTraceEntry {
87   gint64 timestamp;
88   guint32 sequence;
89   guint32 data;
90   gchar message[112];
91 };
93 GstTrace*       gst_trace_new                   (const gchar *filename, gint size);
95 void            gst_trace_destroy               (GstTrace *trace);
96 void            gst_trace_flush                 (GstTrace *trace);
97 void            gst_trace_text_flush            (GstTrace *trace);
98 /**
99  * gst_trace_get_size:
100  * @trace: a #GstTrace
101  *
102  * Retrieve the buffer size of @trace.
103  */
104 #define         gst_trace_get_size(trace)       ((trace)->bufsize)
105 /**
106  * gst_trace_get_offset:
107  * @trace: a #GstTrace
108  *
109  * Retrieve the current buffer offset of @trace.
110  */
111 #define         gst_trace_get_offset(trace)     ((trace)->bufoffset)
112 /**
113  * gst_trace_get_remaining:
114  * @trace: a #GstTrace
115  *
116  * Retrieve the remaining size in the @trace buffer.
117  */
118 #define         gst_trace_get_remaining(trace)  ((trace)->bufsize - (trace)->bufoffset)
119 void            gst_trace_set_default           (GstTrace *trace);
121 void            _gst_trace_add_entry            (GstTrace *trace, guint32 seq,
122                                                  guint32 data, gchar *msg);
124 void            gst_trace_read_tsc              (gint64 *dst);
127 extern GStaticMutex     _gst_trace_mutex;
129 gboolean                gst_alloc_trace_available       (void);
130 const GList*            gst_alloc_trace_list            (void);
131 GstAllocTrace*          _gst_alloc_trace_register       (const gchar *name);
133 int                     gst_alloc_trace_live_all        (void);
134 void                    gst_alloc_trace_print_all       (void);
135 void                    gst_alloc_trace_print_live      (void);
136 void                    gst_alloc_trace_set_flags_all   (GstAllocTraceFlags flags);
138 GstAllocTrace*          gst_alloc_trace_get             (const gchar *name);
139 void                    gst_alloc_trace_print           (const GstAllocTrace *trace);
140 void                    gst_alloc_trace_set_flags       (GstAllocTrace *trace, GstAllocTraceFlags flags);
143 #ifndef GST_DISABLE_ALLOC_TRACE
144 /**
145  * gst_alloc_trace_register:
146  * @name: The name of the tracer object
147  *
148  * Register a new alloc tracer with the given name
149  */
150 #define gst_alloc_trace_register(name) _gst_alloc_trace_register (name);
152 /**
153  * gst_alloc_trace_new:
154  * @trace: The tracer to use
155  * @mem: The memory allocated
156  *
157  * Use the tracer to trace a new memory allocation
158  */
159 #define gst_alloc_trace_new(trace, mem)                 \
160 G_STMT_START {                                          \
161   if (G_UNLIKELY ((trace)->flags)) {                    \
162     g_static_mutex_lock (&_gst_trace_mutex);            \
163     if ((trace)->flags & GST_ALLOC_TRACE_LIVE)          \
164       (trace)->live++;                                  \
165     if ((trace)->flags & GST_ALLOC_TRACE_MEM_LIVE)      \
166       (trace)->mem_live =                               \
167         g_slist_prepend ((trace)->mem_live, mem);       \
168     g_static_mutex_unlock (&_gst_trace_mutex);          \
169   }                                                     \
170 } G_STMT_END
172 /**
173  * gst_alloc_trace_free:
174  * @trace: The tracer to use
175  * @mem: The memory that is freed
176  *
177  * Trace a memory free operation
178  */
179 #define gst_alloc_trace_free(trace, mem)                \
180 G_STMT_START {                                          \
181   if (G_UNLIKELY ((trace)->flags)) {                    \
182     g_static_mutex_lock (&_gst_trace_mutex);            \
183     if ((trace)->flags & GST_ALLOC_TRACE_LIVE)          \
184       (trace)->live--;                                  \
185     if ((trace)->flags & GST_ALLOC_TRACE_MEM_LIVE)      \
186       (trace)->mem_live =                               \
187         g_slist_remove ((trace)->mem_live, mem);        \
188     g_static_mutex_unlock (&_gst_trace_mutex);          \
189   }                                                     \
190 } G_STMT_END
192 #else
193 #define gst_alloc_trace_register(name) (NULL)
194 #define gst_alloc_trace_new(trace, mem)
195 #define gst_alloc_trace_free(trace, mem)
196 #endif
199 extern gint _gst_trace_on;
200 /**
201  * gst_trace_add_entry:
202  * @trace: a #GstTrace
203  * @seq: a sequence number
204  * @data: the data to trace
205  * @msg: the trace message
206  *
207  * Add an entry to @trace with sequence number @seq, @data and @msg.
208  * If @trace is NULL, the entry will be added to the default #GstTrace.
209  */
210 #define gst_trace_add_entry(trace,seq,data,msg) \
211   if (_gst_trace_on) { \
212     _gst_trace_add_entry(trace,(guint32)seq,(guint32)data,msg); \
213   }
215 #else /* GST_DISABLE_TRACE */
217 #if defined __GNUC__ && __GNUC__ >= 3
218 #pragma GCC poison      gst_trace_new
219 #pragma GCC poison      gst_trace_destroy
220 #pragma GCC poison      gst_trace_flush
221 #pragma GCC poison      gst_trace_text_flush
222 #pragma GCC poison      gst_trace_get_size
223 #pragma GCC poison      gst_trace_get_offset
224 #pragma GCC poison      gst_trace_get_remaining
225 #pragma GCC poison      gst_trace_set_default
226 #pragma GCC poison      _gst_trace_add_entry
227 #pragma GCC poison      gst_trace_read_tsc
228 #endif
230 #define         gst_alloc_trace_register(name)  (NULL)
231 #define         gst_alloc_trace_new(trace, mem)
232 #define         gst_alloc_trace_free(trace, mem)
234 #define         gst_alloc_trace_available()     (FALSE)
235 #define         gst_alloc_trace_list()          (NULL)
236 #define         _gst_alloc_trace_register(name) (NULL)
238 #define         gst_alloc_trace_live_all()      (0)
239 #define         gst_alloc_trace_print_all()
240 #define         gst_alloc_trace_print_live()
241 #define         gst_alloc_trace_set_flags_all(flags)
243 #define         gst_alloc_trace_get(name)       (NULL)
244 #define         gst_alloc_trace_print(trace)
245 #define         gst_alloc_trace_set_flags(trace,flags)
247 #define         gst_trace_add_entry(trace,seq,data,msg)
249 #endif /* GST_DISABLE_TRACE */
251 G_END_DECLS
253 #endif /* __GST_TRACE_H__ */