Changeset 729

Show
Ignore:
Timestamp:
11/27/07 08:50:48 (13 years ago)
Author:
ppalmers
Message:

some more transmit tweaks

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/ppalmers-streaming/src/dice/dice_avdevice.cpp

    r723 r729  
    534534 
    535535    // prepare transmit SP's 
    536 //     for (unsigned int i=0;i<m_nb_rx;i++) { 
    537     for (unsigned int i=0;i<1;i++) { 
     536    for (unsigned int i=0;i<m_nb_rx;i++) { 
    538537        fb_quadlet_t nb_audio; 
    539538        fb_quadlet_t nb_midi; 
  • branches/ppalmers-streaming/src/genericavc/avc_avdevice.cpp

    r720 r729  
    426426    Streaming::StreamProcessor *p; 
    427427 
     428    if ( outputPlug->getNrOfChannels() == 0 ) { 
     429        debugError("Receive plug has no channels\n"); 
     430        return false; 
     431    } 
    428432    p=new Streaming::AmdtpReceiveStreamProcessor( 
    429433                             get1394Service().getPort(), 
  • branches/ppalmers-streaming/src/libstreaming/amdtp/AmdtpReceiveStreamProcessor.cpp

    r722 r729  
    4444AmdtpReceiveStreamProcessor::AmdtpReceiveStreamProcessor(int port, int dimension) 
    4545    : StreamProcessor(ePT_Receive , port) 
    46     , m_dimension(dimension
     46    , m_dimension( dimension
    4747{} 
    4848 
     49unsigned int 
     50AmdtpReceiveStreamProcessor::getNominalPacketsNeeded(unsigned int nframes) 
     51{ 
     52    unsigned int nominal_frames_per_second = m_manager->getNominalRate(); 
     53    uint64_t nominal_ticks_per_frame = TICKS_PER_SECOND / nominal_frames_per_second; 
     54    uint64_t nominal_ticks = nominal_ticks_per_frame * nframes; 
     55    uint64_t nominal_packets = nominal_ticks / TICKS_PER_CYCLE; 
     56    return nominal_packets; 
     57} 
    4958 
    5059unsigned int 
    5160AmdtpReceiveStreamProcessor::getPacketsPerPeriod() 
    5261{ 
    53     return (m_manager->getPeriodSize())/m_syt_interval
     62    return getNominalPacketsNeeded(m_manager->getPeriodSize())
    5463} 
    5564 
  • branches/ppalmers-streaming/src/libstreaming/amdtp/AmdtpReceiveStreamProcessor.h

    r722 r729  
    9797                    {return m_syt_interval;}; 
    9898    virtual unsigned int getPacketsPerPeriod(); 
     99    virtual unsigned int getNominalPacketsNeeded(unsigned int nframes); 
    99100 
    100101protected: 
  • branches/ppalmers-streaming/src/libstreaming/amdtp/AmdtpTransmitStreamProcessor.cpp

    r727 r729  
    346346 
    347347unsigned int 
     348AmdtpTransmitStreamProcessor::getNominalPacketsNeeded(unsigned int nframes) 
     349{ 
     350    unsigned int nominal_frames_per_second = m_manager->getNominalRate(); 
     351    uint64_t nominal_ticks_per_frame = TICKS_PER_SECOND / nominal_frames_per_second; 
     352    uint64_t nominal_ticks = nominal_ticks_per_frame * nframes; 
     353    uint64_t nominal_packets = nominal_ticks / TICKS_PER_CYCLE; 
     354    return nominal_packets; 
     355} 
     356 
     357unsigned int 
    348358AmdtpTransmitStreamProcessor::getPacketsPerPeriod() 
    349359{ 
    350     return ( m_manager->getPeriodSize() ) /m_syt_interval
     360    return getNominalPacketsNeeded(m_manager->getPeriodSize())
    351361} 
    352362 
  • branches/ppalmers-streaming/src/libstreaming/amdtp/AmdtpTransmitStreamProcessor.h

    r722 r729  
    103103    virtual unsigned int getNominalFramesPerPacket() 
    104104                    {return m_syt_interval;}; 
    105     unsigned int getPacketsPerPeriod(); 
     105    virtual unsigned int getPacketsPerPeriod(); 
     106    virtual unsigned int getNominalPacketsNeeded(unsigned int nframes); 
    106107 
    107108protected: 
  • branches/ppalmers-streaming/src/libstreaming/generic/IsoStream.h

    r719 r729  
    7373        virtual unsigned int getPacketsPerPeriod() {return 1;}; 
    7474        virtual unsigned int getMaxPacketSize() {return 1024;}; //FIXME: arbitrary 
     75        virtual unsigned int getNominalPacketsNeeded(unsigned int nframes) {return 1;}; //FIXME: arbitrary 
    7576 
    7677        virtual enum raw1394_iso_disposition 
  • branches/ppalmers-streaming/src/libstreaming/generic/StreamProcessor.cpp

    r727 r729  
    109109    // using here (which can also be negative). 
    110110    return (int64_t)(((float)until_next) / TICKS_PER_USEC); 
     111} 
     112 
     113void 
     114StreamProcessor::setSyncDelay(int d) { 
     115    debugOutput(DEBUG_LEVEL_VERBOSE, "Setting SP %p SyncDelay to %d ticks\n", this, d); 
     116    m_sync_delay = d; 
    111117} 
    112118 
     
    536542//                 } 
    537543//             } 
    538 //             // force some delay 
     544            // force some delay 
    539545//             usleep(125); 
    540546//             return RAW1394_ISO_AGAIN; 
     
    694700    } else { 
    695701        bool result = true; 
    696         while(nbframes--) { 
     702        while(nbframes++) { 
    697703            result &= m_data_buffer->writeDummyFrame(); 
    698704        } 
     
    931937{ 
    932938    float ticks_per_frame; 
    933     unsigned int ringbuffer_size_frames = m_manager->getNbBuffers() * m_manager->getPeriodSize(); 
     939    unsigned int ringbuffer_size_frames = (m_manager->getNbBuffers() + 1) * m_manager->getPeriodSize(); 
    934940 
    935941    debugOutput(DEBUG_LEVEL_VERBOSE, "Enter from state: %s\n", ePSToString(m_state)); 
  • branches/ppalmers-streaming/src/libstreaming/generic/StreamProcessor.h

    r727 r729  
    341341         * @param d sync delay 
    342342         */ 
    343         void setSyncDelay(int d) {m_sync_delay = d;}
     343        void setSyncDelay(int d)
    344344 
    345345        /** 
     
    395395         */ 
    396396        virtual unsigned int getNominalFramesPerPacket() = 0; 
     397 
     398        /** 
     399         * @brief get the nominal number of packets needed for a certain amount of frames 
     400         * @return the nominal number of packet necessary 
     401         */ 
     402        virtual unsigned int getNominalPacketsNeeded(unsigned int nframes) = 0; 
    397403 
    398404    protected: 
  • branches/ppalmers-streaming/src/libstreaming/StreamProcessorManager.cpp

    r727 r729  
    4040// time to a later time instant also causes the xmit buffer fill to be 
    4141// lower on average. 
    42 #define FFADO_SIGNAL_DELAY_TICKS 3072 
     42#define FFADO_SIGNAL_DELAY_TICKS 3072*4 
    4343 
    4444namespace Streaming { 
     
    159159    } 
    160160    m_isoManager->setVerboseLevel(getDebugLevel()); 
    161     m_isoManager->setTransmitBufferNbPeriods(getNbBuffers() - 1); 
     161     
     162    // try to queue up 75% of the frames in the transmit buffer 
     163    unsigned int nb_frames = (getNbBuffers() - 1) * getPeriodSize() * 1000 / 2000; 
     164    m_isoManager->setTransmitBufferNbFrames(nb_frames); 
    162165 
    163166    if(!m_isoManager->init()) { 
     
    506509            aligned &= (diff_between_streams_frames[i] == 0); 
    507510 
    508             // position the stream 
     511            // reposition the stream 
    509512            if(!s->shiftStream(diff_between_streams_frames[i])) { 
    510513                debugError("Could not shift SP %p %d frames\n", s, diff_between_streams_frames[i]); 
     
    800803    // also check if xruns will occur should we transfer() now 
    801804    #ifdef DEBUG 
    802     int waited = -1
     805    int waited = 0
    803806    #endif 
    804807    bool ready_for_transfer = false; 
     
    818821            xrun_occurred |= (*it)->xrunOccurred(); 
    819822        } 
    820         usleep(125); // MAGIC: one cycle sleep... 
    821         #ifdef DEBUG 
    822         waited++; 
    823         #endif 
     823        if (!ready_for_transfer) { 
     824            usleep(125); // MAGIC: one cycle sleep... 
     825 
     826            // in order to avoid this in the future, we increase the sync delay of the sync source SP 
     827            int d = m_SyncSource->getSyncDelay() + TICKS_PER_CYCLE; 
     828            m_SyncSource->setSyncDelay(d); 
     829 
     830            #ifdef DEBUG 
     831            waited++; 
     832            #endif 
     833        } 
    824834    } // we are either ready or an xrun occurred 
    825835 
  • branches/ppalmers-streaming/src/libstreaming/util/IsoHandlerManager.cpp

    r723 r729  
    4141   m_State(E_Created), 
    4242   m_poll_timeout(100), m_poll_fds(0), m_poll_nfds(0), 
    43    m_realtime(false), m_priority(0), m_xmit_nb_periods( 1 ) 
    44 
    45  
    46 
     43   m_realtime(false), m_priority(0), m_xmit_nb_frames( 20 ) 
     44{} 
    4745 
    4846IsoHandlerManager::IsoHandlerManager(bool run_rt, unsigned int rt_prio) : 
    4947   m_State(E_Created), 
    5048   m_poll_timeout(100), m_poll_fds(0), m_poll_nfds(0), 
    51    m_realtime(run_rt), m_priority(rt_prio), m_xmit_nb_periods( 1 ) 
    52 
    53  
    54 
    55  
    56 IsoHandlerManager::~IsoHandlerManager() 
    57 
    58  
    59 
     49   m_realtime(run_rt), m_priority(rt_prio), m_xmit_nb_frames( 20 ) 
     50{} 
    6051 
    6152bool IsoHandlerManager::init() 
     
    471462//         int buffers=irq_interval * 2; 
    472463 
    473         // we should queue up as much as possible 
    474         int buffers = packets_per_period * m_xmit_nb_periods
     464        // the SPM specifies how many packets to buffer 
     465        int buffers = stream->getNominalPacketsNeeded(m_xmit_nb_frames)
    475466 
    476467        // create the actual handler 
  • branches/ppalmers-streaming/src/libstreaming/util/IsoHandlerManager.h

    r722 r729  
    7373        IsoHandlerManager(); 
    7474        IsoHandlerManager(bool run_rt, unsigned int rt_prio); 
    75         virtual ~IsoHandlerManager()
     75        virtual ~IsoHandlerManager() {}
    7676 
    7777        void setPollTimeout(int t) {m_poll_timeout=t;}; ///< set the timeout used for poll() 
    7878        int getPollTimeout() {return m_poll_timeout;};  ///< get the timeout used for poll() 
    7979 
    80         void setTransmitBufferNbPeriods(unsigned int t) {m_xmit_nb_periods = t;}; 
    81         int getTransmitBufferNbPeriods() {return m_xmit_nb_periods;}; 
     80        void setTransmitBufferNbFrames(unsigned int t) {m_xmit_nb_frames = t;}; 
     81        int getTransmitBufferNbFrames() {return m_xmit_nb_frames;}; 
    8282 
    8383        void setVerboseLevel(int l); ///< set the verbose level 
     
    153153        Util::PosixThread *m_isoManagerThread; 
    154154 
    155         // the preferred number of periods to buffer on xmit 
    156         unsigned int m_xmit_nb_periods; 
     155        // the preferred number of packets to buffer on xmit 
     156        unsigned int m_xmit_nb_frames; 
    157157 
    158158        // debug stuff