Changeset 437

Show
Ignore:
Timestamp:
03/13/07 11:22:17 (16 years ago)
Author:
pieterpalmers
Message:

- made test-freebob use debugmodule infrastructure
- test-mixer now takes a port argument

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/streaming-rework/tests/test-freebob.cpp

    r436 r437  
    134134            arguments->verbose = strtol( arg, &tail, 0 ); 
    135135            if ( errno ) { 
    136                 fprintf( stderr,  "Could not parse 'verbose' argument\n" ); 
     136                debugError(  "Could not parse 'verbose' argument\n" ); 
    137137                return ARGP_ERR_UNKNOWN; 
    138138            } 
     
    143143            arguments->port = strtol( arg, &tail, 0 ); 
    144144            if ( errno ) { 
    145                 fprintf( stderr,  "Could not parse 'port' argument\n" ); 
     145                debugError(  "Could not parse 'port' argument\n" ); 
    146146                return ARGP_ERR_UNKNOWN; 
    147147            } 
    148148        } else { 
    149149            if ( errno ) { 
    150                 fprintf( stderr, "Could not parse 'port' argumen\n" ); 
     150                debugError( "Could not parse 'port' argumen\n" ); 
    151151                return ARGP_ERR_UNKNOWN; 
    152152            } 
     
    157157            arguments->node_id = strtol( arg, &tail, 0 ); 
    158158            if ( errno ) { 
    159                 fprintf( stderr,  "Could not parse 'node' argument\n" ); 
     159                debugError(  "Could not parse 'node' argument\n" ); 
    160160                return ARGP_ERR_UNKNOWN; 
    161161            } 
     
    163163        } else { 
    164164            if ( errno ) { 
    165                 fprintf( stderr, "Could not parse 'node' argumen\n" ); 
     165                debugError( "Could not parse 'node' argumen\n" ); 
    166166                return ARGP_ERR_UNKNOWN; 
    167167            } 
     
    197197    // Default values. 
    198198    arguments.silent      = 0; 
    199     arguments.verbose     = 0
     199    arguments.verbose     = DEBUG_LEVEL_NORMAL
    200200    arguments.port        = 0; 
    201201    arguments.node_id     = 0; 
     
    207207    // be reflected in `arguments'. 
    208208    if ( argp_parse ( &argp, argc, argv, 0, 0, &arguments ) ) { 
    209         fprintf( stderr, "Could not parse command line\n" ); 
     209        debugError( "Could not parse command line\n" ); 
    210210        return -1; 
    211211    } 
    212212 
    213     printf("verbose level = %d\n", arguments.verbose); 
    214  
    215     printf( "Using freebob library version: %s\n\n", freebob_get_version() ); 
     213    setDebugLevel(arguments.verbose); 
     214 
     215    debugOutput(DEBUG_LEVEL_NORMAL, "verbose level = %d\n", arguments.verbose); 
     216 
     217    debugOutput(DEBUG_LEVEL_NORMAL,  "Using freebob library version: %s\n\n", freebob_get_version() ); 
    216218     
    217219    if ( strcmp( arguments.args[0], "Discover" ) == 0 ) { 
    218220        DeviceManager *m_deviceManager = new DeviceManager(); 
    219221        if ( !m_deviceManager ) { 
    220             fprintf( stderr, "Could not allocate device manager\n" ); 
     222            debugError( "Could not allocate device manager\n" ); 
    221223            return -1; 
    222224        } 
    223225        if ( !m_deviceManager->initialize( arguments.port ) ) { 
    224             fprintf( stderr, "Could not initialize device manager\n" ); 
     226            debugError( "Could not initialize device manager\n" ); 
    225227            delete m_deviceManager; 
    226228            return -1; 
    227229        } 
    228         if ( arguments.verbose ) { 
    229             m_deviceManager->setVerboseLevel(arguments.verbose); 
    230         } 
     230 
     231        m_deviceManager->setVerboseLevel(arguments.verbose); 
    231232        if ( !m_deviceManager->discover() ) { 
    232             fprintf( stderr, "Could not discover devices\n" ); 
     233            debugError( "Could not discover devices\n" ); 
    233234            delete m_deviceManager; 
    234235            return -1; 
    235236        } 
     237         
     238        int devices_on_bus = m_deviceManager->getNbDevices(); 
     239        debugOutput(DEBUG_LEVEL_NORMAL, "port = %d, devices_on_bus = %d\n", arguments.port, devices_on_bus); 
     240         
     241        for(int i=0;i<devices_on_bus;i++) { 
     242            int node_id=m_deviceManager->getDeviceNodeId(i); 
     243            debugOutput(DEBUG_LEVEL_NORMAL, " device = %d, node = %d\n", i, node_id); 
     244            IAvDevice* avDevice = m_deviceManager->getAvDevice( node_id ); 
     245            if ( avDevice ) { 
     246                avDevice->showDevice(); 
     247            } 
     248        } 
     249         
    236250        delete m_deviceManager; 
    237251        return 0; 
     
    240254        int samplerate = strtol( arguments.args[1], &tail, 0 ); 
    241255        if ( errno ) { 
    242             fprintf( stderr,  "Could not parse samplerate argument\n" ); 
     256            debugError(  "Could not parse samplerate argument\n" ); 
    243257            return -1; 
    244258        } 
     
    246260        DeviceManager *m_deviceManager = new DeviceManager(); 
    247261        if ( !m_deviceManager ) { 
    248             fprintf( stderr, "Could not allocate device manager\n" ); 
     262            debugError( "Could not allocate device manager\n" ); 
    249263            return -1; 
    250264        } 
    251265        if ( !m_deviceManager->initialize( arguments.port ) ) { 
    252             fprintf( stderr, "Could not initialize device manager\n" ); 
     266            debugError( "Could not initialize device manager\n" ); 
    253267            delete m_deviceManager; 
    254268            return -1; 
    255269        } 
    256         if ( arguments.verbose ) { 
    257             m_deviceManager->setVerboseLevel(arguments.verbose); 
    258         } 
     270         
     271        m_deviceManager->setVerboseLevel(arguments.verbose); 
    259272        if ( !m_deviceManager->discover() ) { 
    260             fprintf( stderr, "Could not discover devices\n" ); 
     273            debugError( "Could not discover devices\n" ); 
    261274            delete m_deviceManager; 
    262275            return -1; 
     
    266279            IAvDevice* avDevice = m_deviceManager->getAvDevice( arguments.node_id ); 
    267280            if ( avDevice ) { 
    268                 if ( avDevice->setSamplingFrequency( parseSampleRate( samplerate ) ) ) { 
     281                if ( avDevice->setSampleRate( parseSampleRate( samplerate ) ) ) { 
    269282                    m_deviceManager->discover(); 
    270283                } else { 
    271                     fprintf( stderr, "Could not set samplerate\n" ); 
     284                    debugError( "Could not set samplerate\n" ); 
    272285                } 
    273286            } 
     
    276289                 
    277290            int devices_on_bus = m_deviceManager->getNbDevices(); 
    278             printf("  port = %d, devices_on_bus = %d\n", arguments.port, devices_on_bus); 
     291            debugOutput(DEBUG_LEVEL_NORMAL, "  port = %d, devices_on_bus = %d\n", arguments.port, devices_on_bus); 
    279292     
    280293            for(i=0;i<devices_on_bus;i++) { 
    281294                int node_id=m_deviceManager->getDeviceNodeId(i); 
    282                 printf("  set samplerate for device = %d, node = %d\n", i, node_id); 
     295                debugOutput(DEBUG_LEVEL_NORMAL, "  set samplerate for device = %d, node = %d\n", i, node_id); 
    283296                IAvDevice* avDevice = m_deviceManager->getAvDevice( node_id ); 
    284297                if ( avDevice ) { 
    285                     if ( !avDevice->setSamplingFrequency( parseSampleRate( samplerate ) ) ) { 
    286                         fprintf( stderr, "Could not set samplerate\n" ); 
     298                    if ( !avDevice->setSampleRate( parseSampleRate( samplerate ) ) ) { 
     299                        debugError( "Could not set samplerate\n" ); 
    287300                    } 
    288301                } 
     
    310323        DeviceManager *m_deviceManager = new DeviceManager(); 
    311324        if ( !m_deviceManager ) { 
    312             fprintf( stderr, "Could not allocate device manager\n" ); 
     325            debugError( "Could not allocate device manager\n" ); 
    313326            return -1; 
    314327        } 
    315328        if ( !m_deviceManager->initialize( arguments.port ) ) { 
    316             fprintf( stderr, "Could not initialize device manager\n" ); 
     329            debugError( "Could not initialize device manager\n" ); 
    317330            delete m_deviceManager; 
    318331            return -1; 
    319332        } 
    320         if ( arguments.verbose ) { 
    321             m_deviceManager->setVerboseLevel(arguments.verbose); 
    322         } 
     333         
     334        m_deviceManager->setVerboseLevel(arguments.verbose); 
    323335        if ( !m_deviceManager->discover() ) { 
    324             fprintf( stderr, "Could not discover devices\n" ); 
     336            debugError( "Could not discover devices\n" ); 
    325337            delete m_deviceManager; 
    326338            return -1; 
    327339        } 
    328340 
    329         printf("server started\n"); 
    330         printf("press ctrl-c to stop it & continue\n"); 
     341        debugOutput(DEBUG_LEVEL_NORMAL, "server started\n"); 
     342        debugOutput(DEBUG_LEVEL_NORMAL, "press ctrl-c to stop it & continue\n"); 
    331343         
    332344        signal (SIGINT, sighandler); 
     
    340352        signal (SIGINT, SIG_DFL); 
    341353         
    342         printf("server stopped\n"); 
     354        debugOutput(DEBUG_LEVEL_NORMAL, "server stopped\n"); 
    343355        delete m_deviceManager; 
    344356        return 0; 
    345357         
    346358    } else { 
    347         printf( "unknown operation\n" ); 
     359        debugOutput(DEBUG_LEVEL_NORMAL, "unknown operation\n" ); 
    348360    } 
    349361 
     
    353365    vector<string> my_paths; 
    354366     
    355     printf("listing path: %s\n", path); 
     367    debugOutput(DEBUG_LEVEL_NORMAL, "listing path: %s\n", path); 
    356368     
    357369    osc_paths.clear(); 
     
    359371 
    360372    if (lo_send(t, path, "s", "list") == -1) { 
    361         printf(" OSC error %d: %s\n", lo_address_errno(t), lo_address_errstr(t)); 
     373        debugOutput(DEBUG_LEVEL_NORMAL, " OSC error %d: %s\n", lo_address_errno(t), lo_address_errstr(t)); 
    362374    } 
    363375 
    364376    if (lo_server_recv_noblock(s, 1000) == 0) { 
    365         printf("timeout\n"); 
     377        debugOutput(DEBUG_LEVEL_NORMAL, "timeout\n"); 
    366378        return; 
    367379    } 
     
    385397void list_osc_params(lo_server s, lo_address t, const char *path) { 
    386398    vector<string> my_paths; 
    387     printf("params for: %s\n", path); 
     399    debugOutput(DEBUG_LEVEL_NORMAL, "params for: %s\n", path); 
    388400     
    389401    osc_params.clear(); 
     
    391403 
    392404    if (lo_send(t, path, "s", "params") == -1) { 
    393         printf(" OSC error %d: %s\n", lo_address_errno(t), lo_address_errstr(t)); 
     405        debugOutput(DEBUG_LEVEL_NORMAL, " OSC error %d: %s\n", lo_address_errno(t), lo_address_errstr(t)); 
    394406    } 
    395407     
    396408    if (lo_server_recv_noblock(s, 1000) == 0) { 
    397         printf("timeout\n"); 
     409        debugOutput(DEBUG_LEVEL_NORMAL, "timeout\n"); 
    398410        return; 
    399411    } 
     
    408420    { 
    409421        string value=osc_param_get_value(s, t, path, (*it).c_str()); 
    410         printf("  %20s = %s\n", (*it).c_str(), value.c_str()); 
     422        debugOutput(DEBUG_LEVEL_NORMAL, "  %20s = %s\n", (*it).c_str(), value.c_str()); 
    411423    } 
    412424 
     
    417429 
    418430    if (lo_send(t, path, "ss", "get", param) == -1) { 
    419         printf(" OSC error %d: %s\n", lo_address_errno(t), lo_address_errstr(t)); 
     431        debugOutput(DEBUG_LEVEL_NORMAL, " OSC error %d: %s\n", lo_address_errno(t), lo_address_errstr(t)); 
    420432    } 
    421433     
     
    430442void osc_error_handler(int num, const char *msg, const char *path) 
    431443{ 
    432     printf("liblo server error %d in path %s: %s\n", num, path, msg); 
     444    debugOutput(DEBUG_LEVEL_NORMAL, "liblo server error %d in path %s: %s\n", num, path, msg); 
    433445} 
    434446 
     
    443455                break; 
    444456            default: 
    445                 printf("unexpected data type in response message\n"); 
     457                debugOutput(DEBUG_LEVEL_NORMAL, "unexpected data type in response message\n"); 
    446458        } 
    447459    } 
     
    459471                break; 
    460472            default: 
    461                 printf("unexpected data type in response message\n"); 
     473                debugOutput(DEBUG_LEVEL_NORMAL, "unexpected data type in response message\n"); 
    462474        } 
    463475    } 
  • branches/streaming-rework/tests/test-mixer.cpp

    r436 r437  
    7070{ 
    7171 
    72     if (argc < 2) { 
    73         printf("usage: NODE_ID FB_ID\n"); 
     72    if (argc < 3) { 
     73        printf("usage: PORT NODE_ID FB_ID\n"); 
    7474        exit(0); 
    7575    } 
     
    7777    int errno = 0; 
    7878    char* tail; 
    79     int node_id = strtol( argv[1], &tail, 0 ); 
    80     int fb_id   = strtol( argv[2], &tail, 0 ); 
     79    int port = strtol( argv[1], &tail, 0 ); 
     80    int node_id = strtol( argv[2], &tail, 0 ); 
     81    int fb_id   = strtol( argv[3], &tail, 0 ); 
    8182 
    8283    if (errno) { 
     
    8586    } 
    8687    Ieee1394Service ieee1394service; 
    87     if ( !ieee1394service.initialize( 0 ) ) { 
     88    if ( !ieee1394service.initialize( port ) ) { 
    8889        fprintf( stderr, "could not set port on ieee1394service\n" ); 
    8990        return -1;