Changeset 797
- Timestamp:
- 01/01/08 12:24:37 (13 years ago)
- Files:
-
- trunk/libffado/config.h.in (modified) (2 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) (4 diffs)
- trunk/libffado/src/libstreaming/StreamProcessorManager.cpp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/libffado/config.h.in
r796 r797 36 36 #define SHAREDIR "$sharedir" 37 37 38 #define MINIMUM_INTERRUPTS_PER_PERIOD 4U39 #define MAX_ISO_XMIT_BUFFER_FILL_PCT 7038 #define MINIMUM_INTERRUPTS_PER_PERIOD 2U 39 #define MAX_ISO_XMIT_BUFFER_FILL_PCT 50 40 40 41 41 #define ISOHANDLER_PER_HANDLER_THREAD 0 … … 58 58 #define STREAMPROCESSORMANAGER_NB_ALIGN_TRIES 40 59 59 60 #define STREAMPROCESSORMANAGER_DYNAMIC_SYNC_DELAY 0 60 61 61 62 // FIXME: note that it will probably be better to use a DLL bandwidth that is trunk/libffado/src/libieee1394/IsoHandlerManager.cpp
r796 r797 337 337 unsigned int page_size = getpagesize() - 2; // for one reason or another this is necessary 338 338 339 // hardware interrupts can only occur when one DMA descriptor is full,340 // and the size of one DMA descriptor in bufferfill mode is PAGE_SIZE.341 // the number of packets that fits into this descriptor is dependent on342 // the max_packet_size parameter:343 // packets_per_descriptor = PAGE_SIZE / max_packet_size344 //345 // Hence if we want N hardware IRQ's in one period, we have to ensure that346 // there are at least N descriptors for one period worth of packets347 // hence:348 // packets_per_interrupt = packets_per_period / MINIMUM_INTERRUPTS_PER_PERIOD349 // packets_per_descriptor <= packets_per_interrupt350 //351 // or:352 // => PAGE_SIZE / max_packet_size <= packets_per_period / MINIMUM_INTERRUPTS_PER_PERIOD353 // => PAGE_SIZE * MINIMUM_INTERRUPTS_PER_PERIOD / packets_per_period <= max_packet_size354 355 unsigned int min_max_packet_size=(MINIMUM_INTERRUPTS_PER_PERIOD * page_size) / packets_per_period;356 357 if (max_packet_size < min_max_packet_size) {358 debugOutput(DEBUG_LEVEL_VERBOSE, "correcting stream max packet size (%u) to (%u) to ensure enough interrupts\n",359 max_packet_size, min_max_packet_size);360 max_packet_size = min_max_packet_size;361 }362 363 339 // Ensure we don't request a packet size bigger than the 364 340 // kernel-enforced maximum which is currently 1 page. … … 370 346 unsigned int irq_interval = packets_per_period / MINIMUM_INTERRUPTS_PER_PERIOD; 371 347 if(irq_interval <= 0) irq_interval=1; 372 // unsigned int irq_interval=2; // this is not the HW IRQ interval373 348 374 349 // the receive buffer size doesn't matter for the latency, … … 391 366 unsigned int packets_per_period = stream->getPacketsPerPeriod(); 392 367 unsigned int max_packet_size = stream->getMaxPacketSize(); 393 unsigned int page_size = getpagesize() - 2; // for one reason or another this is necessary 394 395 // hardware interrupts can only occur when one DMA descriptor is full, 396 // and the size of one DMA descriptor in bufferfill mode is PAGE_SIZE. 397 // the number of packets that fits into this descriptor is dependent on 398 // the max_packet_size parameter: 399 // packets_per_descriptor = PAGE_SIZE / max_packet_size 400 // 401 // Hence if we want N hardware IRQ's in one period, we have to ensure that 402 // there are at least N descriptors for one period worth of packets 403 // hence: 404 // packets_per_interrupt = packets_per_period / MINIMUM_INTERRUPTS_PER_PERIOD 405 // packets_per_descriptor <= packets_per_interrupt 406 // 407 // or: 408 // => PAGE_SIZE / max_packet_size <= packets_per_period / MINIMUM_INTERRUPTS_PER_PERIOD 409 // => PAGE_SIZE * MINIMUM_INTERRUPTS_PER_PERIOD / packets_per_period <= max_packet_size 410 411 unsigned int min_max_packet_size=(MINIMUM_INTERRUPTS_PER_PERIOD * page_size) / packets_per_period; 412 413 if (max_packet_size < min_max_packet_size) { 414 debugOutput(DEBUG_LEVEL_VERBOSE, "correcting stream max packet size (%u) to (%u) to ensure enough interrupts\n", 415 max_packet_size, min_max_packet_size); 416 max_packet_size = min_max_packet_size; 417 } 368 unsigned int page_size = getpagesize(); 418 369 419 370 // Ensure we don't request a packet size bigger than the … … 424 375 } 425 376 426 // unsigned int irq_interval = packets_per_period / MINIMUM_INTERRUPTS_PER_PERIOD;427 // if(irq_interval <= 0) irq_interval=1;428 unsigned int irq_interval=2; // this is not the HW IRQ interval377 max_packet_size = page_size; 378 unsigned int irq_interval = packets_per_period / MINIMUM_INTERRUPTS_PER_PERIOD; 379 if(irq_interval <= 0) irq_interval=1; 429 380 430 381 // the SP specifies how many packets to ISO-buffer trunk/libffado/src/libstreaming/amdtp/AmdtpTransmitStreamProcessor.cpp
r796 r797 211 211 transmit_at_cycle, cycles_until_transmit, 212 212 presentation_time, (unsigned int)TICKS_TO_CYCLES(presentation_time) ); 213 debugShowBackLogLines(200); 214 flushDebugOutput(); 215 // however, if we can send this sufficiently before the presentation 216 // time, it could be harmless. 217 // NOTE: dangerous since the device has no way of reporting that it didn't get 218 // this packet on time. 219 if(cycles_until_presentation >= min_cycles_before_presentation) 220 { 221 // we are not that late and can still try to transmit the packet 222 m_dbc += fillDataPacketHeader(packet, length, m_last_timestamp); 223 return (fc < (signed)(2*m_syt_interval) ? eCRV_Defer : eCRV_Packet); 224 } 225 else // definitely too late 226 { 213 //debugShowBackLogLines(200); 214 // // however, if we can send this sufficiently before the presentation 215 // // time, it could be harmless. 216 // // NOTE: dangerous since the device has no way of reporting that it didn't get 217 // // this packet on time. 218 // if(cycles_until_presentation >= min_cycles_before_presentation) 219 // { 220 // // we are not that late and can still try to transmit the packet 221 // m_dbc += fillDataPacketHeader(packet, length, m_last_timestamp); 222 // return (fc < (signed)(2*m_syt_interval) ? eCRV_Defer : eCRV_Packet); 223 // } 224 // else // definitely too late 225 // { 227 226 return eCRV_XRun; 228 }227 // } 229 228 } 230 229 else if(cycles_until_transmit <= max_cycles_to_transmit_early) trunk/libffado/src/libstreaming/generic/StreamProcessor.cpp
r796 r797 127 127 packets_to_prebuffer); 128 128 129 // only queue a part (70%)of the theoretical max in order not to have too much 'not ready' cycles129 // only queue a part of the theoretical max in order not to have too much 'not ready' cycles 130 130 packets_to_prebuffer = (packets_to_prebuffer * MAX_ISO_XMIT_BUFFER_FILL_PCT * 1000) / 100000; 131 131 debugOutput(DEBUG_LEVEL_VERBOSE, " reduce to %d%%: %u\n", … … 490 490 int cycle_diff = diffCycles(cycle, now_cycles); 491 491 492 #ifdef DEBUG493 492 if(cycle_diff < 0 && (m_state == ePS_Running || m_state == ePS_DryRunning)) { 494 493 debugWarning("Requesting packet for cycle %04d which is in the past (now=%04dcy)\n", … … 498 497 // flushDebugOutput(); 499 498 // assert(0); 500 } 501 } 502 #endif 499 debugWarning("generatePacketData xrun\n"); 500 m_in_xrun = true; 501 debugOutput(DEBUG_LEVEL_VERBOSE, "Should update state to WaitingForStreamDisable due to data xrun\n"); 502 m_next_state = ePS_WaitingForStreamDisable; 503 // execute the requested change 504 if (!updateState()) { // we are allowed to change the state directly 505 debugError("Could not update state!\n"); 506 return RAW1394_ISO_ERROR; 507 } 508 goto send_empty_packet; 509 } 510 } 503 511 504 512 // store the previous timestamp … … 604 612 m_in_xrun = true; 605 613 debugOutput(DEBUG_LEVEL_VERBOSE, "Should update state to WaitingForStreamDisable due to header xrun\n"); 606 m_cycle_to_switch_state = cycle+1; // switch in the next cycle607 614 m_next_state = ePS_WaitingForStreamDisable; 608 615 // execute the requested change trunk/libffado/src/libstreaming/StreamProcessorManager.cpp
r796 r797 712 712 // check if xruns occurred on the Iso side. 713 713 // also check if xruns will occur should we transfer() now 714 #if STREAMPROCESSORMANAGER_DYNAMIC_SYNC_DELAY 714 715 #ifdef DEBUG 715 716 int waited = 0; 716 717 #endif 718 #endif 717 719 bool ready_for_transfer = false; 718 720 bool ready; … … 735 737 xrun_occurred |= (*it)->xrunOccurred(); 736 738 } 739 #if STREAMPROCESSORMANAGER_DYNAMIC_SYNC_DELAY 737 740 if (!ready_for_transfer) { 738 741 … … 751 754 #endif 752 755 } 756 #endif 753 757 } // we are either ready or an xrun occurred 754 758 759 #if STREAMPROCESSORMANAGER_DYNAMIC_SYNC_DELAY 755 760 // in order to avoid a runaway value of the sync delay, we gradually decrease 756 761 // it. It will be increased by a 'too early' event (cfr some lines higher) … … 765 770 } 766 771 #endif 772 #endif 767 773 768 774 // this is to notify the client of the delay that we introduced by waiting