Changeset 798
- Timestamp:
- 01/01/08 13:27:35 (16 years ago)
- Files:
-
- trunk/libffado/config.h.in (modified) (3 diffs)
- trunk/libffado/src/libstreaming/amdtp/AmdtpTransmitStreamProcessor.cpp (modified) (5 diffs)
- trunk/libffado/src/libstreaming/generic/StreamProcessor.cpp (modified) (3 diffs)
- trunk/libffado/src/libstreaming/motu/MotuTransmitStreamProcessor.cpp (modified) (2 diffs)
- trunk/libffado/src/libstreaming/StreamProcessorManager.cpp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/libffado/config.h.in
r797 r798 28 28 29 29 /* Define to 1 if SSE assembly is available. */ 30 #define USE_SSE $USE_SSE 30 // broken 31 //#define USE_SSE $USE_SSE 32 #define USE_SSE 0 31 33 32 34 #define CACHEDIR "~/.ffado" … … 49 51 // time to a later time instant also causes the xmit buffer fill to be 50 52 // lower on average. 51 #define STREAMPROCESSORMANAGER_SIGNAL_DELAY_TICKS (3072* 1)53 #define STREAMPROCESSORMANAGER_SIGNAL_DELAY_TICKS (3072*4) 52 54 53 55 #define STREAMPROCESSORMANAGER_CYCLES_FOR_DRYRUN 40000 … … 69 71 #define AMDTP_TRANSMIT_TRANSFER_DELAY (11776U) 70 72 73 // the absolute minimum number of cycles we want to transmit 74 // a packet ahead of the presentation time. The nominal time 75 // the packet is transmitted ahead of the presentation time is 76 // given by AMDTP_TRANSMIT_TRANSFER_DELAY (in ticks), but in case we 77 // are too late for that, this constant defines how late we can 78 // be. 79 #define AMDTP_MIN_CYCLES_BEFORE_PRESENTATION 1 80 81 // the absolute maximum number of cycles we want to transmit 82 // a packet ahead of the ideal transmit time. The nominal time 83 // the packet is transmitted ahead of the presentation time is 84 // given by AMDTP_TRANSMIT_TRANSFER_DELAY (in ticks), but we can send 85 // packets early if we want to. (not completely according to spec) 86 // (for spec compliance you need to specify a value of 1 or 2) 87 #define AMDTP_MAX_CYCLES_TO_TRANSMIT_EARLY 6 88 71 89 #define MOTU_TRANSMIT_TRANSFER_DELAY (11776U) 72 90 trunk/libffado/src/libstreaming/amdtp/AmdtpTransmitStreamProcessor.cpp
r797 r798 79 79 int cycles_until_transmit; 80 80 81 // FIXME: should become a define82 // the absolute minimum number of cycles we want to transmit83 // a packet ahead of the presentation time. The nominal time84 // the packet is transmitted ahead of the presentation time is85 // given by AMDTP_TRANSMIT_TRANSFER_DELAY (in ticks), but in case we86 // are too late for that, this constant defines how late we can87 // be.88 const int min_cycles_before_presentation = 1;89 // FIXME: should become a define90 // the absolute maximum number of cycles we want to transmit91 // a packet ahead of the ideal transmit time. The nominal time92 // the packet is transmitted ahead of the presentation time is93 // given by AMDTP_TRANSMIT_TRANSFER_DELAY (in ticks), but we can send94 // packets early if we want to. (not completely according to spec)95 const int max_cycles_to_transmit_early = 2;96 97 81 debugOutput ( DEBUG_LEVEL_ULTRA_VERBOSE, "Try for cycle %d\n", cycle ); 98 82 // check whether the packet buffer has packets for us to send. … … 147 131 // we can still postpone the queueing of the packets 148 132 // if we are far enough ahead of the presentation time 149 if ( cycles_until_presentation <= min_cycles_before_presentation)133 if ( cycles_until_presentation <= AMDTP_MIN_CYCLES_BEFORE_PRESENTATION ) 150 134 { 151 135 debugOutput ( DEBUG_LEVEL_VERBOSE, … … 216 200 // // NOTE: dangerous since the device has no way of reporting that it didn't get 217 201 // // this packet on time. 218 // if(cycles_until_presentation >= min_cycles_before_presentation)202 // if(cycles_until_presentation >= AMDTP_MIN_CYCLES_BEFORE_PRESENTATION) 219 203 // { 220 204 // // we are not that late and can still try to transmit the packet … … 227 211 // } 228 212 } 229 else if(cycles_until_transmit <= max_cycles_to_transmit_early)213 else if(cycles_until_transmit <= AMDTP_MAX_CYCLES_TO_TRANSMIT_EARLY) 230 214 { 231 215 // it's time send the packet … … 242 226 presentation_time, ( unsigned int ) TICKS_TO_CYCLES ( presentation_time ) ); 243 227 #ifdef DEBUG 244 if ( cycles_until_transmit > max_cycles_to_transmit_early+ 1 )228 if ( cycles_until_transmit > AMDTP_MAX_CYCLES_TO_TRANSMIT_EARLY + 1 ) 245 229 { 246 230 debugOutput ( DEBUG_LEVEL_VERY_VERBOSE, trunk/libffado/src/libstreaming/generic/StreamProcessor.cpp
r797 r798 444 444 } 445 445 446 unsigned int ctr; 447 int now_cycles; 448 int cycle_diff; 449 446 450 if(m_last_cycle == -1) { 447 451 debugOutput(DEBUG_LEVEL_VERBOSE, "Handler for %s SP %p is alive (cycle = %d)\n", getTypeString(), this, cycle); … … 458 462 debugWarning("(%p) dropped %d packets on cycle %u (last_cycle=%u, dropped=%d)\n", this, dropped_cycles, cycle, m_last_cycle, dropped); 459 463 m_dropped += dropped_cycles; 460 // flushDebugOutput(); 461 // assert(0); 464 // HACK: this should not be necessary, since the header generation functions should trigger the xrun. 465 // but apparently there are some issues with the 1394 stack 466 m_in_xrun = true; 467 if(m_state == ePS_Running) { 468 debugShowBackLogLines(200); 469 debugWarning("dropped packets xrun\n"); 470 debugOutput(DEBUG_LEVEL_VERBOSE, "Should update state to WaitingForStreamDisable due to dropped packets xrun\n"); 471 m_next_state = ePS_WaitingForStreamDisable; 472 // execute the requested change 473 if (!updateState()) { // we are allowed to change the state directly 474 debugError("Could not update state!\n"); 475 return RAW1394_ISO_ERROR; 476 } 477 goto send_empty_packet; 478 } 462 479 } 463 480 } … … 483 500 // we the packet we are constructing will be sent out 484 501 // on 'cycle', not 'now'. 485 unsigned intctr = m_1394service.getCycleTimer();486 intnow_cycles = (int)CYCLE_TIMER_GET_CYCLES(ctr);502 ctr = m_1394service.getCycleTimer(); 503 now_cycles = (int)CYCLE_TIMER_GET_CYCLES(ctr); 487 504 488 505 // the difference between the cycle this 489 506 // packet is intended for and 'now' 490 intcycle_diff = diffCycles(cycle, now_cycles);507 cycle_diff = diffCycles(cycle, now_cycles); 491 508 492 509 if(cycle_diff < 0 && (m_state == ePS_Running || m_state == ePS_DryRunning)) { trunk/libffado/src/libstreaming/motu/MotuTransmitStreamProcessor.cpp
r796 r798 117 117 const int max_cycles_to_transmit_early = 2; 118 118 119 try_block_of_frames:120 119 debugOutput ( DEBUG_LEVEL_ULTRA_VERBOSE, "Try for cycle %d\n", cycle ); 121 120 // check whether the packet buffer has packets for us to send. … … 304 303 305 304 // Set up each frames's SPH. 306 for ( unsignedint i=0; i < n_events; i++, quadlet += dbs) {305 for (int i=0; i < n_events; i++, quadlet += dbs) { 307 306 //FIXME: not sure which is best for the MOTU 308 307 // int64_t ts_frame = addTicks(ts, (unsigned int)(i * ticks_per_frame)); trunk/libffado/src/libstreaming/StreamProcessorManager.cpp
r797 r798 704 704 m_time_of_transfer); 705 705 706 xrun_occurred = false; 707 708 #if STREAMPROCESSORMANAGER_DYNAMIC_SYNC_DELAY 706 709 // normally we can transfer frames at this time, but in some cases this is not true 707 710 // e.g. when there are not enough frames in the receive buffer. … … 712 715 // check if xruns occurred on the Iso side. 713 716 // also check if xruns will occur should we transfer() now 714 #if STREAMPROCESSORMANAGER_DYNAMIC_SYNC_DELAY715 717 #ifdef DEBUG 716 718 int waited = 0; 717 719 #endif 718 #endif 720 719 721 bool ready_for_transfer = false; 720 722 bool ready; 721 xrun_occurred = false;722 723 while (!ready_for_transfer && !xrun_occurred) { 723 724 // FIXME: can deadlock when the iso handlers die (e.g. unplug the device) … … 737 738 xrun_occurred |= (*it)->xrunOccurred(); 738 739 } 739 #if STREAMPROCESSORMANAGER_DYNAMIC_SYNC_DELAY 740 if(!ready_for_transfer) { 741 debugWarning("xrun_occurred = %d\n", xrun_occurred); 742 } 740 743 if (!ready_for_transfer) { 741 744 … … 754 757 #endif 755 758 } 756 #endif757 759 } // we are either ready or an xrun occurred 758 759 #if STREAMPROCESSORMANAGER_DYNAMIC_SYNC_DELAY 760 760 761 // in order to avoid a runaway value of the sync delay, we gradually decrease 761 762 // it. It will be increased by a 'too early' event (cfr some lines higher)