Changeset 407

Show
Ignore:
Timestamp:
02/20/07 06:38:52 (16 years ago)
Author:
pieterpalmers
Message:

- Changed the way the device class configure options are handled. Now they are handled in the makefiles instead of the source files. The only source file that still contains the #ifdef's is devicemanager.cpp, to conditionally include the device class include files and to conditionally probe the classes that might be supported.
- added a configure option to disable the compilation of the test programs in tests/
- cleaned up the ADMTP transmit streamprocessor. Now it sends silenced packets when in the disabled state, instead of no-data packets
- added a getNodeID() to ieee1394service
- made comments in ieee1394service.h doxygen compliant

Files:

Legend:

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

    r404 r407  
    2525m4_define(freebob_major_version, 1) 
    2626m4_define(freebob_minor_version, 999) 
    27 m4_define(freebob_micro_version, 1
     27m4_define(freebob_micro_version, 2
    2828 
    2929m4_define(freebob_version, freebob_major_version.freebob_minor_version.freebob_micro_version) 
     
    287287[build_all=false]) 
    288288 
     289AC_ARG_ENABLE(tests, 
     290    AC_HELP_STRING([--enable-tests], 
     291                   [build programs in the tests directory (default=yes)]), 
     292[case "${enableval}" in 
     293  yes) build_tests=true;; 
     294  no)  build_tests=false;; 
     295  *) AC_MSG_ERROR(bad value ${enableval} for --enable-tests) ;; 
     296esac], 
     297[build_tests=true]) 
    289298 
    290299CFLAGS="$CFLAGS -Wall -std=gnu99" 
     
    309318fi; 
    310319 
     320build_amdtp=false 
     321 
    311322if test "${build_bebob}" = true; then 
    312323   CFLAGS="$CFLAGS -DENABLE_BEBOB" 
    313324   CXXFLAGS="$CXXFLAGS -DENABLE_BEBOB"  
    314325   supported_devices="${supported_devices}BeBoB  " 
    315    BIN_PROGRAMS="$BIN_PROGRAMS freebob-downloader freebob-sync" 
     326   build_amdtp=true 
    316327fi; 
    317328 
     
    320331   CXXFLAGS="$CXXFLAGS -DENABLE_MOTU"  
    321332   supported_devices="${supported_devices}Motu  " 
    322    BIN_PROGRAMS="$BIN_PROGRAMS" 
    323333fi; 
    324334 
     
    327337   CXXFLAGS="$CXXFLAGS -DENABLE_DICE"  
    328338   supported_devices="${supported_devices}DICE  " 
    329    BIN_PROGRAMS="$BIN_PROGRAMS" 
     339   build_amdtp=true 
    330340fi; 
    331341 
     
    334344   CXXFLAGS="$CXXFLAGS -DENABLE_METRIC_HALO" 
    335345   supported_devices="${supported_devices}Metric Halo (useless)  " 
    336    BIN_PROGRAMS="$BIN_PROGRAMS" 
    337346fi; 
    338347 
     
    341350   CXXFLAGS="$CXXFLAGS -DENABLE_BOUNCE" 
    342351   supported_devices="${supported_devices}Bounce  " 
    343    BIN_PROGRAMS="$BIN_PROGRAMS" 
     352   build_amdtp=true 
    344353fi; 
    345354 
     
    348357   CXXFLAGS="$CXXFLAGS -DENABLE_RME"  
    349358   supported_devices="${supported_devices}RME (useless)  " 
    350    BIN_PROGRAMS="$BIN_PROGRAMS" 
    351359fi; 
    352360 
     
    354362    AC_ERROR(You need to enable at least one device class to support!) 
    355363fi; 
     364 
     365AM_CONDITIONAL(BUILD_BEBOB,test "${build_bebob}" = true) 
     366AM_CONDITIONAL(BUILD_MOTU,test "${build_motu}" = true) 
     367AM_CONDITIONAL(BUILD_DICE,test "${build_dice}" = true) 
     368AM_CONDITIONAL(BUILD_METRIC_HALO,test "${build_metric_halo}" = true) 
     369AM_CONDITIONAL(BUILD_BOUNCE,test "${build_bounce}" = true) 
     370AM_CONDITIONAL(BUILD_RME,test "${build_rme}" = true) 
     371 
     372AM_CONDITIONAL(BUILD_AMDTP,test "${build_amdtp}" = true) 
     373 
     374AM_CONDITIONAL(BUILD_TESTS,test "${build_tests}" = true) 
    356375 
    357376AC_SUBST([CFLAGS]) 
     
    394413 
    395414  Building support for: $supported_devices 
     415   build AMDTP support: $build_amdtp 
     416    
     417  Building tests:       $build_tests 
    396418 
    397419  Source directory:     $srcdir 
  • branches/streaming-rework/libfreebob/freebob_bounce.h

    r209 r407  
    2828#define FREEBOB_BOUNCE_SERVER_MODELNAME   "freebob-server" 
    2929 
     30// NOTE: this is currently free, but it is not really allowed to use 
     31#define FREEBOB_BOUNCE_SERVER_VENDORID    0x000B0001 
     32#define FREEBOB_BOUNCE_SERVER_MODELID     0x000B0001 
     33#define FREEBOB_BOUNCE_SERVER_SPECID      0x000B0001 
     34 
     35 
    3036#define FREEBOB_BOUNCE_SERVER_GETXMLDESCRIPTION_CMD 
    3137#define AVC1394_SUBUNIT_TYPE_FREEBOB_BOUNCE_SERVER      0x0D 
  • branches/streaming-rework/src/bebob/bebob_avdevice.cpp

    r404 r407  
    1818 * MA 02111-1307 USA. 
    1919 */ 
    20  
    21 #ifdef ENABLE_BEBOB 
    2220 
    2321#include "bebob/bebob_avdevice.h" 
     
    16071605 
    16081606} // end of namespace 
    1609  
    1610 #endif //#ifdef ENABLE_BEBOB 
  • branches/streaming-rework/src/bebob/bebob_avdevice.h

    r404 r407  
    1818 * MA 02111-1307 USA. 
    1919 */ 
    20  
    21 #ifdef ENABLE_BEBOB 
    22  
    2320#ifndef BEBOB_AVDEVICE_H 
    2421#define BEBOB_AVDEVICE_H 
     
    197194 
    198195#endif 
    199  
    200 #endif //#ifdef ENABLE_BEBOB 
  • branches/streaming-rework/src/bebob/bebob_avdevice_subunit.cpp

    r404 r407  
    1818 * MA 02111-1307 USA. 
    1919 */ 
    20  
    21 #ifdef ENABLE_BEBOB 
    2220 
    2321#include "bebob/bebob_functionblock.h" 
     
    588586    return true; 
    589587} 
    590  
    591 #endif //#ifdef ENABLE_BEBOB 
  • branches/streaming-rework/src/bebob/bebob_avdevice_subunit.h

    r404 r407  
    1818 * MA 02111-1307 USA. 
    1919 */ 
    20  
    21 #ifdef ENABLE_BEBOB 
    22  
    2320#ifndef BEBOB_AVDEVICESUBUNIT_H 
    2421#define BEBOB_AVDEVICESUBUNIT_H 
     
    156153 
    157154#endif 
    158  
    159 #endif //#ifdef ENABLE_BEBOB 
  • branches/streaming-rework/src/bebob/bebob_avdevice_xml.cpp

    r404 r407  
    1818 * MA 02111-1307 USA. 
    1919 */ 
    20  
    21 #ifdef ENABLE_BEBOB 
    22  
    2320// AvDevice XML stuff 
    2421 
     
    122119 
    123120} 
    124  
    125 #endif //#ifdef ENABLE_BEBOB 
  • branches/streaming-rework/src/bebob/bebob_avplug.cpp

    r404 r407  
    1818 * MA 02111-1307 USA. 
    1919 */ 
    20  
    21 #ifdef ENABLE_BEBOB 
    2220 
    2321#include "bebob/bebob_avplug.h" 
     
    22222220 
    22232221} 
    2224  
    2225 #endif //#ifdef ENABLE_BEBOB 
  • branches/streaming-rework/src/bebob/bebob_avplug.h

    r404 r407  
    1818 * MA 02111-1307 USA. 
    1919 */ 
    20  
    21 #ifdef ENABLE_BEBOB 
    2220 
    2321#ifndef BEBOB_AVPLUG_H 
     
    358356 
    359357#endif 
    360  
    361 #endif //#ifdef ENABLE_BEBOB 
  • branches/streaming-rework/src/bebob/bebob_avplug_xml.cpp

    r404 r407  
    1818 * MA 02111-1307 USA. 
    1919 */ 
    20   
    21 #ifdef ENABLE_BEBOB 
    2220 
    2321// AvPlug XML stuff 
     
    300298 
    301299} 
    302  
    303 #endif //#ifdef ENABLE_BEBOB 
  • branches/streaming-rework/src/bebob/bebob_dl_bcd.cpp

    r404 r407  
    1919 */ 
    2020 
    21 #ifdef ENABLE_BEBOB 
    22  
    2321#include "bebob_dl_bcd.h" 
    2422 
     
    384382    printf( "\tCNE CRC:\t\t0x%08x\n", m_cneCRC ); 
    385383} 
    386  
    387 #endif //#ifdef ENABLE_BEBOB 
  • branches/streaming-rework/src/bebob/bebob_dl_bcd.h

    r404 r407  
    1818 * MA 02111-1307 USA. 
    1919 */ 
    20  
    21 #ifdef ENABLE_BEBOB 
    22  
    2320#ifndef BEBOB_DL_BCD_H 
    2421#define BEBOB_DL_BCD_H 
     
    116113 
    117114#endif 
    118  
    119 #endif //#ifdef ENABLE_BEBOB 
  • branches/streaming-rework/src/bebob/bebob_dl_codes.cpp

    r404 r407  
    1818 * MA 02111-1307 USA. 
    1919 */ 
    20  
    21 #ifdef ENABLE_BEBOB 
    22  
    2320#include "bebob/bebob_dl_codes.h" 
    2421#include "bebob/bebob_dl_bcd.h" 
     
    346343    return result; 
    347344} 
    348  
    349 #endif //#ifdef ENABLE_BEBOB 
  • branches/streaming-rework/src/bebob/bebob_dl_mgr.cpp

    r404 r407  
    1818 * MA 02111-1307 USA. 
    1919 */ 
    20  
    21 #ifdef ENABLE_BEBOB 
    22  
    2320#include "bebob_dl_mgr.h" 
    2421#include "bebob_dl_codes.h" 
     
    716713    return false; 
    717714} 
    718  
    719 #endif //#ifdef ENABLE_BEBOB 
  • branches/streaming-rework/src/bebob/bebob_dl_mgr.h

    r404 r407  
    1818 * MA 02111-1307 USA. 
    1919 */ 
    20  
    21 #ifdef ENABLE_BEBOB 
    22  
    2320#ifndef BEBOB_DL_MGR_H 
    2421#define BEBOB_DL_MGR_H 
     
    127124 
    128125#endif 
    129  
    130 #endif //#ifdef ENABLE_BEBOB 
  • branches/streaming-rework/src/bebob/bebob_functionblock.cpp

    r404 r407  
    1818 * MA 02111-1307 USA. 
    1919 */ 
    20  
    21 #ifdef ENABLE_BEBOB 
    22  
    2320#include "bebob/bebob_functionblock.h" 
    2421#include "bebob/bebob_avdevice_subunit.h" 
     
    553550    return true; 
    554551} 
    555  
    556 #endif //#ifdef ENABLE_BEBOB 
  • branches/streaming-rework/src/bebob/bebob_functionblock.h

    r404 r407  
    1818 * MA 02111-1307 USA. 
    1919 */ 
    20  
    21 #ifdef ENABLE_BEBOB 
    22  
    2320#ifndef BEBOB_FUNCTION_BLOCK_H 
    2421#define BEBOB_FUNCTION_BLOCK_H 
     
    220217 
    221218#endif 
    222  
    223 #endif //#ifdef ENABLE_BEBOB 
  • branches/streaming-rework/src/bounce/bounce_avdevice.cpp

    r405 r407  
    1919 * MA 02111-1307 USA. 
    2020 */ 
    21  
    22 #ifdef ENABLE_BOUNCE 
    23  
    2421#include "bounce/bounce_avdevice.h" 
    2522#include "configrom.h" 
     
    247244            } else { 
    248245                debugOutput(DEBUG_LEVEL_VERBOSE, "Added port %s\n",buff); 
    249  
    250246            } 
    251247        } 
     
    339335// 
    340336//              // set the channel obtained by the connection management 
    341                 m_receiveProcessor->setChannel(1); 
    342                 break; 
    343         case 1: 
     337    #warning TEST CODE FOR BOUNCE DEVICE !! 
     338        if (m_configRom->getNodeId()==0) { 
     339            m_receiveProcessor->setChannel(1); 
     340        } else { 
     341            m_receiveProcessor->setChannel(0); 
     342        } 
     343                break; 
     344        case 1: 
    344345//              // do connection management: make connection 
    345346//              iso_channel = iec61883_cmp_connect( 
     
    353354//              // set the channel obtained by the connection management 
    354355// //           m_receiveProcessor2->setChannel(iso_channel); 
    355                 m_transmitProcessor->setChannel(0); 
     356    #warning TEST CODE FOR BOUNCE DEVICE !! 
     357        if (m_configRom->getNodeId()==0) { 
     358            m_transmitProcessor->setChannel(0); 
     359        } else { 
     360            m_transmitProcessor->setChannel(1); 
     361        } 
    356362                break; 
    357363        default: 
     
    405411 
    406412} // namespace 
    407  
    408 #endif // #ifdef ENABLE_BOUNCE 
  • branches/streaming-rework/src/bounce/bounce_avdevice.h

    r405 r407  
    1919 * MA 02111-1307 USA. 
    2020 */ 
    21  
    22 #ifdef ENABLE_BOUNCE 
    23  
    2421#ifndef BOUNCEDEVICE_H 
    2522#define BOUNCEDEVICE_H 
     
    112109 
    113110#endif 
    114  
    115 #endif // #ifdef ENABLE_BOUNCE 
  • branches/streaming-rework/src/devicemanager.cpp

    r405 r407  
    2727#include "libfreebobavc/ieee1394service.h" 
    2828#include "debugmodule/debugmodule.h" 
    29 #include "bebob/bebob_avdevice.h" 
    30 #include "bounce/bounce_avdevice.h" 
    31 #include "motu/motu_avdevice.h" 
    32 #include "rme/rme_avdevice.h" 
    33 #include "maudio/maudio_avdevice.h" 
    34 #include "dice/dice_avdevice.h" 
    35 #include "metrichalo/mh_avdevice.h" 
    3629 
    3730#include <iostream> 
     
    3932 
    4033#include <unistd.h> 
     34 
     35#include "libstreaming/StreamProcessor.h" 
     36 
     37#ifdef ENABLE_BEBOB 
     38    #include "bebob/bebob_avdevice.h" 
     39    #include "maudio/maudio_avdevice.h" 
     40#endif 
     41 
     42#ifdef ENABLE_BOUNCE 
     43    #include "bounce/bounce_avdevice.h" 
     44#endif 
     45 
     46#ifdef ENABLE_MOTU 
     47#include "motu/motu_avdevice.h" 
     48#endif 
     49 
     50#ifdef ENABLE_RME 
     51#include "rme/rme_avdevice.h" 
     52#endif 
     53 
     54#ifdef ENABLE_DICE 
     55#include "dice/dice_avdevice.h" 
     56#endif 
     57 
     58#ifdef ENABLE_METRIC_HALO 
     59#include "metrichalo/mh_avdevice.h" 
     60#endif 
    4161 
    4262using namespace std; 
     
    101121    { 
    102122        debugOutput( DEBUG_LEVEL_VERBOSE, "Probing node %d...\n", nodeId ); 
     123 
     124        if (nodeId == m_1394Service->getLocalNodeId()) { 
     125            debugOutput( DEBUG_LEVEL_VERBOSE, "Skipping local node (%d)...\n", nodeId ); 
     126            continue; 
     127        } 
    103128 
    104129        std::auto_ptr<ConfigRom> configRom = 
     
    261286{ 
    262287        return m_avDevices.size(); 
     288} 
     289 
     290/** 
     291 * Return the streamprocessor that is to be used as 
     292 * the sync source. 
     293 * 
     294 * Algorithm still to be determined 
     295 * 
     296 * @return StreamProcessor that is sync source 
     297 */ 
     298FreebobStreaming::StreamProcessor * 
     299DeviceManager::getSyncSource() { 
     300    IAvDevice* device = getAvDeviceByIndex(0); 
     301     
     302    #warning TEST CODE FOR BOUNCE DEVICE !! 
     303    if (device->getConfigRom().getNodeId()==0) { 
     304        return device->getStreamProcessorByIndex(0); 
     305    } else { 
     306        return device->getStreamProcessorByIndex(1); 
     307    } 
     308     
    263309} 
    264310 
  • branches/streaming-rework/src/devicemanager.h

    r365 r407  
    3232class Ieee1394Service; 
    3333class IAvDevice; 
     34namespace FreebobStreaming { 
     35    class StreamProcessor; 
     36} 
    3437 
    3538typedef std::vector< IAvDevice* > IAvDeviceVector; 
     
    6265    bool loadCache( Glib::ustring fileName ); 
    6366 
     67    FreebobStreaming::StreamProcessor *getSyncSource(); 
     68 
    6469protected: 
    6570    IAvDevice* getDriverForDevice( std::auto_ptr<ConfigRom>( configRom ), 
  • branches/streaming-rework/src/dice/dice_avdevice.cpp

    r404 r407  
    1818 * MA 02111-1307 USA. 
    1919 */ 
    20  
    21 #ifdef ENABLE_DICE 
    2220#warning DICE support is currently useless 
    2321 
     
    241239 
    242240} 
    243  
    244 #endif //#ifdef ENABLE_DICE 
  • branches/streaming-rework/src/dice/dice_avdevice.h

    r404 r407  
    1818 * MA 02111-1307 USA. 
    1919 */ 
    20  
    21 #ifdef ENABLE_DICE 
    22  
    2320#ifndef DICEDEVICE_H 
    2421#define DICEDEVICE_H 
     
    10097 
    10198#endif 
    102  
    103 #endif //#ifdef ENABLE_DICE 
  • branches/streaming-rework/src/freebob_streaming.cpp

    r386 r407  
    118118                return 0; 
    119119        } 
    120  
     120         
    121121        // iterate over the found devices 
    122122        // add the stream processors of the devices to the managers 
     
    127127            debugOutput(DEBUG_LEVEL_VERBOSE, "Setting samplerate to %d for (%p)\n",  
    128128                        dev->options.sample_rate, device); 
     129                         
    129130            // Set the device's sampling rate to that requested 
    130131            // FIXME: does this really belong here?  If so we need to handle errors. 
     
    154155                } 
    155156            } 
     157        } 
     158         
     159        // set the sync source 
     160        if (!dev->processorManager->setSyncSource(dev->m_deviceManager->getSyncSource())) { 
     161            debugWarning("Could not set processorManager sync source (%p)\n", 
     162                dev->m_deviceManager->getSyncSource()); 
    156163        } 
    157164 
  • branches/streaming-rework/src/libfreebobavc/ieee1394service.cpp

    r405 r407  
    9898} 
    9999 
     100nodeid_t Ieee1394Service::getLocalNodeId() { 
     101    return raw1394_get_local_id(m_handle) & 0x3F; 
     102} 
     103 
    100104bool 
    101105Ieee1394Service::read( fb_nodeid_t nodeId, 
  • branches/streaming-rework/src/libfreebobavc/ieee1394service.h

    r340 r407  
    4242        { return m_port; } 
    4343   /** 
    44     * getNodecount - get number of nodes on the bus 
     44    * @brief get number of nodes on the bus 
    4545    * 
    4646    * Since the root node always has 
     
    4848    * LOCAL_BUS|(count-1)). 
    4949    * 
    50     * Returns: the number of nodes on the bus to which the port is connected. 
     50    * @return the number of nodes on the bus to which the port is connected. 
    5151    * This value can change with every bus reset. 
    5252    */ 
    5353    int getNodeCount(); 
    54  
     54     
    5555   /** 
    56     * read - send async read request to a node and wait for response. 
    57     * @node: target node (\XXX needs 0xffc0 stuff) 
    58     * @addr: address to read from 
    59     * @length: amount of data to read in quadlets 
    60     * @buffer: pointer to buffer where data will be saved 
     56    * @brief get the node id of the local node 
     57    * 
     58    * @return the node id of the local node 
     59    * This value can change with every bus reset. 
     60    */ 
     61    nodeid_t getLocalNodeId(); 
     62     
     63   /** 
     64    * @brief send async read request to a node and wait for response. 
    6165    * 
    6266    * This does the complete transaction and will return when it's finished. 
    6367    * 
    64     * Returns: true on success or false on failure (sets errno) 
     68    * @param node target node (\todo needs 0xffc0 stuff) 
     69    * @param addr address to read from 
     70    * @param length amount of data to read in quadlets 
     71    * @param buffer pointer to buffer where data will be saved 
     72     
     73    * @return true on success or false on failure (sets errno) 
    6574    */ 
    6675    bool read( fb_nodeid_t nodeId, 
     
    7887 
    7988    /** 
    80     * write - send async write request to a node and wait for response. 
    81     * @node: target node (\XXX needs 0xffc0 stuff) 
    82     * @addr: address to write to 
    83     * @length: amount of data to write in quadlets 
    84     * @data: pointer to data to be sent 
     89    * @brief send async write request to a node and wait for response. 
    8590    * 
    8691    * This does the complete transaction and will return when it's finished. 
    8792    * 
    88     * Returns: true on success or false on failure (sets errno) 
     93    * @param node target node (\XXX needs 0xffc0 stuff) 
     94    * @param addr address to write to 
     95    * @param length amount of data to write in quadlets 
     96    * @param data pointer to data to be sent 
     97    * 
     98    * @return true on success or false on failure (sets errno) 
    8999    */ 
    90100    bool write( fb_nodeid_t nodeId, 
  • branches/streaming-rework/src/libstreaming/AmdtpPort.cpp

    r404 r407  
    2626 * 
    2727 */ 
    28 #ifdef ENABLE_BEBOB 
    29     #ifndef ENABLE_AMDTP_SP 
    30         #define ENABLE_AMDTP_SP 
    31     #endif 
    32 #endif 
    33  
    34 #ifdef ENABLE_DICE  
    35     #ifndef ENABLE_AMDTP_SP 
    36         #define ENABLE_AMDTP_SP 
    37     #endif 
    38 #endif 
    39  
    40 #ifdef ENABLE_BOUNCE 
    41     #ifndef ENABLE_AMDTP_SP 
    42         #define ENABLE_AMDTP_SP 
    43     #endif 
    44 #endif 
    45  
    46 #ifdef ENABLE_AMDTP_SP 
    47  
    4828#include "AmdtpPort.h" 
    4929#include <assert.h> 
     
    5232 
    5333} // end of namespace FreebobStreaming 
    54  
    55 #endif // #ifdef ENABLE_AMDTP_SP 
  • branches/streaming-rework/src/libstreaming/AmdtpPort.h

    r404 r407  
    2626 * 
    2727 */ 
    28 #ifdef ENABLE_BEBOB 
    29     #ifndef ENABLE_AMDTP_SP 
    30         #define ENABLE_AMDTP_SP 
    31     #endif 
    32 #endif 
    33  
    34 #ifdef ENABLE_DICE  
    35     #ifndef ENABLE_AMDTP_SP 
    36         #define ENABLE_AMDTP_SP 
    37     #endif 
    38 #endif 
    39  
    40 #ifdef ENABLE_BOUNCE 
    41     #ifndef ENABLE_AMDTP_SP 
    42         #define ENABLE_AMDTP_SP 
    43     #endif 
    44 #endif 
    45  
    46 #ifdef ENABLE_AMDTP_SP 
    47  
    4828#ifndef __FREEBOB_AMDTPPORT__ 
    4929#define __FREEBOB_AMDTPPORT__ 
     
    11999 
    120100#endif /* __FREEBOB_AMDTPPORT__ */ 
    121  
    122 #endif // #ifdef ENABLE_AMDTP_SP 
  • branches/streaming-rework/src/libstreaming/AmdtpPortInfo.cpp

    r404 r407  
    2626 * 
    2727 */ 
    28  
    29 #ifdef ENABLE_BEBOB 
    30     #ifndef ENABLE_AMDTP_SP 
    31         #define ENABLE_AMDTP_SP 
    32     #endif 
    33 #endif 
    34  
    35 #ifdef ENABLE_DICE  
    36     #ifndef ENABLE_AMDTP_SP 
    37         #define ENABLE_AMDTP_SP 
    38     #endif 
    39 #endif 
    40  
    41 #ifdef ENABLE_BOUNCE 
    42     #ifndef ENABLE_AMDTP_SP 
    43         #define ENABLE_AMDTP_SP 
    44     #endif 
    45 #endif 
    46  
    47 #ifdef ENABLE_AMDTP_SP 
    48  
    4928#include "AmdtpPortInfo.h" 
    5029#include <assert.h> 
     
    5534 
    5635} // end of namespace FreebobStreaming 
    57  
    58 #endif // #ifdef ENABLE_AMDTP_SP 
  • branches/streaming-rework/src/libstreaming/AmdtpPortInfo.h

    r404 r407  
    2626 * 
    2727 */ 
    28   
    29 #ifdef ENABLE_BEBOB 
    30     #ifndef ENABLE_AMDTP_SP 
    31         #define ENABLE_AMDTP_SP 
    32     #endif 
    33 #endif 
    34  
    35 #ifdef ENABLE_DICE  
    36     #ifndef ENABLE_AMDTP_SP 
    37         #define ENABLE_AMDTP_SP 
    38     #endif 
    39 #endif 
    40  
    41 #ifdef ENABLE_BOUNCE 
    42     #ifndef ENABLE_AMDTP_SP 
    43         #define ENABLE_AMDTP_SP 
    44     #endif 
    45 #endif 
    46  
    47 #ifdef ENABLE_AMDTP_SP 
    48  
    4928#ifndef __FREEBOB_AMDTPPORTINFO__ 
    5029#define __FREEBOB_AMDTPPORTINFO__ 
     
    10786 
    10887#endif /* __FREEBOB_AMDTPPORTINFO__ */ 
    109  
    110 #endif // #ifdef ENABLE_AMDTP_SP 
  • branches/streaming-rework/src/libstreaming/AmdtpStreamProcessor.cpp

    r404 r407  
    2626 * 
    2727 */ 
    28  
    29 #ifdef ENABLE_BEBOB 
    30     #ifndef ENABLE_AMDTP_SP 
    31         #define ENABLE_AMDTP_SP 
    32     #endif 
    33 #endif 
    34  
    35 #ifdef ENABLE_DICE  
    36     #ifndef ENABLE_AMDTP_SP 
    37         #define ENABLE_AMDTP_SP 
    38     #endif 
    39 #endif 
    40  
    41 #ifdef ENABLE_BOUNCE 
    42     #ifndef ENABLE_AMDTP_SP 
    43         #define ENABLE_AMDTP_SP 
    44     #endif 
    45 #endif 
    46  
    47 #ifdef ENABLE_AMDTP_SP 
    48  
    4928#include "AmdtpStreamProcessor.h" 
    5029#include "Port.h" 
     
    5736 
    5837// in ticks 
    59 #define TRANSMIT_TRANSFER_DELAY 6000U 
     38#define TRANSMIT_TRANSFER_DELAY 9000U 
    6039// the number of cycles to send a packet in advance of it's timestamp 
    6140#define TRANSMIT_ADVANCE_CYCLES 1U 
     
    190169            ts_head = addTicks(ts_head, sync_lag_cycles * TICKS_PER_CYCLE); 
    191170             
    192             m_data_buffer->setBufferTailTimestamp(ts_head); 
     171            m_data_buffer->setBufferHeadTimestamp(ts_head); 
    193172             
    194173            #ifdef DEBUG 
     
    213192    // the base timestamp is the one of the next sample in the buffer 
    214193    m_data_buffer->getBufferHeadTimestamp(&ts_head, &fc); // thread safe 
    215      
    216     int64_t timestamp = ts_head; 
    217194 
    218195    // we send a packet some cycles in advance, to avoid the 
     
    236213     
    237214    // time until the packet is to be sent (if > 0: send packet) 
    238     int64_t until_next=substractTicks(timestamp, cycle_timer + ticks_to_advance); 
    239  
    240 #ifdef DEBUG 
    241     if(!m_is_disabled) { 
    242         uint32_t timestamp_u=timestamp; 
    243         uint32_t syt = addTicks(timestamp_u, TRANSMIT_TRANSFER_DELAY); 
    244  
    245         debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "T: TS=%011llu, NOW=%011llu, CYN=%04d, CYT=%04d\n", 
    246             timestamp, cycle_timer, now_cycles, cycle 
    247             ); 
    248         debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "    UTN=%11lld\n", 
    249             until_next 
    250             ); 
    251         debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "    CY_NOW=%04d, CY_TARGET=%04d, CY_DIFF=%04d, CY_SYT=%04d\n", 
    252             now_cycles, cycle, cycle_diff, TICKS_TO_CYCLES(syt) 
    253             ); 
    254     } 
    255 #endif 
    256  
    257     #ifdef DEBUG_OFF 
    258     if((cycle % 1000) == 0) { 
    259         uint32_t timestamp_u=timestamp; 
    260         uint32_t syt = TICKS_TO_SYT(addTicks(timestamp_u, TRANSMIT_TRANSFER_DELAY)); 
    261         uint32_t now=m_handler->getCycleTimer(); 
    262         uint32_t now_ticks=CYCLE_TIMER_TO_TICKS(now); 
     215    int64_t until_next=substractTicks(ts_head, cycle_timer + ticks_to_advance); 
     216 
     217    // if until_next < 0 we should send a filled packet 
     218    // otherwise we should send a NO-DATA packet 
     219    if((until_next<0) && (m_running)) { 
     220        // add the transmit transfer delay to construct the playout time (=SYT timestamp) 
     221        uint64_t ts_packet=addTicks(ts_head, TRANSMIT_TRANSFER_DELAY); 
     222     
     223        // if we are disabled, send a silent packet 
     224        // and advance the buffer head timestamp 
     225        if(m_is_disabled) { 
     226             
     227            transmitSilenceBlock((char *)(data+8), m_syt_interval, 0); 
     228            m_dbc += fillDataPacketHeader(packet, length, ts_packet); 
     229             
     230            debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "XMIT SYNC: CY=%04u TSH=%011llu TSP=%011llu\n", 
     231                cycle, ts_head, ts_packet); 
     232 
     233            // update the base timestamp 
     234            uint32_t ts_step=(uint32_t)((float)(m_syt_interval) 
     235                             *m_SyncSource->m_data_buffer->getRate()); 
     236             
     237            // the next buffer head timestamp 
     238            ts_head=addTicks(ts_head,ts_step); 
     239            m_data_buffer->setBufferHeadTimestamp(ts_head); 
     240             
     241            // defer to make sure we get to be enabled asap 
     242            return RAW1394_ISO_DEFER; 
     243             
     244        } else { // enabled & packet due, read from the buffer 
     245            if (m_data_buffer->readFrames(m_syt_interval, (char *)(data + 8))) { 
     246                m_dbc += fillDataPacketHeader(packet, length, ts_packet); 
     247                 
     248                // process all ports that should be handled on a per-packet base 
     249                // this is MIDI for AMDTP (due to the need of DBC) 
     250                if (!encodePacketPorts((quadlet_t *)(data+8), m_syt_interval, packet->dbc)) { 
     251                    debugWarning("Problem encoding Packet Ports\n"); 
     252                } 
     253                 
     254                debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "XMIT: CY=%04u TSH=%011llu TSP=%011llu\n", 
     255                    cycle, ts_head, ts_packet); 
     256                 
     257                return RAW1394_ISO_OK; 
     258                 
     259            } else if (now_cycles<cycle) { 
     260                // we can still postpone the queueing of the packets 
     261                // because the ISO transmit packet buffer is not empty yet 
     262                return RAW1394_ISO_AGAIN; 
     263                 
     264            } else { // there is no more data in the ringbuffer 
     265                // compose a silent packet, we should always 
     266                // send a valid packet 
     267                transmitSilenceBlock((char *)(data+8), m_syt_interval, 0); 
     268                m_dbc += fillDataPacketHeader(packet, length, ts_packet); 
     269             
     270                debugWarning("Transmit buffer underrun (now %d, queue %d, target %d)\n",  
     271                        now_cycles, cycle, TICKS_TO_CYCLES(ts_packet)); 
     272                // signal underrun 
     273                m_xruns++; 
     274                // disable the processing, will be re-enabled when 
     275                // the xrun is handled 
     276                m_disabled=true; 
     277                m_is_disabled=true; 
     278                 
     279                return RAW1394_ISO_DEFER; 
     280            } 
     281        } 
    263282         
    264         uint32_t test_ts=sytXmitToFullTicks(syt, cycle, now); 
    265  
    266         debugOutput(DEBUG_LEVEL_VERBOSE, "T %04d: SYT=%08X,            CY=%02d OFF=%04d\n", 
    267             cycle, syt, CYCLE_TIMER_GET_CYCLES(syt), CYCLE_TIMER_GET_OFFSET(syt) 
    268             ); 
    269         debugOutput(DEBUG_LEVEL_VERBOSE, "T %04d: NOW=%011lu, SEC=%03u CY=%02u OFF=%04u\n", 
    270             cycle, now_ticks, CYCLE_TIMER_GET_SECS(now), CYCLE_TIMER_GET_CYCLES(now), CYCLE_TIMER_GET_OFFSET(now) 
    271             ); 
    272         debugOutput(DEBUG_LEVEL_VERBOSE, "T %04d: TSS=%011lu, SEC=%03u CY=%02u OFF=%04u\n", 
    273             cycle, test_ts, TICKS_TO_SECS(test_ts), TICKS_TO_CYCLES(test_ts), TICKS_TO_OFFSET(test_ts) 
    274             ); 
    275         debugOutput(DEBUG_LEVEL_VERBOSE, "T %04d: TSO=%011lu, SEC=%03u CY=%02u OFF=%04u\n", 
    276             cycle, timestamp_u, TICKS_TO_SECS(timestamp_u), TICKS_TO_CYCLES(timestamp_u), TICKS_TO_OFFSET(timestamp_u) 
    277             ); 
    278     } 
    279     #endif 
    280     // don't process the stream when it is not enabled, not running 
    281     // or when the next sample is not due yet. 
    282      
    283     // we do have to generate (semi) valid packets 
    284     // that means that we'll send NODATA packets. 
    285     if((until_next>0) || m_is_disabled || !m_running) { 
    286         // no-data packets have syt=0xFFFF 
    287         // and have the usual amount of events as dummy data (?) 
    288         packet->fdf = IEC61883_FDF_NODATA; 
    289         packet->syt = 0xffff; 
    290          
    291         // FIXME: either make this a setting or choose  
    292         bool send_payload=true; 
    293         if(send_payload) { 
    294             // the dbc is incremented even with no data packets 
    295             m_dbc += m_syt_interval; 
    296      
    297             // this means no-data packets with payload (DICE doesn't like that) 
    298             *length = 2*sizeof(quadlet_t) + m_syt_interval * m_dimension * sizeof(quadlet_t); 
    299         } else { 
    300             // dbc is not incremented 
    301              
    302             // this means no-data packets without payload 
    303             *length = 2*sizeof(quadlet_t); 
    304         } 
    305  
     283    } else { // no packet due, send no-data packet 
     284        m_dbc += fillNoDataPacketHeader(packet, length); 
    306285        return RAW1394_ISO_DEFER; 
    307286    } 
    308287     
    309     // construct the packet 
    310      
    311     // add the transmit transfer delay to construct the playout time (=SYT timestamp) 
    312     uint64_t ts=addTicks(timestamp, TRANSMIT_TRANSFER_DELAY); 
    313  
    314     unsigned int nevents = m_syt_interval; 
    315     if (m_data_buffer->readFrames(nevents, (char *)(data + 8))) { 
    316      
    317         m_dbc += m_syt_interval; 
    318          
    319         packet->fdf = m_fdf; 
    320  
    321         // convert the timestamp to SYT format 
    322         uint16_t timestamp_SYT = TICKS_TO_SYT(ts); 
    323         packet->syt = ntohs(timestamp_SYT); 
    324          
    325         *length = nevents*sizeof(quadlet_t)*m_dimension + 8; 
    326  
    327         // process all ports that should be handled on a per-packet base 
    328         // this is MIDI for AMDTP (due to the need of DBC) 
    329         if (!encodePacketPorts((quadlet_t *)(data+8), nevents, packet->dbc)) { 
    330             debugWarning("Problem encoding Packet Ports\n"); 
    331         } 
    332  
    333         debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "XMIT: CY=%04u TS=%011llu TSS=%011llu\n", 
    334             cycle, timestamp, ts); 
    335  
    336         return RAW1394_ISO_OK; 
    337          
    338     } else if (now_cycles<cycle) { 
    339         // we can still postpone the queueing of the packets 
    340         return RAW1394_ISO_AGAIN; 
    341     } else { // there is no more data in the ringbuffer 
    342  
    343         debugWarning("Transmit buffer underrun (now %d, queue %d, target %d)\n",  
    344                  now_cycles, cycle, TICKS_TO_CYCLES(ts)); 
    345  
    346         // signal underrun 
    347         m_xruns++; 
    348  
    349         // disable the processing, will be re-enabled when 
    350         // the xrun is handled 
    351         m_disabled=true; 
    352         m_is_disabled=true; 
    353  
    354         // compose a no-data packet, we should always 
    355         // send a valid packet 
    356          
    357         // FIXME: either make this a setting or choose  
    358         bool send_payload=true; 
    359         if(send_payload) { 
    360             // the dbc is incremented even with no data packets 
    361             m_dbc += m_syt_interval; 
    362      
    363             // this means no-data packets with payload (DICE doesn't like that) 
    364             *length = 2*sizeof(quadlet_t) + m_syt_interval * m_dimension * sizeof(quadlet_t); 
    365         } else { 
    366             // dbc is not incremented 
    367              
    368             // this means no-data packets without payload 
    369             *length = 2*sizeof(quadlet_t); 
    370         } 
    371  
    372         return RAW1394_ISO_DEFER; 
    373     } 
    374  
    375288    // we shouldn't get here 
    376289    return RAW1394_ISO_ERROR; 
    377290 
     291} 
     292 
     293unsigned int AmdtpTransmitStreamProcessor::fillDataPacketHeader( 
     294        struct iec61883_packet *packet, unsigned int* length, 
     295        uint32_t ts) { 
     296     
     297    packet->fdf = m_fdf; 
     298 
     299    // convert the timestamp to SYT format 
     300    uint16_t timestamp_SYT = TICKS_TO_SYT(ts); 
     301    packet->syt = ntohs(timestamp_SYT); 
     302     
     303    *length = m_syt_interval*sizeof(quadlet_t)*m_dimension + 8; 
     304 
     305    return m_syt_interval; 
     306} 
     307 
     308unsigned int AmdtpTransmitStreamProcessor::fillNoDataPacketHeader( 
     309        struct iec61883_packet *packet, unsigned int* length) { 
     310     
     311    // no-data packets have syt=0xFFFF 
     312    // and have the usual amount of events as dummy data (?) 
     313    packet->fdf = IEC61883_FDF_NODATA; 
     314    packet->syt = 0xffff; 
     315     
     316    // FIXME: either make this a setting or choose  
     317    bool send_payload=true; 
     318    if(send_payload) { 
     319        // this means no-data packets with payload (DICE doesn't like that) 
     320        *length = 2*sizeof(quadlet_t) + m_syt_interval * m_dimension * sizeof(quadlet_t); 
     321        return m_syt_interval; 
     322    } else { 
     323        // dbc is not incremented 
     324        // this means no-data packets without payload 
     325        *length = 2*sizeof(quadlet_t); 
     326        return 0; 
     327    } 
    378328} 
    379329 
     
    937887        debugWarning("Dropped %d packets on cycle %d\n",dropped, cycle); 
    938888    } 
    939 #endif 
     889 
    940890 
    941891    debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"ch%2u: CY=%4u, SYT=%08X (%4ucy + %04uticks) (running=%d, disabled=%d,%d)\n", 
     
    944894        m_running,m_disabled,m_is_disabled); 
    945895 
     896    debugOutput(DEBUG_LEVEL_VERY_VERBOSE,  
     897        "RCV: CH = %d, FDF = %X. SYT = %6d, DBS = %3d, DBC = %3d, FMT = %3d, LEN = %4d\n",  
     898        channel, packet->fdf, 
     899        packet->syt, 
     900        packet->dbs, 
     901        packet->dbc, 
     902        packet->fmt,  
     903        length); 
     904 
     905#endif 
    946906    // check our enable status 
    947907    if (!m_disabled && m_is_disabled) { 
     
    10771037// ISO buffering 
    10781038int AmdtpReceiveStreamProcessor::getMinimalSyncDelay() { 
    1079     return (int)(m_handler->getWakeupInterval() * m_syt_interval * m_ticks_per_frame); 
     1039    return ((int)(m_handler->getWakeupInterval() * m_syt_interval * m_ticks_per_frame)+10000); 
    10801040} 
    10811041 
     
    14411401 
    14421402} // end of namespace FreebobStreaming 
    1443  
    1444 #endif // #ifdef ENABLE_AMDTP_SP 
  • branches/streaming-rework/src/libstreaming/AmdtpStreamProcessor.h

    r404 r407  
    2626 * 
    2727 */ 
    28 #ifdef ENABLE_BEBOB 
    29     #ifndef ENABLE_AMDTP_SP 
    30         #define ENABLE_AMDTP_SP 
    31     #endif 
    32 #endif 
    33  
    34 #ifdef ENABLE_DICE  
    35     #ifndef ENABLE_AMDTP_SP 
    36         #define ENABLE_AMDTP_SP 
    37     #endif 
    38 #endif 
    39  
    40 #ifdef ENABLE_BOUNCE 
    41     #ifndef ENABLE_AMDTP_SP 
    42         #define ENABLE_AMDTP_SP 
    43     #endif 
    44 #endif 
    45  
    46 #ifdef ENABLE_AMDTP_SP 
    47  
    4828#ifndef __FREEBOB_AMDTPSTREAMPROCESSOR__ 
    4929#define __FREEBOB_AMDTPSTREAMPROCESSOR__ 
     
    141121    bool prefill(); 
    142122     
     123    unsigned int fillNoDataPacketHeader(struct iec61883_packet *packet, unsigned int* length); 
     124    unsigned int fillDataPacketHeader(struct iec61883_packet *packet, unsigned int* length, uint32_t ts); 
     125     
     126     
    143127    bool transferSilence(unsigned int size); 
    144128 
     
    235219#endif /* __FREEBOB_AMDTPSTREAMPROCESSOR__ */ 
    236220 
    237 #endif // #ifdef ENABLE_AMDTP_SP 
    238  
  • branches/streaming-rework/src/libstreaming/MotuPort.cpp

    r404 r407  
    2727 */ 
    2828 
    29 #ifdef ENABLE_MOTU 
    30  
    3129#include "MotuPort.h" 
    3230#include <assert.h> 
     
    3533 
    3634} // end of namespace FreebobStreaming 
    37  
    38 #endif //#ifdef ENABLE_MOTU 
  • branches/streaming-rework/src/libstreaming/MotuPort.h

    r404 r407  
    2626 * 
    2727 */ 
    28   
    29 #ifdef ENABLE_MOTU 
    30  
    3128#ifndef __FREEBOB_MOTUPORT__ 
    3229#define __FREEBOB_MOTUPORT__ 
     
    121118#endif /* __FREEBOB_MOTUPORT__ */ 
    122119 
    123 #endif //#ifdef ENABLE_MOTU 
    124  
  • branches/streaming-rework/src/libstreaming/MotuPortInfo.cpp

    r404 r407  
    2626 * 
    2727 */ 
    28   
    29 #ifdef ENABLE_MOTU 
    30  
    3128#include "MotuPortInfo.h" 
    3229#include <assert.h> 
     
    3633 
    3734} // end of namespace FreebobStreaming 
    38  
    39 #endif //#ifdef ENABLE_MOTU 
  • branches/streaming-rework/src/libstreaming/MotuPortInfo.h

    r404 r407  
    2626 * 
    2727 */ 
    28 #ifdef ENABLE_MOTU 
    29  
    3028#ifndef __FREEBOB_MOTUPORTINFO__ 
    3129#define __FREEBOB_MOTUPORTINFO__ 
     
    9290 
    9391#endif /* __FREEBOB_MOTUPORTINFO__ */ 
    94  
    95 #endif //#ifdef ENABLE_MOTU 
    96  
  • branches/streaming-rework/src/libstreaming/MotuStreamProcessor.cpp

    r402 r407  
    2727 * 
    2828 */ 
    29   
    30 #ifdef ENABLE_MOTU 
    31  
    3229#include "MotuStreamProcessor.h" 
    3330#include "Port.h" 
     
    13981395 
    13991396} // end of namespace FreebobStreaming 
    1400 #endif 
  • branches/streaming-rework/src/libstreaming/MotuStreamProcessor.h

    r402 r407  
    3535 
    3636#include "../libutil/DelayLockedLoop.h" 
    37  
    38 #ifdef ENABLE_MOTU 
    3937 
    4038namespace FreebobStreaming { 
     
    181179} // end of namespace FreebobStreaming 
    182180 
    183 #endif /* ENABLE_MOTU */ 
    184  
    185181#endif /* __FREEBOB_MOTUSTREAMPROCESSOR__ */ 
    186182 
  • branches/streaming-rework/src/libstreaming/StreamProcessor.cpp

    r401 r407  
    8080     
    8181    debugOutputShort( DEBUG_LEVEL_NORMAL, "  Device framerate      : Sync: %f, Buffer %f\n",  
    82         24576000.0*m_SyncSource->m_data_buffer->getRate(), 
    83         24576000.0*m_data_buffer->getRate() 
     82        24576000.0/m_SyncSource->m_data_buffer->getRate(), 
     83        24576000.0/m_data_buffer->getRate() 
    8484        ); 
    8585     
     
    197197 
    198198#ifdef DEBUG 
    199     uint64_t now_cycles=TICKS_TO_CYCLES(m_handler->getCycleTimerTicks()); 
    200     const int64_t max=(int64_t)(TICKS_PER_SECOND/2); 
     199    uint64_t now_cycles=CYCLE_TIMER_GET_CYCLES(m_handler->getCycleTimer()); 
     200    const int64_t max=(int64_t)(CYCLES_PER_SECOND/2); 
    201201     
    202202    int64_t diff=(int64_t)m_cycle_to_enable_at-(int64_t)now_cycles; 
  • branches/streaming-rework/src/libstreaming/StreamProcessorManager.cpp

    r399 r407  
    155155 
    156156bool StreamProcessorManager::setSyncSource(StreamProcessor *s) { 
     157    debugOutput( DEBUG_LEVEL_VERBOSE, "Setting sync source to (%p)\n", s); 
     158 
    157159    m_SyncSource=s; 
    158160    return true; 
     
    411413                 
    412414        debugOutput( DEBUG_LEVEL_VERBOSE, "Starting IsoHandlers...\n"); 
    413         if (!m_isoManager->startHandlers(0)) { 
     415        if (!m_isoManager->startHandlers(-1)) { 
    414416                debugFatal("Could not start handlers...\n"); 
    415417                return false; 
  • branches/streaming-rework/src/libutil/TimestampedBuffer.cpp

    r399 r407  
    104104 * Returns the effective rate calculated by the DLL. 
    105105 * 
    106  * @return rate (in frames/timeunit
     106 * @return rate (in timeunits/frame
    107107 */ 
    108108float TimestampedBuffer::getRate() { 
    109     return ((float) m_update_period)/m_dll_e2; 
     109    debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"getRate: %f/%f=%f\n", 
     110        m_dll_e2,(float)m_update_period, m_dll_e2/((float) m_update_period)); 
     111     
     112    return m_dll_e2/((float) m_update_period); 
    110113} 
    111114 
     
    545548 
    546549    // add the offsets 
    547     int64_t diff=m_buffer_next_tail_timestamp - m_buffer_tail_timestamp; 
    548     if (diff < 0) diff += m_wrap_at; 
    549      
    550     float rate; 
    551      
    552     if (diff) { 
    553         rate=(float)diff / (float)m_update_period; 
    554     } else { 
    555         rate=m_nominal_rate; 
    556     } 
    557          
    558550    int64_t ts=new_timestamp; 
    559551    ts += m_tick_offset; 
     
    574566#endif 
    575567     
     568    int64_t diff=m_buffer_next_tail_timestamp - m_buffer_tail_timestamp; 
     569    if (diff < 0) diff += m_wrap_at; 
     570 
    576571    pthread_mutex_lock(&m_framecounter_lock); 
    577572     
     
    584579     
    585580    debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "Set buffer tail timestamp for (%p) to %11llu => %11lld, NTS=%llu, DLL2=%f, RATE=%f\n", 
    586                 this, new_timestamp, ts, m_buffer_next_tail_timestamp, m_dll_e2, rate); 
     581                this, new_timestamp, ts, m_buffer_next_tail_timestamp, m_dll_e2, m_nominal_rate); 
     582 
     583
     584 
     585/** 
     586 * @brief Sets the buffer head timestamp. 
     587 *  
     588 * Set the buffer tail timestamp such that the buffer head timestamp becomes  
     589 * \ref new_timestamp. This does not consider offsets, because it's use is to 
     590 * make sure the following is true after setBufferHeadTimestamp(x): 
     591 *   x == getBufferHeadTimestamp() 
     592 *  
     593 * This is thread safe. 
     594 *  
     595 * @param new_timestamp  
     596 */ 
     597void TimestampedBuffer::setBufferHeadTimestamp(uint64_t new_timestamp) { 
     598     
     599#ifdef DEBUG 
     600    if (new_timestamp >= m_wrap_at) { 
     601        debugWarning("timestamp not wrapped: %llu\n",new_timestamp); 
     602    }     
     603#endif 
     604 
     605    int64_t ts=new_timestamp; 
     606 
     607    int64_t diff=m_buffer_next_tail_timestamp - m_buffer_tail_timestamp; 
     608    if (diff < 0) diff += m_wrap_at; 
     609     
     610    pthread_mutex_lock(&m_framecounter_lock); 
     611     
     612    // add the time 
     613    ts += (int64_t)(m_nominal_rate * (float)m_framecounter); 
     614     
     615    if (ts >= (int64_t)m_wrap_at) { 
     616        ts -= m_wrap_at; 
     617    } else if (ts < 0) { 
     618        ts += m_wrap_at; 
     619    } 
     620     
     621    m_buffer_tail_timestamp = ts; 
     622     
     623    m_dll_e2=m_update_period * m_nominal_rate; 
     624    m_buffer_next_tail_timestamp = (uint64_t)((float)m_buffer_tail_timestamp + m_dll_e2); 
     625     
     626    pthread_mutex_unlock(&m_framecounter_lock);     
     627     
     628    debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "Set buffer head timestamp for (%p) to %11llu => %11lld, NTS=%llu, DLL2=%f, RATE=%f\n", 
     629                this, new_timestamp, ts, m_buffer_next_tail_timestamp, m_dll_e2, m_nominal_rate); 
    587630 
    588631} 
  • branches/streaming-rework/src/libutil/TimestampedBuffer.h

    r401 r407  
    113113     
    114114    void setBufferTailTimestamp(uint64_t new_timestamp); 
     115    void setBufferHeadTimestamp(uint64_t new_timestamp); 
    115116     
    116117    uint64_t getTimestampFromTail(int nframes); 
  • branches/streaming-rework/src/Makefile.am

    r404 r407  
    2424 
    2525lib_LTLIBRARIES = libfreebob.la 
     26 
     27libfreebob_la_LDFLAGS =                                 \ 
     28        -version-info $(LT_VERSION) $(LIBRAW1394_LIBS)  \ 
     29        $(LIBIEC61883_LIBS) $(LIBAVC1394_LIBS)          \ 
     30        $(LIBXML_LIBS) $(LIBXMLCPP_LIBS) -lpthread -lrt 
    2631 
    2732libfreebob_la_LIBADD = -lrt 
     
    5055        libutil/TimeSource.h libutil/TimestampedBuffer.h 
    5156 
     57# common sources 
    5258libfreebob_la_SOURCES = \ 
    5359        configrom.cpp \ 
     
    5763        freebob_streaming.cpp \ 
    5864        xmlparser.c \ 
    59         bebob/bebob_avdevice.cpp \ 
    60         bebob/bebob_avdevice_subunit.cpp \ 
    61         bebob/bebob_avdevice_xml.cpp \ 
    62         bebob/bebob_avplug.cpp \ 
    63         bebob/bebob_avplug_xml.cpp \ 
    64         bebob/bebob_dl_bcd.cpp \ 
    65         bebob/bebob_dl_codes.cpp \ 
    66         bebob/bebob_dl_mgr.cpp \ 
    67         bebob/bebob_functionblock.cpp \ 
    68         bounce/bounce_avdevice.cpp \ 
    69         dice/dice_avdevice.cpp \ 
    70         maudio/maudio_avdevice.cpp \ 
    71         metrichalo/mh_avdevice.cpp \ 
    72         motu/motu_avdevice.cpp \ 
    73         rme/rme_avdevice.cpp \ 
    7465        debugmodule/debugmodule.cpp \ 
    7566        libfreebobavc/avc_connect.cpp \ 
     
    8778        libfreebobavc/avc_unit_info.cpp \ 
    8879        libfreebobavc/ieee1394service.cpp \ 
    89         libstreaming/AmdtpPort.cpp \ 
    90         libstreaming/AmdtpPortInfo.cpp \ 
    91         libstreaming/AmdtpStreamProcessor.cpp \ 
    9280        libstreaming/cip.c \ 
    9381        libstreaming/IsoHandler.cpp \ 
    9482        libstreaming/IsoHandlerManager.cpp \ 
    9583        libstreaming/IsoStream.cpp \ 
    96         libstreaming/MotuPort.cpp \ 
    97         libstreaming/MotuPortInfo.cpp \ 
    98         libstreaming/MotuStreamProcessor.cpp \ 
    9984        libstreaming/Port.cpp \ 
    10085        libstreaming/PortManager.cpp \ 
     
    11297        libutil/TimestampedBuffer.cpp 
    11398 
    114 libfreebob_la_LDFLAGS =                                 \ 
    115         -version-info $(LT_VERSION) $(LIBRAW1394_LIBS)  \ 
    116         $(LIBIEC61883_LIBS) $(LIBAVC1394_LIBS)          \ 
    117         $(LIBXML_LIBS) $(LIBXMLCPP_LIBS) -lpthread -lrt 
    118  
    119 nobase_dist_pkgdata_DATA =                              \ 
     99# class specific sources 
     100bebob_src = \ 
     101        bebob/bebob_avdevice.cpp \ 
     102        bebob/bebob_avdevice_subunit.cpp \ 
     103        bebob/bebob_avdevice_xml.cpp \ 
     104        bebob/bebob_avplug.cpp \ 
     105        bebob/bebob_avplug_xml.cpp \ 
     106        bebob/bebob_dl_bcd.cpp \ 
     107        bebob/bebob_dl_codes.cpp \ 
     108        bebob/bebob_dl_mgr.cpp \ 
     109        bebob/bebob_functionblock.cpp \ 
     110        maudio/maudio_avdevice.cpp 
     111 
     112motu_src = \ 
     113        motu/motu_avdevice.cpp \ 
     114        libstreaming/MotuPort.cpp \ 
     115        libstreaming/MotuPortInfo.cpp \ 
     116        libstreaming/MotuStreamProcessor.cpp 
     117 
     118dice_src = \ 
     119        dice/dice_avdevice.cpp 
     120 
     121bounce_src = \ 
     122        bounce/bounce_avdevice.cpp 
     123 
     124metric_halo_src = \ 
     125        metrichalo/mh_avdevice.cpp 
     126 
     127rme_src = \ 
     128        rme/rme_avdevice.cpp 
     129 
     130amdtp_src = \ 
     131        libstreaming/AmdtpPort.cpp \ 
     132        libstreaming/AmdtpPortInfo.cpp \ 
     133        libstreaming/AmdtpStreamProcessor.cpp 
     134 
     135# data 
     136#  generic 
     137nobase_dist_pkgdata_DATA = 
     138#  bebob specific 
     139bebob_pkgdata =                                 \ 
    120140        maudio/refdesign.xml                            \ 
    121141        maudio/fw410.xml                                \ 
    122142        maudio/fwap.xml 
    123143 
    124  
    125 ############### 
    126  
    127 bin_PROGRAMS = @BIN_PROGRAMS@ 
    128  
    129 EXTRA_PROGRAMS = freebob-downloader freebob-sync 
     144# programs intended for installation in the 'bin' directory 
     145#  generic 
     146bin_PROGRAMS =  
     147 
     148#  class specific 
     149bebob_bin = freebob-downloader freebob-sync 
     150 
    130151freebob_downloader_SOURCES = freebob-downloader.cpp 
    131152freebob_downloader_LDADD = $(top_builddir)/src/libfreebob.la 
     
    134155freebob_sync_LDADD = $(top_builddir)/src/libfreebob.la 
    135156 
    136 ############### 
    137  
     157# programs not intended for installation 
     158# generic 
    138159noinst_PROGRAMS = test-dll test-debugmodule test-unittests test-ser 
    139160 
     
    149170test_ser_SOURCES = ser.cpp 
    150171test_ser_LDADD = $(top_builddir)/src/libfreebob.la 
     172 
     173# build customisation 
     174 
     175if BUILD_BEBOB 
     176libfreebob_la_SOURCES += $(bebob_src) 
     177bin_PROGRAMS += $(bebob_bin) 
     178noinst_PROGRAMS += $(bebob_noinst) 
     179nobase_dist_pkgdata_DATA += $(bebob_pkgdata) 
     180endif 
     181 
     182if BUILD_BOUNCE 
     183libfreebob_la_SOURCES += $(bounce_src) 
     184bin_PROGRAMS += $(bounce_bin) 
     185noinst_PROGRAMS += $(bounce_noinst) 
     186nobase_dist_pkgdata_DATA += $(bounce_pkgdata) 
     187endif 
     188 
     189if BUILD_DICE 
     190libfreebob_la_SOURCES += $(dice_src) 
     191bin_PROGRAMS += $(dice_bin) 
     192noinst_PROGRAMS += $(dice_noinst) 
     193nobase_dist_pkgdata_DATA += $(dice_pkgdata) 
     194endif 
     195 
     196if BUILD_MOTU 
     197libfreebob_la_SOURCES += $(motu_src) 
     198bin_PROGRAMS += $(motu_bin) 
     199noinst_PROGRAMS += $(motu_noinst) 
     200nobase_dist_pkgdata_DATA += $(motu_pkgdata) 
     201endif 
     202 
     203if BUILD_METRIC_HALO 
     204libfreebob_la_SOURCES += $(metric_halo_src) 
     205bin_PROGRAMS += $(metric_halo_bin) 
     206noinst_PROGRAMS += $(metric_halo_noinst) 
     207nobase_dist_pkgdata_DATA += $(metric_halo_pkgdata) 
     208endif 
     209 
     210if BUILD_RME 
     211libfreebob_la_SOURCES += $(rme_src) 
     212bin_PROGRAMS += $(rme_bin) 
     213noinst_PROGRAMS += $(rme_noinst) 
     214nobase_dist_pkgdata_DATA += $(rme_pkgdata) 
     215endif 
     216 
     217if BUILD_AMDTP 
     218libfreebob_la_SOURCES += $(amdtp_src) 
     219bin_PROGRAMS += $(amdtp_bin) 
     220noinst_PROGRAMS += $(amdtp_noinst) 
     221nobase_dist_pkgdata_DATA += $(amdtp_pkgdata) 
     222endif 
  • branches/streaming-rework/src/maudio/maudio_avdevice.cpp

    r404 r407  
    1818 * MA 02111-1307 USA. 
    1919 */ 
    20  
    21 #ifdef ENABLE_BEBOB 
    22  
    2320#include "maudio/maudio_avdevice.h" 
    2421#include "configrom.h" 
     
    548545 
    549546} 
    550  
    551 #endif //#ifdef ENABLE_BEBOB 
  • branches/streaming-rework/src/maudio/maudio_avdevice.h

    r404 r407  
    1818 * MA 02111-1307 USA. 
    1919 */ 
    20  
    21 #ifdef ENABLE_BEBOB 
    2220 
    2321#ifndef MAUDIODEVICE_H 
     
    8987 
    9088#endif 
    91  
    92 #endif //#ifdef ENABLE_BEBOB 
  • branches/streaming-rework/src/metrichalo/mh_avdevice.cpp

    r404 r407  
    1919 */ 
    2020 
    21 #ifdef ENABLE_METRIC_HALO 
    2221#warning Metric Halo support is currently useless 
    2322 
     
    239238 
    240239} 
    241  
    242 #endif //#ifdef ENABLE_METRIC_HALO 
  • branches/streaming-rework/src/metrichalo/mh_avdevice.h

    r404 r407  
    1818 * MA 02111-1307 USA. 
    1919 */ 
    20  
    21 #ifdef ENABLE_METRIC_HALO 
    2220 
    2321#ifndef MHDEVICE_H 
     
    10098 
    10199#endif 
    102  
    103 #endif //#ifdef ENABLE_MH 
  • branches/streaming-rework/src/motu/motu_avdevice.cpp

    r404 r407  
    1919 * MA 02111-1307 USA. 
    2020 */ 
    21  
    22 #ifdef ENABLE_MOTU 
    23  
    2421#include "motu/motu_avdevice.h" 
    2522#include "configrom.h" 
     
    937934 
    938935} 
    939 #endif // ENABLE_MOTU 
  • branches/streaming-rework/src/motu/motu_avdevice.h

    r404 r407  
    1919 * MA 02111-1307 USA. 
    2020 */ 
    21  
    22 #ifdef ENABLE_MOTU 
    2321 
    2422#ifndef MOTUDEVICE_H 
     
    163161 
    164162#endif 
    165  
    166 #endif // ENABLE_MOTU 
  • branches/streaming-rework/src/rme/rme_avdevice.cpp

    r404 r407  
    1919 * MA 02111-1307 USA. 
    2020 */ 
    21  
    22 #ifdef ENABLE_RME 
    2321#warning RME support is currently useless (detection only) 
    2422 
     
    550548 
    551549} 
    552  
    553 #endif //#ifdef ENABLE_RME 
  • branches/streaming-rework/src/rme/rme_avdevice.h

    r404 r407  
    1919 * MA 02111-1307 USA. 
    2020 */ 
    21  
    22 #ifdef ENABLE_RME 
    23  
    2421#ifndef RMEDEVICE_H 
    2522#define RMEDEVICE_H 
     
    116113 
    117114#endif 
    118  
    119 #endif //#ifdef ENABLE_RME 
  • branches/streaming-rework/src/ser.cpp

    r365 r407  
    11#include "devicemanager.h" 
    2 #include "bebob/bebob_avdevice.h" 
    32#include "libutil/serialize.h" 
    43 
  • branches/streaming-rework/tests/freebob-server.c

    r199 r407  
    1 /* 
     1/* freebob-server.c 
     2 * Copyright (C) 2006,2007 Pieter Palmers 
     3 * 
     4 * This file is part of FreeBob. 
     5*/ 
     6/* Inspired on: 
     7
    28* avc_vcr.c - An example of an AV/C Tape Recorder target implementation 
    39* 
     
    3238#include <signal.h> 
    3339 
     40#include <arpa/inet.h> 
     41 
    3442#include <libraw1394/raw1394.h> 
    3543#include <libraw1394/csr.h> 
     
    291299        i = strlen(dir.textual_leafs[0]); 
    292300        strncpy(dir.textual_leafs[0], FREEBOB_BOUNCE_SERVER_VENDORNAME "                                          ", i); 
     301         
     302        dir.vendor_id=FREEBOB_BOUNCE_SERVER_VENDORID; 
     303        dir.model_id=FREEBOB_BOUNCE_SERVER_MODELID; 
     304         
     305        /* update the rom */ 
    293306        retval = rom1394_set_directory(rom, &dir); 
    294307        printf("rom1394_set_directory returned %d, romsize %d:",retval,rom_size); 
     
    304317         
    305318        /* add an AV/C unit directory */ 
    306         dir.unit_spec_id    = 0x0000a02d
     319        dir.unit_spec_id    = FREEBOB_BOUNCE_SERVER_SPECID
    307320        dir.unit_sw_version = 0x00010001; 
    308321        leaf = FREEBOB_BOUNCE_SERVER_MODELNAME; 
     
    347360{ 
    348361        raw1394handle_t handle; 
    349  
     362    int p=0; 
     363     
    350364        signal (SIGINT, sighandler); 
    351365        signal (SIGPIPE, sighandler); 
     
    353367        handle = raw1394_new_handle(); 
    354368 
     369    if (argc==2) p=atoi(argv[1]); 
     370 
    355371        if ( !handle ) 
    356372        { 
     
    367383        } 
    368384 
    369         if ( raw1394_set_port( handle, 0 ) < 0 ) 
     385        if ( raw1394_set_port( handle, p ) < 0 ) 
    370386        { 
    371387                perror( "couldn't set port" ); 
    372388                exit( EXIT_FAILURE ); 
     389        } else { 
     390           printf("Using port %d\n",p); 
    373391        } 
    374392 
  • branches/streaming-rework/tests/Makefile.am

    r392 r407  
    2020INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src $(LIBXML_CFLAGS) \ 
    2121        $(LIBAVC1394_CFLAGS) 
     22         
     23noinst_PROGRAMS = 
    2224 
    23 noinst_PROGRAMS = test-freebob test-extplugcmd test-fw410 freebob-server \ 
     25if BUILD_TESTS 
     26noinst_PROGRAMS += test-freebob test-extplugcmd test-fw410 freebob-server \ 
    2427                test-volume test-mixer test-cycletimer test-sytmonitor \ 
    2528                test-timestampedbuffer 
     29endif 
    2630 
    2731noinst_HEADERS =  
  • branches/streaming-rework/tests/test-timestampedbuffer.cpp

    r395 r407  
    295295    usleep(1000); 
    296296     
    297     debugOutput(DEBUG_LEVEL_NORMAL, "Start test 1...\n"); 
    298  
    299     int dummyframe_in[arguments.events_per_frame*arguments.frames_per_packet]; 
    300     int dummyframe_out[arguments.events_per_frame*arguments.frames_per_packet]; 
    301     
    302     for (unsigned int i=0;i<arguments.events_per_frame*arguments.frames_per_packet;i++) { 
    303         dummyframe_in[i]=i; 
    304     } 
    305      
    306     uint64_t time=arguments.start_at_cycle*3072; 
    307      
    308     // initialize the timestamp 
    309     uint64_t timestamp=time; 
    310     if (timestamp >= arguments.wrap_at) { 
    311         // here we need a modulo because start_at_cycle can be large 
    312         timestamp %= arguments.wrap_at; 
    313     } 
    314     t->setBufferTailTimestamp(timestamp); 
    315      
    316     timestamp += (uint64_t)(arguments.rate * arguments.frames_per_packet); 
    317     if (timestamp >= arguments.wrap_at) { 
    318         timestamp -= arguments.wrap_at; 
    319     } 
    320     
    321     for(unsigned int cycle=arguments.start_at_cycle; 
    322         cycle < arguments.start_at_cycle+arguments.total_cycles;  
    323         cycle++) { 
    324          
    325         // simulate the rate adaptation 
    326         int64_t diff=(time%arguments.wrap_at)-timestamp; 
    327          
    328         if (diff>(int64_t)arguments.wrap_at/2) { 
    329             diff -= arguments.wrap_at; 
    330         } else if (diff<(-(int64_t)arguments.wrap_at)/2){ 
    331             diff += arguments.wrap_at; 
    332         } 
    333          
    334         debugOutput(DEBUG_LEVEL_NORMAL, "Simulating cycle %d @ time=%011llu, diff=%lld\n",cycle,time,diff); 
    335          
    336         if(diff>0) { 
    337             uint64_t ts_head, fc_head; 
    338             uint64_t ts_tail, fc_tail; 
    339              
    340             // write one packet 
     297    debugOutput(DEBUG_LEVEL_NORMAL, "Start setBufferHeadTimestamp test...\n"); 
     298    { 
     299        bool pass=true; 
     300        uint64_t time=arguments.start_at_cycle*3072; 
     301        int dummyframe_in[arguments.events_per_frame*arguments.frames_per_packet]; 
     302         
     303        // initialize the timestamp 
     304        uint64_t timestamp=time; 
     305        if (timestamp >= arguments.wrap_at) { 
     306            // here we need a modulo because start_at_cycle can be large 
     307            timestamp %= arguments.wrap_at; 
     308        } 
     309         
     310        // account for the fact that there is offset, 
     311        // and that setBufferHeadTimestamp doesn't take offset 
     312        // into account 
     313        uint64_t timestamp2=timestamp+t->getTickOffset(); 
     314        if (timestamp2>=arguments.wrap_at) { 
     315            timestamp2-=arguments.wrap_at; 
     316        } 
     317         
     318        t->setBufferHeadTimestamp(timestamp2); 
     319         
     320        timestamp += (uint64_t)(arguments.rate * arguments.frames_per_packet); 
     321        if (timestamp >= arguments.wrap_at) { 
     322            timestamp -= arguments.wrap_at; 
     323        } 
     324         
     325        // write some packets 
     326        for (unsigned int i=0;i<20;i++) { 
    341327            t->writeFrames(arguments.frames_per_packet, (char *)&dummyframe_in, timestamp); 
    342  
    343             // read the buffer head timestamp 
    344             t->getBufferHeadTimestamp(&ts_head, &fc_head); 
    345             t->getBufferTailTimestamp(&ts_tail, &fc_tail); 
    346             debugOutput(DEBUG_LEVEL_NORMAL,  
    347                     " TS after write: HEAD: %011llu, FC=%04u\n", 
    348                     ts_head,fc_head); 
    349             debugOutput(DEBUG_LEVEL_NORMAL,  
    350                     "                 TAIL: %011llu, FC=%04u\n", 
    351                     ts_tail,fc_tail); 
    352  
    353             // read one packet 
    354             t->readFrames(arguments.frames_per_packet, (char *)&dummyframe_out); 
    355  
    356             // read the buffer head timestamp 
    357             t->getBufferHeadTimestamp(&ts_head, &fc_head); 
    358             t->getBufferTailTimestamp(&ts_tail, &fc_tail); 
    359             debugOutput(DEBUG_LEVEL_NORMAL,  
    360                     " TS after write: HEAD: %011llu, FC=%04u\n", 
    361                     ts_head,fc_head); 
    362             debugOutput(DEBUG_LEVEL_NORMAL,  
    363                     "                 TAIL: %011llu, FC=%04u\n", 
    364                     ts_tail,fc_tail); 
    365  
    366             // check 
    367             bool pass=true; 
    368             for (unsigned int i=0;i<arguments.events_per_frame*arguments.frames_per_packet;i++) { 
    369                 pass = pass && (dummyframe_in[i]==dummyframe_out[i]); 
    370             } 
    371             if (!pass) { 
    372                 debugOutput(DEBUG_LEVEL_NORMAL, "write/read check for cycle %d failed\n",cycle); 
    373             } 
    374  
    375             // update the timestamp 
    376328            timestamp += (uint64_t)(arguments.rate * arguments.frames_per_packet); 
    377329            if (timestamp >= arguments.wrap_at) { 
     
    379331            } 
    380332        } 
    381  
    382         // simulate the cycle timer clock in ticks 
    383         time += 3072; 
    384         if (time >= arguments.wrap_at) { 
    385             time -= arguments.wrap_at; 
    386         } 
    387          
    388         // allow for the messagebuffer thread to catch up 
    389         usleep(200); 
    390          
    391         if(!run) break; 
    392     } 
    393  
    394     // second run, now do block processing 
    395     debugOutput(DEBUG_LEVEL_NORMAL, "Start test 2...\n"); 
    396     unsigned int blocksize=32; 
    397     int dummyframe_out_block[arguments.events_per_frame*arguments.frames_per_packet*blocksize]; 
    398      
    399     time=arguments.start_at_cycle*3072; 
    400      
    401     // initialize the timestamp 
    402     timestamp=time; 
    403     if (timestamp >= arguments.wrap_at) { 
    404         // here we need a modulo because start_at_cycle can be large 
    405         timestamp %= arguments.wrap_at; 
    406     } 
    407     t->setBufferTailTimestamp(timestamp); 
    408      
    409     timestamp += (uint64_t)(arguments.rate * arguments.frames_per_packet); 
    410     if (timestamp >= arguments.wrap_at) { 
    411         timestamp -= arguments.wrap_at; 
    412     } 
    413     
    414     for(unsigned int cycle=arguments.start_at_cycle; 
    415         cycle < arguments.start_at_cycle+arguments.total_cycles;  
    416         cycle++) { 
    417          
    418         // simulate the rate adaptation 
    419         int64_t diff=(time%arguments.wrap_at)-timestamp; 
    420          
    421         if (diff>(int64_t)arguments.wrap_at/2) { 
    422             diff -= arguments.wrap_at; 
    423         } else if (diff<(-(int64_t)arguments.wrap_at)/2){ 
    424             diff += arguments.wrap_at; 
    425         } 
    426          
    427         debugOutput(DEBUG_LEVEL_NORMAL, "Simulating cycle %d @ time=%011llu, diff=%lld\n",cycle,time,diff); 
    428          
    429         if(diff>0) { 
    430             uint64_t ts_head, fc_head; 
    431             uint64_t ts_tail, fc_tail; 
    432              
    433             // write one packet 
    434             t->writeFrames(arguments.frames_per_packet, (char *)&dummyframe_in, timestamp); 
    435  
    436             // read the buffer head timestamp 
    437             t->getBufferHeadTimestamp(&ts_head, &fc_head); 
    438             t->getBufferTailTimestamp(&ts_tail, &fc_tail); 
    439             debugOutput(DEBUG_LEVEL_NORMAL,  
    440                     " TS after write: HEAD: %011llu, FC=%04u\n", 
    441                     ts_head,fc_head); 
    442             debugOutput(DEBUG_LEVEL_NORMAL,  
    443                     "                 TAIL: %011llu, FC=%04u\n", 
    444                     ts_tail,fc_tail); 
    445  
    446             if (fc_head > blocksize) { 
    447                 debugOutput(DEBUG_LEVEL_NORMAL,"Reading one block (%u frames)\n",blocksize); 
     333     
     334        for(unsigned int cycle=arguments.start_at_cycle; 
     335            cycle < arguments.start_at_cycle+arguments.total_cycles;  
     336            cycle++) { 
     337                uint64_t ts_head, fc_head; 
    448338                 
    449                 // read one block 
    450                 t->readFrames(blocksize, (char *)&dummyframe_out_block); 
     339                t->setBufferHeadTimestamp(timestamp); 
     340                t->getBufferHeadTimestamp(&ts_head, &fc_head); 
     341                 
     342                if (timestamp != ts_head) { 
     343                    debugError(" cycle %4u error: %011llu != %011llu\n", 
     344                        timestamp, ts_head); 
     345                        pass=false; 
     346                } 
     347                 
     348                timestamp += (uint64_t)(arguments.rate * arguments.frames_per_packet); 
     349                if (timestamp >= arguments.wrap_at) { 
     350                    timestamp -= arguments.wrap_at; 
     351                } 
     352             
     353            // simulate the cycle timer clock in ticks 
     354            time += 3072; 
     355            if (time >= arguments.wrap_at) { 
     356                time -= arguments.wrap_at; 
     357            } 
     358             
     359            // allow for the messagebuffer thread to catch up 
     360            usleep(200); 
     361             
     362            if(!run) break; 
     363        } 
     364         
     365        if(!pass) { 
     366            debugError("Test failed, exiting...\n"); 
     367     
     368            delete t; 
     369            delete c; 
     370             
     371            return -1; 
     372             
     373        } 
     374    } 
     375     
     376 
     377     
     378    debugOutput(DEBUG_LEVEL_NORMAL, "Start read/write test...\n"); 
     379    { 
     380        int dummyframe_in[arguments.events_per_frame*arguments.frames_per_packet]; 
     381        int dummyframe_out[arguments.events_per_frame*arguments.frames_per_packet]; 
     382     
     383        for (unsigned int i=0;i<arguments.events_per_frame*arguments.frames_per_packet;i++) { 
     384            dummyframe_in[i]=i; 
     385        } 
     386         
     387        uint64_t time=arguments.start_at_cycle*3072; 
     388         
     389        // initialize the timestamp 
     390        uint64_t timestamp=time; 
     391        if (timestamp >= arguments.wrap_at) { 
     392            // here we need a modulo because start_at_cycle can be large 
     393            timestamp %= arguments.wrap_at; 
     394        } 
     395        t->setBufferTailTimestamp(timestamp); 
     396         
     397        timestamp += (uint64_t)(arguments.rate * arguments.frames_per_packet); 
     398        if (timestamp >= arguments.wrap_at) { 
     399            timestamp -= arguments.wrap_at; 
     400        } 
     401     
     402        for(unsigned int cycle=arguments.start_at_cycle; 
     403            cycle < arguments.start_at_cycle+arguments.total_cycles;  
     404            cycle++) { 
     405             
     406            // simulate the rate adaptation 
     407            int64_t diff=(time%arguments.wrap_at)-timestamp; 
     408             
     409            if (diff>(int64_t)arguments.wrap_at/2) { 
     410                diff -= arguments.wrap_at; 
     411            } else if (diff<(-(int64_t)arguments.wrap_at)/2){ 
     412                diff += arguments.wrap_at; 
     413            } 
     414             
     415            debugOutput(DEBUG_LEVEL_NORMAL, "Simulating cycle %d @ time=%011llu, diff=%lld\n",cycle,time,diff); 
     416             
     417            if(diff>0) { 
     418                uint64_t ts_head, fc_head; 
     419                uint64_t ts_tail, fc_tail; 
     420                 
     421                // write one packet 
     422                t->writeFrames(arguments.frames_per_packet, (char *)&dummyframe_in, timestamp); 
    451423     
    452424                // read the buffer head timestamp 
     
    454426                t->getBufferTailTimestamp(&ts_tail, &fc_tail); 
    455427                debugOutput(DEBUG_LEVEL_NORMAL,  
    456                         " TS after read: HEAD: %011llu, FC=%04u\n", 
     428                        " TS after write: HEAD: %011llu, FC=%04u\n", 
    457429                        ts_head,fc_head); 
    458430                debugOutput(DEBUG_LEVEL_NORMAL,  
    459                         "                TAIL: %011llu, FC=%04u\n", 
     431                        "                TAIL: %011llu, FC=%04u\n", 
    460432                        ts_tail,fc_tail); 
    461             } 
    462              
    463             // update the timestamp 
    464             timestamp += (uint64_t)(arguments.rate * arguments.frames_per_packet); 
    465             if (timestamp >= arguments.wrap_at) { 
    466                 timestamp -= arguments.wrap_at; 
    467             } 
    468         } 
    469  
    470         // simulate the cycle timer clock in ticks 
    471         time += 3072; 
    472         if (time >= arguments.wrap_at) { 
    473             time -= arguments.wrap_at; 
    474         } 
    475          
    476         // allow for the messagebuffer thread to catch up 
    477         usleep(200); 
    478          
    479         if(!run) break; 
    480     } 
    481      
     433     
     434                // read one packet 
     435                t->readFrames(arguments.frames_per_packet, (char *)&dummyframe_out); 
     436     
     437                // read the buffer head timestamp 
     438                t->getBufferHeadTimestamp(&ts_head, &fc_head); 
     439                t->getBufferTailTimestamp(&ts_tail, &fc_tail); 
     440                debugOutput(DEBUG_LEVEL_NORMAL,  
     441                        " TS after write: HEAD: %011llu, FC=%04u\n", 
     442                        ts_head,fc_head); 
     443                debugOutput(DEBUG_LEVEL_NORMAL,  
     444                        "                 TAIL: %011llu, FC=%04u\n", 
     445                        ts_tail,fc_tail); 
     446     
     447                // check 
     448                bool pass=true; 
     449                for (unsigned int i=0;i<arguments.events_per_frame*arguments.frames_per_packet;i++) { 
     450                    pass = pass && (dummyframe_in[i]==dummyframe_out[i]); 
     451                } 
     452                if (!pass) { 
     453                    debugOutput(DEBUG_LEVEL_NORMAL, "write/read check for cycle %d failed\n",cycle); 
     454                } 
     455     
     456                // update the timestamp 
     457                timestamp += (uint64_t)(arguments.rate * arguments.frames_per_packet); 
     458                if (timestamp >= arguments.wrap_at) { 
     459                    timestamp -= arguments.wrap_at; 
     460                } 
     461            } 
     462     
     463            // simulate the cycle timer clock in ticks 
     464            time += 3072; 
     465            if (time >= arguments.wrap_at) { 
     466                time -= arguments.wrap_at; 
     467            } 
     468             
     469            // allow for the messagebuffer thread to catch up 
     470            usleep(200); 
     471             
     472            if(!run) break; 
     473        } 
     474    } 
     475     
     476    // second run, now do block processing 
     477    debugOutput(DEBUG_LEVEL_NORMAL, "Start block read test...\n"); 
     478    { 
     479        unsigned int blocksize=32; 
     480        int dummyframe_out_block[arguments.events_per_frame*arguments.frames_per_packet*blocksize]; 
     481        int dummyframe_in[arguments.events_per_frame*arguments.frames_per_packet]; 
     482     
     483        for (unsigned int i=0;i<arguments.events_per_frame*arguments.frames_per_packet;i++) { 
     484            dummyframe_in[i]=i; 
     485        } 
     486         
     487        uint64_t time=arguments.start_at_cycle*3072; 
     488         
     489        // initialize the timestamp 
     490        uint64_t timestamp=time; 
     491        if (timestamp >= arguments.wrap_at) { 
     492            // here we need a modulo because start_at_cycle can be large 
     493            timestamp %= arguments.wrap_at; 
     494        } 
     495        t->setBufferTailTimestamp(timestamp); 
     496         
     497        timestamp += (uint64_t)(arguments.rate * arguments.frames_per_packet); 
     498        if (timestamp >= arguments.wrap_at) { 
     499            timestamp -= arguments.wrap_at; 
     500        } 
     501     
     502        for(unsigned int cycle=arguments.start_at_cycle; 
     503            cycle < arguments.start_at_cycle+arguments.total_cycles;  
     504            cycle++) { 
     505             
     506            // simulate the rate adaptation 
     507            int64_t diff=(time%arguments.wrap_at)-timestamp; 
     508             
     509            if (diff>(int64_t)arguments.wrap_at/2) { 
     510                diff -= arguments.wrap_at; 
     511            } else if (diff<(-(int64_t)arguments.wrap_at)/2){ 
     512                diff += arguments.wrap_at; 
     513            } 
     514             
     515            debugOutput(DEBUG_LEVEL_NORMAL, "Simulating cycle %d @ time=%011llu, diff=%lld\n",cycle,time,diff); 
     516             
     517            if(diff>0) { 
     518                uint64_t ts_head, fc_head; 
     519                uint64_t ts_tail, fc_tail; 
     520                 
     521                // write one packet 
     522                t->writeFrames(arguments.frames_per_packet, (char *)&dummyframe_in, timestamp); 
     523     
     524                // read the buffer head timestamp 
     525                t->getBufferHeadTimestamp(&ts_head, &fc_head); 
     526                t->getBufferTailTimestamp(&ts_tail, &fc_tail); 
     527                debugOutput(DEBUG_LEVEL_NORMAL,  
     528                        " TS after write: HEAD: %011llu, FC=%04u\n", 
     529                        ts_head,fc_head); 
     530                debugOutput(DEBUG_LEVEL_NORMAL,  
     531                        "                 TAIL: %011llu, FC=%04u\n", 
     532                        ts_tail,fc_tail); 
     533     
     534                if (fc_head > blocksize) { 
     535                    debugOutput(DEBUG_LEVEL_NORMAL,"Reading one block (%u frames)\n",blocksize); 
     536                     
     537                    // read one block 
     538                    t->readFrames(blocksize, (char *)&dummyframe_out_block); 
     539         
     540                    // read the buffer head timestamp 
     541                    t->getBufferHeadTimestamp(&ts_head, &fc_head); 
     542                    t->getBufferTailTimestamp(&ts_tail, &fc_tail); 
     543                    debugOutput(DEBUG_LEVEL_NORMAL,  
     544                            " TS after read: HEAD: %011llu, FC=%04u\n", 
     545                            ts_head,fc_head); 
     546                    debugOutput(DEBUG_LEVEL_NORMAL,  
     547                            "                TAIL: %011llu, FC=%04u\n", 
     548                            ts_tail,fc_tail); 
     549                } 
     550                 
     551                // update the timestamp 
     552                timestamp += (uint64_t)(arguments.rate * arguments.frames_per_packet); 
     553                if (timestamp >= arguments.wrap_at) { 
     554                    timestamp -= arguments.wrap_at; 
     555                } 
     556            } 
     557     
     558            // simulate the cycle timer clock in ticks 
     559            time += 3072; 
     560            if (time >= arguments.wrap_at) { 
     561                time -= arguments.wrap_at; 
     562            } 
     563             
     564            // allow for the messagebuffer thread to catch up 
     565            usleep(200); 
     566             
     567            if(!run) break; 
     568        } 
     569    } 
    482570 
    483571    delete t;