switch MIDI Clock slave code to use DEBUG_TRACE; don't make it require start/stop...
[ardour2.git] / libs / ardour / debug.cc
blob45f7e68434910263c9b3066bbef86c37167dbf90
1 /*
2 Copyright (C) 2009 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #include <cstring>
21 #include <cstdlib>
22 #include <iostream>
24 #include "ardour/debug.h"
26 #include "i18n.h"
28 using namespace std;
30 void
31 ARDOUR::debug_print (const char* prefix, string str)
33 cerr << prefix << ": " << str;
36 void
37 ARDOUR::set_debug_bits (uint64_t bits)
39 debug_bits = bits;
42 int
43 ARDOUR::parse_debug_options (const char* str)
45 char* p;
46 char* sp;
47 uint64_t bits = 0;
48 char* copy = strdup (str);
50 p = strtok_r (copy, ",", &sp);
52 while (p) {
53 if (strcasecmp (p, "list") == 0) {
54 list_debug_options ();
55 free (copy);
56 return 1;
59 if (strcasecmp (p, "all") == 0) {
60 ARDOUR::set_debug_bits (~0ULL);
61 free (copy);
62 return 0;
65 if (strncasecmp (p, "midisourceio", strlen (p)) == 0) {
66 bits |= ARDOUR::DEBUG::MidiSourceIO;
67 } else if (strncasecmp (p, "midiplaylistio", strlen (p)) == 0) {
68 bits |= ARDOUR::DEBUG::MidiPlaylistIO;
69 } else if (strncasecmp (p, "mididiskstreamio", strlen (p)) == 0) {
70 bits |= ARDOUR::DEBUG::MidiDiskstreamIO;
71 } else if (strncasecmp (p, "snapbbt", strlen (p)) == 0) {
72 bits |= ARDOUR::DEBUG::SnapBBT;
73 } else if (strncasecmp (p, "configuration", strlen (p)) == 0) {
74 bits |= ARDOUR::DEBUG::Configuration;
75 } else if (strncasecmp (p, "latency", strlen (p)) == 0) {
76 bits |= ARDOUR::DEBUG::Latency;
77 } else if (strncasecmp (p, "processors", strlen (p)) == 0) {
78 bits |= ARDOUR::DEBUG::Processors;
79 } else if (strncasecmp (p, "graph", strlen (p)) == 0) {
80 bits |= ARDOUR::DEBUG::Graph;
81 } else if (strncasecmp (p, "destruction", strlen (p)) == 0) {
82 bits |= ARDOUR::DEBUG::Destruction;
83 } else if (strncasecmp (p, "mtc", strlen (p)) == 0) {
84 bits |= ARDOUR::DEBUG::MTC;
85 } else if (strncasecmp (p, "transport", strlen (p)) == 0) {
86 bits |= ARDOUR::DEBUG::Transport;
87 } else if (strncasecmp (p, "slave", strlen (p)) == 0) {
88 bits |= ARDOUR::DEBUG::Slave;
89 } else if (strncasecmp (p, "sessionevents", strlen (p)) == 0) {
90 bits |= ARDOUR::DEBUG::SessionEvents;
91 } else if (strncasecmp (p, "midiio", strlen (p)) == 0) {
92 bits |= ARDOUR::DEBUG::MidiIO;
93 } else if (strncasecmp (p, "midiclock", strlen (p)) == 0) {
94 bits |= ARDOUR::DEBUG::MidiClock;
97 p = strtok_r (0, ",", &sp);
100 free (copy);
101 ARDOUR::set_debug_bits (bits);
102 return 0;
105 void
106 ARDOUR::list_debug_options ()
108 cerr << _("The following debug options are available. Separate multipe options with commas.\nNames are case-insensitive and can be abbreviated.") << endl << endl;
109 cerr << "\tAll" << endl;
110 cerr << "\tMidiSourceIO" << endl;
111 cerr << "\tMidiPlaylistIO" << endl;
112 cerr << "\tMidiDiskstreamIO" << endl;
113 cerr << "\tSnapBBT" << endl;
114 cerr << "\tConfiguration" << endl;
115 cerr << "\tLatency" << endl;
116 cerr << "\tGraph" << endl;
117 cerr << "\tDestruction" << endl;
118 cerr << "\tMTC" << endl;
119 cerr << "\tTransport" << endl;
120 cerr << "\tSlave" << endl;
121 cerr << "\tSessionEvents" << endl;
122 cerr << "\tMidiIO" << endl;
123 cerr << "\tLatencyCompensation" << endl;
124 cerr << "\tMidiClock" << endl;