Changeset 857

Show
Ignore:
Timestamp:
01/19/08 04:11:20 (15 years ago)
Author:
ppalmers
Message:

Introduce distinction between empty and silent packets. When shutting down a transmit SP, we now send silent (= valid, but all audio muted) packets instead of empty (w/o
payload) packets for a while. This should solve the shutdown issue with the motu's.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libffado/src/libstreaming/amdtp/AmdtpTransmitStreamProcessor.cpp

    r856 r857  
    271271{ 
    272272    struct iec61883_packet *packet = ( struct iec61883_packet * ) data; 
    273     debugOutput ( DEBUG_LEVEL_ULTRA_VERBOSE, "XMIT NONE (cy %04d): CY=%04u, TSP=%011llu (%04u)\n", 
     273    debugOutput ( DEBUG_LEVEL_ULTRA_VERBOSE, "XMIT SILENT (cy %04d): CY=%04u, TSP=%011llu (%04u)\n", 
    274274                cycle, m_last_timestamp, ( unsigned int ) TICKS_TO_CYCLES ( m_last_timestamp ) ); 
    275275 
    276     /* Our node ID can change after a bus reset, so it is best to fetch 
    277     * our node ID for each packet. */ 
    278276    packet->sid = m_local_node_id; 
    279277 
     
    291289 
    292290    m_dbc += fillNoDataPacketHeader ( packet, length ); 
    293     return eCRV_OK
     291    return eCRV_Packet
    294292} 
    295293 
    296294enum StreamProcessor::eChildReturnValue 
    297295AmdtpTransmitStreamProcessor::generateSilentPacketData ( 
     296    unsigned char *data, unsigned int *length, 
     297    unsigned char *tag, unsigned char *sy, 
     298    int cycle, unsigned int dropped, unsigned int max_length ) 
     299{ 
     300    return eCRV_OK; // no need to do anything 
     301} 
     302 
     303enum StreamProcessor::eChildReturnValue 
     304AmdtpTransmitStreamProcessor::generateEmptyPacketHeader ( 
     305    unsigned char *data, unsigned int *length, 
     306    unsigned char *tag, unsigned char *sy, 
     307    int cycle, unsigned int dropped, unsigned int max_length ) 
     308{ 
     309    struct iec61883_packet *packet = ( struct iec61883_packet * ) data; 
     310    debugOutput ( DEBUG_LEVEL_ULTRA_VERBOSE, "XMIT EMPTY (cy %04d): CY=%04u, TSP=%011llu (%04u)\n", 
     311                cycle, m_last_timestamp, ( unsigned int ) TICKS_TO_CYCLES ( m_last_timestamp ) ); 
     312    packet->sid = m_local_node_id; 
     313 
     314    packet->dbs = m_dimension; 
     315    packet->fn = 0; 
     316    packet->qpc = 0; 
     317    packet->sph = 0; 
     318    packet->reserved = 0; 
     319    packet->dbc = m_dbc; 
     320    packet->eoh1 = 2; 
     321    packet->fmt = IEC61883_FMT_AMDTP; 
     322 
     323    *tag = IEC61883_TAG_WITH_CIP; 
     324    *sy = 0; 
     325 
     326    m_dbc += fillNoDataPacketHeader ( packet, length ); 
     327    return eCRV_OK; 
     328} 
     329 
     330enum StreamProcessor::eChildReturnValue 
     331AmdtpTransmitStreamProcessor::generateEmptyPacketData ( 
    298332    unsigned char *data, unsigned int *length, 
    299333    unsigned char *tag, unsigned char *sy, 
  • trunk/libffado/src/libstreaming/amdtp/AmdtpTransmitStreamProcessor.h

    r856 r857  
    8686                            unsigned char *tag, unsigned char *sy, 
    8787                            int cycle, unsigned int dropped, unsigned int max_length); 
     88    enum eChildReturnValue generateEmptyPacketHeader(unsigned char *data, unsigned int *length, 
     89                                    unsigned char *tag, unsigned char *sy, 
     90                                    int cycle, unsigned int dropped, unsigned int max_length); 
     91    enum eChildReturnValue generateEmptyPacketData(unsigned char *data, unsigned int *length, 
     92                                  unsigned char *tag, unsigned char *sy, 
     93                                  int cycle, unsigned int dropped, unsigned int max_length); 
    8894    enum eChildReturnValue generateSilentPacketHeader(unsigned char *data, unsigned int *length, 
    8995                                    unsigned char *tag, unsigned char *sy, 
  • trunk/libffado/src/libstreaming/generic/StreamProcessor.cpp

    r846 r857  
    622622                return RAW1394_ISO_ERROR; 
    623623            } 
     624        } 
     625        // generate the silent packet header 
     626        enum eChildReturnValue result = generateSilentPacketHeader(data, length, tag, sy, cycle, dropped_cycles, max_length); 
     627        if (result == eCRV_Packet) { 
     628            debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "XMIT SILENT: CY=%04u TS=%011llu\n", 
     629                    cycle, m_last_timestamp); 
     630            // update some accounting 
     631            m_last_good_cycle = cycle; 
     632            m_last_dropped = dropped_cycles; 
     633 
     634            // assumed not to xrun 
     635            enum eChildReturnValue result2 = generateSilentPacketData(data, length, tag, sy, cycle, dropped_cycles, max_length); 
     636            return RAW1394_ISO_OK; 
    624637        } else { 
    625             // not time to disable yet 
     638            debugError("Invalid return value: %d\n", result); 
     639            return RAW1394_ISO_ERROR; 
    626640        } 
    627641    } 
     
    738752//             usleep(125); // only when using thread-per-handler 
    739753//             return RAW1394_ISO_AGAIN; 
    740             generateSilentPacketHeader(data, length, tag, sy, cycle, dropped_cycles, max_length); 
    741             generateSilentPacketData(data, length, tag, sy, cycle, dropped_cycles, max_length); 
     754            generateEmptyPacketHeader(data, length, tag, sy, cycle, dropped_cycles, max_length); 
     755            generateEmptyPacketData(data, length, tag, sy, cycle, dropped_cycles, max_length); 
    742756            return RAW1394_ISO_DEFER; 
    743757        } else { 
     
    761775 
    762776    debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "XMIT EMPTY: CY=%04u\n", cycle); 
    763     generateSilentPacketHeader(data, length, tag, sy, cycle, dropped_cycles, max_length); 
    764     generateSilentPacketData(data, length, tag, sy, cycle, dropped_cycles, max_length); 
     777    generateEmptyPacketHeader(data, length, tag, sy, cycle, dropped_cycles, max_length); 
     778    generateEmptyPacketData(data, length, tag, sy, cycle, dropped_cycles, max_length); 
    765779    return RAW1394_ISO_OK; 
    766780} 
     
    12371251    uint64_t tx; 
    12381252    if (t < 0) { 
    1239         tx = addTicks(m_1394service.getCycleTimerTicks(), 200 * TICKS_PER_CYCLE); 
     1253        tx = addTicks(m_1394service.getCycleTimerTicks(), 2000 * TICKS_PER_CYCLE); 
    12401254    } else { 
    12411255        tx = t; 
     
    12601274    uint64_t tx; 
    12611275    if (t < 0) { 
    1262         tx = addTicks(m_1394service.getCycleTimerTicks(), 200 * TICKS_PER_CYCLE); 
     1276        tx = addTicks(m_1394service.getCycleTimerTicks(), 2000 * TICKS_PER_CYCLE); 
    12631277    } else { 
    12641278        tx = t; 
  • trunk/libffado/src/libstreaming/generic/StreamProcessor.h

    r841 r857  
    280280                                    unsigned int max_length) 
    281281        {debugWarning("call not allowed\n"); return eCRV_Invalid;}; 
     282    virtual enum eChildReturnValue generateEmptyPacketHeader(unsigned char *data, unsigned int *length, 
     283                                            unsigned char *tag, unsigned char *sy, 
     284                                            int cycle, unsigned int dropped, 
     285                                            unsigned int max_length) 
     286        {debugWarning("call not allowed\n"); return eCRV_Invalid;}; 
     287    virtual enum eChildReturnValue generateEmptyPacketData(unsigned char *data, unsigned int *length, 
     288                                          unsigned char *tag, unsigned char *sy, 
     289                                          int cycle, unsigned int dropped, 
     290                                          unsigned int max_length) 
     291        {debugWarning("call not allowed\n"); return eCRV_Invalid;}; 
    282292    virtual enum eChildReturnValue generateSilentPacketHeader(unsigned char *data, unsigned int *length, 
    283293                                            unsigned char *tag, unsigned char *sy, 
  • trunk/libffado/src/libstreaming/motu/MotuTransmitStreamProcessor.cpp

    r833 r857  
    316316 
    317317enum StreamProcessor::eChildReturnValue 
    318 MotuTransmitStreamProcessor::generateSilentPacketHeader ( 
     318MotuTransmitStreamProcessor::generateEmptyPacketHeader ( 
    319319    unsigned char *data, unsigned int *length, 
    320320    unsigned char *tag, unsigned char *sy, 
    321321    int cycle, unsigned int dropped, unsigned int max_length ) 
    322322{ 
    323     debugOutput ( DEBUG_LEVEL_VERY_VERBOSE, "XMIT NONE: CY=%04u, TSP=%011llu (%04u)\n", 
     323    debugOutput ( DEBUG_LEVEL_VERY_VERBOSE, "XMIT EMPTY: CY=%04u, TSP=%011llu (%04u)\n", 
    324324                cycle, m_last_timestamp, ( unsigned int ) TICKS_TO_CYCLES ( m_last_timestamp ) ); 
    325325 
     
    332332    m_tx_dbc += fillNoDataPacketHeader ( (quadlet_t *)data, length ); 
    333333    return eCRV_OK; 
     334} 
     335 
     336enum StreamProcessor::eChildReturnValue 
     337MotuTransmitStreamProcessor::generateEmptyPacketData ( 
     338    unsigned char *data, unsigned int *length, 
     339    unsigned char *tag, unsigned char *sy, 
     340    int cycle, unsigned int dropped, unsigned int max_length ) 
     341{ 
     342    return eCRV_OK; // no need to do anything 
     343} 
     344 
     345enum StreamProcessor::eChildReturnValue 
     346MotuTransmitStreamProcessor::generateSilentPacketHeader ( 
     347    unsigned char *data, unsigned int *length, 
     348    unsigned char *tag, unsigned char *sy, 
     349    int cycle, unsigned int dropped, unsigned int max_length ) 
     350{ 
     351    debugOutput ( DEBUG_LEVEL_VERY_VERBOSE, "XMIT SILENT: CY=%04u, TSP=%011llu (%04u)\n", 
     352                cycle, m_last_timestamp, ( unsigned int ) TICKS_TO_CYCLES ( m_last_timestamp ) ); 
     353 
     354    // Do housekeeping expected for all packets sent to the MOTU, even 
     355    // for packets containing no audio data. 
     356    *sy = 0x00; 
     357    *tag = 1;      // All MOTU packets have a CIP-like header 
     358    *length = 8; 
     359 
     360    m_tx_dbc += fillNoDataPacketHeader ( (quadlet_t *)data, length ); 
     361    return eCRV_Packet; 
    334362} 
    335363 
  • trunk/libffado/src/libstreaming/motu/MotuTransmitStreamProcessor.h

    r748 r857  
    6464                            unsigned char *tag, unsigned char *sy, 
    6565                            int cycle, unsigned int dropped, unsigned int max_length); 
     66    enum eChildReturnValue generateEmptyPacketHeader(unsigned char *data, unsigned int *length, 
     67                                    unsigned char *tag, unsigned char *sy, 
     68                                    int cycle, unsigned int dropped, unsigned int max_length); 
     69    enum eChildReturnValue generateEmptyPacketData(unsigned char *data, unsigned int *length, 
     70                                  unsigned char *tag, unsigned char *sy, 
     71                                  int cycle, unsigned int dropped, unsigned int max_length); 
    6672    enum eChildReturnValue generateSilentPacketHeader(unsigned char *data, unsigned int *length, 
    6773                                    unsigned char *tag, unsigned char *sy, 
  • trunk/libffado/src/libstreaming/StreamProcessorManager.cpp

    r841 r857  
    562562    } 
    563563    // wait for the SP's to get into the dry-running/stopped state 
    564     int cnt = 2000; 
     564    int cnt = 8000; 
    565565    bool ready = false; 
    566566    while (!ready && cnt) { 
     
    612612    } 
    613613    // wait for the SP's to get into the stopped state 
    614     cnt = 2000; 
     614    cnt = 8000; 
    615615    ready = false; 
    616616    while (!ready && cnt) {