Changeset 657

Show
Ignore:
Timestamp:
10/17/07 20:55:35 (15 years ago)
Author:
jwoithe
Message:

Make bandwidth allocation dependent on actual device configuration (and therefore the number of channels actually active).

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libffado/src/motu/motu_avdevice.cpp

    r656 r657  
    422422    // FIXME: The bandwidth allocation calculation can probably be 
    423423    // refined somewhat since this is currently based on a rudimentary 
    424     // understanding of the iso protocol. 
     424    // understanding of the ieee1394 iso protocol. 
    425425    // Currently we assume the following. 
    426426    //   * Ack/iso gap = 0.05 us 
    427427    //   * DATA_PREFIX = 0.16 us 
    428428    //   * DATA_END    = 0.26 us 
     429 
    429430    // These numbers are the worst-case figures given in the ieee1394 
    430     // standard.  This gives approximately 0.5 us of overheads per 
    431     // packet - around 25 bandwidth allocation units (from the ieee1394 
    432     // standard 1 bandwidth allocation unit is 125/6144 us).  We further 
    433     // assume the MOTU is running at S400 (which it should be) so one 
    434     // allocation unit is equivalent to 1 transmitted byte; thus the 
    435     // bandwidth allocation required for the packets themselves is just 
    436     // the size of the packet.  We allocate based on the maximum packet 
    437     // size (1160 bytes at 192 kHz) so the sampling frequency can be 
    438     // changed dynamically if this ends up being useful in future. 
    439     // Therefore we get a *per stream* bandwidth figure of 25+1160. 
    440     m_bandwidth = 25 + 1160; 
     431    // standard.  This gives approximately 0.5 us of overheads per packet - 
     432    // around 25 bandwidth allocation units (from the ieee1394 standard 1 
     433    // bandwidth allocation unit is 125/6144 us).  We further assume the 
     434    // MOTU is running at S400 (which it should be) so one allocation unit 
     435    // is equivalent to 1 transmitted byte; thus the bandwidth allocation 
     436    // required for the packets themselves is just the size of the packet.  
     437    // We used to allocate based on the maximum packet size (1160 bytes at 
     438    // 192 kHz for the traveler) but now do this based on the actual device 
     439    // state by utilising the result from getEventSize() and remembering 
     440    // that each packet has an 8 byte CIP header.  Note that m_bandwidth is 
     441    // a *per stream* bandwidth - it must be allocated for both the transmit 
     442    // and receive streams. 
     443    signed int max_event_size = event_size_out>event_size_in?event_size_out:event_size_in; 
     444    signed int n_events_per_packet = samp_freq<=48000?8:(samp_freq<=96000?16:32); 
     445    m_bandwidth = 25 + (n_events_per_packet*max_event_size); 
    441446 
    442447    // Assign iso channels if not already done