2009-11-30 08:38:38 -05:00
/*
Copyright ( C ) 2009 Paul Davis
This program is free software ; you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation ; either version 2 of the License , or
( at your option ) any later version .
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
You should have received a copy of the GNU General Public License
along with this program ; if not , write to the Free Software
Foundation , Inc . , 675 Mass Ave , Cambridge , MA 0213 9 , USA .
*/
# include <cstring>
# include <cstdlib>
# include <iostream>
# include "ardour/debug.h"
# include "i18n.h"
using namespace std ;
void
ARDOUR : : debug_print ( const char * prefix , string str )
{
cerr < < prefix < < " : " < < str ;
}
void
ARDOUR : : set_debug_bits ( uint64_t bits )
{
debug_bits = bits ;
}
int
ARDOUR : : parse_debug_options ( const char * str )
{
char * p ;
char * sp ;
uint64_t bits = 0 ;
char * copy = strdup ( str ) ;
p = strtok_r ( copy , " , " , & sp ) ;
while ( p ) {
if ( strcasecmp ( p , " list " ) = = 0 ) {
list_debug_options ( ) ;
free ( copy ) ;
return 1 ;
}
if ( strcasecmp ( p , " all " ) = = 0 ) {
ARDOUR : : set_debug_bits ( ~ 0ULL ) ;
free ( copy ) ;
return 0 ;
}
if ( strncasecmp ( p , " midisourceio " , strlen ( p ) ) = = 0 ) {
bits | = ARDOUR : : DEBUG : : MidiSourceIO ;
} else if ( strncasecmp ( p , " midiplaylistio " , strlen ( p ) ) = = 0 ) {
bits | = ARDOUR : : DEBUG : : MidiPlaylistIO ;
} else if ( strncasecmp ( p , " mididiskstreamio " , strlen ( p ) ) = = 0 ) {
bits | = ARDOUR : : DEBUG : : MidiDiskstreamIO ;
} else if ( strncasecmp ( p , " snapbbt " , strlen ( p ) ) = = 0 ) {
bits | = ARDOUR : : DEBUG : : SnapBBT ;
} else if ( strncasecmp ( p , " configuration " , strlen ( p ) ) = = 0 ) {
bits | = ARDOUR : : DEBUG : : Configuration ;
} else if ( strncasecmp ( p , " latency " , strlen ( p ) ) = = 0 ) {
bits | = ARDOUR : : DEBUG : : Latency ;
} else if ( strncasecmp ( p , " processors " , strlen ( p ) ) = = 0 ) {
bits | = ARDOUR : : DEBUG : : Processors ;
} else if ( strncasecmp ( p , " graph " , strlen ( p ) ) = = 0 ) {
bits | = ARDOUR : : DEBUG : : Graph ;
} else if ( strncasecmp ( p , " destruction " , strlen ( p ) ) = = 0 ) {
bits | = ARDOUR : : DEBUG : : Destruction ;
} else if ( strncasecmp ( p , " mtc " , strlen ( p ) ) = = 0 ) {
bits | = ARDOUR : : DEBUG : : MTC ;
} else if ( strncasecmp ( p , " transport " , strlen ( p ) ) = = 0 ) {
bits | = ARDOUR : : DEBUG : : Transport ;
2009-11-30 11:12:13 -05:00
} else if ( strncasecmp ( p , " slave " , strlen ( p ) ) = = 0 ) {
2009-11-30 11:53:10 -05:00
bits | = ARDOUR : : DEBUG : : Slave ;
2009-11-30 11:12:13 -05:00
} else if ( strncasecmp ( p , " sessionevents " , strlen ( p ) ) = = 0 ) {
bits | = ARDOUR : : DEBUG : : SessionEvents ;
2009-12-01 12:11:11 -05:00
} else if ( strncasecmp ( p , " midiio " , strlen ( p ) ) = = 0 ) {
bits | = ARDOUR : : DEBUG : : MidiIO ;
2010-01-31 22:36:29 -05:00
} else if ( strncasecmp ( p , " midiclock " , strlen ( p ) ) = = 0 ) {
bits | = ARDOUR : : DEBUG : : MidiClock ;
2010-02-18 08:59:49 -05:00
} else if ( strncasecmp ( p , " properties " , strlen ( p ) ) = = 0 ) {
bits | = ARDOUR : : DEBUG : : Properties ;
2010-01-31 22:36:29 -05:00
}
2009-11-30 08:38:38 -05:00
p = strtok_r ( 0 , " , " , & sp ) ;
}
free ( copy ) ;
ARDOUR : : set_debug_bits ( bits ) ;
return 0 ;
}
void
ARDOUR : : list_debug_options ( )
{
cerr < < _ ( " The following debug options are available. Separate multipe options with commas. \n Names are case-insensitive and can be abbreviated. " ) < < endl < < endl ;
cerr < < " \t All " < < endl ;
cerr < < " \t MidiSourceIO " < < endl ;
cerr < < " \t MidiPlaylistIO " < < endl ;
cerr < < " \t MidiDiskstreamIO " < < endl ;
cerr < < " \t SnapBBT " < < endl ;
cerr < < " \t Configuration " < < endl ;
cerr < < " \t Latency " < < endl ;
cerr < < " \t Graph " < < endl ;
cerr < < " \t Destruction " < < endl ;
cerr < < " \t MTC " < < endl ;
cerr < < " \t Transport " < < endl ;
2009-11-30 11:12:13 -05:00
cerr < < " \t Slave " < < endl ;
cerr < < " \t SessionEvents " < < endl ;
2009-12-01 12:11:11 -05:00
cerr < < " \t MidiIO " < < endl ;
2010-01-04 14:58:41 -05:00
cerr < < " \t LatencyCompensation " < < endl ;
2010-01-31 22:36:29 -05:00
cerr < < " \t MidiClock " < < endl ;
2010-02-18 08:59:49 -05:00
cerr < < " \t Properties " < < endl ;
2009-11-30 08:38:38 -05:00
}