Changeset 407
- Timestamp:
- 02/20/07 06:38:52 (16 years ago)
- Files:
-
- branches/streaming-rework/configure.ac (modified) (10 diffs)
- branches/streaming-rework/libfreebob/freebob_bounce.h (modified) (1 diff)
- branches/streaming-rework/src/bebob/bebob_avdevice.cpp (modified) (2 diffs)
- branches/streaming-rework/src/bebob/bebob_avdevice.h (modified) (2 diffs)
- branches/streaming-rework/src/bebob/bebob_avdevice_subunit.cpp (modified) (2 diffs)
- branches/streaming-rework/src/bebob/bebob_avdevice_subunit.h (modified) (2 diffs)
- branches/streaming-rework/src/bebob/bebob_avdevice_xml.cpp (modified) (2 diffs)
- branches/streaming-rework/src/bebob/bebob_avplug.cpp (modified) (2 diffs)
- branches/streaming-rework/src/bebob/bebob_avplug.h (modified) (2 diffs)
- branches/streaming-rework/src/bebob/bebob_avplug_xml.cpp (modified) (2 diffs)
- branches/streaming-rework/src/bebob/bebob_dl_bcd.cpp (modified) (2 diffs)
- branches/streaming-rework/src/bebob/bebob_dl_bcd.h (modified) (2 diffs)
- branches/streaming-rework/src/bebob/bebob_dl_codes.cpp (modified) (2 diffs)
- branches/streaming-rework/src/bebob/bebob_dl_mgr.cpp (modified) (2 diffs)
- branches/streaming-rework/src/bebob/bebob_dl_mgr.h (modified) (2 diffs)
- branches/streaming-rework/src/bebob/bebob_functionblock.cpp (modified) (2 diffs)
- branches/streaming-rework/src/bebob/bebob_functionblock.h (modified) (2 diffs)
- branches/streaming-rework/src/bounce/bounce_avdevice.cpp (modified) (5 diffs)
- branches/streaming-rework/src/bounce/bounce_avdevice.h (modified) (2 diffs)
- branches/streaming-rework/src/devicemanager.cpp (modified) (4 diffs)
- branches/streaming-rework/src/devicemanager.h (modified) (2 diffs)
- branches/streaming-rework/src/dice/dice_avdevice.cpp (modified) (2 diffs)
- branches/streaming-rework/src/dice/dice_avdevice.h (modified) (2 diffs)
- branches/streaming-rework/src/freebob_streaming.cpp (modified) (3 diffs)
- branches/streaming-rework/src/libfreebobavc/ieee1394service.cpp (modified) (1 diff)
- branches/streaming-rework/src/libfreebobavc/ieee1394service.h (modified) (3 diffs)
- branches/streaming-rework/src/libstreaming/AmdtpPort.cpp (modified) (2 diffs)
- branches/streaming-rework/src/libstreaming/AmdtpPort.h (modified) (2 diffs)
- branches/streaming-rework/src/libstreaming/AmdtpPortInfo.cpp (modified) (2 diffs)
- branches/streaming-rework/src/libstreaming/AmdtpPortInfo.h (modified) (2 diffs)
- branches/streaming-rework/src/libstreaming/AmdtpStreamProcessor.cpp (modified) (9 diffs)
- branches/streaming-rework/src/libstreaming/AmdtpStreamProcessor.h (modified) (3 diffs)
- branches/streaming-rework/src/libstreaming/MotuPort.cpp (modified) (2 diffs)
- branches/streaming-rework/src/libstreaming/MotuPort.h (modified) (2 diffs)
- branches/streaming-rework/src/libstreaming/MotuPortInfo.cpp (modified) (2 diffs)
- branches/streaming-rework/src/libstreaming/MotuPortInfo.h (modified) (2 diffs)
- branches/streaming-rework/src/libstreaming/MotuStreamProcessor.cpp (modified) (2 diffs)
- branches/streaming-rework/src/libstreaming/MotuStreamProcessor.h (modified) (2 diffs)
- branches/streaming-rework/src/libstreaming/StreamProcessor.cpp (modified) (2 diffs)
- branches/streaming-rework/src/libstreaming/StreamProcessorManager.cpp (modified) (2 diffs)
- branches/streaming-rework/src/libutil/TimestampedBuffer.cpp (modified) (4 diffs)
- branches/streaming-rework/src/libutil/TimestampedBuffer.h (modified) (1 diff)
- branches/streaming-rework/src/Makefile.am (modified) (7 diffs)
- branches/streaming-rework/src/maudio/maudio_avdevice.cpp (modified) (2 diffs)
- branches/streaming-rework/src/maudio/maudio_avdevice.h (modified) (2 diffs)
- branches/streaming-rework/src/metrichalo/mh_avdevice.cpp (modified) (2 diffs)
- branches/streaming-rework/src/metrichalo/mh_avdevice.h (modified) (2 diffs)
- branches/streaming-rework/src/motu/motu_avdevice.cpp (modified) (2 diffs)
- branches/streaming-rework/src/motu/motu_avdevice.h (modified) (2 diffs)
- branches/streaming-rework/src/rme/rme_avdevice.cpp (modified) (2 diffs)
- branches/streaming-rework/src/rme/rme_avdevice.h (modified) (2 diffs)
- branches/streaming-rework/src/ser.cpp (modified) (1 diff)
- branches/streaming-rework/tests/freebob-server.c (modified) (7 diffs)
- branches/streaming-rework/tests/Makefile.am (modified) (1 diff)
- branches/streaming-rework/tests/test-timestampedbuffer.cpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/streaming-rework/configure.ac
r404 r407 25 25 m4_define(freebob_major_version, 1) 26 26 m4_define(freebob_minor_version, 999) 27 m4_define(freebob_micro_version, 1)27 m4_define(freebob_micro_version, 2) 28 28 29 29 m4_define(freebob_version, freebob_major_version.freebob_minor_version.freebob_micro_version) … … 287 287 [build_all=false]) 288 288 289 AC_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) ;; 296 esac], 297 [build_tests=true]) 289 298 290 299 CFLAGS="$CFLAGS -Wall -std=gnu99" … … 309 318 fi; 310 319 320 build_amdtp=false 321 311 322 if test "${build_bebob}" = true; then 312 323 CFLAGS="$CFLAGS -DENABLE_BEBOB" 313 324 CXXFLAGS="$CXXFLAGS -DENABLE_BEBOB" 314 325 supported_devices="${supported_devices}BeBoB " 315 BIN_PROGRAMS="$BIN_PROGRAMS freebob-downloader freebob-sync"326 build_amdtp=true 316 327 fi; 317 328 … … 320 331 CXXFLAGS="$CXXFLAGS -DENABLE_MOTU" 321 332 supported_devices="${supported_devices}Motu " 322 BIN_PROGRAMS="$BIN_PROGRAMS"323 333 fi; 324 334 … … 327 337 CXXFLAGS="$CXXFLAGS -DENABLE_DICE" 328 338 supported_devices="${supported_devices}DICE " 329 BIN_PROGRAMS="$BIN_PROGRAMS"339 build_amdtp=true 330 340 fi; 331 341 … … 334 344 CXXFLAGS="$CXXFLAGS -DENABLE_METRIC_HALO" 335 345 supported_devices="${supported_devices}Metric Halo (useless) " 336 BIN_PROGRAMS="$BIN_PROGRAMS"337 346 fi; 338 347 … … 341 350 CXXFLAGS="$CXXFLAGS -DENABLE_BOUNCE" 342 351 supported_devices="${supported_devices}Bounce " 343 BIN_PROGRAMS="$BIN_PROGRAMS"352 build_amdtp=true 344 353 fi; 345 354 … … 348 357 CXXFLAGS="$CXXFLAGS -DENABLE_RME" 349 358 supported_devices="${supported_devices}RME (useless) " 350 BIN_PROGRAMS="$BIN_PROGRAMS"351 359 fi; 352 360 … … 354 362 AC_ERROR(You need to enable at least one device class to support!) 355 363 fi; 364 365 AM_CONDITIONAL(BUILD_BEBOB,test "${build_bebob}" = true) 366 AM_CONDITIONAL(BUILD_MOTU,test "${build_motu}" = true) 367 AM_CONDITIONAL(BUILD_DICE,test "${build_dice}" = true) 368 AM_CONDITIONAL(BUILD_METRIC_HALO,test "${build_metric_halo}" = true) 369 AM_CONDITIONAL(BUILD_BOUNCE,test "${build_bounce}" = true) 370 AM_CONDITIONAL(BUILD_RME,test "${build_rme}" = true) 371 372 AM_CONDITIONAL(BUILD_AMDTP,test "${build_amdtp}" = true) 373 374 AM_CONDITIONAL(BUILD_TESTS,test "${build_tests}" = true) 356 375 357 376 AC_SUBST([CFLAGS]) … … 394 413 395 414 Building support for: $supported_devices 415 build AMDTP support: $build_amdtp 416 417 Building tests: $build_tests 396 418 397 419 Source directory: $srcdir branches/streaming-rework/libfreebob/freebob_bounce.h
r209 r407 28 28 #define FREEBOB_BOUNCE_SERVER_MODELNAME "freebob-server" 29 29 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 30 36 #define FREEBOB_BOUNCE_SERVER_GETXMLDESCRIPTION_CMD 31 37 #define AVC1394_SUBUNIT_TYPE_FREEBOB_BOUNCE_SERVER 0x0D branches/streaming-rework/src/bebob/bebob_avdevice.cpp
r404 r407 18 18 * MA 02111-1307 USA. 19 19 */ 20 21 #ifdef ENABLE_BEBOB22 20 23 21 #include "bebob/bebob_avdevice.h" … … 1607 1605 1608 1606 } // end of namespace 1609 1610 #endif //#ifdef ENABLE_BEBOBbranches/streaming-rework/src/bebob/bebob_avdevice.h
r404 r407 18 18 * MA 02111-1307 USA. 19 19 */ 20 21 #ifdef ENABLE_BEBOB22 23 20 #ifndef BEBOB_AVDEVICE_H 24 21 #define BEBOB_AVDEVICE_H … … 197 194 198 195 #endif 199 200 #endif //#ifdef ENABLE_BEBOBbranches/streaming-rework/src/bebob/bebob_avdevice_subunit.cpp
r404 r407 18 18 * MA 02111-1307 USA. 19 19 */ 20 21 #ifdef ENABLE_BEBOB22 20 23 21 #include "bebob/bebob_functionblock.h" … … 588 586 return true; 589 587 } 590 591 #endif //#ifdef ENABLE_BEBOBbranches/streaming-rework/src/bebob/bebob_avdevice_subunit.h
r404 r407 18 18 * MA 02111-1307 USA. 19 19 */ 20 21 #ifdef ENABLE_BEBOB22 23 20 #ifndef BEBOB_AVDEVICESUBUNIT_H 24 21 #define BEBOB_AVDEVICESUBUNIT_H … … 156 153 157 154 #endif 158 159 #endif //#ifdef ENABLE_BEBOBbranches/streaming-rework/src/bebob/bebob_avdevice_xml.cpp
r404 r407 18 18 * MA 02111-1307 USA. 19 19 */ 20 21 #ifdef ENABLE_BEBOB22 23 20 // AvDevice XML stuff 24 21 … … 122 119 123 120 } 124 125 #endif //#ifdef ENABLE_BEBOBbranches/streaming-rework/src/bebob/bebob_avplug.cpp
r404 r407 18 18 * MA 02111-1307 USA. 19 19 */ 20 21 #ifdef ENABLE_BEBOB22 20 23 21 #include "bebob/bebob_avplug.h" … … 2222 2220 2223 2221 } 2224 2225 #endif //#ifdef ENABLE_BEBOBbranches/streaming-rework/src/bebob/bebob_avplug.h
r404 r407 18 18 * MA 02111-1307 USA. 19 19 */ 20 21 #ifdef ENABLE_BEBOB22 20 23 21 #ifndef BEBOB_AVPLUG_H … … 358 356 359 357 #endif 360 361 #endif //#ifdef ENABLE_BEBOBbranches/streaming-rework/src/bebob/bebob_avplug_xml.cpp
r404 r407 18 18 * MA 02111-1307 USA. 19 19 */ 20 21 #ifdef ENABLE_BEBOB22 20 23 21 // AvPlug XML stuff … … 300 298 301 299 } 302 303 #endif //#ifdef ENABLE_BEBOBbranches/streaming-rework/src/bebob/bebob_dl_bcd.cpp
r404 r407 19 19 */ 20 20 21 #ifdef ENABLE_BEBOB22 23 21 #include "bebob_dl_bcd.h" 24 22 … … 384 382 printf( "\tCNE CRC:\t\t0x%08x\n", m_cneCRC ); 385 383 } 386 387 #endif //#ifdef ENABLE_BEBOBbranches/streaming-rework/src/bebob/bebob_dl_bcd.h
r404 r407 18 18 * MA 02111-1307 USA. 19 19 */ 20 21 #ifdef ENABLE_BEBOB22 23 20 #ifndef BEBOB_DL_BCD_H 24 21 #define BEBOB_DL_BCD_H … … 116 113 117 114 #endif 118 119 #endif //#ifdef ENABLE_BEBOBbranches/streaming-rework/src/bebob/bebob_dl_codes.cpp
r404 r407 18 18 * MA 02111-1307 USA. 19 19 */ 20 21 #ifdef ENABLE_BEBOB22 23 20 #include "bebob/bebob_dl_codes.h" 24 21 #include "bebob/bebob_dl_bcd.h" … … 346 343 return result; 347 344 } 348 349 #endif //#ifdef ENABLE_BEBOBbranches/streaming-rework/src/bebob/bebob_dl_mgr.cpp
r404 r407 18 18 * MA 02111-1307 USA. 19 19 */ 20 21 #ifdef ENABLE_BEBOB22 23 20 #include "bebob_dl_mgr.h" 24 21 #include "bebob_dl_codes.h" … … 716 713 return false; 717 714 } 718 719 #endif //#ifdef ENABLE_BEBOBbranches/streaming-rework/src/bebob/bebob_dl_mgr.h
r404 r407 18 18 * MA 02111-1307 USA. 19 19 */ 20 21 #ifdef ENABLE_BEBOB22 23 20 #ifndef BEBOB_DL_MGR_H 24 21 #define BEBOB_DL_MGR_H … … 127 124 128 125 #endif 129 130 #endif //#ifdef ENABLE_BEBOBbranches/streaming-rework/src/bebob/bebob_functionblock.cpp
r404 r407 18 18 * MA 02111-1307 USA. 19 19 */ 20 21 #ifdef ENABLE_BEBOB22 23 20 #include "bebob/bebob_functionblock.h" 24 21 #include "bebob/bebob_avdevice_subunit.h" … … 553 550 return true; 554 551 } 555 556 #endif //#ifdef ENABLE_BEBOBbranches/streaming-rework/src/bebob/bebob_functionblock.h
r404 r407 18 18 * MA 02111-1307 USA. 19 19 */ 20 21 #ifdef ENABLE_BEBOB22 23 20 #ifndef BEBOB_FUNCTION_BLOCK_H 24 21 #define BEBOB_FUNCTION_BLOCK_H … … 220 217 221 218 #endif 222 223 #endif //#ifdef ENABLE_BEBOBbranches/streaming-rework/src/bounce/bounce_avdevice.cpp
r405 r407 19 19 * MA 02111-1307 USA. 20 20 */ 21 22 #ifdef ENABLE_BOUNCE23 24 21 #include "bounce/bounce_avdevice.h" 25 22 #include "configrom.h" … … 247 244 } else { 248 245 debugOutput(DEBUG_LEVEL_VERBOSE, "Added port %s\n",buff); 249 250 246 } 251 247 } … … 339 335 // 340 336 // // 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: 344 345 // // do connection management: make connection 345 346 // iso_channel = iec61883_cmp_connect( … … 353 354 // // set the channel obtained by the connection management 354 355 // // 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 } 356 362 break; 357 363 default: … … 405 411 406 412 } // namespace 407 408 #endif // #ifdef ENABLE_BOUNCEbranches/streaming-rework/src/bounce/bounce_avdevice.h
r405 r407 19 19 * MA 02111-1307 USA. 20 20 */ 21 22 #ifdef ENABLE_BOUNCE23 24 21 #ifndef BOUNCEDEVICE_H 25 22 #define BOUNCEDEVICE_H … … 112 109 113 110 #endif 114 115 #endif // #ifdef ENABLE_BOUNCEbranches/streaming-rework/src/devicemanager.cpp
r405 r407 27 27 #include "libfreebobavc/ieee1394service.h" 28 28 #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"36 29 37 30 #include <iostream> … … 39 32 40 33 #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 41 61 42 62 using namespace std; … … 101 121 { 102 122 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 } 103 128 104 129 std::auto_ptr<ConfigRom> configRom = … … 261 286 { 262 287 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 */ 298 FreebobStreaming::StreamProcessor * 299 DeviceManager::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 263 309 } 264 310 branches/streaming-rework/src/devicemanager.h
r365 r407 32 32 class Ieee1394Service; 33 33 class IAvDevice; 34 namespace FreebobStreaming { 35 class StreamProcessor; 36 } 34 37 35 38 typedef std::vector< IAvDevice* > IAvDeviceVector; … … 62 65 bool loadCache( Glib::ustring fileName ); 63 66 67 FreebobStreaming::StreamProcessor *getSyncSource(); 68 64 69 protected: 65 70 IAvDevice* getDriverForDevice( std::auto_ptr<ConfigRom>( configRom ), branches/streaming-rework/src/dice/dice_avdevice.cpp
r404 r407 18 18 * MA 02111-1307 USA. 19 19 */ 20 21 #ifdef ENABLE_DICE22 20 #warning DICE support is currently useless 23 21 … … 241 239 242 240 } 243 244 #endif //#ifdef ENABLE_DICEbranches/streaming-rework/src/dice/dice_avdevice.h
r404 r407 18 18 * MA 02111-1307 USA. 19 19 */ 20 21 #ifdef ENABLE_DICE22 23 20 #ifndef DICEDEVICE_H 24 21 #define DICEDEVICE_H … … 100 97 101 98 #endif 102 103 #endif //#ifdef ENABLE_DICEbranches/streaming-rework/src/freebob_streaming.cpp
r386 r407 118 118 return 0; 119 119 } 120 120 121 121 // iterate over the found devices 122 122 // add the stream processors of the devices to the managers … … 127 127 debugOutput(DEBUG_LEVEL_VERBOSE, "Setting samplerate to %d for (%p)\n", 128 128 dev->options.sample_rate, device); 129 129 130 // Set the device's sampling rate to that requested 130 131 // FIXME: does this really belong here? If so we need to handle errors. … … 154 155 } 155 156 } 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()); 156 163 } 157 164 branches/streaming-rework/src/libfreebobavc/ieee1394service.cpp
r405 r407 98 98 } 99 99 100 nodeid_t Ieee1394Service::getLocalNodeId() { 101 return raw1394_get_local_id(m_handle) & 0x3F; 102 } 103 100 104 bool 101 105 Ieee1394Service::read( fb_nodeid_t nodeId, branches/streaming-rework/src/libfreebobavc/ieee1394service.h
r340 r407 42 42 { return m_port; } 43 43 /** 44 * getNodecount -get number of nodes on the bus44 * @brief get number of nodes on the bus 45 45 * 46 46 * Since the root node always has … … 48 48 * LOCAL_BUS|(count-1)). 49 49 * 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. 51 51 * This value can change with every bus reset. 52 52 */ 53 53 int getNodeCount(); 54 54 55 55 /** 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. 61 65 * 62 66 * This does the complete transaction and will return when it's finished. 63 67 * 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) 65 74 */ 66 75 bool read( fb_nodeid_t nodeId, … … 78 87 79 88 /** 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. 85 90 * 86 91 * This does the complete transaction and will return when it's finished. 87 92 * 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) 89 99 */ 90 100 bool write( fb_nodeid_t nodeId, branches/streaming-rework/src/libstreaming/AmdtpPort.cpp
r404 r407 26 26 * 27 27 */ 28 #ifdef ENABLE_BEBOB29 #ifndef ENABLE_AMDTP_SP30 #define ENABLE_AMDTP_SP31 #endif32 #endif33 34 #ifdef ENABLE_DICE35 #ifndef ENABLE_AMDTP_SP36 #define ENABLE_AMDTP_SP37 #endif38 #endif39 40 #ifdef ENABLE_BOUNCE41 #ifndef ENABLE_AMDTP_SP42 #define ENABLE_AMDTP_SP43 #endif44 #endif45 46 #ifdef ENABLE_AMDTP_SP47 48 28 #include "AmdtpPort.h" 49 29 #include <assert.h> … … 52 32 53 33 } // end of namespace FreebobStreaming 54 55 #endif // #ifdef ENABLE_AMDTP_SPbranches/streaming-rework/src/libstreaming/AmdtpPort.h
r404 r407 26 26 * 27 27 */ 28 #ifdef ENABLE_BEBOB29 #ifndef ENABLE_AMDTP_SP30 #define ENABLE_AMDTP_SP31 #endif32 #endif33 34 #ifdef ENABLE_DICE35 #ifndef ENABLE_AMDTP_SP36 #define ENABLE_AMDTP_SP37 #endif38 #endif39 40 #ifdef ENABLE_BOUNCE41 #ifndef ENABLE_AMDTP_SP42 #define ENABLE_AMDTP_SP43 #endif44 #endif45 46 #ifdef ENABLE_AMDTP_SP47 48 28 #ifndef __FREEBOB_AMDTPPORT__ 49 29 #define __FREEBOB_AMDTPPORT__ … … 119 99 120 100 #endif /* __FREEBOB_AMDTPPORT__ */ 121 122 #endif // #ifdef ENABLE_AMDTP_SPbranches/streaming-rework/src/libstreaming/AmdtpPortInfo.cpp
r404 r407 26 26 * 27 27 */ 28 29 #ifdef ENABLE_BEBOB30 #ifndef ENABLE_AMDTP_SP31 #define ENABLE_AMDTP_SP32 #endif33 #endif34 35 #ifdef ENABLE_DICE36 #ifndef ENABLE_AMDTP_SP37 #define ENABLE_AMDTP_SP38 #endif39 #endif40 41 #ifdef ENABLE_BOUNCE42 #ifndef ENABLE_AMDTP_SP43 #define ENABLE_AMDTP_SP44 #endif45 #endif46 47 #ifdef ENABLE_AMDTP_SP48 49 28 #include "AmdtpPortInfo.h" 50 29 #include <assert.h> … … 55 34 56 35 } // end of namespace FreebobStreaming 57 58 #endif // #ifdef ENABLE_AMDTP_SPbranches/streaming-rework/src/libstreaming/AmdtpPortInfo.h
r404 r407 26 26 * 27 27 */ 28 29 #ifdef ENABLE_BEBOB30 #ifndef ENABLE_AMDTP_SP31 #define ENABLE_AMDTP_SP32 #endif33 #endif34 35 #ifdef ENABLE_DICE36 #ifndef ENABLE_AMDTP_SP37 #define ENABLE_AMDTP_SP38 #endif39 #endif40 41 #ifdef ENABLE_BOUNCE42 #ifndef ENABLE_AMDTP_SP43 #define ENABLE_AMDTP_SP44 #endif45 #endif46 47 #ifdef ENABLE_AMDTP_SP48 49 28 #ifndef __FREEBOB_AMDTPPORTINFO__ 50 29 #define __FREEBOB_AMDTPPORTINFO__ … … 107 86 108 87 #endif /* __FREEBOB_AMDTPPORTINFO__ */ 109 110 #endif // #ifdef ENABLE_AMDTP_SPbranches/streaming-rework/src/libstreaming/AmdtpStreamProcessor.cpp
r404 r407 26 26 * 27 27 */ 28 29 #ifdef ENABLE_BEBOB30 #ifndef ENABLE_AMDTP_SP31 #define ENABLE_AMDTP_SP32 #endif33 #endif34 35 #ifdef ENABLE_DICE36 #ifndef ENABLE_AMDTP_SP37 #define ENABLE_AMDTP_SP38 #endif39 #endif40 41 #ifdef ENABLE_BOUNCE42 #ifndef ENABLE_AMDTP_SP43 #define ENABLE_AMDTP_SP44 #endif45 #endif46 47 #ifdef ENABLE_AMDTP_SP48 49 28 #include "AmdtpStreamProcessor.h" 50 29 #include "Port.h" … … 57 36 58 37 // in ticks 59 #define TRANSMIT_TRANSFER_DELAY 6000U38 #define TRANSMIT_TRANSFER_DELAY 9000U 60 39 // the number of cycles to send a packet in advance of it's timestamp 61 40 #define TRANSMIT_ADVANCE_CYCLES 1U … … 190 169 ts_head = addTicks(ts_head, sync_lag_cycles * TICKS_PER_CYCLE); 191 170 192 m_data_buffer->setBuffer TailTimestamp(ts_head);171 m_data_buffer->setBufferHeadTimestamp(ts_head); 193 172 194 173 #ifdef DEBUG … … 213 192 // the base timestamp is the one of the next sample in the buffer 214 193 m_data_buffer->getBufferHeadTimestamp(&ts_head, &fc); // thread safe 215 216 int64_t timestamp = ts_head;217 194 218 195 // we send a packet some cycles in advance, to avoid the … … 236 213 237 214 // 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 } 263 282 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); 306 285 return RAW1394_ISO_DEFER; 307 286 } 308 287 309 // construct the packet310 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 format322 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 base328 // 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 packets340 return RAW1394_ISO_AGAIN;341 } else { // there is no more data in the ringbuffer342 343 debugWarning("Transmit buffer underrun (now %d, queue %d, target %d)\n",344 now_cycles, cycle, TICKS_TO_CYCLES(ts));345 346 // signal underrun347 m_xruns++;348 349 // disable the processing, will be re-enabled when350 // the xrun is handled351 m_disabled=true;352 m_is_disabled=true;353 354 // compose a no-data packet, we should always355 // send a valid packet356 357 // FIXME: either make this a setting or choose358 bool send_payload=true;359 if(send_payload) {360 // the dbc is incremented even with no data packets361 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 incremented367 368 // this means no-data packets without payload369 *length = 2*sizeof(quadlet_t);370 }371 372 return RAW1394_ISO_DEFER;373 }374 375 288 // we shouldn't get here 376 289 return RAW1394_ISO_ERROR; 377 290 291 } 292 293 unsigned 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 308 unsigned 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 } 378 328 } 379 329 … … 937 887 debugWarning("Dropped %d packets on cycle %d\n",dropped, cycle); 938 888 } 939 #endif 889 940 890 941 891 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"ch%2u: CY=%4u, SYT=%08X (%4ucy + %04uticks) (running=%d, disabled=%d,%d)\n", … … 944 894 m_running,m_disabled,m_is_disabled); 945 895 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 946 906 // check our enable status 947 907 if (!m_disabled && m_is_disabled) { … … 1077 1037 // ISO buffering 1078 1038 int 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); 1080 1040 } 1081 1041 … … 1441 1401 1442 1402 } // end of namespace FreebobStreaming 1443 1444 #endif // #ifdef ENABLE_AMDTP_SPbranches/streaming-rework/src/libstreaming/AmdtpStreamProcessor.h
r404 r407 26 26 * 27 27 */ 28 #ifdef ENABLE_BEBOB29 #ifndef ENABLE_AMDTP_SP30 #define ENABLE_AMDTP_SP31 #endif32 #endif33 34 #ifdef ENABLE_DICE35 #ifndef ENABLE_AMDTP_SP36 #define ENABLE_AMDTP_SP37 #endif38 #endif39 40 #ifdef ENABLE_BOUNCE41 #ifndef ENABLE_AMDTP_SP42 #define ENABLE_AMDTP_SP43 #endif44 #endif45 46 #ifdef ENABLE_AMDTP_SP47 48 28 #ifndef __FREEBOB_AMDTPSTREAMPROCESSOR__ 49 29 #define __FREEBOB_AMDTPSTREAMPROCESSOR__ … … 141 121 bool prefill(); 142 122 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 143 127 bool transferSilence(unsigned int size); 144 128 … … 235 219 #endif /* __FREEBOB_AMDTPSTREAMPROCESSOR__ */ 236 220 237 #endif // #ifdef ENABLE_AMDTP_SP238 branches/streaming-rework/src/libstreaming/MotuPort.cpp
r404 r407 27 27 */ 28 28 29 #ifdef ENABLE_MOTU30 31 29 #include "MotuPort.h" 32 30 #include <assert.h> … … 35 33 36 34 } // end of namespace FreebobStreaming 37 38 #endif //#ifdef ENABLE_MOTUbranches/streaming-rework/src/libstreaming/MotuPort.h
r404 r407 26 26 * 27 27 */ 28 29 #ifdef ENABLE_MOTU30 31 28 #ifndef __FREEBOB_MOTUPORT__ 32 29 #define __FREEBOB_MOTUPORT__ … … 121 118 #endif /* __FREEBOB_MOTUPORT__ */ 122 119 123 #endif //#ifdef ENABLE_MOTU124 branches/streaming-rework/src/libstreaming/MotuPortInfo.cpp
r404 r407 26 26 * 27 27 */ 28 29 #ifdef ENABLE_MOTU30 31 28 #include "MotuPortInfo.h" 32 29 #include <assert.h> … … 36 33 37 34 } // end of namespace FreebobStreaming 38 39 #endif //#ifdef ENABLE_MOTUbranches/streaming-rework/src/libstreaming/MotuPortInfo.h
r404 r407 26 26 * 27 27 */ 28 #ifdef ENABLE_MOTU29 30 28 #ifndef __FREEBOB_MOTUPORTINFO__ 31 29 #define __FREEBOB_MOTUPORTINFO__ … … 92 90 93 91 #endif /* __FREEBOB_MOTUPORTINFO__ */ 94 95 #endif //#ifdef ENABLE_MOTU96 branches/streaming-rework/src/libstreaming/MotuStreamProcessor.cpp
r402 r407 27 27 * 28 28 */ 29 30 #ifdef ENABLE_MOTU31 32 29 #include "MotuStreamProcessor.h" 33 30 #include "Port.h" … … 1398 1395 1399 1396 } // end of namespace FreebobStreaming 1400 #endifbranches/streaming-rework/src/libstreaming/MotuStreamProcessor.h
r402 r407 35 35 36 36 #include "../libutil/DelayLockedLoop.h" 37 38 #ifdef ENABLE_MOTU39 37 40 38 namespace FreebobStreaming { … … 181 179 } // end of namespace FreebobStreaming 182 180 183 #endif /* ENABLE_MOTU */184 185 181 #endif /* __FREEBOB_MOTUSTREAMPROCESSOR__ */ 186 182 branches/streaming-rework/src/libstreaming/StreamProcessor.cpp
r401 r407 80 80 81 81 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() 84 84 ); 85 85 … … 197 197 198 198 #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); 201 201 202 202 int64_t diff=(int64_t)m_cycle_to_enable_at-(int64_t)now_cycles; branches/streaming-rework/src/libstreaming/StreamProcessorManager.cpp
r399 r407 155 155 156 156 bool StreamProcessorManager::setSyncSource(StreamProcessor *s) { 157 debugOutput( DEBUG_LEVEL_VERBOSE, "Setting sync source to (%p)\n", s); 158 157 159 m_SyncSource=s; 158 160 return true; … … 411 413 412 414 debugOutput( DEBUG_LEVEL_VERBOSE, "Starting IsoHandlers...\n"); 413 if (!m_isoManager->startHandlers( 0)) {415 if (!m_isoManager->startHandlers(-1)) { 414 416 debugFatal("Could not start handlers...\n"); 415 417 return false; branches/streaming-rework/src/libutil/TimestampedBuffer.cpp
r399 r407 104 104 * Returns the effective rate calculated by the DLL. 105 105 * 106 * @return rate (in frames/timeunit)106 * @return rate (in timeunits/frame) 107 107 */ 108 108 float 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); 110 113 } 111 114 … … 545 548 546 549 // 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 558 550 int64_t ts=new_timestamp; 559 551 ts += m_tick_offset; … … 574 566 #endif 575 567 568 int64_t diff=m_buffer_next_tail_timestamp - m_buffer_tail_timestamp; 569 if (diff < 0) diff += m_wrap_at; 570 576 571 pthread_mutex_lock(&m_framecounter_lock); 577 572 … … 584 579 585 580 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 */ 597 void 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); 587 630 588 631 } branches/streaming-rework/src/libutil/TimestampedBuffer.h
r401 r407 113 113 114 114 void setBufferTailTimestamp(uint64_t new_timestamp); 115 void setBufferHeadTimestamp(uint64_t new_timestamp); 115 116 116 117 uint64_t getTimestampFromTail(int nframes); branches/streaming-rework/src/Makefile.am
r404 r407 24 24 25 25 lib_LTLIBRARIES = libfreebob.la 26 27 libfreebob_la_LDFLAGS = \ 28 -version-info $(LT_VERSION) $(LIBRAW1394_LIBS) \ 29 $(LIBIEC61883_LIBS) $(LIBAVC1394_LIBS) \ 30 $(LIBXML_LIBS) $(LIBXMLCPP_LIBS) -lpthread -lrt 26 31 27 32 libfreebob_la_LIBADD = -lrt … … 50 55 libutil/TimeSource.h libutil/TimestampedBuffer.h 51 56 57 # common sources 52 58 libfreebob_la_SOURCES = \ 53 59 configrom.cpp \ … … 57 63 freebob_streaming.cpp \ 58 64 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 \74 65 debugmodule/debugmodule.cpp \ 75 66 libfreebobavc/avc_connect.cpp \ … … 87 78 libfreebobavc/avc_unit_info.cpp \ 88 79 libfreebobavc/ieee1394service.cpp \ 89 libstreaming/AmdtpPort.cpp \90 libstreaming/AmdtpPortInfo.cpp \91 libstreaming/AmdtpStreamProcessor.cpp \92 80 libstreaming/cip.c \ 93 81 libstreaming/IsoHandler.cpp \ 94 82 libstreaming/IsoHandlerManager.cpp \ 95 83 libstreaming/IsoStream.cpp \ 96 libstreaming/MotuPort.cpp \97 libstreaming/MotuPortInfo.cpp \98 libstreaming/MotuStreamProcessor.cpp \99 84 libstreaming/Port.cpp \ 100 85 libstreaming/PortManager.cpp \ … … 112 97 libutil/TimestampedBuffer.cpp 113 98 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 100 bebob_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 112 motu_src = \ 113 motu/motu_avdevice.cpp \ 114 libstreaming/MotuPort.cpp \ 115 libstreaming/MotuPortInfo.cpp \ 116 libstreaming/MotuStreamProcessor.cpp 117 118 dice_src = \ 119 dice/dice_avdevice.cpp 120 121 bounce_src = \ 122 bounce/bounce_avdevice.cpp 123 124 metric_halo_src = \ 125 metrichalo/mh_avdevice.cpp 126 127 rme_src = \ 128 rme/rme_avdevice.cpp 129 130 amdtp_src = \ 131 libstreaming/AmdtpPort.cpp \ 132 libstreaming/AmdtpPortInfo.cpp \ 133 libstreaming/AmdtpStreamProcessor.cpp 134 135 # data 136 # generic 137 nobase_dist_pkgdata_DATA = 138 # bebob specific 139 bebob_pkgdata = \ 120 140 maudio/refdesign.xml \ 121 141 maudio/fw410.xml \ 122 142 maudio/fwap.xml 123 143 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 146 bin_PROGRAMS = 147 148 # class specific 149 bebob_bin = freebob-downloader freebob-sync 150 130 151 freebob_downloader_SOURCES = freebob-downloader.cpp 131 152 freebob_downloader_LDADD = $(top_builddir)/src/libfreebob.la … … 134 155 freebob_sync_LDADD = $(top_builddir)/src/libfreebob.la 135 156 136 # ##############137 157 # programs not intended for installation 158 # generic 138 159 noinst_PROGRAMS = test-dll test-debugmodule test-unittests test-ser 139 160 … … 149 170 test_ser_SOURCES = ser.cpp 150 171 test_ser_LDADD = $(top_builddir)/src/libfreebob.la 172 173 # build customisation 174 175 if BUILD_BEBOB 176 libfreebob_la_SOURCES += $(bebob_src) 177 bin_PROGRAMS += $(bebob_bin) 178 noinst_PROGRAMS += $(bebob_noinst) 179 nobase_dist_pkgdata_DATA += $(bebob_pkgdata) 180 endif 181 182 if BUILD_BOUNCE 183 libfreebob_la_SOURCES += $(bounce_src) 184 bin_PROGRAMS += $(bounce_bin) 185 noinst_PROGRAMS += $(bounce_noinst) 186 nobase_dist_pkgdata_DATA += $(bounce_pkgdata) 187 endif 188 189 if BUILD_DICE 190 libfreebob_la_SOURCES += $(dice_src) 191 bin_PROGRAMS += $(dice_bin) 192 noinst_PROGRAMS += $(dice_noinst) 193 nobase_dist_pkgdata_DATA += $(dice_pkgdata) 194 endif 195 196 if BUILD_MOTU 197 libfreebob_la_SOURCES += $(motu_src) 198 bin_PROGRAMS += $(motu_bin) 199 noinst_PROGRAMS += $(motu_noinst) 200 nobase_dist_pkgdata_DATA += $(motu_pkgdata) 201 endif 202 203 if BUILD_METRIC_HALO 204 libfreebob_la_SOURCES += $(metric_halo_src) 205 bin_PROGRAMS += $(metric_halo_bin) 206 noinst_PROGRAMS += $(metric_halo_noinst) 207 nobase_dist_pkgdata_DATA += $(metric_halo_pkgdata) 208 endif 209 210 if BUILD_RME 211 libfreebob_la_SOURCES += $(rme_src) 212 bin_PROGRAMS += $(rme_bin) 213 noinst_PROGRAMS += $(rme_noinst) 214 nobase_dist_pkgdata_DATA += $(rme_pkgdata) 215 endif 216 217 if BUILD_AMDTP 218 libfreebob_la_SOURCES += $(amdtp_src) 219 bin_PROGRAMS += $(amdtp_bin) 220 noinst_PROGRAMS += $(amdtp_noinst) 221 nobase_dist_pkgdata_DATA += $(amdtp_pkgdata) 222 endif branches/streaming-rework/src/maudio/maudio_avdevice.cpp
r404 r407 18 18 * MA 02111-1307 USA. 19 19 */ 20 21 #ifdef ENABLE_BEBOB22 23 20 #include "maudio/maudio_avdevice.h" 24 21 #include "configrom.h" … … 548 545 549 546 } 550 551 #endif //#ifdef ENABLE_BEBOBbranches/streaming-rework/src/maudio/maudio_avdevice.h
r404 r407 18 18 * MA 02111-1307 USA. 19 19 */ 20 21 #ifdef ENABLE_BEBOB22 20 23 21 #ifndef MAUDIODEVICE_H … … 89 87 90 88 #endif 91 92 #endif //#ifdef ENABLE_BEBOBbranches/streaming-rework/src/metrichalo/mh_avdevice.cpp
r404 r407 19 19 */ 20 20 21 #ifdef ENABLE_METRIC_HALO22 21 #warning Metric Halo support is currently useless 23 22 … … 239 238 240 239 } 241 242 #endif //#ifdef ENABLE_METRIC_HALObranches/streaming-rework/src/metrichalo/mh_avdevice.h
r404 r407 18 18 * MA 02111-1307 USA. 19 19 */ 20 21 #ifdef ENABLE_METRIC_HALO22 20 23 21 #ifndef MHDEVICE_H … … 100 98 101 99 #endif 102 103 #endif //#ifdef ENABLE_MHbranches/streaming-rework/src/motu/motu_avdevice.cpp
r404 r407 19 19 * MA 02111-1307 USA. 20 20 */ 21 22 #ifdef ENABLE_MOTU23 24 21 #include "motu/motu_avdevice.h" 25 22 #include "configrom.h" … … 937 934 938 935 } 939 #endif // ENABLE_MOTUbranches/streaming-rework/src/motu/motu_avdevice.h
r404 r407 19 19 * MA 02111-1307 USA. 20 20 */ 21 22 #ifdef ENABLE_MOTU23 21 24 22 #ifndef MOTUDEVICE_H … … 163 161 164 162 #endif 165 166 #endif // ENABLE_MOTUbranches/streaming-rework/src/rme/rme_avdevice.cpp
r404 r407 19 19 * MA 02111-1307 USA. 20 20 */ 21 22 #ifdef ENABLE_RME23 21 #warning RME support is currently useless (detection only) 24 22 … … 550 548 551 549 } 552 553 #endif //#ifdef ENABLE_RMEbranches/streaming-rework/src/rme/rme_avdevice.h
r404 r407 19 19 * MA 02111-1307 USA. 20 20 */ 21 22 #ifdef ENABLE_RME23 24 21 #ifndef RMEDEVICE_H 25 22 #define RMEDEVICE_H … … 116 113 117 114 #endif 118 119 #endif //#ifdef ENABLE_RMEbranches/streaming-rework/src/ser.cpp
r365 r407 1 1 #include "devicemanager.h" 2 #include "bebob/bebob_avdevice.h"3 2 #include "libutil/serialize.h" 4 3 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 * 2 8 * avc_vcr.c - An example of an AV/C Tape Recorder target implementation 3 9 * … … 32 38 #include <signal.h> 33 39 40 #include <arpa/inet.h> 41 34 42 #include <libraw1394/raw1394.h> 35 43 #include <libraw1394/csr.h> … … 291 299 i = strlen(dir.textual_leafs[0]); 292 300 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 */ 293 306 retval = rom1394_set_directory(rom, &dir); 294 307 printf("rom1394_set_directory returned %d, romsize %d:",retval,rom_size); … … 304 317 305 318 /* add an AV/C unit directory */ 306 dir.unit_spec_id = 0x0000a02d;319 dir.unit_spec_id = FREEBOB_BOUNCE_SERVER_SPECID; 307 320 dir.unit_sw_version = 0x00010001; 308 321 leaf = FREEBOB_BOUNCE_SERVER_MODELNAME; … … 347 360 { 348 361 raw1394handle_t handle; 349 362 int p=0; 363 350 364 signal (SIGINT, sighandler); 351 365 signal (SIGPIPE, sighandler); … … 353 367 handle = raw1394_new_handle(); 354 368 369 if (argc==2) p=atoi(argv[1]); 370 355 371 if ( !handle ) 356 372 { … … 367 383 } 368 384 369 if ( raw1394_set_port( handle, 0) < 0 )385 if ( raw1394_set_port( handle, p ) < 0 ) 370 386 { 371 387 perror( "couldn't set port" ); 372 388 exit( EXIT_FAILURE ); 389 } else { 390 printf("Using port %d\n",p); 373 391 } 374 392 branches/streaming-rework/tests/Makefile.am
r392 r407 20 20 INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src $(LIBXML_CFLAGS) \ 21 21 $(LIBAVC1394_CFLAGS) 22 23 noinst_PROGRAMS = 22 24 23 noinst_PROGRAMS = test-freebob test-extplugcmd test-fw410 freebob-server \ 25 if BUILD_TESTS 26 noinst_PROGRAMS += test-freebob test-extplugcmd test-fw410 freebob-server \ 24 27 test-volume test-mixer test-cycletimer test-sytmonitor \ 25 28 test-timestampedbuffer 29 endif 26 30 27 31 noinst_HEADERS = branches/streaming-rework/tests/test-timestampedbuffer.cpp
r395 r407 295 295 usleep(1000); 296 296 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++) { 341 327 t->writeFrames(arguments.frames_per_packet, (char *)&dummyframe_in, timestamp); 342 343 // read the buffer head timestamp344 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 packet354 t->readFrames(arguments.frames_per_packet, (char *)&dummyframe_out);355 356 // read the buffer head timestamp357 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 // check367 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 timestamp376 328 timestamp += (uint64_t)(arguments.rate * arguments.frames_per_packet); 377 329 if (timestamp >= arguments.wrap_at) { … … 379 331 } 380 332 } 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; 448 338 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); 451 423 452 424 // read the buffer head timestamp … … 454 426 t->getBufferTailTimestamp(&ts_tail, &fc_tail); 455 427 debugOutput(DEBUG_LEVEL_NORMAL, 456 " TS after read: HEAD: %011llu, FC=%04u\n",428 " TS after write: HEAD: %011llu, FC=%04u\n", 457 429 ts_head,fc_head); 458 430 debugOutput(DEBUG_LEVEL_NORMAL, 459 " TAIL: %011llu, FC=%04u\n",431 " TAIL: %011llu, FC=%04u\n", 460 432 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 } 482 570 483 571 delete t;