Changeset 730
- Timestamp:
- 11/27/07 10:28:51 (16 years ago)
- Files:
-
- branches/ppalmers-streaming/config.h.in (modified) (2 diffs)
- branches/ppalmers-streaming/deb (added)
- branches/ppalmers-streaming/deb/SConscript (added)
- branches/ppalmers-streaming/libffado/ffado.h (modified) (1 diff)
- branches/ppalmers-streaming/SConstruct (modified) (4 diffs)
- branches/ppalmers-streaming/src/debugmodule/debugmodule.cpp (modified) (3 diffs)
- branches/ppalmers-streaming/src/debugmodule/debugmodule.h (modified) (3 diffs)
- branches/ppalmers-streaming/src/devicemanager.h (modified) (1 diff)
- branches/ppalmers-streaming/src/ffadodevice.cpp (modified) (1 diff)
- branches/ppalmers-streaming/src/libosc (deleted)
- branches/ppalmers-streaming/src/SConscript (modified) (3 diffs)
- branches/ppalmers-streaming/support/dbus (added)
- branches/ppalmers-streaming/support/dbus/control-interface.xml (moved) (moved from branches/ppalmers-streaming/tests/control-interface.xml)
- branches/ppalmers-streaming/support/dbus/controlclient.cpp (moved) (moved from branches/ppalmers-streaming/tests/controlclient.cpp)
- branches/ppalmers-streaming/support/dbus/controlclient.h (moved) (moved from branches/ppalmers-streaming/tests/controlclient.h)
- branches/ppalmers-streaming/support/dbus/controlserver.cpp (moved) (moved from branches/ppalmers-streaming/tests/controlserver.cpp)
- branches/ppalmers-streaming/support/dbus/controlserver.h (moved) (moved from branches/ppalmers-streaming/tests/controlserver.h)
- branches/ppalmers-streaming/support/dbus/ffado-dbus-server.cpp (copied) (copied from branches/ppalmers-streaming/tests/test-ffado.cpp) (14 diffs)
- branches/ppalmers-streaming/support/dbus/SConscript (added)
- branches/ppalmers-streaming/support/dbus/test-dbus-server.cpp (moved) (moved from branches/ppalmers-streaming/tests/test-dbus-server.cpp)
- branches/ppalmers-streaming/support/dbus/test-dbus.cpp (moved) (moved from branches/ppalmers-streaming/tests/test-dbus.cpp)
- branches/ppalmers-streaming/support/firmware/SConscript (modified) (2 diffs)
- branches/ppalmers-streaming/support/SConscript (modified) (1 diff)
- branches/ppalmers-streaming/tests/SConscript (modified) (3 diffs)
- branches/ppalmers-streaming/tests/test-ffado.cpp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/ppalmers-streaming/config.h.in
r609 r730 13 13 14 14 /* Define to the full name and version of this package. */ 15 #define PACKAGE_STRING "$PACKAGE $VERSION "15 #define PACKAGE_STRING "$PACKAGE $VERSION-$REVISION" 16 16 17 17 /* Define to the one symbol short name of this package. */ … … 19 19 20 20 /* Define to the version of this package. */ 21 #define PACKAGE_VERSION $VERSION21 #define PACKAGE_VERSION "$VERSION-$REVISION" 22 22 23 23 /* Define to 1 if SSE assembly is available. */ 24 24 /*#define USE_SSE 1*/ 25 26 /* Version number of package */27 #define VERSION "$VERSION"28 25 29 26 #define CACHEDIR "~/.ffado" branches/ppalmers-streaming/libffado/ffado.h
r453 r730 145 145 typedef struct ffado_device_info { 146 146 /* TODO: How is the device specification done? */ 147 // char xml_location[FFADO_STREAMING_MAX_URL_LENGTH]; // can be an osc url or an XML filename148 147 // ffado_device_info_location_type location_type; 149 148 } ffado_device_info_t; branches/ppalmers-streaming/SConstruct
r724 r730 136 136 'alsa' : '1.0.0', 137 137 'libxml++-2.6' : '2.13.0', 138 'liblo' : '0.22',139 138 'dbus-1' : '1.0', 140 139 } … … 203 202 env.Alias( "install", env['bindir'] ) 204 203 204 205 env['REVISION'] = os.popen('svnversion .').read()[:-1] 206 # This may be as simple as '89' or as complex as '4123:4184M'. 207 # We'll just use the last bit. 208 env['REVISION'] = env['REVISION'].split(':')[-1] 209 210 if env['REVISION'] == 'exported': 211 env['REVISION'] = '' 212 205 213 env['PACKAGE'] = "libffado" 206 env['VERSION'] = "1.999. 6"214 env['VERSION'] = "1.999.7" 207 215 env['LIBVERSION'] = "1.0.0" 208 216 … … 215 223 # Start building 216 224 # 217 218 225 env.ScanReplace( "config.h.in" ) 219 226 … … 227 234 env.SConscript( dirs=subdirs, exports="env" ) 228 235 236 if 'debian' in COMMAND_LINE_TARGETS: 237 env.SConscript("deb/SConscript", exports="env") 229 238 230 239 # By default only src is built but all is cleaned branches/ppalmers-streaming/src/debugmodule/debugmodule.cpp
r720 r730 46 46 47 47 ColorEntry colorTable[] = { 48 { "", "" }, 48 49 { "\033[31mFatal", "\033[0m" }, 49 50 { "\033[31mError", "\033[0m" }, … … 213 214 DebugModule::getPreSequence( debug_level_t level ) const 214 215 { 215 if ( ( level <= eDL_Normal ) && ( level >= eDL_ Fatal) ) {216 if ( ( level <= eDL_Normal ) && ( level >= eDL_Message ) ) { 216 217 return colorTable[level].preSequence; 217 218 } … … 222 223 DebugModule::getPostSequence( debug_level_t level ) const 223 224 { 224 if ( ( level <= eDL_Normal ) && ( level >= eDL_ Fatal) ) {225 if ( ( level <= eDL_Normal ) && ( level >= eDL_Message ) ) { 225 226 return colorTable[level].postSequence; 226 227 } branches/ppalmers-streaming/src/debugmodule/debugmodule.h
r698 r730 34 34 typedef short debug_level_t; 35 35 36 #define DEBUG_LEVEL_FATAL 0 37 #define DEBUG_LEVEL_ERROR 1 38 #define DEBUG_LEVEL_WARNING 2 39 #define DEBUG_LEVEL_NORMAL 3 40 #define DEBUG_LEVEL_INFO 4 41 #define DEBUG_LEVEL_VERBOSE 5 42 #define DEBUG_LEVEL_VERY_VERBOSE 6 43 #define DEBUG_LEVEL_ULTRA_VERBOSE 7 36 #define DEBUG_LEVEL_MESSAGE 0 37 #define DEBUG_LEVEL_FATAL 1 38 #define DEBUG_LEVEL_ERROR 2 39 #define DEBUG_LEVEL_WARNING 3 40 #define DEBUG_LEVEL_NORMAL 4 41 #define DEBUG_LEVEL_INFO 5 42 #define DEBUG_LEVEL_VERBOSE 6 43 #define DEBUG_LEVEL_VERY_VERBOSE 7 44 #define DEBUG_LEVEL_ULTRA_VERBOSE 8 44 45 45 46 #define DEBUG_MAX_MESSAGE_LENGTH 512 … … 95 96 ##args ) 96 97 98 // these are for messages that are also displayed when not compiled 99 // for debug 100 #define printMessage( format, args... ) \ 101 m_debugModule.print( DebugModule::eDL_Message, \ 102 __FILE__, \ 103 __FUNCTION__, \ 104 __LINE__, \ 105 format, \ 106 ##args ) 107 #define printMessageShort( format, args... ) \ 108 m_debugModule.printShort( DebugModule::eDL_Message, \ 109 format, \ 110 ##args ) 111 97 112 #define DECLARE_DEBUG_MODULE static DebugModule m_debugModule 98 113 #define IMPL_DEBUG_MODULE( ClassName, RegisterName, Level ) \ … … 182 197 public: 183 198 enum { 199 eDL_Message = DEBUG_LEVEL_MESSAGE, 184 200 eDL_Fatal = DEBUG_LEVEL_FATAL, 185 201 eDL_Error = DEBUG_LEVEL_ERROR, branches/ppalmers-streaming/src/devicemanager.h
r674 r730 32 32 33 33 #include "libutil/OptionContainer.h" 34 // #include "libosc/OscServer.h"35 // #include "libosc/OscNode.h"36 34 #include "libcontrol/BasicElements.h" 37 35 branches/ppalmers-streaming/src/ffadodevice.cpp
r674 r730 118 118 119 119 retval=setOption("id",idstr.str()); 120 /* if (retval) {121 setOscBase(idstr.str());122 }*/123 120 return retval; 124 121 } branches/ppalmers-streaming/src/SConscript
r712 r730 42 42 libieee1394/ieee1394service.cpp \ 43 43 libieee1394/IEC61883.cpp \ 44 libosc/OscArgument.cpp \45 libosc/OscClient.cpp \46 libosc/OscMessage.cpp \47 libosc/OscNode.cpp \48 libosc/OscResponse.cpp \49 libosc/OscServer.cpp \50 44 libstreaming/StreamProcessorManager.cpp \ 51 45 libstreaming/util/cip.c \ … … 197 191 libenv.MergeFlags( env['ALSA_FLAGS'] ) 198 192 libenv.MergeFlags( env['LIBXML26_FLAGS'] ) 199 libenv.MergeFlags( env['LIBLO_FLAGS'] )200 193 201 194 #env1.AppendUnique( LINKFLAGS = env.Split("-Wl,-rpath $libdir -Wl,-soname -Wl,libffado.so.1 --version-info=1:0:0") ) … … 248 241 "test-dll" : "libutil/test-dll.cpp", \ 249 242 "test-unittests-util" : "libutil/unittests.cpp", \ 250 "test-unittests-osc" : "libosc/unittests.cpp" \251 243 } 252 244 branches/ppalmers-streaming/support/dbus/ffado-dbus-server.cpp
r639 r730 52 52 #include <sstream> 53 53 54 #include <lo/lo.h>55 56 54 using namespace std; 57 55 58 56 DECLARE_GLOBAL_DEBUG_MODULE; 59 60 // prototypes & stuff for listing the OSC space61 void list_osc_paths(lo_server s, lo_address t, const char *path);62 void list_osc_params(lo_server s, lo_address t, const char *path);63 string osc_param_get_value(lo_server s, lo_address t, const char *path, const char *param);64 65 vector<string> osc_paths;66 vector<string> osc_params;67 string osc_value;68 69 int osc_path_response_handler(const char *path, const char *types, lo_arg **argv, int argc,70 void *data, void *user_data);71 72 int osc_param_response_handler(const char *path, const char *types, lo_arg **argv, int argc,73 void *data, void *user_data);74 75 int osc_data_response_handler(const char *path, const char *types, lo_arg **argv, int argc,76 void *data, void *user_data);77 78 void osc_error_handler(int num, const char *msg, const char *path);79 57 80 58 // DBUS stuff … … 94 72 95 73 // Program documentation. 96 static char doc[] = "FFADO -- a driver for Firewire Audio devices (test application)\n\n" 97 "OPERATION: Discover\n" 98 " SetSamplerate samplerate\n" 99 " SetClockSource [id]\n" 100 " ListOscSpace\n" 101 " OscServer\n" 102 " DBus\n" 74 static char doc[] = "ffado-dbus-server -- expose the mixer features of connected FFADO devices through DBus\n\n" 103 75 ; 104 76 105 77 // A description of the arguments we accept. 106 static char args_doc[] = " OPERATION";78 static char args_doc[] = ""; 107 79 108 80 struct arguments … … 124 96 125 97 126 {"node", 'n', "id", 0, " Node to use" },98 {"node", 'n', "id", 0, "Only expose mixer of a device on a specific node" }, 127 99 {"port", 'p', "nr", 0, "IEEE1394 Port to use" }, 128 100 { 0 } … … 148 120 arguments->verbose = strtol( arg, &tail, 0 ); 149 121 if ( errno ) { 150 fprintf( stderr,"Could not parse 'verbose' argument\n" );122 debugError( "Could not parse 'verbose' argument\n" ); 151 123 return ARGP_ERR_UNKNOWN; 152 124 } … … 157 129 arguments->port = strtol( arg, &tail, 0 ); 158 130 if ( errno ) { 159 fprintf( stderr,"Could not parse 'port' argument\n" );131 debugError( "Could not parse 'port' argument\n" ); 160 132 return ARGP_ERR_UNKNOWN; 161 133 } 162 134 } else { 163 135 if ( errno ) { 164 fprintf( stderr,"Could not parse 'port' argumen\n" );136 debugError("Could not parse 'port' argumen\n" ); 165 137 return ARGP_ERR_UNKNOWN; 166 138 } … … 171 143 arguments->node_id = strtol( arg, &tail, 0 ); 172 144 if ( errno ) { 173 fprintf( stderr,"Could not parse 'node' argument\n" );145 debugError( "Could not parse 'node' argument\n" ); 174 146 return ARGP_ERR_UNKNOWN; 175 147 } … … 177 149 } else { 178 150 if ( errno ) { 179 fprintf( stderr,"Could not parse 'node' argumen\n" );151 debugError("Could not parse 'node' argumen\n" ); 180 152 return ARGP_ERR_UNKNOWN; 181 153 } … … 183 155 break; 184 156 case ARGP_KEY_ARG: 185 if (state->arg_num >= 3) {157 if (state->arg_num >= 1) { 186 158 // Too many arguments. 187 159 argp_usage( state ); … … 190 162 break; 191 163 case ARGP_KEY_END: 192 if (state->arg_num < 1) {164 if (state->arg_num < 0) { 193 165 // Not enough arguments. 194 166 argp_usage( state ); … … 207 179 debugOutput( DEBUG_LEVEL_NORMAL, "Debug output flushed...\n" ); 208 180 flushDebugOutput(); 209 210 181 return retval; 211 182 } … … 230 201 // be reflected in `arguments'. 231 202 if ( argp_parse ( &argp, argc, argv, 0, 0, &arguments ) ) { 232 fprintf( stderr,"Could not parse command line\n" );203 debugError("Could not parse command line\n" ); 233 204 return exitfunction(-1); 234 205 } 235 206 236 printf("verbose level = %d\n", arguments.verbose); 237 238 printf( "Using ffado library version: %s\n\n", ffado_get_version() ); 239 240 if ( strcmp( arguments.args[0], "Discover" ) == 0 ) { 207 debugOutput( DEBUG_LEVEL_NORMAL, "verbose level = %d\n", arguments.verbose); 208 debugOutput( DEBUG_LEVEL_NORMAL, "Using ffado library version: %s\n\n", ffado_get_version() ); 209 241 210 DeviceManager *m_deviceManager = new DeviceManager(); 242 211 if ( !m_deviceManager ) { 243 fprintf( stderr, "Could not allocate device manager\n" ); 212 debugError("Could not allocate device manager\n" ); 213 return exitfunction(-1); 214 } 215 if ( !m_deviceManager->initialize( arguments.port ) ) { 216 debugError("Could not initialize device manager\n" ); 217 delete m_deviceManager; 244 218 return exitfunction(-1); 245 219 } … … 247 221 m_deviceManager->setVerboseLevel(arguments.verbose); 248 222 } 249 if ( !m_deviceManager->initialize( arguments.port ) ) {250 fprintf( stderr, "Could not initialize device manager\n" );251 delete m_deviceManager;252 return exitfunction(-1);253 }254 if ( arguments.verbose ) {255 m_deviceManager->setVerboseLevel(arguments.verbose);256 }257 223 if ( !m_deviceManager->discover() ) { 258 fprintf( stderr, "Could not discover devices\n" ); 259 delete m_deviceManager; 260 return exitfunction(-1); 261 } 262 delete m_deviceManager; 263 return exitfunction(0); 264 } else if ( strcmp( arguments.args[0], "SetSamplerate" ) == 0 ) { 265 char* tail; 266 int samplerate = strtol( arguments.args[1], &tail, 0 ); 267 if ( errno ) { 268 fprintf( stderr, "Could not parse samplerate argument\n" ); 269 return exitfunction(-1); 270 } 271 272 DeviceManager *m_deviceManager = new DeviceManager(); 273 if ( !m_deviceManager ) { 274 fprintf( stderr, "Could not allocate device manager\n" ); 275 return exitfunction(-1); 276 } 277 if ( arguments.verbose ) { 278 m_deviceManager->setVerboseLevel(arguments.verbose); 279 } 280 if ( !m_deviceManager->initialize( arguments.port ) ) { 281 fprintf( stderr, "Could not initialize device manager\n" ); 282 delete m_deviceManager; 283 return exitfunction(-1); 284 } 285 if ( arguments.verbose ) { 286 m_deviceManager->setVerboseLevel(arguments.verbose); 287 } 288 if ( !m_deviceManager->discover() ) { 289 fprintf( stderr, "Could not discover devices\n" ); 290 delete m_deviceManager; 291 return exitfunction(-1); 292 } 293 294 if(arguments.node_id_set) { 295 FFADODevice* avDevice = m_deviceManager->getAvDevice( arguments.node_id ); 296 if ( avDevice ) { 297 avDevice->setVerboseLevel(arguments.verbose); 298 if ( ! avDevice->setSamplingFrequency( samplerate ) ) { 299 fprintf( stderr, "Could not set samplerate\n" ); 300 } 301 } 302 } else { 303 int i=0; 304 305 int devices_on_bus = m_deviceManager->getNbDevices(); 306 printf(" port = %d, devices_on_bus = %d\n", arguments.port, devices_on_bus); 307 308 for(i=0;i<devices_on_bus;i++) { 309 int node_id=m_deviceManager->getDeviceNodeId(i); 310 printf(" set samplerate for device = %d, node = %d\n", i, node_id); 311 FFADODevice* avDevice = m_deviceManager->getAvDevice( node_id ); 312 if ( avDevice ) { 313 avDevice->setVerboseLevel(arguments.verbose); 314 if ( !avDevice->setSamplingFrequency( samplerate ) ) { 315 fprintf( stderr, "Could not set samplerate\n" ); 316 } 317 } 318 } 319 } 320 delete m_deviceManager; 321 return exitfunction(0); 322 } else if ( strcmp( arguments.args[0], "SetClockSource" ) == 0 ) { 323 char* tail; 324 unsigned int targetid = (unsigned int)strtol( arguments.args[1], &tail, 0 ); 325 if ( errno ) { 326 fprintf( stderr, "Could not parse clock source argument\n" ); 327 targetid=0xFFFF; 328 } 329 DeviceManager *m_deviceManager = new DeviceManager(); 330 if ( !m_deviceManager ) { 331 fprintf( stderr, "Could not allocate device manager\n" ); 332 return exitfunction(-1); 333 } 334 if ( arguments.verbose ) { 335 m_deviceManager->setVerboseLevel(arguments.verbose); 336 } 337 if ( !m_deviceManager->initialize( arguments.port ) ) { 338 fprintf( stderr, "Could not initialize device manager\n" ); 339 delete m_deviceManager; 340 return exitfunction(-1); 341 } 342 if ( arguments.verbose ) { 343 m_deviceManager->setVerboseLevel(arguments.verbose); 344 } 345 if ( !m_deviceManager->discover() ) { 346 fprintf( stderr, "Could not discover devices\n" ); 347 delete m_deviceManager; 348 return exitfunction(-1); 349 } 350 351 if(arguments.node_id_set) { 352 FFADODevice* avDevice = m_deviceManager->getAvDevice( arguments.node_id ); 353 if ( avDevice ) { 354 FFADODevice::ClockSource s; 355 356 avDevice->setVerboseLevel(arguments.verbose); 357 FFADODevice::ClockSourceVector sources=avDevice->getSupportedClockSources(); 358 for ( FFADODevice::ClockSourceVector::const_iterator it 359 = sources.begin(); 360 it != sources.end(); 361 ++it ) 362 { 363 FFADODevice::ClockSource c=*it; 364 printf( " Type: %s, Id: %d, Valid: %d, Active: %d, Description: %s\n", 365 FFADODevice::ClockSourceTypeToString(c.type), c.id, c.valid, c.active, c.description.c_str()); 366 367 if (c.id==targetid) { 368 s=*it; 369 } 370 } 371 372 if (s.type != FFADODevice::eCT_Invalid) { 373 printf(" set clock source to %d\n", s.id); 374 if ( ! avDevice->setActiveClockSource( s ) ) { 375 fprintf( stderr, "Could not set clock source\n" ); 376 } 377 } else { 378 printf(" no clock source with id %d found\n", targetid); 379 } 380 } 381 } else { 382 fprintf( stderr, "please specify a node\n" ); 383 } 384 delete m_deviceManager; 385 return exitfunction(0); 386 } else if ( strcmp( arguments.args[0], "ListOscSpace" ) == 0 ) { 387 // list osc space by using OSC messages 388 // a server is assumed to be present 389 390 /* start a new server. 391 when sending a message from this context, the response 392 address will be set to this server's address. 393 */ 394 lo_server s = lo_server_new(NULL, osc_error_handler); 395 lo_address t = lo_address_new(NULL, "17820"); 396 397 list_osc_paths(s, t, "/"); 398 399 lo_address_free(t); 400 lo_server_free(s); 401 402 } else if ( strcmp( arguments.args[0], "OscServer" ) == 0 ) { 403 DeviceManager *m_deviceManager = new DeviceManager(); 404 if ( !m_deviceManager ) { 405 fprintf( stderr, "Could not allocate device manager\n" ); 406 return exitfunction(-1); 407 } 408 if ( !m_deviceManager->initialize( arguments.port ) ) { 409 fprintf( stderr, "Could not initialize device manager\n" ); 410 delete m_deviceManager; 411 return exitfunction(-1); 412 } 413 if ( arguments.verbose ) { 414 m_deviceManager->setVerboseLevel(arguments.verbose); 415 } 416 if ( !m_deviceManager->discover() ) { 417 fprintf( stderr, "Could not discover devices\n" ); 418 delete m_deviceManager; 419 return exitfunction(-1); 420 } 421 422 printf("server started\n"); 423 printf("press ctrl-c to stop it & continue\n"); 424 425 signal (SIGINT, sighandler); 426 427 run=1; 428 while(run) { 429 sleep(1); 430 fflush(stdout); 431 fflush(stderr); 432 } 433 signal (SIGINT, SIG_DFL); 434 435 printf("server stopped\n"); 436 delete m_deviceManager; 437 return exitfunction(0); 438 } else if ( strcmp( arguments.args[0], "DBus" ) == 0 ) { 439 DeviceManager *m_deviceManager = new DeviceManager(); 440 if ( !m_deviceManager ) { 441 fprintf( stderr, "Could not allocate device manager\n" ); 442 return exitfunction(-1); 443 } 444 if ( !m_deviceManager->initialize( arguments.port ) ) { 445 fprintf( stderr, "Could not initialize device manager\n" ); 446 delete m_deviceManager; 447 return exitfunction(-1); 448 } 449 if ( arguments.verbose ) { 450 m_deviceManager->setVerboseLevel(arguments.verbose); 451 } 452 if ( !m_deviceManager->discover() ) { 453 fprintf( stderr, "Could not discover devices\n" ); 224 debugError("Could not discover devices\n" ); 454 225 delete m_deviceManager; 455 226 return exitfunction(-1); … … 469 240 = new DBusControl::Container(conn, "/org/ffado/Control/DeviceManager", *m_deviceManager); 470 241 471 print f("DBUS test service running\n");472 print f("press ctrl-c to stop it & continue\n");242 printMessage("DBUS test service running\n"); 243 printMessage("press ctrl-c to stop it & continue\n"); 473 244 474 245 dispatcher.enter(); … … 478 249 signal (SIGINT, SIG_DFL); 479 250 480 print f("server stopped\n");251 printMessage("server stopped\n"); 481 252 delete m_deviceManager; 482 253 return exitfunction(0); 483 } else { 484 printf( "unknown operation\n" ); 485 } 486 487 } 488 489 void list_osc_paths(lo_server s, lo_address t, const char *path) { 490 vector<string> my_paths; 491 492 printf("listing path: %s\n", path); 493 494 osc_paths.clear(); 495 lo_server_add_method(s, "/response", NULL, osc_path_response_handler, NULL); 496 497 if (lo_send(t, path, "s", "list") == -1) { 498 printf(" OSC error %d: %s\n", lo_address_errno(t), lo_address_errstr(t)); 499 } 500 501 if (lo_server_recv_noblock(s, 1000) == 0) { 502 printf("timeout\n"); 503 return; 504 } 505 506 lo_server_del_method(s, "/response", NULL); 507 508 list_osc_params(s, t, path); 509 510 my_paths=osc_paths; 511 for ( vector<string>::iterator it = my_paths.begin(); 512 it != my_paths.end(); 513 ++it ) 514 { 515 string new_path=string(path) + *it; 516 new_path += string("/"); 517 list_osc_paths(s, t, new_path.c_str()); 518 } 519 520 } 521 522 void list_osc_params(lo_server s, lo_address t, const char *path) { 523 vector<string> my_paths; 524 printf("params for: %s\n", path); 525 526 osc_params.clear(); 527 lo_server_add_method(s, "/response", NULL, osc_param_response_handler, NULL); 528 529 if (lo_send(t, path, "s", "params") == -1) { 530 printf(" OSC error %d: %s\n", lo_address_errno(t), lo_address_errstr(t)); 531 } 532 533 if (lo_server_recv_noblock(s, 1000) == 0) { 534 printf("timeout\n"); 535 return; 536 } 537 538 lo_server_del_method(s, "/response", NULL); 539 540 vector<string> my_params=osc_params; 541 542 for ( vector<string>::iterator it = my_params.begin(); 543 it != my_params.end(); 544 ++it ) 545 { 546 string value=osc_param_get_value(s, t, path, (*it).c_str()); 547 printf(" %20s = %s\n", (*it).c_str(), value.c_str()); 548 } 549 550 } 551 552 string osc_param_get_value(lo_server s, lo_address t, const char *path, const char *param) { 553 lo_server_add_method(s, "/response", NULL, osc_data_response_handler, NULL); 554 555 if (lo_send(t, path, "ss", "get", param) == -1) { 556 printf(" OSC error %d: %s\n", lo_address_errno(t), lo_address_errstr(t)); 557 } 558 559 if (lo_server_recv_noblock(s, 1000) == 0) { 560 return string("timeout"); 561 } 562 563 lo_server_del_method(s, "/response", NULL); 564 return osc_value; 565 } 566 567 void osc_error_handler(int num, const char *msg, const char *path) 568 { 569 printf("liblo server error %d in path %s: %s\n", num, path, msg); 570 } 571 572 int osc_path_response_handler(const char *path, const char *types, lo_arg **argv, int argc, 573 void *data, void *user_data) 574 { 575 for (int i=0; i< argc;i++) { 576 switch (lo_type(types[i])) { 577 /** Standard C, NULL terminated string. */ 578 case LO_STRING: 579 osc_paths.push_back(string(&(argv[i]->s))); 580 break; 581 default: 582 printf("unexpected data type in response message\n"); 583 } 584 } 585 return 1; 586 } 587 588 int osc_param_response_handler(const char *path, const char *types, lo_arg **argv, int argc, 589 void *data, void *user_data) 590 { 591 for (int i=0; i< argc;i++) { 592 switch (lo_type(types[i])) { 593 /** Standard C, NULL terminated string. */ 594 case LO_STRING: 595 osc_params.push_back(string(&(argv[i]->s))); 596 break; 597 default: 598 printf("unexpected data type in response message\n"); 599 } 600 } 601 return 1; 602 } 603 604 int osc_data_response_handler(const char *path, const char *types, lo_arg **argv, int argc, 605 void *data, void *user_data) 606 { 607 std::ostringstream str; 608 609 if(argc==1) { 610 switch (lo_type(types[0])) { 611 /* basic OSC types */ 612 /** 32 bit signed integer. */ 613 case LO_INT32: 614 str << "0x" << std::hex << argv[0]->i; 615 osc_value=str.str(); 616 break; 617 case LO_INT64: 618 str << "0x" << std::hex << argv[0]->h; 619 osc_value=str.str(); 620 break; 621 /** 32 bit IEEE-754 float. */ 622 case LO_FLOAT: 623 str << argv[0]->f; 624 osc_value=str.str(); 625 break; 626 /** Standard C, NULL terminated string. */ 627 case LO_STRING: 628 osc_value=string(&argv[0]->s); 629 break; 630 default: 631 osc_value="unsupported response datatype"; 632 } 633 } else { 634 osc_value="invalid response"; 635 } 636 return 1; 637 } 254 } branches/ppalmers-streaming/support/firmware/SConscript
r689 r730 19 19 env.MergeFlags( env['ALSA_FLAGS'] ) 20 20 env.MergeFlags( env['LIBXML26_FLAGS'] ) 21 env.MergeFlags( env['LIBLO_FLAGS'] )22 21 23 22 apps = { … … 27 26 28 27 if env['ENABLE_BEBOB']: 29 apps[" bridgeco-downloader"] = "bridgeco-downloader.cpp"30 installapps += [ " bridgeco-downloader" ]28 apps["ffado-bridgeco-downloader"] = "bridgeco-downloader.cpp" 29 installapps += [ "ffado-bridgeco-downloader" ] 31 30 32 31 if env['ENABLE_FIREWORKS']: 33 apps["f ireworks-downloader"] = "fireworks-downloader.cpp"34 installapps += [ "f ireworks-downloader" ]32 apps["ffado-fireworks-downloader"] = "fireworks-downloader.cpp" 33 installapps += [ "ffado-fireworks-downloader" ] 35 34 36 35 for app in apps.keys(): branches/ppalmers-streaming/support/SConscript
r688 r730 18 18 # 19 19 20 env.SConscript( dirs=["mixer","firmware" ], exports="env" )20 env.SConscript( dirs=["mixer","firmware","dbus"], exports="env" ) 21 21 branches/ppalmers-streaming/tests/SConscript
r663 r730 5 5 env = env.Copy() 6 6 7 env.PrependUnique( CPPPATH=["#/src" , "#/external/dbus/include"] )8 env.PrependUnique( LIBPATH=[env['build_base']+"src" , env['build_base']+"external/dbus"] )9 env.PrependUnique( LIBS=["ffado" , "dbus-c++"] )7 env.PrependUnique( CPPPATH=["#/src"] ) 8 env.PrependUnique( LIBPATH=[env['build_base']+"src"] ) 9 env.PrependUnique( LIBS=["ffado"] ) 10 10 11 11 if not env.GetOption( "clean" ): 12 env.MergeFlags( env["DBUS1_FLAGS"] )13 12 env.MergeFlags( env['LIBRAW1394_FLAGS'] ) 14 13 env.MergeFlags( env['LIBXML26_FLAGS'] ) 15 16 env.Xml2Cpp_Proxy('controlclient-glue.h', 'control-interface.xml')17 env.Xml2Cpp_Adaptor('controlserver-glue.h', 'control-interface.xml')18 14 19 15 # … … 22 18 # 23 19 apps = { 24 "test-ffado" : "test-ffado.cpp controlserver.cpp",20 "test-ffado" : "test-ffado.cpp", 25 21 "test-fw410" : "test-fw410.cpp", 26 22 "test-avccmd" : "test-avccmd.cpp", … … 33 29 "test-streamdump" : "test-streamdump.cpp", 34 30 "test-sytmonitor" : "test-sytmonitor.cpp SytMonitor.cpp", 35 "test-dbus" : "test-dbus.cpp controlclient.cpp",36 "test-dbus-server" : "test-dbus-server.cpp controlserver.cpp",37 31 } 38 32 branches/ppalmers-streaming/tests/test-ffado.cpp
r639 r730 36 36 #include "ffadodevice.h" 37 37 38 #include <dbus-c++/dbus.h>39 #include "controlserver.h"40 #include "libcontrol/BasicElements.h"41 42 38 #include <signal.h> 43 39 … … 52 48 #include <sstream> 53 49 54 #include <lo/lo.h>55 56 50 using namespace std; 57 51 58 52 DECLARE_GLOBAL_DEBUG_MODULE; 59 60 // prototypes & stuff for listing the OSC space61 void list_osc_paths(lo_server s, lo_address t, const char *path);62 void list_osc_params(lo_server s, lo_address t, const char *path);63 string osc_param_get_value(lo_server s, lo_address t, const char *path, const char *param);64 65 vector<string> osc_paths;66 vector<string> osc_params;67 string osc_value;68 69 int osc_path_response_handler(const char *path, const char *types, lo_arg **argv, int argc,70 void *data, void *user_data);71 72 int osc_param_response_handler(const char *path, const char *types, lo_arg **argv, int argc,73 void *data, void *user_data);74 75 int osc_data_response_handler(const char *path, const char *types, lo_arg **argv, int argc,76 void *data, void *user_data);77 78 void osc_error_handler(int num, const char *msg, const char *path);79 80 // DBUS stuff81 DBus::BusDispatcher dispatcher;82 83 // signal handler84 int run=1;85 static void sighandler (int sig)86 {87 run = 0;88 dispatcher.leave();89 }90 53 91 54 // global's … … 98 61 " SetSamplerate samplerate\n" 99 62 " SetClockSource [id]\n" 100 " ListOscSpace\n"101 " OscServer\n"102 " DBus\n"103 63 ; 104 64 … … 384 344 delete m_deviceManager; 385 345 return exitfunction(0); 386 } else if ( strcmp( arguments.args[0], "ListOscSpace" ) == 0 ) {387 // list osc space by using OSC messages388 // a server is assumed to be present389 390 /* start a new server.391 when sending a message from this context, the response392 address will be set to this server's address.393 */394 lo_server s = lo_server_new(NULL, osc_error_handler);395 lo_address t = lo_address_new(NULL, "17820");396 397 list_osc_paths(s, t, "/");398 399 lo_address_free(t);400 lo_server_free(s);401 402 } else if ( strcmp( arguments.args[0], "OscServer" ) == 0 ) {403 DeviceManager *m_deviceManager = new DeviceManager();404 if ( !m_deviceManager ) {405 fprintf( stderr, "Could not allocate device manager\n" );406 return exitfunction(-1);407 }408 if ( !m_deviceManager->initialize( arguments.port ) ) {409 fprintf( stderr, "Could not initialize device manager\n" );410 delete m_deviceManager;411 return exitfunction(-1);412 }413 if ( arguments.verbose ) {414 m_deviceManager->setVerboseLevel(arguments.verbose);415 }416 if ( !m_deviceManager->discover() ) {417 fprintf( stderr, "Could not discover devices\n" );418 delete m_deviceManager;419 return exitfunction(-1);420 }421 422 printf("server started\n");423 printf("press ctrl-c to stop it & continue\n");424 425 signal (SIGINT, sighandler);426 427 run=1;428 while(run) {429 sleep(1);430 fflush(stdout);431 fflush(stderr);432 }433 signal (SIGINT, SIG_DFL);434 435 printf("server stopped\n");436 delete m_deviceManager;437 return exitfunction(0);438 } else if ( strcmp( arguments.args[0], "DBus" ) == 0 ) {439 DeviceManager *m_deviceManager = new DeviceManager();440 if ( !m_deviceManager ) {441 fprintf( stderr, "Could not allocate device manager\n" );442 return exitfunction(-1);443 }444 if ( !m_deviceManager->initialize( arguments.port ) ) {445 fprintf( stderr, "Could not initialize device manager\n" );446 delete m_deviceManager;447 return exitfunction(-1);448 }449 if ( arguments.verbose ) {450 m_deviceManager->setVerboseLevel(arguments.verbose);451 }452 if ( !m_deviceManager->discover() ) {453 fprintf( stderr, "Could not discover devices\n" );454 delete m_deviceManager;455 return exitfunction(-1);456 }457 458 signal (SIGINT, sighandler);459 460 DBus::_init_threading();461 462 // test DBUS stuff463 DBus::default_dispatcher = &dispatcher;464 465 DBus::Connection conn = DBus::Connection::SessionBus();466 conn.request_name("org.ffado.Control");467 468 DBusControl::Container *container469 = new DBusControl::Container(conn, "/org/ffado/Control/DeviceManager", *m_deviceManager);470 471 printf("DBUS test service running\n");472 printf("press ctrl-c to stop it & continue\n");473 474 dispatcher.enter();475 476 delete container;477 478 signal (SIGINT, SIG_DFL);479 480 printf("server stopped\n");481 delete m_deviceManager;482 return exitfunction(0);483 } else {484 printf( "unknown operation\n" );485 346 } 486 487 347 } 488 489 void list_osc_paths(lo_server s, lo_address t, const char *path) {490 vector<string> my_paths;491 492 printf("listing path: %s\n", path);493 494 osc_paths.clear();495 lo_server_add_method(s, "/response", NULL, osc_path_response_handler, NULL);496 497 if (lo_send(t, path, "s", "list") == -1) {498 printf(" OSC error %d: %s\n", lo_address_errno(t), lo_address_errstr(t));499 }500 501 if (lo_server_recv_noblock(s, 1000) == 0) {502 printf("timeout\n");503 return;504 }505 506 lo_server_del_method(s, "/response", NULL);507 508 list_osc_params(s, t, path);509 510 my_paths=osc_paths;511 for ( vector<string>::iterator it = my_paths.begin();512 it != my_paths.end();513 ++it )514 {515 string new_path=string(path) + *it;516 new_path += string("/");517 list_osc_paths(s, t, new_path.c_str());518 }519 520 }521 522 void list_osc_params(lo_server s, lo_address t, const char *path) {523 vector<string> my_paths;524 printf("params for: %s\n", path);525 526 osc_params.clear();527 lo_server_add_method(s, "/response", NULL, osc_param_response_handler, NULL);528 529 if (lo_send(t, path, "s", "params") == -1) {530 printf(" OSC error %d: %s\n", lo_address_errno(t), lo_address_errstr(t));531 }532 533 if (lo_server_recv_noblock(s, 1000) == 0) {534 printf("timeout\n");535 return;536 }537 538 lo_server_del_method(s, "/response", NULL);539 540 vector<string> my_params=osc_params;541 542 for ( vector<string>::iterator it = my_params.begin();543 it != my_params.end();544 ++it )545 {546 string value=osc_param_get_value(s, t, path, (*it).c_str());547 printf(" %20s = %s\n", (*it).c_str(), value.c_str());548 }549 550 }551 552 string osc_param_get_value(lo_server s, lo_address t, const char *path, const char *param) {553 lo_server_add_method(s, "/response", NULL, osc_data_response_handler, NULL);554 555 if (lo_send(t, path, "ss", "get", param) == -1) {556 printf(" OSC error %d: %s\n", lo_address_errno(t), lo_address_errstr(t));557 }558 559 if (lo_server_recv_noblock(s, 1000) == 0) {560 return string("timeout");561 }562 563 lo_server_del_method(s, "/response", NULL);564 return osc_value;565 }566 567 void osc_error_handler(int num, const char *msg, const char *path)568 {569 printf("liblo server error %d in path %s: %s\n", num, path, msg);570 }571 572 int osc_path_response_handler(const char *path, const char *types, lo_arg **argv, int argc,573 void *data, void *user_data)574 {575 for (int i=0; i< argc;i++) {576 switch (lo_type(types[i])) {577 /** Standard C, NULL terminated string. */578 case LO_STRING:579 osc_paths.push_back(string(&(argv[i]->s)));580 break;581 default:582 printf("unexpected data type in response message\n");583 }584 }585 return 1;586 }587 588 int osc_param_response_handler(const char *path, const char *types, lo_arg **argv, int argc,589 void *data, void *user_data)590 {591 for (int i=0; i< argc;i++) {592 switch (lo_type(types[i])) {593 /** Standard C, NULL terminated string. */594 case LO_STRING:595 osc_params.push_back(string(&(argv[i]->s)));596 break;597 default:598 printf("unexpected data type in response message\n");599 }600 }601 return 1;602 }603 604 int osc_data_response_handler(const char *path, const char *types, lo_arg **argv, int argc,605 void *data, void *user_data)606 {607 std::ostringstream str;608 609 if(argc==1) {610 switch (lo_type(types[0])) {611 /* basic OSC types */612 /** 32 bit signed integer. */613 case LO_INT32:614 str << "0x" << std::hex << argv[0]->i;615 osc_value=str.str();616 break;617 case LO_INT64:618 str << "0x" << std::hex << argv[0]->h;619 osc_value=str.str();620 break;621 /** 32 bit IEEE-754 float. */622 case LO_FLOAT:623 str << argv[0]->f;624 osc_value=str.str();625 break;626 /** Standard C, NULL terminated string. */627 case LO_STRING:628 osc_value=string(&argv[0]->s);629 break;630 default:631 osc_value="unsupported response datatype";632 }633 } else {634 osc_value="invalid response";635 }636 return 1;637 }