Changeset 1031
- Timestamp:
- 04/25/08 09:39:51 (16 years ago)
- Files:
-
- trunk/libffado/src/libieee1394/IsoHandler.cpp (modified) (11 diffs)
- trunk/libffado/src/libieee1394/IsoHandler.h (modified) (3 diffs)
- trunk/libffado/src/libieee1394/IsoHandlerManager.cpp (modified) (4 diffs)
- trunk/libffado/src/libstreaming/amdtp/AmdtpTransmitStreamProcessor.cpp (modified) (1 diff)
- trunk/libffado/src/libstreaming/generic/StreamProcessor.cpp (modified) (11 diffs)
- trunk/libffado/src/libstreaming/generic/StreamProcessor.h (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/libffado/src/libieee1394/IsoHandler.cpp
r1005 r1031 27 27 #include "ieee1394service.h" 28 28 #include "IsoHandlerManager.h" 29 30 #include "cycletimer.h" 29 31 30 32 #include "libstreaming/generic/StreamProcessor.h" … … 54 56 unsigned int skipped = (dropped1 & 0xFFFF0000) >> 16; 55 57 unsigned int dropped = dropped1 & 0xFFFF; 56 57 58 return xmitHandler->getPacket(data, length, tag, sy, cycle, dropped, skipped); 58 59 } … … 89 90 , m_max_packet_size( 1024 ) 90 91 , m_irq_interval( -1 ) 92 , m_last_cycle( -1 ) 91 93 , m_Client( 0 ) 92 94 , m_speed( RAW1394_ISO_SPEED_400 ) … … 108 110 , m_max_packet_size( max_packet_size ) 109 111 , m_irq_interval( irq ) 112 , m_last_cycle( -1 ) 110 113 , m_Client( 0 ) 111 114 , m_speed( RAW1394_ISO_SPEED_400 ) … … 114 117 #ifdef DEBUG 115 118 , m_packets ( 0 ) 119 , m_dropped( 0 ) 116 120 #endif 117 121 { … … 132 136 , m_State( E_Created ) 133 137 #ifdef DEBUG 134 , m_packets ( 0 ) 138 , m_packets( 0 ) 139 , m_dropped( 0 ) 135 140 #endif 136 141 { … … 298 303 m_speed, m_prebuffers); 299 304 } 305 #ifdef DEBUG 306 debugOutputShort( DEBUG_LEVEL_NORMAL, " Last cycle, dropped.........: %4d, %4u\n", 307 m_last_cycle, m_dropped); 308 #endif 309 300 310 } 301 311 302 312 void IsoHandler::setVerboseLevel(int l) 303 313 { 314 debugError("setdebuglevel (%p, %d)\n", this, l); 304 315 setDebugLevel(l); 305 316 } … … 345 356 unsigned char channel, unsigned char tag, unsigned char sy, 346 357 unsigned int cycle, unsigned int dropped, unsigned int skipped) { 358 359 unsigned int pkt_ctr = cycle << 12; 347 360 348 361 debugOutputExtreme(DEBUG_LEVEL_ULTRA_VERBOSE, … … 355 368 this, getTypeString(), length, m_max_packet_size); 356 369 } 370 if(m_last_cycle == -1) { 371 debugOutput(DEBUG_LEVEL_VERBOSE, "Handler for %s SP %p is alive (cycle = %u)\n", getTypeString(), this, cycle); 372 } 357 373 #endif 374 375 // keep track of dropped cycles 376 int dropped_cycles = 0; 377 if (m_last_cycle != (int)cycle && m_last_cycle != -1) { 378 dropped_cycles = diffCycles(cycle, m_last_cycle) - 1; 379 if (dropped_cycles < 0) { 380 debugWarning("(%p) dropped < 1 (%d), cycle: %d, last_cycle: %d, dropped: %d, 'skipped'=%u\n", 381 this, dropped_cycles, cycle, m_last_cycle, dropped, skipped); 382 } 383 if (dropped_cycles > 0) { 384 debugWarning("(%p) dropped %d packets on cycle %u, 'dropped'=%u, 'skipped'=%u, cycle=%d, m_last_cycle=%d\n", 385 this, dropped_cycles, cycle, dropped, skipped, cycle, m_last_cycle); 386 m_dropped += dropped_cycles; 387 } 388 } 389 m_last_cycle = cycle; 390 391 // iterate the client if required 358 392 if(m_Client) { 359 enum raw1394_iso_disposition retval = m_Client->putPacket(data, length, channel, tag, sy, cycle, dropped, skipped);393 enum raw1394_iso_disposition retval = m_Client->putPacket(data, length, channel, tag, sy, pkt_ctr, dropped_cycles, skipped); 360 394 if (retval == RAW1394_ISO_OK) { 361 395 if (m_dont_exit_iterate_loop) { … … 382 416 int cycle, unsigned int dropped, unsigned int skipped) { 383 417 418 unsigned int pkt_ctr; 419 if (cycle < 0) { 420 pkt_ctr = 0xFFFFFFFF; 421 } else { 422 pkt_ctr = cycle << 12; 423 } 424 384 425 debugOutputExtreme(DEBUG_LEVEL_ULTRA_VERBOSE, 385 426 "sending packet: length=%d, cycle=%d\n", 386 427 *length, cycle); 428 387 429 #ifdef DEBUG 388 430 m_packets++; 431 if(m_last_cycle == -1) { 432 debugOutput(DEBUG_LEVEL_VERBOSE, "Handler for %s SP %p is alive (cycle = %d)\n", getTypeString(), this, cycle); 433 } 389 434 #endif 435 436 // keep track of dropped cycles 437 int dropped_cycles = 0; 438 if (m_last_cycle != cycle && m_last_cycle != -1) { 439 dropped_cycles = diffCycles(cycle, m_last_cycle) - 1; 440 // correct for skipped packets 441 // since those are not dropped, but only delayed 442 dropped_cycles -= skipped; 443 444 #ifdef DEBUG 445 if(skipped) { 446 debugWarning("(%p) skipped %d cycles, cycle: %d, last_cycle: %d, dropped: %d\n", 447 this, skipped, cycle, m_last_cycle, dropped); 448 } 449 if (dropped_cycles < 0) { 450 debugWarning("(%p) dropped < 1 (%d), cycle: %d, last_cycle: %d, dropped: %d, skipped: %d\n", 451 this, dropped_cycles, cycle, m_last_cycle, dropped, skipped); 452 } 453 if (dropped_cycles > 0) { 454 debugWarning("(%p) dropped %d packets on cycle %u (last_cycle=%u, dropped=%d, skipped: %d)\n", 455 this, dropped_cycles, cycle, m_last_cycle, dropped, skipped); 456 m_dropped += dropped_cycles; 457 } 458 #endif 459 } 460 if (cycle >= 0) { 461 m_last_cycle = cycle; 462 } 463 390 464 if(m_Client) { 391 465 enum raw1394_iso_disposition retval; 392 retval = m_Client->getPacket(data, length, tag, sy, cycle, dropped, skipped, m_max_packet_size);466 retval = m_Client->getPacket(data, length, tag, sy, pkt_ctr, dropped, skipped, m_max_packet_size); 393 467 #ifdef DEBUG 394 468 if (*length > m_max_packet_size) { … … 411 485 } 412 486 } 487 413 488 *tag = 0; 414 489 *sy = 0; trunk/libffado/src/libieee1394/IsoHandler.h
r1005 r1031 138 138 void allowIterateLoop() {m_dont_exit_iterate_loop = true;}; 139 139 140 141 /** 142 * @brief get last cycle number seen by handler 143 * @return cycle number 144 */ 145 int getLastCycle() {return m_last_cycle;}; 146 140 147 private: 141 148 IsoHandlerManager& m_manager; … … 145 152 unsigned int m_max_packet_size; 146 153 int m_irq_interval; 154 int m_last_cycle; 147 155 148 156 Streaming::StreamProcessor *m_Client; // FIXME: implement with functors … … 167 175 168 176 #ifdef DEBUG 169 int m_packets; 177 unsigned int m_packets; 178 unsigned int m_dropped; 170 179 #endif 171 180 trunk/libffado/src/libieee1394/IsoHandlerManager.cpp
r1027 r1031 453 453 return false; 454 454 } 455 m_IsoTaskTransmit->setVerboseLevel(getDebugLevel()); 455 456 m_IsoThreadTransmit = new Util::PosixThread(m_IsoTaskTransmit, m_realtime, 456 457 m_priority + ISOHANDLERMANAGER_ISO_PRIO_INCREASE … … 462 463 return false; 463 464 } 465 m_IsoThreadTransmit->setVerboseLevel(getDebugLevel()); 464 466 465 467 debugOutput( DEBUG_LEVEL_VERBOSE, "Create iso thread for %p receive...\n", this); … … 469 471 return false; 470 472 } 473 m_IsoTaskReceive->setVerboseLevel(getDebugLevel()); 471 474 m_IsoThreadReceive = new Util::PosixThread(m_IsoTaskReceive, m_realtime, 472 475 m_priority + ISOHANDLERMANAGER_ISO_PRIO_INCREASE … … 478 481 return false; 479 482 } 483 m_IsoThreadReceive->setVerboseLevel(getDebugLevel()); 480 484 // register the thread with the RT watchdog 481 485 Util::Watchdog *watchdog = m_service.getWatchdog(); trunk/libffado/src/libstreaming/amdtp/AmdtpTransmitStreamProcessor.cpp
r1021 r1031 48 48 , m_dimension( dimension ) 49 49 , m_dbc( 0 ) 50 , m_nb_audio_ports( 0 )51 , m_nb_midi_ports( 0 )52 50 #if AMDTP_ALLOW_PAYLOAD_IN_NODATA_XMIT 53 51 , m_send_nodata_payload ( AMDTP_SEND_PAYLOAD_IN_NODATA_XMIT_BY_DEFAULT ) 54 52 #endif 53 , m_nb_audio_ports( 0 ) 54 , m_nb_midi_ports( 0 ) 55 55 {} 56 56 trunk/libffado/src/libstreaming/generic/StreamProcessor.cpp
r1005 r1031 70 70 , m_local_node_id ( 0 ) // local cache 71 71 , m_channel( -1 ) 72 , m_dropped( 0 )73 72 , m_last_timestamp( 0 ) 74 73 , m_last_timestamp2( 0 ) … … 77 76 , m_scratch_buffer_size_bytes( 0 ) 78 77 , m_ticks_per_frame( 0 ) 79 , m_last_cycle( -1 )80 78 , m_sync_delay( 0 ) 81 79 , m_in_xrun( false ) … … 289 287 StreamProcessor::putPacket(unsigned char *data, unsigned int length, 290 288 unsigned char channel, unsigned char tag, unsigned char sy, 291 unsigned int cycle, unsigned int dropped, 292 unsigned int skipped) { 293 #ifdef DEBUG 294 if(m_last_cycle == -1) { 295 debugOutput(DEBUG_LEVEL_VERBOSE, "Handler for %s SP %p is alive (cycle = %u)\n", getTypeString(), this, cycle); 296 } 297 #endif 298 299 int dropped_cycles = 0; 300 if (m_last_cycle != (int)cycle && m_last_cycle != -1) { 301 dropped_cycles = diffCycles(cycle, m_last_cycle) - 1; 302 if (dropped_cycles < 0) { 303 debugWarning("(%p) dropped < 1 (%d), cycle: %d, last_cycle: %d, dropped: %d, 'skipped'=%u\n", 304 this, dropped_cycles, cycle, m_last_cycle, dropped, skipped); 305 } 306 if (dropped_cycles > 0) { 307 debugWarning("(%p) dropped %d packets on cycle %u, 'dropped'=%u, 'skipped'=%u, cycle=%d, m_last_cycle=%d\n", 308 this, dropped_cycles, cycle, dropped, skipped, cycle, m_last_cycle); 309 m_dropped += dropped_cycles; 310 m_last_cycle = cycle; 311 dumpInfo(); 312 } 313 } 314 m_last_cycle = cycle; 289 unsigned int pkt_ctr, 290 unsigned int dropped_cycles, unsigned int skipped) { 291 unsigned int cycle = CYCLE_TIMER_GET_CYCLES(pkt_ctr); 315 292 316 293 // bypass based upon state … … 407 384 "RECV: CY=%04u TS=%011llu\n", 408 385 cycle, m_last_timestamp); 409 // update some accounting410 m_last_good_cycle = cycle;411 m_last_dropped = dropped_cycles;412 386 413 387 if(m_correct_last_timestamp) { … … 502 476 StreamProcessor::getPacket(unsigned char *data, unsigned int *length, 503 477 unsigned char *tag, unsigned char *sy, 504 int cycle, unsigned int dropped,478 unsigned int pkt_ctr, unsigned int dropped_cycles, 505 479 unsigned int skipped, unsigned int max_length) { 506 if ( cycle<0) {480 if (pkt_ctr == 0xFFFFFFFF) { 507 481 *tag = 0; 508 482 *sy = 0; … … 510 484 return RAW1394_ISO_OK; 511 485 } 486 unsigned int cycle = CYCLE_TIMER_GET_CYCLES(pkt_ctr); 512 487 513 488 unsigned int ctr; … … 516 491 int cycle_diff; 517 492 518 #ifdef DEBUG 519 if(m_last_cycle == -1) { 520 debugOutput(DEBUG_LEVEL_VERBOSE, "Handler for %s SP %p is alive (cycle = %d)\n", getTypeString(), this, cycle); 521 } 522 #endif 523 524 int dropped_cycles = 0; 525 if (m_last_cycle != cycle && m_last_cycle != -1) { 526 dropped_cycles = diffCycles(cycle, m_last_cycle) - 1; 527 // correct for skipped packets 528 // since those are not dropped, but only delayed 529 dropped_cycles =- skipped; 530 if(skipped) { 531 debugWarning("(%p) skipped %d cycles, cycle: %d, last_cycle: %d, dropped: %d\n", 532 this, skipped, cycle, m_last_cycle, dropped); 533 } 534 if (dropped_cycles < 0) { 535 debugWarning("(%p) dropped < 1 (%d), cycle: %d, last_cycle: %d, dropped: %d, skipped: %d\n", 536 this, dropped_cycles, cycle, m_last_cycle, dropped, skipped); 537 } 538 if (dropped_cycles > 0) { 539 debugWarning("(%p) dropped %d packets on cycle %u (last_cycle=%u, dropped=%d, skipped: %d)\n", 540 this, dropped_cycles, cycle, m_last_cycle, dropped, skipped); 541 m_dropped += dropped_cycles; 542 // HACK: this should not be necessary, since the header generation functions should trigger the xrun. 543 // but apparently there are some issues with the 1394 stack 544 m_in_xrun = true; 545 if(m_state == ePS_Running) { 546 debugShowBackLogLines(200); 547 debugWarning("dropped packets xrun\n"); 548 debugOutput(DEBUG_LEVEL_VERBOSE, "Should update state to WaitingForStreamDisable due to dropped packets xrun\n"); 549 m_cycle_to_switch_state = cycle + 1; 550 m_next_state = ePS_WaitingForStreamDisable; 551 // execute the requested change 552 if (!updateState()) { // we are allowed to change the state directly 553 debugError("Could not update state!\n"); 554 return RAW1394_ISO_ERROR; 555 } 556 goto send_empty_packet; 557 } 558 } 559 } 560 if (cycle >= 0) { 561 m_last_cycle = cycle; 493 // note that we can ignore skipped cycles since 494 // the protocol will take care of that 495 if (dropped_cycles > 0) { 496 // HACK: this should not be necessary, since the header generation functions should trigger the xrun. 497 // but apparently there are some issues with the 1394 stack 498 m_in_xrun = true; 499 if(m_state == ePS_Running) { 500 debugShowBackLogLines(200); 501 debugWarning("dropped packets xrun\n"); 502 debugOutput(DEBUG_LEVEL_VERBOSE, "Should update state to WaitingForStreamDisable due to dropped packets xrun\n"); 503 m_cycle_to_switch_state = cycle + 1; 504 m_next_state = ePS_WaitingForStreamDisable; 505 // execute the requested change 506 if (!updateState()) { // we are allowed to change the state directly 507 debugError("Could not update state!\n"); 508 return RAW1394_ISO_ERROR; 509 } 510 goto send_empty_packet; 511 } 562 512 } 563 513 … … 637 587 "XMIT SILENT: CY=%04u TS=%011llu\n", 638 588 cycle, m_last_timestamp); 639 // update some accounting640 m_last_good_cycle = cycle;641 m_last_dropped = dropped_cycles;642 589 643 590 // assumed not to xrun … … 694 641 "XMIT: CY=%04u TS=%011llu NOW_CY=%04u AHEAD=%04d\n", 695 642 cycle, m_last_timestamp, now_cycles, ahead); 696 // update some accounting697 m_last_good_cycle = cycle;698 m_last_dropped = dropped_cycles;699 643 700 644 // valid packet timestamp … … 1475 1419 case ePS_WaitingForStream: 1476 1420 // a running stream has been detected 1477 debugOutput(DEBUG_LEVEL_VERBOSE, "StreamProcessor %p started dry-running at cycle %d\n", this, m_last_cycle); 1421 debugOutput(DEBUG_LEVEL_VERBOSE, 1422 "StreamProcessor %p started dry-running\n", 1423 this); 1478 1424 m_local_node_id = m_1394service.getLocalNodeId() & 0x3f; 1479 1425 if (getType() == ePT_Receive) { … … 1574 1520 case ePS_WaitingForStreamEnable: 1575 1521 // a running stream has been detected 1576 debugOutput(DEBUG_LEVEL_VERBOSE, "StreamProcessor %p started running at cycle %d\n",1577 this , m_last_cycle);1522 debugOutput(DEBUG_LEVEL_VERBOSE, "StreamProcessor %p started running\n", 1523 this); 1578 1524 m_in_xrun = false; 1579 1525 m_min_ahead = 7999; trunk/libffado/src/libstreaming/generic/StreamProcessor.h
r1005 r1031 153 153 putPacket(unsigned char *data, unsigned int length, 154 154 unsigned char channel, unsigned char tag, unsigned char sy, 155 unsigned int cycle, unsigned int dropped, unsigned int skipped);155 unsigned int pkt_ctr, unsigned int dropped, unsigned int skipped); 156 156 157 157 enum raw1394_iso_disposition 158 158 getPacket(unsigned char *data, unsigned int *length, 159 unsigned char *tag, unsigned char *sy, 160 int cycle, unsigned int dropped, unsigned int skipped, unsigned int max_length); 159 unsigned char *tag, unsigned char *sy, 160 unsigned int pkt_ctr, unsigned int dropped, 161 unsigned int skipped, unsigned int max_length); 161 162 162 163 bool getFrames(unsigned int nbframes, int64_t ts); ///< transfer the buffer contents to the client … … 301 302 302 303 protected: // FIXME: move to private 303 uint64_t m_dropped; /// FIXME:debug304 uint64_t m_last_dropped; /// FIXME:debug305 int m_last_good_cycle; /// FIXME:debug306 304 uint64_t m_last_timestamp; /// last timestamp (in ticks) 307 305 private: … … 415 413 void setTicksPerFrame(float tpf); 416 414 417 int getLastCycle() {return m_last_cycle;};418 419 415 int getBufferFill(); 420 416 … … 463 459 protected: 464 460 float m_ticks_per_frame; 465 int m_last_cycle;466 461 unsigned int m_sync_delay; 467 462 private: