Changeset 435

Show
Ignore:
Timestamp:
03/11/07 06:20:31 (17 years ago)
Author:
pieterpalmers
Message:

src/devicemanager:
- start OSC server for the device manager

src/devicemanager,
src/iavdevice,
src/libieee1394/configrom:
- inherit from OscNode? to become Osc'able

src/bounce,
src/libstreaming/AmdtpStreamProcessor,
src/libstreaming/AmdtpSlaveStreamProcessor:
- fixed bounce device implementation, now working

src/bebob:
- fixed midi bug

General:
- removed 'intermediate XML'
- removed obsolete tests
- removed obsolete files
- removed obsolete API calls

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/streaming-rework/configure.ac

    r414 r435  
    11# configure.ac - Configure script for FreeBoB. 
    22# Copyright (C) 2005,06 by Daniel Wagner. 
    3 # Copyright (C) 2006    by Pieter Palmers. 
     3# Copyright (C) 2006,07 by Pieter Palmers. 
    44# 
    55# This file is part of FreeBoB. 
     
    2525m4_define(freebob_major_version, 1) 
    2626m4_define(freebob_minor_version, 999) 
    27 m4_define(freebob_micro_version, 3
     27m4_define(freebob_micro_version, 4
    2828 
    2929m4_define(freebob_version, freebob_major_version.freebob_minor_version.freebob_micro_version) 
     
    117117PKG_CHECK_MODULES(LIBAVC1394, libavc1394 >= 0.5.3) 
    118118PKG_CHECK_MODULES(ALSA, alsa >= 1.0.0) 
    119 PKG_CHECK_MODULES(LIBXML, libxml-2.0 >= 2.6.0) 
    120119PKG_CHECK_MODULES(LIBXMLCPP, libxml++-2.6 >= 2.14.0) 
     120PKG_CHECK_MODULES(LIBLO, liblo >= 0.22) 
    121121 
    122122# Setup CFLAGS and CXXFLAGS 
     
    391391AC_SUBST([LIBAVC1394_CFLAGS]) 
    392392AC_SUBST([LIBAVC1394_LIBS]) 
    393 AC_SUBST([LIBXML_LIBS]) 
    394 AC_SUBST([LIBXML_CFLAGS]) 
     393AC_SUBST([LIBLO_LIBS]) 
     394AC_SUBST([LIBLO_CFLAGS]) 
    395395 
    396396AC_SUBST([BIN_PROGRAMS]) 
  • branches/streaming-rework/libfreebob/freebob.h

    r386 r435  
    11/* freebob.h 
    2  * Copyright (C) 2005 Pieter Palmers 
     2 * Copyright (C) 2005,07 Pieter Palmers 
    33 * Copyright (C) 2006 Daniel Wagner 
    44 * 
     
    4141typedef struct freebob_handle* freebob_handle_t; 
    4242 
    43 /* 
    44  * Buffer specification 
    45  */ 
    46 typedef struct _freebob_stream_spec freebob_stream_spec_t; 
    47 typedef struct _freebob_stream_info freebob_stream_info_t; 
    48 typedef struct _freebob_connection_spec freebob_connection_spec_t; 
    49 typedef struct _freebob_connection_info freebob_connection_info_t; 
    50 typedef struct _freebob_supported_stream_format_spec freebob_supported_stream_format_spec_t; 
    51 typedef struct _freebob_supported_stream_format_info freebob_supported_stream_format_info_t; 
    52  
    53 /* 
    54  * Stream specification 
    55  */ 
    56 struct _freebob_stream_spec { 
    57     int location; 
    58     int position; 
    59     int format; 
    60     int type; 
    61     int destination_port; 
    62     char name[FREEBOB_MAX_NAME_LEN]; 
    63 }; 
    64  
    65 struct _freebob_stream_info { 
    66     int nb_streams; 
    67     freebob_stream_spec_t** streams; 
    68 }; 
    69  
    70 /* 
    71  * Connection specification 
    72  */ 
    73 struct _freebob_connection_spec { 
    74     int id; 
    75     int port; 
    76     int node; 
    77     int plug; 
    78     int dimension;  /* due to the midi stuff, the dimension isn't equal */ 
    79                     /* to the number of streams */ 
    80     int samplerate; /* this should be equal for all connections when */ 
    81                     /* using jack. maybe not when using other api's */ 
    82     int iso_channel; 
    83     enum freebob_direction direction; 
    84     int is_master; 
    85     freebob_stream_info_t* stream_info; 
    86 }; 
    87  
    88 /* 
    89  * topology info 
    90  */ 
    91 struct _freebob_connection_info { 
    92     int direction; 
    93     int nb_connections; 
    94     freebob_connection_spec_t** connections; 
    95 }; 
    96  
    97 /* 
    98  * Supported stream formats 
    99  */ 
    100 struct _freebob_supported_stream_format_spec { 
    101     int samplerate; 
    102     int nb_audio_channels; 
    103     int nb_midi_channels; 
    104 }; 
    105  
    106 struct _freebob_supported_stream_format_info { 
    107     int direction; 
    108     int nb_formats; 
    109     freebob_supported_stream_format_spec_t** formats; 
    110 }; 
    111  
    112  
    11343#ifdef __cplusplus 
    11444extern "C" { 
     
    12454freebob_discover_devices( freebob_handle_t freebob_handle, int verbose_level ); 
    12555 
    126  
    127 freebob_connection_info_t* 
    128 freebob_get_connection_info( freebob_handle_t freebob_handle, 
    129                              int node_id, 
    130                              enum freebob_direction direction ); 
    131  
    132 freebob_supported_stream_format_info_t* 
    133 freebob_get_supported_stream_format_info( freebob_handle_t freebob_handle, 
    134                                           int node_id, 
    135                                           enum freebob_direction direction ); 
    136  
    137 void 
    138 freebob_free_connection_info( freebob_connection_info_t* connection_info ); 
    139 void 
    140 freebob_free_connection_spec( freebob_connection_spec_t* connection_spec ); 
    141 void 
    142 freebob_free_stream_info( freebob_stream_info_t* stream_info ); 
    143 void 
    144 freebob_free_stream_spec( freebob_stream_spec_t* stream_spec ); 
    145 void 
    146 freebob_free_supported_stream_format_info( freebob_supported_stream_format_info_t* stream_info ); 
    147 void 
    148 freebob_free_supported_stream_format_spec( freebob_supported_stream_format_spec_t* stream_spec ); 
    149  
    150  
    151  
    152 void 
    153 freebob_print_connection_info( freebob_connection_info_t* connection_info ); 
    154 void 
    155 freebob_print_supported_stream_format_info( freebob_supported_stream_format_info_t* stream_info ); 
    156  
    15756int freebob_node_is_valid_freebob_device(freebob_handle_t fb_handle, int node_id); 
    15857int freebob_get_nb_devices_on_bus(freebob_handle_t fb_handle); 
     
    16160int freebob_set_samplerate(freebob_handle_t freebob_handle, int node_id, int samplerate); 
    16261 
    163 /* debug function */ 
    164 void 
    165 freebob_print_xml_description( freebob_handle_t freebob_handle, 
    166                                int node_id, 
    167                                enum freebob_direction direction ); 
    168  
     62/* ABI stuff */ 
    16963const char* 
    17064freebob_get_version(); 
  • branches/streaming-rework/libfreebob/freebob_streaming.h

    r424 r435  
    451451int freebob_streaming_transfer_capture_buffers(freebob_device_t *dev); 
    452452 
    453 /** 
    454  * Returns the packetizer thread to allow RT enabling by the host. 
    455  *  
    456  * @param dev the freebob device 
    457  * 
    458  * @return the thread. 
    459  */ 
    460 pthread_t freebob_streaming_get_packetizer_thread(freebob_device_t *dev); 
    461  
    462  
    463453#ifdef __cplusplus 
    464454} 
  • branches/streaming-rework/libfreebob/Makefile.am

    r336 r435  
    1919libfreebobincludedir = $(includedir)/libfreebob 
    2020 
    21 libfreebobinclude_HEADERS = freebob.h freebob_streaming.h xmlparser.h freebob_bounce.h 
     21libfreebobinclude_HEADERS = freebob.h freebob_streaming.h 
  • branches/streaming-rework/src/bebob/bebob_avdevice.cpp

    r426 r435  
    11021102                        // and how to handle this (pp: here) 
    11031103                        channelInfo->m_streamPosition - 1, 
    1104                         channelInfo->m_location
     1104                        channelInfo->m_location - 1
    11051105                        Streaming::AmdtpPortInfo::E_MBLA 
    11061106                ); 
     
    11151115                        // and how to handle this (pp: here) 
    11161116                        channelInfo->m_streamPosition - 1, 
    1117                         channelInfo->m_location
     1117                        channelInfo->m_location - 1
    11181118                        Streaming::AmdtpPortInfo::E_Midi 
    11191119                ); 
  • branches/streaming-rework/src/bebob/bebob_avdevice.h

    r426 r435  
    2626#include "libavc/avc_definitions.h" 
    2727#include "libavc/avc_extended_cmd_generic.h" 
    28 #include "libfreebob/xmlparser.h" 
    2928 
    3029#include "bebob/bebob_avplug.h" 
  • branches/streaming-rework/src/bebob/bebob_avplug.h

    r420 r435  
    2828#include "libavc/avc_definitions.h" 
    2929#include "libavc/avc_generic.h" 
    30 #include "libfreebob/xmlparser.h" 
    3130 
    3231#include "libutil/serialize.h" 
     
    130129    const AvPlugVector& getOutputConnections() const 
    131130        { return m_outputConnections; } 
    132  
    133     bool addXmlDescription( xmlNodePtr conectionSet ); 
    134     bool addXmlDescriptionStreamFormats( xmlNodePtr streamFormats ); 
    135131 
    136132    static PlugAddress::EPlugDirection convertPlugDirection( 
  • branches/streaming-rework/src/bounce/bounce_avdevice.cpp

    r426 r435  
    162162} 
    163163 
    164 #define BOUNCE_NR_OF_CHANNELS 2 
    165  
    166164bool 
    167165BounceDevice::addPortsToProcessor( 
     
    177175     
    178176    int i=0; 
    179     for (i=0;i<BOUNCE_NR_OF_CHANNELS;i++) { 
     177    for (i=0;i<BOUNCE_NB_AUDIO_CHANNELS;i++) { 
    180178        char *buff; 
    181         asprintf(&buff,"%s%s_Port%d",id.c_str(),direction==Streaming::AmdtpAudioPort::E_Playback?"p":"c",i); 
     179        asprintf(&buff,"%s%s_Port%d",id.c_str(),direction==Streaming::Port::E_Playback?"p":"c",i); 
    182180 
    183181        Streaming::Port *p=NULL; 
     
    205203            } 
    206204        } 
    207  
    208205        free(buff); 
    209  
     206    } 
     207     
     208    for (i=0;i<BOUNCE_NB_MIDI_CHANNELS;i++) { 
     209        char *buff; 
     210        asprintf(&buff,"%s_Midi%s%d",id.c_str(),direction==Streaming::Port::E_Playback?"Out":"In",i); 
     211 
     212        Streaming::Port *p=NULL; 
     213        p=new Streaming::AmdtpMidiPort( 
     214                buff, 
     215                direction, 
     216                // \todo: streaming backend expects indexing starting from 0 
     217                // but bebob reports it starting from 1. Decide where 
     218                // and how to handle this (pp: here) 
     219                BOUNCE_NB_AUDIO_CHANNELS, 
     220                i, 
     221                Streaming::AmdtpPortInfo::E_Midi 
     222        ); 
     223 
     224        if (!p) { 
     225            debugOutput(DEBUG_LEVEL_VERBOSE, "Skipped port %s\n",buff); 
     226        } else { 
     227 
     228            if (!processor->addPort(p)) { 
     229                debugWarning("Could not register port with stream processor\n"); 
     230                free(buff); 
     231                return false; 
     232            } else { 
     233                debugOutput(DEBUG_LEVEL_VERBOSE, "Added port %s\n",buff); 
     234            } 
     235        } 
     236        free(buff); 
    210237     } 
    211238 
     
    228255                             m_p1394Service->getPort(), 
    229256                             m_samplerate, 
    230                              BOUNCE_NR_OF_CHANNELS); 
     257                             BOUNCE_NB_AUDIO_CHANNELS+(BOUNCE_NB_MIDI_CHANNELS?1:0)); 
    231258 
    232259    if(!p->init()) { 
     
    249276        // we are snooping, so this is receive too. 
    250277        p=new Streaming::AmdtpReceiveStreamProcessor( 
    251                                   m_p1394Service->getPort(), 
    252                                   m_samplerate, 
    253                                   BOUNCE_NR_OF_CHANNELS); 
     278                                m_p1394Service->getPort(), 
     279                                m_samplerate, 
     280                                BOUNCE_NB_AUDIO_CHANNELS+(BOUNCE_NB_MIDI_CHANNELS?1:0)); 
    254281    } else { 
    255282        p=new Streaming::AmdtpTransmitStreamProcessor( 
    256283                                m_p1394Service->getPort(), 
    257284                                m_samplerate, 
    258                                 BOUNCE_NR_OF_CHANNELS); 
     285                                BOUNCE_NB_AUDIO_CHANNELS+(BOUNCE_NB_MIDI_CHANNELS?1:0)); 
    259286    } 
    260287     
  • branches/streaming-rework/src/bounce/bounce_avdevice.h

    r426 r435  
    2525#include "libavc/avc_definitions.h" 
    2626#include "libavc/avc_extended_cmd_generic.h" 
    27 #include "libfreebob/xmlparser.h" 
    2827 
    2928#include "libstreaming/AmdtpStreamProcessor.h" 
     
    3433 
    3534#include "iavdevice.h" 
    36 #include "libfreebob/freebob_bounce.h" 
    3735 
    3836#include <vector> 
     
    4341#define BOUNCE_REGISTER_RX_ISOCHANNEL 0x14 
    4442#define BOUNCE_INVALID_OFFSET 0xFFFFF00000000000ULL 
     43 
     44#define BOUNCE_NB_AUDIO_CHANNELS 4 
     45 
     46// don't define more than 8 midi channels! 
     47#define BOUNCE_NB_MIDI_CHANNELS  2 
    4548 
    4649class ConfigRom; 
  • branches/streaming-rework/src/bounce/bounce_slave_avdevice.cpp

    r426 r435  
    2626 * 
    2727 */ 
     28 
     29#include "libstreaming/AmdtpSlaveStreamProcessor.h" 
     30 
    2831#include "libieee1394/configrom.h" 
    2932#include "libieee1394/ieee1394service.h" 
    3033 
    3134#include "bounce_slave_avdevice.h" 
    32 #include "libfreebob/freebob_bounce.h" 
    3335 
    3436#include <libraw1394/raw1394.h> 
     
    174176bool 
    175177BounceSlaveDevice::prepare() { 
    176     // snooping does not make sense for a slave device 
    177     setOption("snoopMode", false); 
    178      
    179     // prepare the base class 
    180     // FIXME: when doing proper discovery this won't work anymore 
    181     //        as it relies on a completely symmetric transmit/receive 
    182     if(!BounceDevice::prepare()) { 
    183         debugError("Base class preparation failed\n"); 
    184         return false; 
    185     } 
    186      
    187     // do any customisations here 
    188      
     178    debugOutput(DEBUG_LEVEL_NORMAL, "Preparing BounceSlaveDevice...\n" ); 
     179     
     180    // create & add streamprocessors 
     181    Streaming::StreamProcessor *p; 
     182     
     183    p=new Streaming::AmdtpSlaveReceiveStreamProcessor( 
     184                             m_p1394Service->getPort(), 
     185                             m_samplerate, 
     186                             BOUNCE_NB_AUDIO_CHANNELS); 
     187 
     188    if(!p->init()) { 
     189        debugFatal("Could not initialize receive processor!\n"); 
     190        delete p; 
     191        return false; 
     192    } 
     193 
     194    if (!addPortsToProcessor(p, 
     195            Streaming::Port::E_Capture)) { 
     196        debugFatal("Could not add plug to processor!\n"); 
     197        delete p; 
     198        return false; 
     199    } 
     200 
     201    m_receiveProcessors.push_back(p); 
     202 
     203    // do the transmit processor 
     204    p=new Streaming::AmdtpSlaveTransmitStreamProcessor( 
     205                                m_p1394Service->getPort(), 
     206                                m_samplerate, 
     207                                BOUNCE_NB_AUDIO_CHANNELS); 
     208     
     209    if(!p->init()) { 
     210        debugFatal("Could not initialize transmit processor!\n"); 
     211        delete p; 
     212        return false; 
     213    } 
     214 
     215    if (!addPortsToProcessor(p, 
     216        Streaming::Port::E_Playback)) { 
     217        debugFatal("Could not add plug to processor!\n"); 
     218        delete p; 
     219        return false; 
     220    } 
     221    m_transmitProcessors.push_back(p); 
     222 
    189223    return true; 
    190224} 
  • branches/streaming-rework/src/bounce/bounce_slave_avdevice.h

    r426 r435  
    3131#include "debugmodule/debugmodule.h" 
    3232#include "bounce_avdevice.h" 
     33 
     34#define FREEBOB_MAX_NAME_LEN 256 
     35 
     36#define FREEBOB_BOUNCE_SERVER_VENDORNAME  "FreeBoB Server" 
     37#define FREEBOB_BOUNCE_SERVER_MODELNAME   "freebob-server" 
     38 
     39// NOTE: this is currently free, but it is not really allowed to use 
     40#define FREEBOB_BOUNCE_SERVER_VENDORID    0x000B0001 
     41#define FREEBOB_BOUNCE_SERVER_MODELID     0x000B0001 
     42#define FREEBOB_BOUNCE_SERVER_SPECID      0x000B0001 
    3343 
    3444namespace Bounce { 
  • branches/streaming-rework/src/devicemanager.cpp

    r426 r435  
    6767 
    6868DeviceManager::DeviceManager() 
    69     : m_1394Service( 0 ) 
     69    : OscNode("devicemanager") 
     70    , m_1394Service( 0 ) 
     71    , m_oscServer( NULL ) 
    7072{ 
    7173    addOption(Util::OptionContainer::Option("slaveMode",false)); 
     
    7577DeviceManager::~DeviceManager() 
    7678{ 
     79    if (m_oscServer) { 
     80        m_oscServer->stop(); 
     81        delete m_oscServer; 
     82    } 
     83 
    7784    for ( IAvDeviceVectorIterator it = m_avDevices.begin(); 
    7885          it != m_avDevices.end(); 
     
    100107        return false; 
    101108    } 
     109     
     110    m_oscServer = new OSC::OscServer("17820"); 
     111     
     112    if (!m_oscServer) { 
     113        debugFatal("failed to create osc server\n"); 
     114        delete m_1394Service; 
     115        m_1394Service = 0; 
     116        return false; 
     117    } 
     118     
     119    if (!m_oscServer->init()) { 
     120        debugFatal("failed to init osc server\n"); 
     121        delete m_oscServer; 
     122        m_oscServer = NULL; 
     123        delete m_1394Service; 
     124        m_1394Service = 0; 
     125        return false; 
     126    } 
     127     
     128    if (!m_oscServer->registerAtRootNode(this)) { 
     129        debugFatal("failed to register devicemanager at server\n"); 
     130        delete m_oscServer; 
     131        m_oscServer = NULL; 
     132        delete m_1394Service; 
     133        m_1394Service = 0; 
     134        return false; 
     135    } 
     136     
     137    if (!m_oscServer->start()) { 
     138        debugFatal("failed to start osc server\n"); 
     139        delete m_oscServer; 
     140        m_oscServer = NULL; 
     141        delete m_1394Service; 
     142        m_1394Service = 0; 
     143        return false; 
     144    } 
    102145 
    103146    return true; 
     
    123166          ++it ) 
    124167    { 
     168        if (!removeChildOscNode(*it)) { 
     169            debugWarning("failed to unregister AvDevice from OSC server\n"); 
     170        } 
    125171        delete *it; 
    126172    } 
     
    190236 
    191237                m_avDevices.push_back( avDevice ); 
     238                 
     239                if (!addChildOscNode(avDevice)) { 
     240                    debugWarning("failed to register AvDevice at OSC server\n"); 
     241                } 
     242 
    192243            } 
    193244        } 
     
    405456    } 
    406457     
    407 } 
    408  
    409 xmlDocPtr 
    410 DeviceManager::getXmlDescription() 
    411 { 
    412     xmlDocPtr doc = xmlNewDoc( BAD_CAST "1.0" ); 
    413     if ( !doc ) { 
    414         debugError( "Couldn't create new xml doc\n" ); 
    415         return 0; 
    416     } 
    417  
    418     xmlNodePtr rootNode = xmlNewNode( 0,  BAD_CAST "FreeBoBConnectionInfo" ); 
    419     if ( !rootNode ) { 
    420         debugError( "Couldn't create root node\n" ); 
    421         xmlFreeDoc( doc ); 
    422         xmlCleanupParser(); 
    423         return 0; 
    424     } 
    425     xmlDocSetRootElement( doc, rootNode ); 
    426  
    427     for ( IAvDeviceVectorIterator it = m_avDevices.begin(); 
    428           it != m_avDevices.end(); 
    429           ++it ) 
    430     { 
    431         IAvDevice* avDevice = *it; 
    432  
    433         xmlNodePtr deviceNode = xmlNewChild( rootNode, 0, 
    434                                              BAD_CAST "Device", 0 ); 
    435         if ( !deviceNode ) { 
    436             debugError( "Couldn't create device node\n" ); 
    437             xmlFreeDoc( doc ); 
    438             xmlCleanupParser(); 
    439             return 0; 
    440         } 
    441  
    442         char* result; 
    443         asprintf( &result, "%d", avDevice->getConfigRom().getNodeId() ); 
    444         if ( !xmlNewChild( deviceNode,  0, 
    445                            BAD_CAST "NodeId",  BAD_CAST result ) ) 
    446         { 
    447             debugError( "Couldn't create 'NodeId' node" ); 
    448             free(result); 
    449             return 0; 
    450         } 
    451         free( result ); 
    452  
    453         std::string res = "Connection Information for " 
    454                           + avDevice->getConfigRom().getVendorName() 
    455                           +", " 
    456                           + avDevice->getConfigRom().getModelName() 
    457                           + " configuration"; 
    458         if ( !xmlNewChild( deviceNode, 
    459                            0, 
    460                            BAD_CAST "Comment", 
    461                            BAD_CAST res.c_str() ) ) { 
    462             debugError( "Couldn't create comment node\n" ); 
    463             xmlFreeDoc( doc ); 
    464             xmlCleanupParser(); 
    465             free(result); 
    466             return 0; 
    467         } 
    468  
    469         res = avDevice->getConfigRom().getVendorName(); 
    470  
    471         if ( !xmlNewChild( deviceNode, 
    472                            0, 
    473                            BAD_CAST "Vendor", 
    474                            BAD_CAST res.c_str() ) ) { 
    475             debugError( "Couldn't create vendor node\n" ); 
    476             xmlFreeDoc( doc ); 
    477             xmlCleanupParser(); 
    478             free(result); 
    479             return 0; 
    480         } 
    481  
    482         res = avDevice->getConfigRom().getModelName(); 
    483  
    484         if ( !xmlNewChild( deviceNode, 
    485                            0, 
    486                            BAD_CAST "Model", 
    487                            BAD_CAST res.c_str() ) ) { 
    488             debugError( "Couldn't create model node\n" ); 
    489             xmlFreeDoc( doc ); 
    490             xmlCleanupParser(); 
    491             free(result); 
    492             return 0; 
    493         } 
    494  
    495         asprintf( &result, "%08x%08x", 
    496                   ( quadlet_t )( avDevice->getConfigRom().getGuid() >> 32 ), 
    497                   ( quadlet_t )( avDevice->getConfigRom().getGuid() & 0xfffffff ) ); 
    498         if ( !xmlNewChild( deviceNode,  0, 
    499                            BAD_CAST "GUID",  BAD_CAST result ) ) { 
    500             debugError( "Couldn't create 'GUID' node\n" ); 
    501             xmlFreeDoc( doc ); 
    502             xmlCleanupParser(); 
    503  
    504             free(result); 
    505             return 0; 
    506         } 
    507         free( result ); 
    508  
    509  
    510         if ( !avDevice->addXmlDescription( deviceNode ) ) { 
    511             debugError( "Adding XML description failed\n" ); 
    512             xmlFreeDoc( doc ); 
    513             xmlCleanupParser(); 
    514             free(result); 
    515             return 0; 
    516         } 
    517  
    518     } 
    519  
    520     return doc; 
    521458} 
    522459 
  • branches/streaming-rework/src/devicemanager.h

    r426 r435  
    2424#include "debugmodule/debugmodule.h" 
    2525 
    26 #include "libfreebob/xmlparser.h" 
     26#include "libieee1394/configrom.h" 
     27#include "libieee1394/ieee1394service.h" 
     28 
    2729#include "libutil/OptionContainer.h" 
     30#include "libosc/OscServer.h" 
     31#include "libosc/OscNode.h" 
    2832 
    2933#include <glibmm/ustring.h> 
     
    4044typedef std::vector< IAvDevice* >::iterator IAvDeviceVectorIterator; 
    4145 
    42 class ConfigRom; 
    43  
    44  
    45 class DeviceManager : public Util::OptionContainer
    46  public: 
     46class DeviceManager  
     47    : public Util::OptionContainer, 
     48      public OSC::OscNode 
     49
     50public: 
    4751    DeviceManager(); 
    4852    ~DeviceManager(); 
     
    6165    unsigned int getAvDeviceCount(); 
    6266 
    63     xmlDocPtr getXmlDescription(); 
    64  
    6567    bool saveCache( Glib::ustring fileName ); 
    6668    bool loadCache( Glib::ustring fileName ); 
     
    7678    Ieee1394Service* m_1394Service; 
    7779    IAvDeviceVector  m_avDevices; 
     80     
     81    OSC::OscServer*  m_oscServer; 
    7882 
    7983    DECLARE_DEBUG_MODULE; 
  • branches/streaming-rework/src/freebob.cpp

    r420 r435  
    2323 
    2424#include "libfreebob/freebob.h" 
    25 #include "libfreebob/xmlparser.h" 
    2625 
    2726#include "debugmodule/debugmodule.h" 
     
    3534#include <stdlib.h> 
    3635#include <string.h> 
    37 #include <libxml/xmlmemory.h> 
    38 #include <libxml/parser.h> 
    3936 
    4037DECLARE_GLOBAL_DEBUG_MODULE; 
     
    109106} 
    110107 
    111 freebob_connection_info_t* 
    112 freebob_get_connection_info( freebob_handle_t freebob_handle, 
    113                              int node_id, 
    114                              enum freebob_direction direction ) 
    115 { 
    116     xmlDocPtr doc; 
    117     doc = freebob_handle->m_deviceManager->getXmlDescription(); 
    118     if ( !doc ) { 
    119         debugFatal( "Could not get XML description\n" ); 
    120         return 0; 
    121     } 
    122  
    123     return freebob_xmlparse_get_connection_info( doc, node_id, direction ); 
    124 } 
    125  
    126 freebob_supported_stream_format_info_t* 
    127 freebob_get_supported_stream_format_info( freebob_handle_t freebob_handle, 
    128                                           int node_id, 
    129                                           enum freebob_direction direction ) 
    130 { 
    131     xmlDocPtr doc; 
    132     doc = freebob_handle->m_deviceManager->getXmlDescription(); 
    133     if ( !doc ) { 
    134         debugFatal( "Could not get XML description\n" ); 
    135         return 0; 
    136     } 
    137  
    138     return freebob_xmlparse_get_stream_formats( doc, node_id, direction ); 
    139 } 
    140  
    141108int 
    142109freebob_node_is_valid_freebob_device( freebob_handle_t freebob_handle, int node_id ) 
     
    169136} 
    170137 
    171 void 
    172 freebob_free_connection_info( freebob_connection_info_t* connection_info ) 
    173 { 
    174     if ( !connection_info ) { 
    175         return; 
    176     } 
    177  
    178     for ( int i = 0; i < connection_info->nb_connections; ++i ) { 
    179         freebob_free_connection_spec( connection_info->connections[i] ); 
    180     } 
    181  
    182     free( connection_info->connections ); 
    183     free( connection_info ); 
    184 } 
    185  
    186 void 
    187 freebob_free_connection_spec( freebob_connection_spec_t* connection_spec ) 
    188 { 
    189     if ( !connection_spec ) { 
    190         return; 
    191     } 
    192  
    193     freebob_free_stream_info( connection_spec->stream_info ); 
    194     free( connection_spec ); 
    195 } 
    196  
    197 void freebob_free_stream_info( freebob_stream_info_t* stream_info ) 
    198 { 
    199     if ( !stream_info ) { 
    200         return; 
    201     } 
    202  
    203     for ( int i = 0; i < stream_info->nb_streams; ++i ) { 
    204         freebob_free_stream_spec( stream_info->streams[i] ); 
    205     } 
    206  
    207     free(stream_info->streams); 
    208     free(stream_info); 
    209 } 
    210  
    211 void freebob_free_stream_spec( freebob_stream_spec_t* stream_spec ) 
    212 { 
    213     if ( !stream_spec ) { 
    214         return; 
    215     } 
    216  
    217     free( stream_spec ); 
    218 } 
    219  
    220 void 
    221 freebob_free_supported_stream_format_info( freebob_supported_stream_format_info_t* stream_info ) 
    222 { 
    223     if ( !stream_info ) { 
    224         return; 
    225     } 
    226  
    227     for ( int i = 0; i < stream_info->nb_formats; ++i ) { 
    228         freebob_free_supported_stream_format_spec( stream_info->formats[i] ); 
    229     } 
    230  
    231     free(stream_info->formats); 
    232     free(stream_info); 
    233 } 
    234  
    235 void 
    236 freebob_free_supported_stream_format_spec( freebob_supported_stream_format_spec_t* stream_spec ) 
    237 { 
    238     if ( !stream_spec ) { 
    239         return; 
    240     } 
    241  
    242     free( stream_spec ); 
    243 } 
    244  
    245 void 
    246 freebob_print_connection_info( freebob_connection_info_t* connection_info ) 
    247 { 
    248     if ( !connection_info ) { 
    249         fprintf( stderr, "connection_info==NULL\n" ); 
    250         return; 
    251     } 
    252  
    253     printf( "Direction:              %d (%s)\n\n", connection_info->direction, 
    254             connection_info->direction? "playback" : "capture" ); 
    255  
    256     puts( "Connection Info" ); 
    257     puts( "===============\n" ); 
    258  
    259     printf("Number of connections:  %d\n\n", 
    260            connection_info->nb_connections ); 
    261  
    262     for ( int i = 0; i < connection_info->nb_connections; ++i) { 
    263         freebob_connection_spec_t* connection_spec 
    264             = connection_info->connections[i]; 
    265  
    266  
    267         if ( connection_spec ) { 
    268             printf( "  Connection %2d\n", i ); 
    269             printf( "  -------------\n" ); 
    270             printf( "    [%2d] Id:         %d\n", i, connection_spec->id ); 
    271             printf( "    [%2d] Port:       %d\n", i, connection_spec->port ); 
    272             printf( "    [%2d] Node:       %d\n", i, connection_spec->node ); 
    273             printf( "    [%2d] Plug:       %d\n", i, connection_spec->plug ); 
    274             printf( "    [%2d] Dimension:  %d\n", i, connection_spec->dimension ); 
    275             printf( "    [%2d] Samplerate: %d\n", i, connection_spec->samplerate ); 
    276             printf( "    [%2d] IsoChannel: %d\n", i, connection_spec->iso_channel ); 
    277             printf( "    [%2d] IsMaster:   %d\n", i, connection_spec->is_master ); 
    278  
    279             if ( connection_info->connections[i]->stream_info ) { 
    280                 printf("    [%2d] Number of stream infos: %d\n\n", 
    281                        i, connection_spec->stream_info->nb_streams ); 
    282  
    283                 printf("    StreamId  Position Location Format Type DPort Name\n"); 
    284                 printf("    --------------------------------------------------\n"); 
    285  
    286                 for ( int j = 0; 
    287                       j < connection_spec->stream_info->nb_streams; 
    288                       ++j ) 
    289                 { 
    290                     freebob_stream_spec_t* stream_spec 
    291                         = connection_spec->stream_info->streams[j]; 
    292  
    293                     printf("    [%2d]:[%2d] " 
    294                            "0x%02x     0x%02x     0x%02x   0x%02x 0x%02x  %s\n", 
    295                            i, j, 
    296                            stream_spec->position, 
    297                            stream_spec->location, 
    298                            stream_spec->format, 
    299                            stream_spec->type, 
    300                            stream_spec->destination_port, 
    301                            stream_spec->name ); 
    302                 } 
    303             } 
    304         } 
    305         printf( "\n" ); 
    306     } 
    307  
    308     return; 
    309 } 
    310  
    311 void 
    312 freebob_print_supported_stream_format_info( freebob_supported_stream_format_info_t* stream_info ) 
    313 { 
    314     if ( !stream_info ) { 
    315         fprintf( stderr, "stream_info==NULL\n" ); 
    316         return; 
    317     } 
    318  
    319     printf( "Direction:              %d (%s)\n\n", stream_info->direction, 
    320             stream_info->direction? "playback" : "capture" ); 
    321  
    322     printf( "Samplerate AudioChannels MidiChannels\n" ); 
    323     printf( "-------------------------------------\n" ); 
    324     for ( int i = 0; i < stream_info->nb_formats; ++i) { 
    325         freebob_supported_stream_format_spec_t* format_spec 
    326             = stream_info->formats[i]; 
    327  
    328         if ( format_spec ) { 
    329             printf( "%05d      %02d            %02d\n", 
    330                     format_spec->samplerate, 
    331                     format_spec->nb_audio_channels, 
    332                     format_spec->nb_midi_channels ); 
    333         } 
    334     } 
    335  
    336     return; 
    337 } 
    338  
    339 /* debug function */ 
    340 void 
    341 freebob_print_xml_description( freebob_handle_t freebob_handle, 
    342                              int node_id, 
    343                              enum freebob_direction direction ) 
    344 { 
    345     xmlDocPtr doc; 
    346     doc = freebob_handle->m_deviceManager->getXmlDescription(); 
    347     if ( !doc ) { 
    348         debugFatal( "Could not get XML description\n" ); 
    349         return; 
    350     } 
    351  
    352     xmlChar* xmlbuff; 
    353     int buffersize; 
    354     xmlDocDumpFormatMemory( doc, &xmlbuff, &buffersize, 1 ); 
    355  
    356         printf("%s\n",(char *)xmlbuff); 
    357  
    358         xmlFree(xmlbuff); 
    359         xmlFree(doc); 
    360     return; 
    361 } 
    362  
    363138void freebob_sleep_after_avc_command( int time ) 
    364139{ 
  • branches/streaming-rework/src/freebob_streaming.cpp

    r424 r435  
    3333*/ 
    3434 
     35#include "libfreebob/freebob.h" 
    3536#include "libfreebob/freebob_streaming.h" 
    3637#include "devicemanager.h" 
     
    5354 
    5455struct _freebob_device 
    55 {       
    56         DeviceManager * m_deviceManager; 
    57         StreamProcessorManager *processorManager; 
    58  
    59         freebob_options_t options; 
    60         freebob_device_info_t device_info; 
     56{ 
     57    DeviceManager * m_deviceManager; 
     58    StreamProcessorManager *processorManager; 
     59 
     60    freebob_options_t options; 
     61    freebob_device_info_t device_info; 
    6162};  
    6263 
    6364freebob_device_t *freebob_streaming_init (freebob_device_info_t *device_info, freebob_options_t options) { 
    64         unsigned int i=0; 
    65  
    66         struct _freebob_device *dev = new struct _freebob_device; 
    67  
    68         debugFatal("%s built %s %s\n", freebob_get_version(), __DATE__, __TIME__); 
    69  
    70         if(!dev) { 
    71                 debugFatal( "Could not allocate streaming device\n" ); 
    72                 return 0; 
    73         } 
    74  
    75         memcpy((void *)&dev->options, (void *)&options, sizeof(dev->options)); 
    76         memcpy((void *)&dev->device_info, (void *)device_info, sizeof(dev->device_info)); 
    77  
    78         dev->m_deviceManager = new DeviceManager(); 
    79         if ( !dev->m_deviceManager ) { 
    80                 debugFatal( "Could not allocate device manager\n" ); 
    81                 delete dev; 
    82                 return 0; 
    83         } 
    84         if ( !dev->m_deviceManager->initialize( dev->options.port ) ) { 
    85                 debugFatal( "Could not initialize device manager\n" ); 
    86                 delete dev->m_deviceManager; 
    87                 delete dev; 
    88                 return 0; 
    89         } 
    90  
    91         // create a processor manager to manage the actual stream 
    92         // processors    
    93         dev->processorManager = new StreamProcessorManager(dev->options.period_size,dev->options.nb_buffers); 
    94         if(!dev->processorManager) { 
    95                 debugFatal("Could not create StreamProcessorManager\n"); 
    96                 delete dev->m_deviceManager; 
    97                 delete dev; 
    98                 return 0; 
    99         } 
    100          
    101         dev->processorManager->setThreadParameters(dev->options.realtime, dev->options.packetizer_priority); 
    102          
    103         dev->processorManager->setVerboseLevel(DEBUG_LEVEL_VERBOSE); 
    104         if(!dev->processorManager->init()) { 
    105                 debugFatal("Could not init StreamProcessorManager\n"); 
     65    unsigned int i=0; 
     66 
     67    struct _freebob_device *dev = new struct _freebob_device; 
     68 
     69    debugFatal("%s built %s %s\n", freebob_get_version(), __DATE__, __TIME__); 
     70 
     71    if(!dev) { 
     72            debugFatal( "Could not allocate streaming device\n" ); 
     73            return 0; 
     74    } 
     75 
     76    memcpy((void *)&dev->options, (void *)&options, sizeof(dev->options)); 
     77    memcpy((void *)&dev->device_info, (void *)device_info, sizeof(dev->device_info)); 
     78 
     79    dev->m_deviceManager = new DeviceManager(); 
     80    if ( !dev->m_deviceManager ) { 
     81            debugFatal( "Could not allocate device manager\n" ); 
     82            delete dev; 
     83            return 0; 
     84    } 
     85    if ( !dev->m_deviceManager->initialize( dev->options.port ) ) { 
     86            debugFatal( "Could not initialize device manager\n" ); 
     87            delete dev->m_deviceManager; 
     88            delete dev; 
     89            return 0; 
     90    } 
     91 
     92    // create a processor manager to manage the actual stream 
     93    // processors        
     94    dev->processorManager = new StreamProcessorManager(dev->options.period_size,dev->options.nb_buffers); 
     95    if(!dev->processorManager) { 
     96            debugFatal("Could not create StreamProcessorManager\n"); 
     97            delete dev->m_deviceManager; 
     98            delete dev; 
     99            return 0; 
     100    } 
     101     
     102    dev->processorManager->setThreadParameters(dev->options.realtime, dev->options.packetizer_priority); 
     103     
     104    dev->processorManager->setVerboseLevel(DEBUG_LEVEL_VERBOSE); 
     105    if(!dev->processorManager->init()) { 
     106            debugFatal("Could not init StreamProcessorManager\n"); 
     107            delete dev->processorManager; 
     108            delete dev->m_deviceManager; 
     109            delete dev; 
     110            return 0; 
     111    } 
     112     
     113    // set slave mode option 
     114    bool slaveMode=(dev->options.slave_mode != 0); 
     115    debugOutput(DEBUG_LEVEL_VERBOSE, "setting slave mode to %d\n", slaveMode); 
     116    if(!dev->m_deviceManager->setOption("slaveMode", slaveMode)) { 
     117            debugWarning("Failed to set slave mode option\n"); 
     118    } 
     119    // set snoop mode option 
     120    bool snoopMode=(dev->options.snoop_mode != 0); 
     121    debugOutput(DEBUG_LEVEL_VERBOSE, "setting snoop mode to %d\n", snoopMode); 
     122    if(!dev->m_deviceManager->setOption("snoopMode", snoopMode)) { 
     123            debugWarning("Failed to set snoop mode option\n"); 
     124    } 
     125     
     126    // discover the devices on the bus 
     127    if(!dev->m_deviceManager->discover(DEBUG_LEVEL_NORMAL)) { 
     128            debugFatal("Could not discover devices\n"); 
     129            delete dev->processorManager; 
     130            delete dev->m_deviceManager; 
     131            delete dev; 
     132            return 0; 
     133    } 
     134     
     135    // are there devices on the bus? 
     136    if(dev->m_deviceManager->getAvDeviceCount()==0) { 
     137            debugFatal("There are no devices on the bus\n"); 
     138            delete dev->processorManager; 
     139            delete dev->m_deviceManager; 
     140            delete dev; 
     141            return 0; 
     142    } 
     143     
     144    // iterate over the found devices 
     145    // add the stream processors of the devices to the managers 
     146    for(i=0;i<dev->m_deviceManager->getAvDeviceCount();i++) { 
     147        IAvDevice *device=dev->m_deviceManager->getAvDeviceByIndex(i); 
     148        assert(device); 
     149 
     150        debugOutput(DEBUG_LEVEL_VERBOSE, "Locking device (%p)\n", device); 
     151         
     152        if (!device->lock()) { 
     153            debugWarning("Could not lock device, skipping device (%p)!\n", device); 
     154            continue; 
     155        } 
     156         
     157        debugOutput(DEBUG_LEVEL_VERBOSE, "Setting samplerate to %d for (%p)\n",  
     158                    dev->options.sample_rate, device); 
     159                     
     160        // Set the device's sampling rate to that requested 
     161        // FIXME: does this really belong here?  If so we need to handle errors. 
     162        if (!device->setSamplingFrequency(parseSampleRate(dev->options.sample_rate))) { 
     163            debugOutput(DEBUG_LEVEL_VERBOSE, " => Retry setting samplerate to %d for (%p)\n",  
     164                        dev->options.sample_rate, device); 
     165         
     166            // try again: 
     167            if (!device->setSamplingFrequency(parseSampleRate(dev->options.sample_rate))) { 
    106168                delete dev->processorManager; 
    107169                delete dev->m_deviceManager; 
    108170                delete dev; 
     171                debugFatal("Could not set sampling frequency to %d\n",dev->options.sample_rate); 
    109172                return 0; 
    110         } 
    111          
    112         // set slave mode option 
    113         bool slaveMode=(dev->options.slave_mode != 0); 
    114         debugOutput(DEBUG_LEVEL_VERBOSE, "setting slave mode to %d\n", slaveMode); 
    115         if(!dev->m_deviceManager->setOption("slaveMode", slaveMode)) { 
    116                 debugWarning("Failed to set slave mode option\n"); 
    117         } 
    118         // set snoop mode option 
    119         bool snoopMode=(dev->options.snoop_mode != 0); 
    120         debugOutput(DEBUG_LEVEL_VERBOSE, "setting snoop mode to %d\n", snoopMode); 
    121         if(!dev->m_deviceManager->setOption("snoopMode", snoopMode)) { 
    122                 debugWarning("Failed to set snoop mode option\n"); 
    123         } 
    124          
    125         // discover the devices on the bus 
    126         if(!dev->m_deviceManager->discover(DEBUG_LEVEL_NORMAL)) { 
    127                 debugFatal("Could not discover devices\n"); 
    128                 delete dev->processorManager; 
    129                 delete dev->m_deviceManager; 
    130                 delete dev; 
    131                 return 0; 
    132         } 
    133          
    134         // are there devices on the bus? 
    135         if(dev->m_deviceManager->getAvDeviceCount()==0) { 
    136                 debugFatal("There are no devices on the bus\n"); 
    137                 delete dev->processorManager; 
    138                 delete dev->m_deviceManager; 
    139                 delete dev; 
    140                 return 0; 
    141         } 
    142          
    143         // iterate over the found devices 
    144         // add the stream processors of the devices to the managers 
    145         for(i=0;i<dev->m_deviceManager->getAvDeviceCount();i++) { 
    146             IAvDevice *device=dev->m_deviceManager->getAvDeviceByIndex(i); 
    147             assert(device); 
    148  
    149             debugOutput(DEBUG_LEVEL_VERBOSE, "Locking device (%p)\n", device); 
    150              
    151             if (!device->lock()) { 
    152                 debugWarning("Could not lock device, skipping device (%p)!\n", device); 
    153                 continue; 
    154173            } 
    155              
    156             debugOutput(DEBUG_LEVEL_VERBOSE, "Setting samplerate to %d for (%p)\n",  
    157                         dev->options.sample_rate, device); 
    158                          
    159             // Set the device's sampling rate to that requested 
    160             // FIXME: does this really belong here?  If so we need to handle errors. 
    161             if (!device->setSamplingFrequency(parseSampleRate(dev->options.sample_rate))) { 
    162                 debugOutput(DEBUG_LEVEL_VERBOSE, " => Retry setting samplerate to %d for (%p)\n",  
    163                             dev->options.sample_rate, device); 
    164              
    165                 // try again: 
    166                 if (!device->setSamplingFrequency(parseSampleRate(dev->options.sample_rate))) { 
    167                     delete dev->processorManager; 
    168                     delete dev->m_deviceManager; 
    169                     delete dev; 
    170                     debugFatal("Could not set sampling frequency to %d\n",dev->options.sample_rate); 
    171                     return 0; 
    172                 } 
     174        } 
     175 
     176        // prepare the device 
     177        device->prepare(); 
     178 
     179        int j=0; 
     180        for(j=0; j<device->getStreamCount();j++) { 
     181            StreamProcessor *streamproc=device->getStreamProcessorByIndex(j); 
     182            debugOutput(DEBUG_LEVEL_VERBOSE, "Registering stream processor %d of device %d with processormanager\n",j,i); 
     183            if (!dev->processorManager->registerProcessor(streamproc)) { 
     184                debugWarning("Could not register stream processor (%p) with the Processor manager\n",streamproc); 
    173185            } 
    174  
    175             // prepare the device 
    176             device->prepare(); 
    177  
    178             int j=0; 
    179             for(j=0; j<device->getStreamCount();j++) { 
    180                 StreamProcessor *streamproc=device->getStreamProcessorByIndex(j); 
    181                 debugOutput(DEBUG_LEVEL_VERBOSE, "Registering stream processor %d of device %d with processormanager\n",j,i); 
    182                 if (!dev->processorManager->registerProcessor(streamproc)) { 
    183                     debugWarning("Could not register stream processor (%p) with the Processor manager\n",streamproc); 
    184                 } 
    185             } 
    186         } 
    187          
    188         // set the sync source 
    189         if (!dev->processorManager->setSyncSource(dev->m_deviceManager->getSyncSource())) { 
    190             debugWarning("Could not set processorManager sync source (%p)\n", 
    191                 dev->m_deviceManager->getSyncSource()); 
    192         } 
    193  
    194         // we are ready! 
    195         debugOutputShort(DEBUG_LEVEL_VERBOSE, "\n\n"); 
    196         return dev; 
     186        } 
     187    } 
     188     
     189    // set the sync source 
     190    if (!dev->processorManager->setSyncSource(dev->m_deviceManager->getSyncSource())) { 
     191        debugWarning("Could not set processorManager sync source (%p)\n", 
     192            dev->m_deviceManager->getSyncSource()); 
     193    } 
     194 
     195    // we are ready! 
     196    debugOutputShort(DEBUG_LEVEL_VERBOSE, "\n\n"); 
     197    return dev; 
    197198 
    198199} 
     
    264265 
    265266int freebob_streaming_stop(freebob_device_t *dev) { 
    266         unsigned int i; 
    267         debugOutput(DEBUG_LEVEL_VERBOSE,"------------- Stop -------------\n"); 
    268  
    269         dev->processorManager->stop(); 
    270  
    271         // create the connections for all devices 
    272         // iterate over the found devices 
    273         // add the stream processors of the devices to the managers 
    274         for(i=0;i<dev->m_deviceManager->getAvDeviceCount();i++) { 
    275             IAvDevice *device=dev->m_deviceManager->getAvDeviceByIndex(i); 
    276             assert(device); 
    277                  
    278             int j=0; 
    279             for(j=0; j<device->getStreamCount();j++) { 
    280                 debugOutput(DEBUG_LEVEL_VERBOSE,"Stopping stream %d of device %d\n",j,i); 
    281                 // stop the stream 
    282                 // start the stream 
    283                 if (!device->stopStreamByIndex(j)) { 
    284                     debugWarning("Could not stop stream %d of device %d\n",j,i); 
    285                     continue; 
    286                 } 
     267    unsigned int i; 
     268    debugOutput(DEBUG_LEVEL_VERBOSE,"------------- Stop -------------\n"); 
     269 
     270    dev->processorManager->stop(); 
     271 
     272    // create the connections for all devices 
     273    // iterate over the found devices 
     274    // add the stream processors of the devices to the managers 
     275    for(i=0;i<dev->m_deviceManager->getAvDeviceCount();i++) { 
     276        IAvDevice *device=dev->m_deviceManager->getAvDeviceByIndex(i); 
     277        assert(device); 
     278             
     279        int j=0; 
     280        for(j=0; j<device->getStreamCount();j++) { 
     281            debugOutput(DEBUG_LEVEL_VERBOSE,"Stopping stream %d of device %d\n",j,i); 
     282            // stop the stream 
     283            // start the stream 
     284            if (!device->stopStreamByIndex(j)) { 
     285                debugWarning("Could not stop stream %d of device %d\n",j,i); 
     286                continue; 
    287287            } 
    288288        } 
    289  
    290         return 0; 
     289    } 
     290 
     291    return 0; 
    291292} 
    292293 
    293294int freebob_streaming_reset(freebob_device_t *dev) { 
    294         debugOutput(DEBUG_LEVEL_VERBOSE,"------------- Reset -------------\n"); 
    295  
    296 //     dev->processorManager->reset(); 
    297  
    298         return 0; 
     295    debugOutput(DEBUG_LEVEL_VERBOSE,"------------- Reset -------------\n"); 
     296 
     297    // dev->processorManager->reset(); 
     298 
     299    return 0; 
    299300} 
    300301 
    301302int freebob_streaming_wait(freebob_device_t *dev) { 
    302         static int periods=0; 
    303         static int periods_print=0; 
    304         static int xruns=0; 
    305                  
    306         periods++; 
    307         if(periods>periods_print) { 
    308                 debugOutputShort(DEBUG_LEVEL_VERBOSE, "\nfreebob_streaming_wait\n"); 
    309                 debugOutputShort(DEBUG_LEVEL_VERBOSE, "============================================\n"); 
    310                 debugOutputShort(DEBUG_LEVEL_VERBOSE, "Xruns: %d\n",xruns); 
    311                 debugOutputShort(DEBUG_LEVEL_VERBOSE, "============================================\n"); 
    312                 dev->processorManager->dumpInfo(); 
    313                 debugOutputShort(DEBUG_LEVEL_VERBOSE, "\n"); 
    314                 periods_print+=100; 
    315        
    316          
    317         if(dev->processorManager->waitForPeriod()) { 
    318                 return dev->options.period_size; 
    319         } else { 
    320                 debugWarning("XRUN detected\n"); 
    321                  
    322                 // do xrun recovery 
    323                 dev->processorManager->handleXrun(); 
    324                 xruns++; 
    325                 return -1; 
    326        
     303    static int periods=0; 
     304    static int periods_print=0; 
     305    static int xruns=0; 
     306     
     307    periods++; 
     308    if(periods>periods_print) { 
     309        debugOutputShort(DEBUG_LEVEL_VERBOSE, "\nfreebob_streaming_wait\n"); 
     310        debugOutputShort(DEBUG_LEVEL_VERBOSE, "============================================\n"); 
     311        debugOutputShort(DEBUG_LEVEL_VERBOSE, "Xruns: %d\n",xruns); 
     312        debugOutputShort(DEBUG_LEVEL_VERBOSE, "============================================\n"); 
     313        dev->processorManager->dumpInfo(); 
     314        debugOutputShort(DEBUG_LEVEL_VERBOSE, "\n"); 
     315        periods_print+=100; 
     316   
     317     
     318    if(dev->processorManager->waitForPeriod()) { 
     319        return dev->options.period_size; 
     320    } else { 
     321        debugWarning("XRUN detected\n"); 
     322         
     323        // do xrun recovery 
     324        dev->processorManager->handleXrun(); 
     325        xruns++; 
     326        return -1; 
     327   
    327328} 
    328329 
    329330int freebob_streaming_transfer_capture_buffers(freebob_device_t *dev) { 
    330         return dev->processorManager->transfer(StreamProcessor::E_Receive); 
     331    return dev->processorManager->transfer(StreamProcessor::E_Receive); 
    331332} 
    332333 
    333334int freebob_streaming_transfer_playback_buffers(freebob_device_t *dev) { 
    334         return dev->processorManager->transfer(StreamProcessor::E_Transmit); 
     335    return dev->processorManager->transfer(StreamProcessor::E_Transmit); 
    335336} 
    336337 
    337338int freebob_streaming_transfer_buffers(freebob_device_t *dev) { 
    338         return dev->processorManager->transfer(); 
     339    return dev->processorManager->transfer(); 
    339340} 
    340341 
    341342 
    342343int freebob_streaming_write(freebob_device_t *dev, int i, freebob_sample_t *buffer, int nsamples) { 
    343 // debugFatal("Not implemented\n"); 
    344         Port *p=dev->processorManager->getPortByIndex(i, Port::E_Playback); 
    345         // use an assert here performancewise,  
    346         // it should already have failed before, if not correct 
    347         assert(p);  
    348          
    349         return p->writeEvents((void *)buffer, nsamples); 
     344    Port *p=dev->processorManager->getPortByIndex(i, Port::E_Playback); 
     345    // use an assert here performancewise,  
     346    // it should already have failed before, if not correct 
     347    assert(p);  
     348         
     349    return p->writeEvents((void *)buffer, nsamples); 
    350350} 
    351351 
    352352int freebob_streaming_read(freebob_device_t *dev, int i, freebob_sample_t *buffer, int nsamples) { 
    353         Port *p=dev->processorManager->getPortByIndex(i, Port::E_Capture); 
    354         // use an assert here performancewise,  
    355         // it should already have failed before, if not correct 
    356         assert(p);  
    357          
    358         return p->readEvents((void *)buffer, nsamples); 
    359 
    360  
    361 pthread_t freebob_streaming_get_packetizer_thread(freebob_device_t *dev) { 
    362 //      debugFatal("Not implemented\n"); 
    363         return 0; 
    364 
    365  
     353    Port *p=dev->processorManager->getPortByIndex(i, Port::E_Capture); 
     354    // use an assert here performancewise,  
     355    // it should already have failed before, if not correct 
     356    assert(p);  
     357         
     358    return p->readEvents((void *)buffer, nsamples); 
     359
    366360 
    367361int freebob_streaming_get_nb_capture_streams(freebob_device_t *dev) { 
    368         return dev->processorManager->getPortCount(Port::E_Capture); 
     362    return dev->processorManager->getPortCount(Port::E_Capture); 
    369363} 
    370364 
    371365int freebob_streaming_get_nb_playback_streams(freebob_device_t *dev) { 
    372         return dev->processorManager->getPortCount(Port::E_Playback); 
     366    return dev->processorManager->getPortCount(Port::E_Playback); 
    373367} 
    374368 
    375369int freebob_streaming_get_capture_stream_name(freebob_device_t *dev, int i, char* buffer, size_t buffersize) { 
    376         Port *p=dev->processorManager->getPortByIndex(i, Port::E_Capture); 
    377         if(!p) { 
    378                 debugWarning("Could not get capture port at index %d\n",i); 
    379                 return -1; 
    380        
    381  
    382         std::string name=p->getName(); 
    383         if (!strncpy(buffer, name.c_str(), buffersize)) { 
    384                 debugWarning("Could not copy name\n"); 
    385                 return -1; 
    386         } else return 0; 
     370    Port *p=dev->processorManager->getPortByIndex(i, Port::E_Capture); 
     371    if(!p) { 
     372        debugWarning("Could not get capture port at index %d\n",i); 
     373        return -1; 
     374   
     375 
     376    std::string name=p->getName(); 
     377    if (!strncpy(buffer, name.c_str(), buffersize)) { 
     378        debugWarning("Could not copy name\n"); 
     379        return -1; 
     380    } else return 0; 
    387381} 
    388382 
    389383int freebob_streaming_get_playback_stream_name(freebob_device_t *dev, int i, char* buffer, size_t buffersize) { 
    390          
    391         Port *p=dev->processorManager->getPortByIndex(i, Port::E_Playback); 
    392         if(!p) { 
    393                 debugWarning("Could not get playback port at index %d\n",i); 
    394                 return -1; 
    395         } 
    396  
    397         std::string name=p->getName(); 
    398         if (!strncpy(buffer, name.c_str(), buffersize)) { 
    399                 debugWarning("Could not copy name\n"); 
    400                 return -1; 
    401         } else return 0; 
     384    Port *p=dev->processorManager->getPortByIndex(i, Port::E_Playback); 
     385    if(!p) { 
     386        debugWarning("Could not get playback port at index %d\n",i); 
     387        return -1; 
     388    } 
     389 
     390    std::string name=p->getName(); 
     391    if (!strncpy(buffer, name.c_str(), buffersize)) { 
     392        debugWarning("Could not copy name\n"); 
     393        return -1; 
     394    } else return 0; 
    402395} 
    403396 
    404397freebob_streaming_stream_type freebob_streaming_get_capture_stream_type(freebob_device_t *dev, int i) { 
    405         Port *p=dev->processorManager->getPortByIndex(i, Port::E_Capture); 
    406         if(!p) { 
    407                 debugWarning("Could not get capture port at index %d\n",i); 
    408                 return freebob_stream_type_invalid; 
    409        
    410         switch(p->getPortType()) { 
    411         case Port::E_Audio: 
    412                 return freebob_stream_type_audio; 
    413         case Port::E_Midi: 
    414                 return freebob_stream_type_midi; 
    415         case Port::E_Control: 
    416                 return freebob_stream_type_control; 
    417         default: 
    418                 return freebob_stream_type_unknown; 
    419        
     398    Port *p=dev->processorManager->getPortByIndex(i, Port::E_Capture); 
     399    if(!p) { 
     400        debugWarning("Could not get capture port at index %d\n",i); 
     401        return freebob_stream_type_invalid; 
     402   
     403    switch(p->getPortType()) { 
     404    case Port::E_Audio: 
     405        return freebob_stream_type_audio; 
     406    case Port::E_Midi: 
     407        return freebob_stream_type_midi; 
     408    case Port::E_Control: 
     409        return freebob_stream_type_control; 
     410    default: 
     411        return freebob_stream_type_unknown; 
     412   
    420413} 
    421414 
    422415freebob_streaming_stream_type freebob_streaming_get_playback_stream_type(freebob_device_t *dev, int i) { 
    423         Port *p=dev->processorManager->getPortByIndex(i, Port::E_Playback); 
    424         if(!p) { 
    425                 debugWarning("Could not get playback port at index %d\n",i); 
    426                 return freebob_stream_type_invalid; 
    427        
    428         switch(p->getPortType()) { 
    429         case Port::E_Audio: 
    430                 return freebob_stream_type_audio; 
    431         case Port::E_Midi: 
    432                 return freebob_stream_type_midi; 
    433         case Port::E_Control: 
    434                 return freebob_stream_type_control; 
    435         default: 
    436                 return freebob_stream_type_unknown; 
    437        
     416    Port *p=dev->processorManager->getPortByIndex(i, Port::E_Playback); 
     417    if(!p) { 
     418        debugWarning("Could not get playback port at index %d\n",i); 
     419        return freebob_stream_type_invalid; 
     420   
     421    switch(p->getPortType()) { 
     422    case Port::E_Audio: 
     423        return freebob_stream_type_audio; 
     424    case Port::E_Midi: 
     425        return freebob_stream_type_midi; 
     426    case Port::E_Control: 
     427        return freebob_stream_type_control; 
     428    default: 
     429        return freebob_stream_type_unknown; 
     430   
    438431} 
    439432 
    440433int freebob_streaming_set_stream_buffer_type(freebob_device_t *dev, int i,  
    441         freebob_streaming_buffer_type t, enum Port::E_Direction direction) { 
    442  
    443         Port *p=dev->processorManager->getPortByIndex(i, direction); 
    444         if(!p) { 
    445                 debugWarning("Could not get %s port at index %d\n", 
    446                     (direction==Port::E_Playback?"Playback":"Capture"),i); 
    447                 return -1; 
    448        
    449          
    450         switch(t) { 
    451         case freebob_buffer_type_int24: 
     434    freebob_streaming_buffer_type t, enum Port::E_Direction direction) { 
     435 
     436    Port *p=dev->processorManager->getPortByIndex(i, direction); 
     437    if(!p) { 
     438        debugWarning("Could not get %s port at index %d\n", 
     439            (direction==Port::E_Playback?"Playback":"Capture"),i); 
     440        return -1; 
     441   
     442         
     443    switch(t) { 
     444    case freebob_buffer_type_int24: 
    452445        if (!p->setDataType(Port::E_Int24)) { 
    453446            debugWarning("%s: Could not set data type to Int24\n",p->getName().c_str()); 
     
    459452        } 
    460453        break; 
    461         case freebob_buffer_type_float: 
     454    case freebob_buffer_type_float: 
    462455        if (!p->setDataType(Port::E_Float)) { 
    463456            debugWarning("%s: Could not set data type to Float\n",p->getName().c_str()); 
     
    469462        } 
    470463        break; 
    471         case freebob_buffer_type_midi: 
     464    case freebob_buffer_type_midi: 
    472465        if (!p->setDataType(Port::E_MidiEvent)) { 
    473466            debugWarning("%s: Could not set data type to MidiEvent\n",p->getName().c_str()); 
     
    479472        } 
    480473        break; 
    481         default: 
    482     debugWarning("%s: Unsupported buffer type\n",p->getName().c_str()); 
    483     return -1; 
    484        
     474    default: 
     475        debugWarning("%s: Unsupported buffer type\n",p->getName().c_str()); 
     476        return -1; 
     477   
    485478    return 0; 
    486479 
     
    496489 
    497490int freebob_streaming_stream_onoff(freebob_device_t *dev, int i,  
    498         int on, enum Port::E_Direction direction) { 
    499         Port *p=dev->processorManager->getPortByIndex(i, direction); 
    500         if(!p) { 
    501                 debugWarning("Could not get %s port at index %d\n", 
    502                     (direction==Port::E_Playback?"Playback":"Capture"),i); 
    503                 return -1; 
    504        
    505         if(on) { 
     491    int on, enum Port::E_Direction direction) { 
     492    Port *p=dev->processorManager->getPortByIndex(i, direction); 
     493    if(!p) { 
     494        debugWarning("Could not get %s port at index %d\n", 
     495            (direction==Port::E_Playback?"Playback":"Capture"),i); 
     496        return -1; 
     497   
     498    if(on) { 
    506499        p->enable(); 
    507         } else { 
     500    } else { 
    508501        p->disable(); 
    509        
    510         return 0; 
     502   
     503    return 0; 
    511504} 
    512505 
  • branches/streaming-rework/src/iavdevice.cpp

    r426 r435  
    3333                    Ieee1394Service& ieee1394service, 
    3434                    int nodeId ) 
    35     : m_pConfigRom( configRom ) 
     35    : OscNode() 
     36    , m_pConfigRom( configRom ) 
    3637    , m_p1394Service( &ieee1394service ) 
    3738    , m_verboseLevel( DEBUG_LEVEL_NORMAL ) 
     
    3940{ 
    4041    addOption(Util::OptionContainer::Option("id",std::string("dev?"))); 
    41  
     42     
     43    std::ostringstream nodestr; 
     44    nodestr << "node" << nodeId; 
     45    setOscBase(nodestr.str()); 
     46    ConfigRom& c = getConfigRom(); 
     47     
     48    addChildOscNode(&c); 
    4249} 
    4350 
  • branches/streaming-rework/src/iavdevice.h

    r426 r435  
    2323 
    2424#include "libavc/avc_definitions.h" 
    25 #include "libfreebob/xmlparser.h" 
    2625#include "libutil/OptionContainer.h" 
     26#include "libosc/OscNode.h" 
    2727 
    2828class ConfigRom; 
     
    3939 
    4040*/ 
    41 class IAvDevice : public Util::OptionContainer { 
     41class IAvDevice  
     42    : public Util::OptionContainer, 
     43      public OSC::OscNode 
     44
    4245public: 
    4346        IAvDevice( std::auto_ptr< ConfigRom >( configRom ), 
     
    100103         
    101104        /** 
    102          * @brief Constructs an XML description of the device [obsolete] 
    103          * 
    104          * this is a leftover from v1.0 and isn't used 
    105          * just provide an empty implementation that returns true 
    106          * untill it is removed 
    107          * 
    108          * @param deviceNode  
    109          * @return true if successful, false if not 
    110          */ 
    111         bool addXmlDescription( xmlNodePtr deviceNode ) {return true;}; 
    112          
    113         /** 
    114105         * @brief Outputs the device configuration to stderr/stdout [debug helper] 
    115106         * 
  • branches/streaming-rework/src/libieee1394/configrom.cpp

    r413 r435  
    5656 
    5757ConfigRom::ConfigRom( Ieee1394Service& ieee1394service, fb_nodeid_t nodeId ) 
    58     : m_1394Service( &ieee1394service ) 
     58    : OscNode("ConfigRom") 
     59    , m_1394Service( &ieee1394service ) 
    5960    , m_nodeId( nodeId ) 
    6061    , m_avcDevice( false ) 
     
    8283 
    8384ConfigRom::ConfigRom() 
    84     : m_1394Service( 0 ) 
     85    : OscNode("ConfigRom") 
     86    , m_1394Service( 0 ) 
    8587    , m_nodeId( -1 ) 
    8688    , m_avcDevice( false ) 
     
    572574    return true; 
    573575} 
     576 
     577OSC::OscResponse 
     578ConfigRom::processOscMessage(OSC::OscMessage *m) { 
     579    OSC::OscResponse r=OSC::OscResponse(OSC::OscResponse::eUnhandled); 
     580     
     581    unsigned int nbArgs=m->nbArguments(); 
     582    if (nbArgs>=1) { 
     583        OSC::OscArgument arg0=m->getArgument(0); 
     584        if(arg0.isString()) { // commands 
     585            string cmd=arg0.getString(); 
     586             
     587            debugOutput( DEBUG_LEVEL_VERBOSE, "(%p) CMD? %s\n", this, cmd.c_str()); 
     588            if(cmd == "params") { 
     589                debugOutput( DEBUG_LEVEL_VERBOSE, "Listing node children...\n"); 
     590                OSC::OscMessage& rm=r.getMessage(); 
     591                rm.addArgument("GUID"); 
     592                rm.addArgument("VendorName"); 
     593                rm.addArgument("ModelName"); 
     594                r.setType(OSC::OscResponse::eMessage); 
     595            } 
     596            if(cmd == "get") { 
     597                if(nbArgs != 2) { 
     598                    debugError("Erronous get command received, wrong nb of arguments\n"); 
     599                    m->print(); 
     600                } else { 
     601                    OSC::OscArgument arg1=m->getArgument(1); 
     602                    if(arg1.isString()) { // commands 
     603                        string target=arg1.getString(); 
     604                        OSC::OscMessage& rm=r.getMessage(); 
     605                        if(target == "GUID") { 
     606                            // FIXME: this will only return the lower 32 bits 
     607                            rm.addArgument((int64_t)getGuid()); 
     608                        } else if(target == "VendorName") { 
     609                            rm.addArgument(getVendorName()); 
     610                        } else if(target == "ModelName") { 
     611                            rm.addArgument(getModelName()); 
     612                        } else { 
     613                            debugError("Erronous get command received, non-existant target\n"); 
     614                            m->print(); 
     615                        } 
     616                        r.setType(OSC::OscResponse::eMessage); 
     617                    } else { 
     618                        debugError("Erronous get command received, wrong argument type\n"); 
     619                        m->print(); 
     620                    } 
     621                } 
     622            } 
     623        } 
     624    } 
     625     
     626    return r; 
     627 
     628} 
  • branches/streaming-rework/src/libieee1394/configrom.h

    r413 r435  
    2828#include "debugmodule/debugmodule.h" 
    2929 
     30#include "libosc/OscNode.h" 
     31 
    3032#include <string> 
    3133 
    3234class Ieee1394Service; 
    3335 
    34 class ConfigRom { 
     36class ConfigRom 
     37    : public OSC::OscNode 
     38
    3539 public: 
    3640    ConfigRom( Ieee1394Service& ieee1394service, fb_nodeid_t nodeId ); 
     
    110114    struct csr1212_csr*    m_csr; 
    111115 
     116protected: // OSC handling 
     117    OSC::OscResponse processOscMessage(OSC::OscMessage *m); 
     118 
    112119private: 
    113120    ConfigRom( const ConfigRom& ); // do not allow copy ctor 
  • branches/streaming-rework/src/libstreaming/AmdtpStreamProcessor.cpp

    r424 r435  
    8686     
    8787    struct iec61883_packet *packet = (struct iec61883_packet *) data; 
     88    if (cycle<0) return RAW1394_ISO_OK; 
    8889     
    8990    m_last_cycle=cycle; 
     
    145146     
    146147    uint64_t ts_head, fc; 
    147     if (!m_disabled && m_is_disabled) { 
    148         // this means that we are trying to enable 
    149         if ((unsigned int)cycle == m_cycle_to_enable_at) { 
     148    if (!m_disabled && m_is_disabled) { // this means that we are trying to enable 
     149        // check if we are on or past the enable point 
     150        int cycles_past_enable=diffCycles(cycle, m_cycle_to_enable_at); 
     151         
     152        if (cycles_past_enable >= 0) { 
    150153            m_is_disabled=false; 
    151154             
     
    170173             
    171174            ts_head = substractTicks(ts_head, TICKS_PER_CYCLE); 
     175             
     176            // account for the number of cycles we are too late to enable 
     177            ts_head = addTicks(ts_head, cycles_past_enable * TICKS_PER_CYCLE); 
    172178             
    173179            // account for one extra packet of frames 
     
    233239        if(m_is_disabled) { 
    234240             
    235             transmitSilenceBlock((char *)(data+8), m_syt_interval, 0); 
    236             m_dbc += fillDataPacketHeader(packet, length, ts_packet); 
    237              
    238             debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "XMIT SYNC: CY=%04u TSH=%011llu TSP=%011lu\n", 
    239                 cycle, ts_head, ts_packet); 
    240  
    241             // update the base timestamp 
    242             uint32_t ts_step=(uint32_t)((float)(m_syt_interval) 
    243                              *m_SyncSource->m_data_buffer->getRate()); 
    244              
    245             // the next buffer head timestamp 
    246             ts_head=addTicks(ts_head,ts_step); 
    247             m_data_buffer->setBufferHeadTimestamp(ts_head); 
    248              
     241//             transmitSilenceBlock((char *)(data+8), m_syt_interval, 0); 
     242//             m_dbc += fillDataPacketHeader(packet, length, ts_packet); 
     243//              
     244//             debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "XMIT SYNC: CY=%04u TSH=%011llu TSP=%011lu\n", 
     245//                 cycle, ts_head, ts_packet); 
     246//  
     247//             // update the base timestamp 
     248//             uint32_t ts_step=(uint32_t)((float)(m_syt_interval) 
     249//                              *m_SyncSource->m_data_buffer->getRate()); 
     250//              
     251//             // the next buffer head timestamp 
     252//             ts_head=addTicks(ts_head,ts_step); 
     253//             m_data_buffer->setBufferHeadTimestamp(ts_head); 
     254//              
     255            // no-data 
     256            debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "XMIT SYNC: CY=%04u NONE\n", cycle); 
     257            m_dbc += fillNoDataPacketHeader(packet, length); 
    249258            // defer to make sure we get to be enabled asap 
    250259            return RAW1394_ISO_DEFER; 
     
    589598    // check if a wraparound on the secs will happen between 
    590599    // now and the time we start 
    591     if (CYCLE_TIMER_GET_CYCLES(now)>time_to_enable_at) { 
    592         // the start will happen in the next second 
     600    int until_enable=(int)time_to_enable_at - (int)CYCLE_TIMER_GET_CYCLES(now); 
     601     
     602    if(until_enable>4000) { 
     603        // wraparound on CYCLE_TIMER_GET_CYCLES(now) 
     604        // this means that we are late starting up, 
     605        // and that the start lies in the previous second 
     606        if (now_secs==0) now_secs=127; 
     607        else now_secs--; 
     608    } else if (until_enable<-4000) { 
     609        // wraparound on time_to_enable_at 
     610        // this means that we are early and that the start 
     611        // point lies in the next second 
    593612        now_secs++; 
    594613        if (now_secs>=128) now_secs=0; 
    595614    } 
    596      
     615 
    597616    uint64_t ts_head= now_secs*TICKS_PER_SECOND; 
    598617    ts_head+=time_to_enable_at*TICKS_PER_CYCLE; 
     
    600619    // we also add the nb of cycles we transmit in advance 
    601620    ts_head=addTicks(ts_head, TRANSMIT_ADVANCE_CYCLES*TICKS_PER_CYCLE); 
    602      
    603     // we want the SP to start sending silent packets somewhat earlier than the 
    604     // time it is enabled 
    605     ts_head=substractTicks(ts_head, 100*TICKS_PER_CYCLE); 
    606621     
    607622    m_data_buffer->setBufferTailTimestamp(ts_head); 
     
    752767        /* idea: 
    753768        spec says: current_midi_port=(dbc+j)%8; 
    754         => if we start at (dbc+stream->location-1)%8 [due to location_min=1],  
     769        => if we start at (dbc+stream->location-1)%8,  
    755770        we'll start at the right event for the midi port. 
    756771        => if we increment j with 8, we stay at the right event. 
     
    760775        // first prefill the buffer with NO_DATA's on all time muxed channels 
    761776         
    762         for(j = (dbc & 0x07)+mp->getLocation()-1; j < nevents; j += 8) { 
     777        for(j = (dbc & 0x07)+mp->getLocation(); j < nevents; j += 8) { 
    763778         
    764779            target_event=(quadlet_t *)(data + ((j * m_dimension) + mp->getPosition())); 
     
    914929 
    915930#endif 
    916     // check our enable status 
    917     if (!m_disabled && m_is_disabled) { 
    918         // this means that we are trying to enable 
    919         if (cycle == m_cycle_to_enable_at) { 
     931    if (!m_disabled && m_is_disabled) { // this means that we are trying to enable 
     932        // check if we are on or past the enable point 
     933        int cycles_past_enable=diffCycles(cycle, m_cycle_to_enable_at); 
     934         
     935        if (cycles_past_enable >= 0) { 
    920936            m_is_disabled=false; 
    921937            debugOutput(DEBUG_LEVEL_VERBOSE,"Enabling StreamProcessor %p at %d (SYT=%04X)\n",  
     
    13191335                /* idea: 
    13201336                spec says: current_midi_port=(dbc+j)%8; 
    1321                 => if we start at (dbc+stream->location-1)%8 [due to location_min=1],  
     1337                => if we start at (dbc+stream->location-1)%8,  
    13221338                we'll start at the right event for the midi port. 
    13231339                => if we increment j with 8, we stay at the right event. 
     
    13251341                // FIXME: as we know in advance how big a packet is (syt_interval) we can  
    13261342                //        predict how much loops will be present here 
    1327                 for(j = (dbc & 0x07)+mp->getLocation()-1; j < nevents; j += 8) { 
     1343                for(j = (dbc & 0x07)+mp->getLocation(); j < nevents; j += 8) { 
    13281344                        target_event=(quadlet_t *)(data + ((j * m_dimension) + mp->getPosition())); 
    13291345                        quadlet_t sample_int=ntohl(*target_event); 
  • branches/streaming-rework/src/libstreaming/cip.h

    r261 r435  
    151151                struct iec61883_packet *packet); 
    152152 
    153 #endif 
    154  
    155153#ifdef __cplusplus 
    156154} 
    157155#endif 
     156 
     157#endif 
  • branches/streaming-rework/src/libstreaming/StreamProcessorManager.cpp

    r424 r435  
    3535#include "libstreaming/cycletimer.h" 
    3636 
    37 #define CYCLES_TO_SLEEP_AFTER_RUN_SIGNAL 50 
     37#define CYCLES_TO_SLEEP_AFTER_RUN_SIGNAL 5 
    3838 
    3939#define RUNNING_TIMEOUT_MSEC 4000 
     
    4141#define ENABLE_TIMEOUT_MSEC 4000 
    4242 
    43 #define ENABLE_DELAY_CYCLES 2000 
     43#define ENABLE_DELAY_CYCLES 100 
    4444 
    4545namespace Streaming { 
     
    277277} 
    278278 
    279  
    280279bool StreamProcessorManager::syncStartAll() { 
    281280 
     
    289288        notRunning=false; 
    290289         
    291 //         for ( StreamProcessorVectorIterator it = m_ReceiveProcessors.begin(); 
    292 //                 it != m_ReceiveProcessors.end(); 
    293 //                 ++it ) { 
    294 //             if(!(*it)->isRunning()) notRunning=true; 
    295 //         } 
    296 //  
    297 //         for ( StreamProcessorVectorIterator it = m_TransmitProcessors.begin(); 
    298 //                 it != m_TransmitProcessors.end(); 
    299 //                 ++it ) { 
    300 //             if(!(*it)->isRunning()) notRunning=true; 
    301 //         } 
     290        for ( StreamProcessorVectorIterator it = m_ReceiveProcessors.begin(); 
     291                it != m_ReceiveProcessors.end(); 
     292                ++it ) { 
     293            if(!(*it)->isRunning()) notRunning=true; 
     294        } 
     295 
     296        for ( StreamProcessorVectorIterator it = m_TransmitProcessors.begin(); 
     297                it != m_TransmitProcessors.end(); 
     298                ++it ) { 
     299            if(!(*it)->isRunning()) notRunning=true; 
     300        } 
    302301         
    303302        // EXPERIMENT: 
     
    314313        // other streams still have at least ENABLE_DELAY_CYCLES cycles  
    315314        // to start up 
    316         if(!m_SyncSource->isRunning()) notRunning=true; 
     315//         if(!m_SyncSource->isRunning()) notRunning=true; 
    317316         
    318317        usleep(1000); 
  • branches/streaming-rework/src/libutil/unittests.cpp

    r419 r435  
    2828using namespace Util; 
    2929 
     30#define TEST_SHOULD_RETURN_TRUE(test) \ 
     31    (test ? true : printf( "'" #test "' should return true\n") && false ) 
     32#define TEST_SHOULD_RETURN_FALSE(test) \ 
     33    (test ? printf( "'" #test "' should return true\n") && false : true ) 
     34 
    3035/////////////////////////////////////// 
    3136 
     
    416421         
    417422        Option op1=Option(); 
    418         if(addOption(op1)) { 
    419             printf( "adding an empty option should not succeed\n" ); 
    420             result=false; 
    421         } 
     423        result &= TEST_SHOULD_RETURN_FALSE(addOption(op1)); 
    422424         
    423425        op1=Option("option1"); 
    424         if(addOption(op1)) { 
    425             printf( "adding an option without a value should not succeed\n" ); 
    426             result=false; 
    427         } 
    428          
     426        result &= TEST_SHOULD_RETURN_FALSE(addOption(op1)); 
     427 
    429428        op1=Option("option1", (float)(1.0)); 
    430         if(!addOption(op1)) { 
    431             printf( "could not add valid option (1)\n" ); 
    432             result=false; 
    433         } 
    434         if(addOption(op1)) { 
    435             printf( "adding the same option twice should not succeed\n" ); 
    436             result=false; 
    437         } 
    438         if(!removeOption(op1)) { 
    439             printf( "could not remove option by reference\n" ); 
    440             result=false; 
    441         } 
    442         if(hasOption(op1)) { 
    443             printf( "option not removed (by reference)\n" ); 
    444             result=false; 
    445         } 
     429        result &= TEST_SHOULD_RETURN_TRUE(addOption(op1)); 
     430        result &= TEST_SHOULD_RETURN_FALSE(addOption(op1)); 
     431        result &= TEST_SHOULD_RETURN_TRUE(removeOption(op1)); 
     432        result &= TEST_SHOULD_RETURN_FALSE(hasOption(op1)); 
     433 
    446434         
    447435        op1=Option("option1", (int64_t)1); 
    448         if(!addOption(op1)) { 
    449             printf( "could not add valid option (2)\n" ); 
    450             result=false; 
    451         } 
    452         if(!removeOption("option1")) { 
    453             printf( "could not remove option by name\n" ); 
    454             result=false; 
    455         } 
    456         if(hasOption(op1)) { 
    457             printf( "option not removed (by name)\n" ); 
    458             result=false; 
    459         } 
     436        result &= TEST_SHOULD_RETURN_TRUE(addOption(op1)); 
     437 
     438        result &= TEST_SHOULD_RETURN_TRUE(removeOption("option1")); 
     439 
     440        result &= TEST_SHOULD_RETURN_FALSE(hasOption(op1)); 
     441 
    460442         
    461443        op1=Option("option1", (int64_t)(-1)); 
    462         if(!addOption(op1)) { 
    463             printf( "could not add valid option (3)\n" ); 
    464             result=false; 
    465         } 
     444        result &= TEST_SHOULD_RETURN_TRUE(addOption(op1)); 
     445 
    466446        Option op2=Option("option1", (double)(1.75)); 
    467         if(addOption(op2)) { 
    468             printf( "adding two options with the same name should not be allowed\n" ); 
    469             result=false; 
    470         } 
     447        result &= TEST_SHOULD_RETURN_FALSE(addOption(op2)); 
     448 
    471449         
    472450        op2=Option("option2", (double)(1.75)); 
    473         if(!addOption(op2)) { 
    474             printf( "adding an option with a different name should be allowed (1)\n" ); 
    475             result=false; 
    476         } 
     451        result &= TEST_SHOULD_RETURN_TRUE(addOption(op2)); 
     452 
    477453        Option op3=Option("option3", (int64_t)(1.75)); 
    478         if(!addOption(op3)) { 
    479             printf( "adding an option with a different name should be allowed (2)\n" ); 
    480             result=false; 
    481         } 
    482          
    483         if(countOptions() != 3) { 
    484             printf( "countOptions failed\n" ); 
    485             result=false; 
    486         } 
    487              
     454        result &= TEST_SHOULD_RETURN_TRUE(addOption(op3)); 
     455 
     456         
     457        result &= TEST_SHOULD_RETURN_TRUE(countOptions() == 3); 
     458 
    488459        int i=0; 
    489460        for ( OptionContainer::iterator it = begin(); 
     
    494465            i++; 
    495466        } 
    496         if(i!=3) { 
    497             printf( "did not iterate through the right amount of options\n" ); 
    498             result=false; 
    499         } 
     467        result &= TEST_SHOULD_RETURN_TRUE(i==3); 
    500468         
    501469        clearOptions(); 
     
    525493    bool result=true; 
    526494    testOC oc; 
    527     if(!oc.test()) { 
    528         printf( "OptionContainer test failed\n" ); 
    529         result=false; 
    530     } 
     495    result &= TEST_SHOULD_RETURN_TRUE(oc.test()); 
    531496     
    532497    // now manipulate it externally 
    533498    oc.prepare(); 
    534499     
    535     if(!oc.hasOption("option1")) { 
    536         printf( "option1 should be present\n" ); 
    537         result=false; 
    538     } 
    539     if(!oc.hasOption("option2")) { 
    540         printf( "option2 should be present\n" ); 
    541         result=false; 
    542     } 
    543     if(!oc.hasOption("option3")) { 
    544         printf( "option3 should be present\n" ); 
    545         result=false; 
    546     } 
    547     if(oc.hasOption("option4")) { 
    548         printf( "option4 should not be present\n" ); 
    549         result=false; 
    550     } 
    551  
     500    result &= TEST_SHOULD_RETURN_TRUE(oc.hasOption("option1")); 
     501    result &= TEST_SHOULD_RETURN_TRUE(oc.hasOption("option2")); 
     502    result &= TEST_SHOULD_RETURN_TRUE(oc.hasOption("option3")); 
     503    result &= TEST_SHOULD_RETURN_FALSE(oc.hasOption("option4")); 
     504     
    552505    oc.setOption("option1", 1024); 
    553506    int tst; 
    554     if (!oc.getOption("option1", tst)) { 
    555         printf( "could not get option1 value\n" ); 
    556         result=false; 
    557     } 
    558      
    559     if(tst != 1024) { 
    560         printf( "option1 should be 1024\n" ); 
    561         result=false; 
    562     } 
     507    result &= TEST_SHOULD_RETURN_TRUE(oc.getOption("option1", tst)); 
     508    result &= TEST_SHOULD_RETURN_TRUE(tst == 1024); 
    563509     
    564510    return result; 
  • branches/streaming-rework/src/Makefile.am

    r426 r435  
    1919INCLUDES =                                              \ 
    2020        $(LIBRAW1394_CFLAGS) $(LIBIEC61883_CFLAGS)      \ 
    21         $(LIBAVC1394_CFLAGS) $(LIBXML_CFLAGS)         \ 
    22         $(LIBXMLCPP_CFLAGS)                           \ 
     21        $(LIBAVC1394_CFLAGS)  \ 
     22        $(LIBXMLCPP_CFLAGS)     $(LIBLO_CFLAGS)                       \ 
    2323        -I$(top_srcdir) -I$(top_srcdir)/src 
    2424 
     
    2828        -version-info $(LT_VERSION) $(LIBRAW1394_LIBS)  \ 
    2929        $(LIBIEC61883_LIBS) $(LIBAVC1394_LIBS)          \ 
    30         $(LIBXML_LIBS) $(LIBXMLCPP_LIBS) -lpthread -lrt 
     30        $(LIBXMLCPP_LIBS) $(LIBLO_LIBS) \ 
     31        -lpthread -lrt 
    3132 
    3233libfreebob_la_LIBADD = -lrt 
     
    4849        libavc/avc_plug_info.h libavc/avc_serialize.h libavc/avc_signal_source.h \ 
    4950        libavc/avc_subunit_info.h libavc/avc_unit_info.h \ 
     51        libosc/OscArgument.h libosc/OscNode.h libosc/OscResponse.h libosc/OscServer.h libosc/OscMessage.h \ 
    5052        libstreaming/AmdtpPort.h libstreaming/AmdtpPortInfo.h libstreaming/AmdtpStreamProcessor.h \ 
     53        libstreaming/AmdtpSlaveStreamProcessor.h \ 
    5154        libstreaming/cip.h libstreaming/cycletimer.h libstreaming/IsoHandler.h \ 
    5255        libstreaming/IsoHandlerManager.h libstreaming/IsoStream.h libstreaming/MotuPort.h \ 
     
    6669        freebob_streaming.cpp \ 
    6770        iavdevice.cpp \ 
    68         xmlparser.c \ 
    6971        debugmodule/debugmodule.cpp \ 
    7072        libavc/avc_connect.cpp \ 
     
    8688        libieee1394/ieee1394service.cpp \ 
    8789        libieee1394/IEC61883.cpp \ 
     90        libosc/OscArgument.cpp \ 
     91        libosc/OscMessage.cpp \ 
     92        libosc/OscNode.cpp \ 
     93        libosc/OscResponse.cpp \ 
     94        libosc/OscServer.cpp \ 
    8895        libstreaming/cip.c \ 
    8996        libstreaming/IsoHandler.cpp \ 
     
    110117        bebob/bebob_avdevice.cpp \ 
    111118        bebob/bebob_avdevice_subunit.cpp \ 
    112         bebob/bebob_avdevice_xml.cpp \ 
    113119        bebob/bebob_avplug.cpp \ 
    114         bebob/bebob_avplug_xml.cpp \ 
    115120        bebob/bebob_dl_bcd.cpp \ 
    116121        bebob/bebob_dl_codes.cpp \ 
     
    130135bounce_src = \ 
    131136        bounce/bounce_avdevice.cpp \ 
    132         bounce/bounce_slave_avdevice.cpp 
     137        bounce/bounce_slave_avdevice.cpp \ 
     138        libstreaming/AmdtpSlaveStreamProcessor.cpp 
    133139 
    134140metric_halo_src = \ 
     
    167173# programs not intended for installation 
    168174# generic 
    169 noinst_PROGRAMS = test-dll test-debugmodule test-unittests test-ser 
     175noinst_PROGRAMS = test-dll test-debugmodule \ 
     176                  test-unittests-util test-unittests-osc \ 
     177                  test-ser 
    170178 
    171179test_dll_SOURCES = libutil/test-dll.cpp 
     
    175183test_debugmodule_LDADD = $(top_builddir)/src/libfreebob.la 
    176184 
    177 test_unittests_SOURCES = libutil/unittests.cpp 
    178 test_unittests_LDADD = $(top_builddir)/src/libfreebob.la 
     185test_unittests_util_SOURCES = libutil/unittests.cpp 
     186test_unittests_util_LDADD = $(top_builddir)/src/libfreebob.la 
     187 
     188test_unittests_osc_SOURCES = libosc/unittests.cpp 
     189test_unittests_osc_LDADD = $(top_builddir)/src/libfreebob.la 
    179190 
    180191test_ser_SOURCES = ser.cpp 
  • branches/streaming-rework/src/maudio/maudio_avdevice.h

    r426 r435  
    2525#include "libavc/avc_definitions.h" 
    2626#include "libavc/avc_extended_cmd_generic.h" 
    27 #include "libfreebob/xmlparser.h" 
    2827 
    2928#include "bebob/bebob_avdevice.h" 
  • branches/streaming-rework/src/metrichalo/mh_avdevice.h

    r426 r435  
    2626#include "debugmodule/debugmodule.h" 
    2727#include "libavc/avc_definitions.h" 
    28 #include "libfreebob/xmlparser.h" 
    2928 
    3029// #include "libstreaming/MHStreamProcessor.h" 
  • branches/streaming-rework/src/motu/motu_avdevice.h

    r426 r435  
    2727#include "debugmodule/debugmodule.h" 
    2828#include "libavc/avc_definitions.h" 
    29 #include "libfreebob/xmlparser.h" 
    3029 
    3130#include "libstreaming/MotuStreamProcessor.h" 
  • branches/streaming-rework/src/rme/rme_avdevice.h

    r426 r435  
    2626#include "debugmodule/debugmodule.h" 
    2727#include "libavc/avc_definitions.h" 
    28 #include "libfreebob/xmlparser.h" 
    2928 
    3029// #include "libstreaming/RmeStreamProcessor.h" 
  • branches/streaming-rework/tests/Makefile.am

    r412 r435  
    2424 
    2525if BUILD_TESTS 
    26 noinst_PROGRAMS += test-freebob test-freebob-cpp test-extplugcmd test-fw410 freebob-server
     26noinst_PROGRAMS += test-freebob test-extplugcmd test-fw410
    2727                test-volume test-mixer test-cycletimer test-sytmonitor \ 
    2828                test-timestampedbuffer test-ieee1394service 
     
    3131noinst_HEADERS =  
    3232 
    33 test_freebob_SOURCES = test-freebob.c 
     33test_freebob_SOURCES = test-freebob.cpp 
    3434test_freebob_LDADD   = $(top_builddir)/src/libfreebob.la \ 
    35         $(LIBXML_LIBS) $(LIBAVC1394_LIBS) $(LIBIEC61883_LIBS) 
    36          
    37 test_freebob_cpp_SOURCES = test-freebob-cpp.cpp 
    38 test_freebob_cpp_LDADD   = $(top_builddir)/src/libfreebob.la \ 
    3935        $(LIBXML_LIBS) $(LIBAVC1394_LIBS) $(LIBIEC61883_LIBS) 
    4036 
     
    5854                               $(LIBAVC1394_LIBS) $(LIBIEC61883_LIBS) -lrom1394 
    5955 
    60 freebob_server_SOURCES = freebob-server.c 
    61 freebob_server_LDADD   = $(top_builddir)/src/libfreebob.la $(LIBXML_LIBS) \ 
    62         $(LIBAVC1394_LIBS) $(LIBIEC61883_LIBS) -lrom1394 
    63  
    6456#TESTS_ENVIRONMENT 
    6557TEST = test-freebob 
  • branches/streaming-rework/tests/test-freebob.cpp

    r412 r435  
    2727 
    2828#include "libfreebob/freebob.h" 
    29 #include "libfreebob/freebob_bounce.h" 
    3029 
    3130#include "debugmodule/debugmodule.h" 
     
    4140#include <string.h> 
    4241 
     42#include <vector> 
     43#include <string> 
     44#include <iostream> 
     45#include <sstream> 
     46 
     47#include <lo/lo.h> 
     48 
     49using namespace std; 
     50 
    4351DECLARE_GLOBAL_DEBUG_MODULE; 
    4452 
     53// prototypes & stuff for listing the OSC space 
     54void list_osc_paths(lo_server s, lo_address t, const char *path); 
     55void list_osc_params(lo_server s, lo_address t, const char *path); 
     56string osc_param_get_value(lo_server s, lo_address t, const char *path, const char *param); 
     57 
     58vector<string> osc_paths; 
     59vector<string> osc_params; 
     60string osc_value; 
     61 
     62int osc_path_response_handler(const char *path, const char *types, lo_arg **argv, int argc,  
     63    void *data, void *user_data); 
     64     
     65int osc_param_response_handler(const char *path, const char *types, lo_arg **argv, int argc,  
     66    void *data, void *user_data); 
     67     
     68int osc_data_response_handler(const char *path, const char *types, lo_arg **argv, int argc,  
     69    void *data, void *user_data); 
     70     
     71void osc_error_handler(int num, const char *msg, const char *path); 
     72 
     73// signal handler 
    4574int run=1; 
    4675static void sighandler (int sig) 
     
    4978} 
    5079 
     80// global's 
    5181const char *argp_program_version = PACKAGE_STRING; 
    5282const char *argp_program_bug_address = PACKAGE_BUGREPORT; 
     
    5484// Program documentation. 
    5585static char doc[] = "FreeBoB -- a driver for Firewire Audio devices (test application)\n\n" 
    56                     "OPERATION: discover\n" 
    57                     "           setsamplerate\n"; 
     86                    "OPERATION: Discover\n" 
     87                    "           SetSamplerate\n" 
     88                    "           ListOscSpace\n" 
     89                    "           OscServer\n"; 
    5890 
    5991// A description of the arguments we accept. 
     
    182214 
    183215    printf( "Using freebob library version: %s\n\n", freebob_get_version() ); 
    184  
    185     DeviceManager *m_deviceManager = new DeviceManager(); 
    186     if ( !m_deviceManager ) { 
    187         fprintf( stderr, "Could not allocate device manager\n" ); 
    188         return -1; 
    189     } 
    190     if ( !m_deviceManager->initialize( arguments.port ) ) { 
    191         fprintf( stderr, "Could not initialize device manager\n" ); 
     216     
     217    if ( strcmp( arguments.args[0], "Discover" ) == 0 ) { 
     218        DeviceManager *m_deviceManager = new DeviceManager(); 
     219        if ( !m_deviceManager ) { 
     220            fprintf( stderr, "Could not allocate device manager\n" ); 
     221            return -1; 
     222        } 
     223        if ( !m_deviceManager->initialize( arguments.port ) ) { 
     224            fprintf( stderr, "Could not initialize device manager\n" ); 
     225            delete m_deviceManager; 
     226            return -1; 
     227        } 
     228        if ( !m_deviceManager->discover(arguments.verbose) ) { 
     229            fprintf( stderr, "Could not discover devices\n" ); 
     230            delete m_deviceManager; 
     231            return -1; 
     232        } 
    192233        delete m_deviceManager; 
    193         return -1; 
    194     } 
    195  
    196     if ( strcmp( arguments.args[0], "discover" ) == 0 ) { 
    197         if ( m_deviceManager->discover(arguments.verbose) ) { 
    198             fprintf( stderr, "Could not discover devices\n" ); 
    199             delete m_deviceManager; 
    200             return -1; 
    201         } 
    202     } else if ( strcmp( arguments.args[0], "setsamplerate" ) == 0 ) { 
     234        return 0; 
     235    } else if ( strcmp( arguments.args[0], "SetSamplerate" ) == 0 ) { 
    203236        char* tail; 
    204237        int samplerate = strtol( arguments.args[1], &tail, 0 ); 
     
    207240            return -1; 
    208241        } 
    209  
    210         if ( m_deviceManager->discover(arguments.verbose) ) { 
     242         
     243        DeviceManager *m_deviceManager = new DeviceManager(); 
     244        if ( !m_deviceManager ) { 
     245            fprintf( stderr, "Could not allocate device manager\n" ); 
     246            return -1; 
     247        } 
     248        if ( !m_deviceManager->initialize( arguments.port ) ) { 
     249            fprintf( stderr, "Could not initialize device manager\n" ); 
     250            delete m_deviceManager; 
     251            return -1; 
     252        } 
     253 
     254        if ( !m_deviceManager->discover(arguments.verbose) ) { 
    211255            fprintf( stderr, "Could not discover devices\n" ); 
    212256            delete m_deviceManager; 
     
    224268            } 
    225269        } else { 
    226         int i=0; 
    227              
    228         int devices_on_bus = m_deviceManager->getNbDevices(); 
    229         printf("  port = %d, devices_on_bus = %d\n", arguments.port, devices_on_bus); 
    230  
    231         for(i=0;i<devices_on_bus;i++) { 
    232             int node_id=m_deviceManager->getDeviceNodeId(i); 
    233             printf("  set samplerate for device = %d, node = %d\n", i, node_id); 
    234             IAvDevice* avDevice = m_deviceManager->getAvDevice( node_id ); 
    235             if ( avDevice ) { 
    236                 if ( !avDevice->setSamplingFrequency( parseSampleRate( samplerate ) ) ) { 
    237                     fprintf( stderr, "Could not set samplerate\n" ); 
     270            int i=0; 
     271                 
     272            int devices_on_bus = m_deviceManager->getNbDevices(); 
     273            printf("  port = %d, devices_on_bus = %d\n", arguments.port, devices_on_bus); 
     274     
     275            for(i=0;i<devices_on_bus;i++) { 
     276                int node_id=m_deviceManager->getDeviceNodeId(i); 
     277                printf("  set samplerate for device = %d, node = %d\n", i, node_id); 
     278                IAvDevice* avDevice = m_deviceManager->getAvDevice( node_id ); 
     279                if ( avDevice ) { 
     280                    if ( !avDevice->setSamplingFrequency( parseSampleRate( samplerate ) ) ) { 
     281                        fprintf( stderr, "Could not set samplerate\n" ); 
     282                    } 
    238283                } 
    239284            } 
    240285        } 
    241  
    242         } 
     286        delete m_deviceManager; 
     287        return 0; 
     288    } else if ( strcmp( arguments.args[0], "ListOscSpace" ) == 0 ) { 
     289        // list osc space by using OSC messages 
     290        // a server is assumed to be present 
     291         
     292        /* start a new server. 
     293        when sending a message from this context, the response 
     294        address will be set to this server's address. 
     295        */ 
     296        lo_server s = lo_server_new(NULL, osc_error_handler); 
     297        lo_address t = lo_address_new(NULL, "17820"); 
     298         
     299        list_osc_paths(s, t, "/"); 
     300         
     301        lo_address_free(t); 
     302        lo_server_free(s); 
     303         
     304    } else if ( strcmp( arguments.args[0], "OscServer" ) == 0 ) { 
     305        DeviceManager *m_deviceManager = new DeviceManager(); 
     306        if ( !m_deviceManager ) { 
     307            fprintf( stderr, "Could not allocate device manager\n" ); 
     308            return -1; 
     309        } 
     310        if ( !m_deviceManager->initialize( arguments.port ) ) { 
     311            fprintf( stderr, "Could not initialize device manager\n" ); 
     312            delete m_deviceManager; 
     313            return -1; 
     314        } 
     315 
     316        if ( !m_deviceManager->discover(arguments.verbose) ) { 
     317            fprintf( stderr, "Could not discover devices\n" ); 
     318            delete m_deviceManager; 
     319            return -1; 
     320        } 
     321 
     322        printf("server started\n"); 
     323        printf("press ctrl-c to stop it & continue\n"); 
     324         
     325        signal (SIGINT, sighandler); 
     326         
     327        run=1; 
     328        while(run) { 
     329            sleep(1); 
     330            fflush(stdout); 
     331            fflush(stderr); 
     332        } 
     333        signal (SIGINT, SIG_DFL); 
     334         
     335        printf("server stopped\n"); 
     336        delete m_deviceManager; 
     337        return 0; 
     338         
    243339    } else { 
    244340        printf( "unknown operation\n" ); 
    245341    } 
    246342 
    247     return 0; 
    248 
     343
     344 
     345void list_osc_paths(lo_server s, lo_address t, const char *path) { 
     346    vector<string> my_paths; 
     347     
     348    printf("listing path: %s\n", path); 
     349     
     350    osc_paths.clear(); 
     351    lo_server_add_method(s, "/response", NULL, osc_path_response_handler, NULL); 
     352 
     353    if (lo_send(t, path, "s", "list") == -1) { 
     354        printf(" OSC error %d: %s\n", lo_address_errno(t), lo_address_errstr(t)); 
     355    } 
     356 
     357    if (lo_server_recv_noblock(s, 1000) == 0) { 
     358        printf("timeout\n"); 
     359        return; 
     360    } 
     361     
     362    lo_server_del_method(s, "/response", NULL); 
     363     
     364    list_osc_params(s, t, path); 
     365     
     366    my_paths=osc_paths; 
     367    for ( vector<string>::iterator it = my_paths.begin(); 
     368            it != my_paths.end(); 
     369            ++it ) 
     370    { 
     371        string new_path=string(path) + *it; 
     372        new_path += string("/"); 
     373        list_osc_paths(s, t, new_path.c_str()); 
     374    } 
     375 
     376
     377 
     378void list_osc_params(lo_server s, lo_address t, const char *path) { 
     379    vector<string> my_paths; 
     380    printf("params for: %s\n", path); 
     381     
     382    osc_params.clear(); 
     383    lo_server_add_method(s, "/response", NULL, osc_param_response_handler, NULL); 
     384 
     385    if (lo_send(t, path, "s", "params") == -1) { 
     386        printf(" OSC error %d: %s\n", lo_address_errno(t), lo_address_errstr(t)); 
     387    } 
     388     
     389    if (lo_server_recv_noblock(s, 1000) == 0) { 
     390        printf("timeout\n"); 
     391        return; 
     392    } 
     393     
     394    lo_server_del_method(s, "/response", NULL); 
     395     
     396    vector<string> my_params=osc_params; 
     397     
     398    for ( vector<string>::iterator it = my_params.begin(); 
     399            it != my_params.end(); 
     400            ++it ) 
     401    { 
     402        string value=osc_param_get_value(s, t, path, (*it).c_str()); 
     403        printf("  %20s = %s\n", (*it).c_str(), value.c_str()); 
     404    } 
     405 
     406
     407 
     408string osc_param_get_value(lo_server s, lo_address t, const char *path, const char *param) { 
     409    lo_server_add_method(s, "/response", NULL, osc_data_response_handler, NULL); 
     410 
     411    if (lo_send(t, path, "ss", "get", param) == -1) { 
     412        printf(" OSC error %d: %s\n", lo_address_errno(t), lo_address_errstr(t)); 
     413    } 
     414     
     415    if (lo_server_recv_noblock(s, 1000) == 0) { 
     416        return string("timeout"); 
     417    } 
     418     
     419    lo_server_del_method(s, "/response", NULL); 
     420    return osc_value; 
     421
     422 
     423void osc_error_handler(int num, const char *msg, const char *path) 
     424
     425    printf("liblo server error %d in path %s: %s\n", num, path, msg); 
     426
     427 
     428int osc_path_response_handler(const char *path, const char *types, lo_arg **argv, int argc, 
     429        void *data, void *user_data) 
     430
     431    for (int i=0; i< argc;i++) { 
     432        switch (lo_type(types[i])) { 
     433            /** Standard C, NULL terminated string. */ 
     434            case LO_STRING: 
     435                osc_paths.push_back(string(&(argv[i]->s))); 
     436                break; 
     437            default: 
     438                printf("unexpected data type in response message\n"); 
     439        } 
     440    } 
     441    return 1; 
     442
     443 
     444int osc_param_response_handler(const char *path, const char *types, lo_arg **argv, int argc, 
     445        void *data, void *user_data) 
     446
     447    for (int i=0; i< argc;i++) { 
     448        switch (lo_type(types[i])) { 
     449            /** Standard C, NULL terminated string. */ 
     450            case LO_STRING: 
     451                osc_params.push_back(string(&(argv[i]->s))); 
     452                break; 
     453            default: 
     454                printf("unexpected data type in response message\n"); 
     455        } 
     456    } 
     457    return 1; 
     458
     459 
     460int osc_data_response_handler(const char *path, const char *types, lo_arg **argv, int argc, 
     461        void *data, void *user_data) 
     462
     463    std::ostringstream str; 
     464     
     465    if(argc==1) { 
     466        switch (lo_type(types[0])) { 
     467            /* basic OSC types */ 
     468            /** 32 bit signed integer. */ 
     469            case LO_INT32: 
     470                str << "0x" << std::hex << argv[0]->i; 
     471                osc_value=str.str(); 
     472                break; 
     473            case LO_INT64: 
     474                str << "0x" << std::hex << argv[0]->h; 
     475                osc_value=str.str(); 
     476                break; 
     477            /** 32 bit IEEE-754 float. */ 
     478            case LO_FLOAT: 
     479                str << argv[0]->f; 
     480                osc_value=str.str(); 
     481                break; 
     482            /** Standard C, NULL terminated string. */ 
     483            case LO_STRING: 
     484                osc_value=string(&argv[0]->s); 
     485                break; 
     486            default: 
     487                osc_value="unsupported response datatype"; 
     488        } 
     489    } else { 
     490        osc_value="invalid response"; 
     491    } 
     492    return 1; 
     493