root/trunk/freebobstreaming/freebob_debug.h

Revision 150, 4.2 kB (checked in by pieterpalmers, 18 years ago)

- implement ALSA SEQ midi support

- fixed some small midi-related things

- changed the debug printing to the jackd messagebuffer based approach

- some small modification to the counters

- modified the packet handling on order to support lower buffer sizes and a lower number of buffers.
- it is possible to compile non-poll based support too

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 /*
2  *   FreeBob Streaming API
3  *   FreeBob = Firewire (pro-)audio for linux
4  *
5  *   http://freebob.sf.net
6  *
7  *   Copyright (C) 2005 Pieter Palmers <pieterpalmers@users.sourceforge.net>
8  *
9  *   This program is free software; you can redistribute it and/or modify
10  *   it under the terms of the GNU General Public License as published by
11  *   the Free Software Foundation; either version 2 of the License, or
12  *   (at your option) any later version.
13  *
14  *   This program is distributed in the hope that it will be useful,
15  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
16  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  *   GNU General Public License for more details.
18  *
19  *   You should have received a copy of the GNU General Public License
20  *   along with this program; if not, write to the Free Software
21  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22  */
23
24 /*
25  * Debug and statistics helper
26  *
27  */
28
29 #ifndef __FREEBOB_DEBUG_H__
30 #define __FREEBOB_DEBUG_H__
31
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35
36 #include "freebob_streaming.h"
37
38 #include <libgen.h>
39 #include <netinet/in.h>
40 #include <sys/time.h>
41 #include "messagebuffer.h"
42
43 unsigned long getCurrentUTime();
44
45 static unsigned long debugGetCurrentUTime() {
46         struct timeval now;
47         gettimeofday(&now, NULL);
48         return now.tv_sec*1000000+now.tv_usec;
49 }
50
51 // debug print control flags
52 #define DEBUG_LEVEL_BUFFERS             (1<<0)
53 #define DEBUG_LEVEL_HANDLERS                    (1<<1)
54 #define DEBUG_LEVEL_HANDLERS_LOWLEVEL   (1<<2)
55 #define DEBUG_LEVEL_XRUN_RECOVERY       (1<<4)
56 #define DEBUG_LEVEL_WAIT                        (1<<5)
57
58 #define DEBUG_LEVEL_RUN_CYCLE           (1<<8)
59
60 #define DEBUG_LEVEL_PACKETCOUNTER               (1<<16)
61 #define DEBUG_LEVEL_STARTUP                             (1<<17)
62 #define DEBUG_LEVEL_THREADS                             (1<<18)
63 #define DEBUG_LEVEL_STREAMS                             (1<<19)
64
65 #define DEBUG
66 #ifdef DEBUG
67 //#if 0
68         #define printMessage(format, args...) freebob_messagebuffer_add( "FREEBOB MSG: %s:%d (%s): " format, basename(__FILE__), __LINE__, __FUNCTION__, ##args )
69         #define printError(format, args...) freebob_messagebuffer_add( "FREEBOB ERR: %s:%d (%s): " format,  basename(__FILE__), __LINE__, __FUNCTION__, ##args )
70        
71 //      #define printEnter() freebob_messagebuffer_add( "FREEBOB ENTERS: %s (%s)\n", __FUNCTION__,  __FILE__)
72 //      #define printExit() freebob_messagebuffer_add( "FREEBOB EXITS: %s (%s)\n", __FUNCTION__,  __FILE__)
73         #define printEnter()
74         #define printExit()
75        
76         #define debugError(format, args...) freebob_messagebuffer_add( stderr, "FREEBOB ERR: %s:%d (%s): " format,  basename(__FILE__), __LINE__, __FUNCTION__, ##args )
77         #define debugPrint(Level, format, args...) if(DEBUG_LEVEL & (Level))  freebob_messagebuffer_add("DEBUG %s:%d (%s): "  format, basename(__FILE__), __LINE__, __FUNCTION__, ##args );
78        
79         #define debugPrintShort(Level, format, args...) if(DEBUG_LEVEL & (Level))  freebob_messagebuffer_add( format,##args );
80         #define debugPrintWithTimeStamp(Level, format, args...) if(DEBUG_LEVEL & (Level)) freebob_messagebuffer_add( "%16lu: "format, debugGetCurrentUTime(),##args );
81         #define SEGFAULT int *test=NULL;        *test=1;
82
83         // default debug level
84         // #define DEBUG_LEVEL 0
85         // #define DEBUG_LEVEL (DEBUG_LEVEL_BUFFERS | DEBUG_LEVEL_RUN_CYCLE | (DEBUG_LEVEL_XRUN_RECOVERY)| DEBUG_LEVEL_STARTUP | DEBUG_LEVEL_WAIT | DEBUG_LEVEL_PACKETCOUNTER)
86         //#define DEBUG_LEVEL (DEBUG_LEVEL_BUFFERS | DEBUG_LEVEL_RUN_CYCLE | (DEBUG_LEVEL_XRUN_RECOVERY)| DEBUG_LEVEL_STARTUP )
87         //#define DEBUG_LEVEL (DEBUG_LEVEL_RUN_CYCLE | (DEBUG_LEVEL_XRUN_RECOVERY)| DEBUG_LEVEL_STARTUP | DEBUG_LEVEL_PACKETCOUNTER| DEBUG_LEVEL_WAIT)
88         #define DEBUG_LEVEL (  DEBUG_LEVEL_RUN_CYCLE | DEBUG_LEVEL_XRUN_RECOVERY | \
89                                            DEBUG_LEVEL_STARTUP | DEBUG_LEVEL_PACKETCOUNTER)
90
91         //#define DEBUG_LEVEL (DEBUG_LEVEL_XRUN_RECOVERY | DEBUG_LEVEL_STARTUP | DEBUG_LEVEL_PACKETCOUNTER)
92
93
94 #else
95         #define DEBUG_LEVEL
96        
97         #define printMessage(format, args...) freebob_messagebuffer_add( "FREEBOB MSG: " format, ##args )
98         #define printError(format, args...)   freebob_messagebuffer_add( "FREEBOB ERR: " format, ##args )
99        
100         #define printEnter()
101         #define printExit()
102        
103         #define debugError(format, args...)
104         #define debugPrint(Level, format, args...)
105         #define debugPrintShort(Level, format, args...)
106         #define debugPrintWithTimeStamp(Level, format, args...)
107 #endif
108
109 #ifdef __cplusplus
110 }
111 #endif
112
113 #endif
Note: See TracBrowser for help on using the browser.