Show
Ignore:
Timestamp:
11/04/07 04:40:10 (16 years ago)
Author:
ppalmers
Message:

restructure the streaming directory

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/ppalmers-streaming/src/bebob/bebob_avdevice.h

    r661 r705  
    4242#include "bebob/bebob_mixer.h" 
    4343 
    44 #include "libstreaming/AmdtpStreamProcessor.h" 
    45 #include "libstreaming/AmdtpPort.h" 
    46 #include "libstreaming/AmdtpPortInfo.h" 
     44#include "libstreaming/amdtp/AmdtpStreamProcessor.h" 
     45#include "libstreaming/amdtp/AmdtpPort.h" 
     46#include "libstreaming/amdtp/AmdtpPortInfo.h" 
    4747 
    4848#include "libutil/serialize.h" 
  • branches/ppalmers-streaming/src/bounce/bounce_avdevice.h

    r639 r705  
    3030#include "libavc/general/avc_extended_cmd_generic.h" 
    3131 
    32 #include "libstreaming/AmdtpStreamProcessor.h" 
    33 #include "libstreaming/AmdtpPort.h" 
    34 #include "libstreaming/AmdtpPortInfo.h" 
     32#include "libstreaming/amdtp/AmdtpStreamProcessor.h" 
     33#include "libstreaming/amdtp/AmdtpPort.h" 
     34#include "libstreaming/amdtp/AmdtpPortInfo.h" 
    3535 
    3636#include "libieee1394/ARMHandler.h" 
  • branches/ppalmers-streaming/src/bounce/bounce_slave_avdevice.cpp

    r587 r705  
    2323 */ 
    2424 
    25 #include "libstreaming/AmdtpSlaveStreamProcessor.h" 
     25#include "libstreaming/amdtp/AmdtpSlaveStreamProcessor.h" 
    2626 
    2727#include "libieee1394/configrom.h" 
  • branches/ppalmers-streaming/src/devicemanager.cpp

    r674 r705  
    3131#include "libieee1394/ieee1394service.h" 
    3232 
    33 #include "libstreaming/StreamProcessor.h" 
     33#include "libstreaming/generic/StreamProcessor.h" 
    3434 
    3535#include "debugmodule/debugmodule.h" 
  • branches/ppalmers-streaming/src/dice/dice_avdevice.cpp

    r672 r705  
    2828#include "libieee1394/ieee1394service.h" 
    2929 
    30 #include "libstreaming/AmdtpStreamProcessor.h" 
     30#include "libstreaming/amdtp/AmdtpStreamProcessor.h" 
    3131 
    3232#include "debugmodule/debugmodule.h" 
  • branches/ppalmers-streaming/src/dice/dice_avdevice.h

    r639 r705  
    3030#include "libavc/avc_definitions.h" 
    3131 
    32 #include "libstreaming/AmdtpStreamProcessor.h" 
    33 #include "libstreaming/AmdtpPort.h" 
     32#include "libstreaming/amdtp/AmdtpStreamProcessor.h" 
     33#include "libstreaming/amdtp/AmdtpPort.h" 
    3434#include "libieee1394/ARMHandler.h" 
    3535 
  • branches/ppalmers-streaming/src/ffado_streaming.cpp

    r554 r705  
    7676    } 
    7777 
    78     dev->m_deviceManager->setVerboseLevel(DEBUG_LEVEL_VERBOSE); 
     78    dev->m_deviceManager->setVerboseLevel(DEBUG_LEVEL_NORMAL); 
    7979    if ( !dev->m_deviceManager->initialize( dev->options.port ) ) { 
    8080            debugFatal( "Could not initialize device manager\n" ); 
  • branches/ppalmers-streaming/src/genericavc/avc_avdevice.h

    r639 r705  
    3434#include "libavc/general/avc_plug.h" 
    3535 
    36 #include "libstreaming/AmdtpStreamProcessor.h" 
    37 #include "libstreaming/AmdtpPort.h" 
    38 #include "libstreaming/AmdtpPortInfo.h" 
     36#include "libstreaming/amdtp/AmdtpStreamProcessor.h" 
     37#include "libstreaming/amdtp/AmdtpPort.h" 
     38#include "libstreaming/amdtp/AmdtpPortInfo.h" 
    3939 
    4040#include "debugmodule/debugmodule.h" 
  • branches/ppalmers-streaming/src/libstreaming/amdtp/AmdtpPort.h

    r703 r705  
    2929 */ 
    3030 
    31 #include "../debugmodule/debugmodule.h" 
    32 #include "Port.h" 
     31#include "debugmodule/debugmodule.h" 
     32#include "../generic/Port.h" 
    3333#include "AmdtpPortInfo.h" 
    3434 
  • branches/ppalmers-streaming/src/libstreaming/amdtp/AmdtpPortInfo.h

    r703 r705  
    2525#define __FFADO_AMDTPPORTINFO__ 
    2626 
    27 #include "../debugmodule/debugmodule.h" 
     27#include "debugmodule/debugmodule.h" 
    2828#include <string> 
    2929 
  • branches/ppalmers-streaming/src/libstreaming/amdtp/AmdtpSlaveStreamProcessor.cpp

    r506 r705  
    2424#include "AmdtpSlaveStreamProcessor.h" 
    2525 
    26 #include "cycletimer.h" 
     26#include "../util/cycletimer.h" 
    2727 
    2828#include <netinet/in.h> 
  • branches/ppalmers-streaming/src/libstreaming/amdtp/AmdtpSlaveStreamProcessor.h

    r445 r705  
    2929 */ 
    3030#include "AmdtpStreamProcessor.h" 
     31#include "../util/cip.h" 
    3132 
    32 #include "../debugmodule/debugmodule.h" 
     33#include "debugmodule/debugmodule.h" 
    3334 
    34 #include "cip.h" 
    3535#include <libiec61883/iec61883.h> 
    3636#include <pthread.h> 
  • branches/ppalmers-streaming/src/libstreaming/amdtp/AmdtpStreamProcessor.cpp

    r703 r705  
    2323 
    2424#include "AmdtpStreamProcessor.h" 
    25 #include "Port.h" 
    2625#include "AmdtpPort.h" 
    2726 
    28 #include "cycletimer.h" 
     27#include "../util/cycletimer.h" 
    2928 
    3029#include <netinet/in.h> 
  • branches/ppalmers-streaming/src/libstreaming/amdtp/AmdtpStreamProcessor.h

    r703 r705  
    2929 */ 
    3030 
    31 #include "../debugmodule/debugmodule.h" 
    32 #include "StreamProcessor.h" 
    33  
    34 #include "cip.h" 
     31#include "debugmodule/debugmodule.h" 
     32 
     33#include "../generic/StreamProcessor.h" 
     34#include "../util/cip.h" 
     35 
    3536#include <libiec61883/iec61883.h> 
    3637#include <pthread.h> 
  • branches/ppalmers-streaming/src/libstreaming/generic/IsoStream.h

    r445 r705  
    2525#define __FFADO_ISOSTREAM__ 
    2626 
     27#include "../util/IsoHandler.h" 
     28 
     29#include "debugmodule/debugmodule.h" 
     30 
    2731#include <libraw1394/raw1394.h> 
    28 #include "../debugmodule/debugmodule.h" 
    29 #include "IsoHandler.h" 
    3032 
    3133namespace Streaming 
  • branches/ppalmers-streaming/src/libstreaming/generic/Port.cpp

    r554 r705  
    2323 
    2424#include "Port.h" 
     25 
    2526#include <stdlib.h> 
    2627#include <assert.h> 
  • branches/ppalmers-streaming/src/libstreaming/generic/Port.h

    r554 r705  
    2525#define __FFADO_PORT__ 
    2626 
     27#include "libutil/ringbuffer.h" 
     28 
     29#include "debugmodule/debugmodule.h" 
     30 
     31#include <string> 
    2732#include <stdint.h> 
    28  
    29 #include "../debugmodule/debugmodule.h" 
    30 #include <string> 
    31 #include "libutil/ringbuffer.h" 
    3233 
    3334namespace Streaming { 
  • branches/ppalmers-streaming/src/libstreaming/generic/PortManager.cpp

    r554 r705  
    2424#include "PortManager.h" 
    2525#include "Port.h" 
     26 
    2627#include <assert.h> 
    2728 
  • branches/ppalmers-streaming/src/libstreaming/generic/PortManager.h

    r554 r705  
    2525#define __FFADO_PORTMANAGER__ 
    2626 
    27 #include "../debugmodule/debugmodule.h" 
    2827#include "Port.h" 
     28 
     29#include "debugmodule/debugmodule.h" 
    2930 
    3031#include <vector> 
  • branches/ppalmers-streaming/src/libstreaming/generic/StreamProcessor.cpp

    r703 r705  
    2222 */ 
    2323 
     24#include "StreamProcessor.h" 
     25#include "../util/cycletimer.h" 
     26#include "../StreamProcessorManager.h" 
     27 
    2428#include "libutil/Atomic.h" 
    25  
    26 #include "StreamProcessor.h" 
    27 #include "StreamProcessorManager.h" 
    28 #include "cycletimer.h" 
    2929 
    3030#include <assert.h> 
  • branches/ppalmers-streaming/src/libstreaming/generic/StreamProcessor.h

    r703 r705  
    2525#define __FFADO_STREAMPROCESSOR__ 
    2626 
    27 #include "../debugmodule/debugmodule.h" 
    28  
    2927#include "IsoStream.h" 
    3028#include "PortManager.h" 
    31  
    32 #include <pthread.h> 
    3329 
    3430#include "libutil/StreamStatistics.h" 
    3531#include "libutil/TimestampedBuffer.h" 
    3632#include "libutil/OptionContainer.h" 
     33 
     34#include "debugmodule/debugmodule.h" 
     35 
     36#include <pthread.h> 
    3737 
    3838namespace Streaming { 
  • branches/ppalmers-streaming/src/libstreaming/motu/MotuPort.h

    r703 r705  
    3030 */ 
    3131 
    32 #include "../debugmodule/debugmodule.h" 
    33 #include "Port.h" 
    3432#include "MotuPortInfo.h" 
     33#include "../generic/Port.h" 
     34 
     35#include "debugmodule/debugmodule.h" 
    3536 
    3637namespace Streaming { 
  • branches/ppalmers-streaming/src/libstreaming/motu/MotuPortInfo.cpp

    r703 r705  
    2424 
    2525#include "MotuPortInfo.h" 
    26 #include <assert.h> 
    2726 
    2827namespace Streaming { 
  • branches/ppalmers-streaming/src/libstreaming/motu/MotuPortInfo.h

    r703 r705  
    2626#define __FFADO_MOTUPORTINFO__ 
    2727 
    28 #include "../debugmodule/debugmodule.h" 
     28#include "debugmodule/debugmodule.h" 
    2929#include <string> 
    3030 
  • branches/ppalmers-streaming/src/libstreaming/motu/MotuStreamProcessor.cpp

    r703 r705  
    2424 
    2525#include "MotuStreamProcessor.h" 
    26 #include "Port.h" 
    2726#include "MotuPort.h" 
    2827 
     28#include "../util/cycletimer.h" 
     29 
    2930#include <math.h> 
    30  
    3131#include <netinet/in.h> 
    32  
    33 #include "cycletimer.h" 
    3432 
    3533// in ticks 
  • branches/ppalmers-streaming/src/libstreaming/motu/MotuStreamProcessor.h

    r703 r705  
    2525#ifndef __FFADO_MOTUSTREAMPROCESSOR__ 
    2626#define __FFADO_MOTUSTREAMPROCESSOR__ 
     27 
     28#include "../generic/StreamProcessor.h" 
     29 
     30#include "libutil/DelayLockedLoop.h" 
     31#include "debugmodule/debugmodule.h" 
     32 
    2733#include <assert.h> 
    28  
    29 #include "../debugmodule/debugmodule.h" 
    30 #include "StreamProcessor.h" 
    31  
    32 #include "../libutil/DelayLockedLoop.h" 
    3334 
    3435namespace Streaming { 
  • branches/ppalmers-streaming/src/libstreaming/StreamProcessorManager.cpp

    r703 r705  
    2323 
    2424#include "StreamProcessorManager.h" 
    25 #include "StreamProcessor.h" 
    26 #include "Port.h" 
     25#include "generic/StreamProcessor.h" 
     26#include "generic/Port.h" 
     27#include "util/cycletimer.h" 
     28 
    2729#include <errno.h> 
    2830#include <assert.h> 
    29  
    30 #include "libstreaming/cycletimer.h" 
    3131 
    3232#define CYCLES_TO_SLEEP_AFTER_RUN_SIGNAL 5 
  • branches/ppalmers-streaming/src/libstreaming/StreamProcessorManager.h

    r703 r705  
    2525#define __FFADO_STREAMPROCESSORMANAGER__ 
    2626 
     27#include "generic/Port.h" 
     28#include "generic/StreamProcessor.h" 
     29#include "util/IsoHandlerManager.h" 
     30 
    2731#include "debugmodule/debugmodule.h" 
    2832#include "libutil/Thread.h" 
    2933#include "libutil/OptionContainer.h" 
    30 #include <semaphore.h> 
    31 #include "Port.h" 
    32 #include "StreamProcessor.h" 
    33 #include "IsoHandlerManager.h" 
    3434 
    3535#include <vector> 
     36#include <semaphore.h> 
    3637 
    3738namespace Streaming { 
  • branches/ppalmers-streaming/src/libstreaming/util/cip.c

    r386 r705  
    1919 */ 
    2020 
     21#include "cip.h" 
     22 
     23#include <netinet/in.h> 
    2124#include <libiec61883/iec61883.h> 
    22 #include "cip.h" 
    23  
    24 #include <netinet/in.h> 
    2525 
    2626 
  • branches/ppalmers-streaming/src/libstreaming/util/cycletimer.h

    r703 r705  
    2727#define __CYCLETIMER_H__ 
    2828 
     29#include "debugmodule/debugmodule.h" 
     30 
    2931#include <inttypes.h> 
    30 #include "debugmodule/debugmodule.h" 
    3132 
    3233#define CSR_CYCLE_TIME            0x200 
  • branches/ppalmers-streaming/src/libstreaming/util/IsoHandler.cpp

    r679 r705  
    2323 
    2424#include "IsoHandler.h" 
    25 #include "IsoStream.h" 
    2625#include "cycletimer.h" 
     26#include "../generic/IsoStream.h" 
    2727 
    2828#include "libutil/TimeSource.h" 
  • branches/ppalmers-streaming/src/libstreaming/util/IsoHandler.h

    r445 r705  
    2525#define __FFADO_ISOHANDLER__ 
    2626 
    27 #include "../debugmodule/debugmodule.h" 
     27#include "debugmodule/debugmodule.h" 
    2828 
    2929#include <libraw1394/raw1394.h> 
  • branches/ppalmers-streaming/src/libstreaming/util/IsoHandlerManager.cpp

    r703 r705  
    2424#include "IsoHandlerManager.h" 
    2525#include "IsoHandler.h" 
    26 #include "IsoStream.h" 
     26#include "../generic/IsoStream.h" 
     27 
     28#include "libutil/PosixThread.h" 
     29 
    2730#include <assert.h> 
    28  
    29 #include "../libutil/PosixThread.h" 
    30  
    3131 
    3232#define MINIMUM_INTERRUPTS_PER_PERIOD  2U 
  • branches/ppalmers-streaming/src/libstreaming/util/IsoHandlerManager.h

    r703 r705  
    2525#define __FFADO_ISOHANDLERMANAGER__ 
    2626 
    27 #include "../debugmodule/debugmodule.h" 
    28 #include "../libutil/Thread.h" 
     27#include "debugmodule/debugmodule.h" 
     28 
     29#include "libutil/Thread.h" 
    2930 
    3031#include <sys/poll.h> 
  • branches/ppalmers-streaming/src/libutil/TimestampedBuffer.cpp

    r512 r705  
    2828 
    2929#include "libutil/Atomic.h" 
    30 #include "libstreaming/cycletimer.h" 
     30#include "libstreaming/util/cycletimer.h" 
    3131 
    3232#include "TimestampedBuffer.h" 
     
    4545#define DLL_COEFF_C   (DLL_OMEGA * DLL_OMEGA) 
    4646 
     47#define ENTER_CRITICAL_SECTION { \ 
     48    pthread_mutex_lock(&m_framecounter_lock); \ 
     49    } 
     50#define EXIT_CRITICAL_SECTION { \ 
     51    pthread_mutex_unlock(&m_framecounter_lock); \ 
     52    } 
     53 
    4754namespace Util { 
    4855 
     
    5360      m_event_size(0), m_events_per_frame(0), m_buffer_size(0), 
    5461      m_bytes_per_frame(0), m_bytes_per_buffer(0), 
     62      m_enabled( false ), m_transparent ( true ), 
    5563      m_wrap_at(0xFFFFFFFFFFFFFFFFLLU), 
    5664      m_Client(c), m_framecounter(0), 
     
    122130    ffado_timestamp_t diff; 
    123131     
    124     pthread_mutex_lock(&m_framecounter_lock)
     132    ENTER_CRITICAL_SECTION
    125133    diff=m_buffer_next_tail_timestamp - m_buffer_tail_timestamp; 
    126     pthread_mutex_unlock(&m_framecounter_lock)
     134    EXIT_CRITICAL_SECTION
    127135     
    128136    debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"getRate: %f/%f=%f\n", 
     
    208216    // of the new offset.  Doing so certainly makes for a smoother MOTU 
    209217    // startup. 
    210     pthread_mutex_lock(&m_framecounter_lock)
     218    ENTER_CRITICAL_SECTION
    211219    m_buffer_tail_timestamp = m_buffer_tail_timestamp - m_tick_offset + nticks; 
    212220    m_buffer_next_tail_timestamp = (ffado_timestamp_t)((double)m_buffer_tail_timestamp + m_dll_e2); 
    213221    m_tick_offset=nticks; 
    214     pthread_mutex_unlock(&m_framecounter_lock)
     222    EXIT_CRITICAL_SECTION
    215223 
    216224    return true; 
     
    225233 * 
    226234 * In order to get the number of frames in the buffer, use the 
    227  * getFrameCounter, getBufferHeadTimestamp, getBufferTailTimestamp 
     235 * getBufferHeadTimestamp, getBufferTailTimestamp 
    228236 * functions 
    229237 * 
     
    348356     
    349357    // increment without updating the DLL 
    350     pthread_mutex_lock(&m_framecounter_lock)
     358    ENTER_CRITICAL_SECTION
    351359    m_framecounter++; 
    352     pthread_mutex_unlock(&m_framecounter_lock)
     360    EXIT_CRITICAL_SECTION
    353361     
    354362    return true; 
     
    370378    unsigned int write_size=nframes*m_event_size*m_events_per_frame; 
    371379 
    372     // add the data payload to the ringbuffer 
    373     if (ffado_ringbuffer_write(m_event_buffer,data,write_size) < write_size) 
    374     { 
    375 //         debugWarning("writeFrames buffer overrun\n"); 
    376         return false; 
    377     } 
    378  
    379     incrementFrameCounter(nframes,ts); 
    380  
    381     return true; 
    382  
    383 
     380    if (m_transparent) { 
     381//         // if the buffer is disabled, it's in a 'transparent' state, meaning 
     382//         // that if too much is put into the buffer, the oldest data is discarded 
     383//         signed int fc; 
     384//         ENTER_CRITICAL_SECTION; 
     385//         fc=m_framecounter; 
     386//         EXIT_CRITICAL_SECTION; 
     387//          
     388//         signed int frames_to_ditch= nframes - (m_buffer_size - m_framecounter) + 1; 
     389//         if ( frames_to_ditch > 0 ) { 
     390//             debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "dropping %d frames\n", frames_to_ditch); 
     391//             dropFrames( frames_to_ditch ); 
     392//         } 
     393//         // add the data payload to the ringbuffer 
     394//         if (ffado_ringbuffer_write(m_event_buffer,data,write_size) < write_size) 
     395//         { 
     396//             debugError("we should have freed up enough space for this\n"); 
     397//             return false; 
     398//         } 
     399//          
     400        // while disabled, we don't update the DLL, we just set the correct 
     401        // timestamp for the frames 
     402        setBufferTailTimestamp(ts); 
     403    } else { 
     404        // add the data payload to the ringbuffer 
     405        if (ffado_ringbuffer_write(m_event_buffer,data,write_size) < write_size) 
     406        { 
     407            return false; 
     408        } 
     409        incrementFrameCounter(nframes,ts); 
     410    } 
     411    return true; 
     412
     413 
     414/** 
     415 * @brief Drop frames from the head of the buffer 
     416 * 
     417 * drops \ref nframes of frames from the head of internal buffer 
     418 * 
     419 * @param nframes number of frames to drop 
     420 * @return true if successful 
     421 */ 
     422bool TimestampedBuffer::dropFrames(unsigned int nframes) { 
     423 
     424    unsigned int read_size=nframes*m_event_size*m_events_per_frame; 
     425 
     426    ffado_ringbuffer_read_advance(m_event_buffer, read_size); 
     427    decrementFrameCounter(nframes); 
     428 
     429    return true; 
     430
     431 
    384432/** 
    385433 * @brief Read frames from the buffer 
     
    651699#endif 
    652700 
    653     pthread_mutex_lock(&m_framecounter_lock)
     701    ENTER_CRITICAL_SECTION
    654702 
    655703    m_buffer_tail_timestamp = ts; 
     
    658706    m_buffer_next_tail_timestamp = (ffado_timestamp_t)((double)m_buffer_tail_timestamp + m_dll_e2); 
    659707 
    660     pthread_mutex_unlock(&m_framecounter_lock)
    661  
    662     debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "Set buffer tail timestamp for (%p) to " 
     708    EXIT_CRITICAL_SECTION
     709 
     710    debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "for (%p) to " 
    663711                                          TIMESTAMP_FORMAT_SPEC" => "TIMESTAMP_FORMAT_SPEC", NTS=" 
    664712                                          TIMESTAMP_FORMAT_SPEC", DLL2=%f, RATE=%f\n", 
    665                 this, new_timestamp, ts, m_buffer_next_tail_timestamp, m_dll_e2, m_nominal_rate); 
     713                this, new_timestamp, ts, m_buffer_next_tail_timestamp, m_dll_e2, getRate()); 
    666714 
    667715} 
     
    689737    ffado_timestamp_t ts=new_timestamp; 
    690738 
    691     pthread_mutex_lock(&m_framecounter_lock)
     739    ENTER_CRITICAL_SECTION
    692740 
    693741    // add the time 
     
    705753    m_buffer_next_tail_timestamp = (ffado_timestamp_t)((double)m_buffer_tail_timestamp + m_dll_e2); 
    706754 
    707     pthread_mutex_unlock(&m_framecounter_lock)
    708  
    709     debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "Set buffer head timestamp for (%p) to "TIMESTAMP_FORMAT_SPEC" => " 
     755    EXIT_CRITICAL_SECTION
     756 
     757    debugOutput(DEBUG_LEVEL_VERBOSE, "for (%p) to "TIMESTAMP_FORMAT_SPEC" => " 
    710758                                          TIMESTAMP_FORMAT_SPEC", NTS="TIMESTAMP_FORMAT_SPEC", DLL2=%f, RATE=%f\n", 
    711                 this, new_timestamp, ts, m_buffer_next_tail_timestamp, m_dll_e2, m_nominal_rate); 
     759                this, new_timestamp, ts, m_buffer_next_tail_timestamp, m_dll_e2, getRate()); 
    712760 
    713761} 
     
    741789 */ 
    742790void TimestampedBuffer::getBufferTailTimestamp(ffado_timestamp_t *ts, signed int *fc) { 
    743     pthread_mutex_lock(&m_framecounter_lock)
     791    ENTER_CRITICAL_SECTION
    744792    *fc = m_framecounter; 
    745793    *ts = m_buffer_tail_timestamp; 
    746     pthread_mutex_unlock(&m_framecounter_lock)
     794    EXIT_CRITICAL_SECTION
    747795} 
    748796 
     
    764812    ffado_timestamp_t timestamp; 
    765813     
    766     pthread_mutex_lock(&m_framecounter_lock)
    767      
     814    ENTER_CRITICAL_SECTION
     815 
    768816    diff=m_buffer_next_tail_timestamp - m_buffer_tail_timestamp; 
    769817    timestamp=m_buffer_tail_timestamp; 
    770818     
    771     pthread_mutex_unlock(&m_framecounter_lock)
     819    EXIT_CRITICAL_SECTION
    772820     
    773821    if (diff < 0) diff += m_wrap_at; 
     
    804852 */ 
    805853void TimestampedBuffer::resetFrameCounter() { 
    806     pthread_mutex_lock(&m_framecounter_lock)
     854    ENTER_CRITICAL_SECTION
    807855    m_framecounter = 0; 
    808     pthread_mutex_unlock(&m_framecounter_lock)
     856    EXIT_CRITICAL_SECTION
    809857} 
    810858 
     
    815863 */ 
    816864void TimestampedBuffer::decrementFrameCounter(int nbframes) { 
    817     pthread_mutex_lock(&m_framecounter_lock)
     865    ENTER_CRITICAL_SECTION
    818866    m_framecounter -= nbframes; 
    819     pthread_mutex_unlock(&m_framecounter_lock)
     867    EXIT_CRITICAL_SECTION
    820868} 
    821869 
     
    835883    ffado_timestamp_t diff; 
    836884     
    837     pthread_mutex_lock(&m_framecounter_lock)
     885    ENTER_CRITICAL_SECTION
    838886    diff=m_buffer_next_tail_timestamp - m_buffer_tail_timestamp; 
    839     pthread_mutex_unlock(&m_framecounter_lock)
     887    EXIT_CRITICAL_SECTION
    840888 
    841889    if (diff < 0) diff += m_wrap_at; 
     
    854902    } 
    855903 
    856     debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "Setting buffer tail timestamp for (%p) to " 
    857                                           TIMESTAMP_FORMAT_SPEC" => "TIMESTAMP_FORMAT_SPEC"\n", 
    858                 this, new_timestamp, ts); 
    859  
    860904#ifdef DEBUG 
    861905    if (new_timestamp >= m_wrap_at) { 
    862         debugWarning("timestamp not wrapped: "TIMESTAMP_FORMAT_SPEC"\n",new_timestamp); 
     906        debugWarning("timestamp not wrapped: "TIMESTAMP_FORMAT_SPEC"\n", new_timestamp); 
    863907    } 
    864908    if ((ts >= m_wrap_at) || (ts < 0 )) { 
     
    868912// FIXME: JMW: at some points during startup the timestamp doesn't change. 
    869913// This still needs to be verified in more detail.   
    870 if (ts>m_buffer_tail_timestamp-1 && ts<m_buffer_tail_timestamp+1) { 
    871   pthread_mutex_lock(&m_framecounter_lock)
    872   m_framecounter += nbframes; 
    873   pthread_mutex_unlock(&m_framecounter_lock)
    874   return; 
    875 
     914// if (ts>m_buffer_tail_timestamp-1 && ts<m_buffer_tail_timestamp+1) { 
     915//   ENTER_CRITICAL_SECTION
     916//   m_framecounter += nbframes; 
     917//   EXIT_CRITICAL_SECTION
     918//   return; 
     919//
    876920     
    877921    // update the DLL 
    878     pthread_mutex_lock(&m_framecounter_lock)
     922    ENTER_CRITICAL_SECTION
    879923    diff = ts-m_buffer_next_tail_timestamp; 
    880     pthread_mutex_unlock(&m_framecounter_lock); 
    881  
    882 #ifdef DEBUG 
    883     if ((diff > ((ffado_timestamp_t)1000)) || (diff < ((ffado_timestamp_t)-1000))) { 
    884         debugWarning("(%p) difference rather large: "TIMESTAMP_FORMAT_SPEC", "TIMESTAMP_FORMAT_SPEC", "TIMESTAMP_FORMAT_SPEC"\n", 
    885             this, diff, ts, m_buffer_next_tail_timestamp); 
    886     } 
    887 #endif 
     924    EXIT_CRITICAL_SECTION; 
     925 
     926    // check whether the update is within the allowed bounds 
     927    const float max_deviation = (100.0/100.0); // maximal relative difference considered normal 
     928    ffado_timestamp_t expected_difference=m_update_period * getRate(); 
     929    ffado_timestamp_t max_abs_diff = expected_difference * max_deviation; 
     930     
     931    if (diff > max_abs_diff) { 
     932        debugWarning("(%p) difference rather large (+): diff="TIMESTAMP_FORMAT_SPEC", expected="TIMESTAMP_FORMAT_SPEC", "TIMESTAMP_FORMAT_SPEC", "TIMESTAMP_FORMAT_SPEC"\n", 
     933            this, diff, expected_difference, ts, m_buffer_next_tail_timestamp); 
     934//         debugShowBackLogLines(40); 
     935     
     936        // we can limit the difference 
     937        // we can't discard it because that would prevent us from tracking the samplerate 
     938        diff = max_abs_diff; 
     939  
     940    } else if (diff < -max_abs_diff) { 
     941        debugWarning("(%p) difference rather large (-): diff="TIMESTAMP_FORMAT_SPEC", expected="TIMESTAMP_FORMAT_SPEC", "TIMESTAMP_FORMAT_SPEC", "TIMESTAMP_FORMAT_SPEC"\n", 
     942            this, diff, expected_difference, ts, m_buffer_next_tail_timestamp); 
     943//         debugShowBackLogLines(40); 
     944         
     945        // we can limit the difference 
     946        // we can't discard it because that would prevent us from tracking the samplerate 
     947        diff = -max_abs_diff; 
     948    } 
    888949 
    889950    // idea to implement it for nbframes values that differ from m_update_period: 
     
    895956 
    896957    // the maximal difference we can allow (64secs) 
    897     const ffado_timestamp_t max=m_wrap_at/2; 
    898  
    899     if(diff > max) { 
    900         diff -= m_wrap_at; 
    901     } else if (diff < -max) { 
    902         diff += m_wrap_at; 
    903     } 
    904  
    905     float err=diff; 
     958//     const ffado_timestamp_t max=m_wrap_at/2; 
     959//  
     960//     if(diff > max) { 
     961//         diff -= m_wrap_at; 
     962//     } else if (diff < -max) { 
     963//         diff += m_wrap_at; 
     964//     } 
     965 
     966    double err=diff; 
    906967 
    907968    debugOutputShort(DEBUG_LEVEL_VERY_VERBOSE, "diff2="TIMESTAMP_FORMAT_SPEC" err=%f\n", 
     
    910971                    m_framecounter, m_buffer_tail_timestamp, m_buffer_next_tail_timestamp); 
    911972 
    912     pthread_mutex_lock(&m_framecounter_lock)
     973    ENTER_CRITICAL_SECTION
    913974    m_framecounter += nbframes; 
    914975 
     
    919980     
    920981    m_dll_e2 += m_dll_c*err; 
    921      
    922 //     debugOutputShort(DEBUG_LEVEL_VERBOSE, "%p %llu %lld %llu %llu %e %e\n", this, new_timestamp, diff, m_buffer_tail_timestamp, m_buffer_next_tail_timestamp, m_dll_e2, 24576000.0/getRate()); 
     982 
     983    EXIT_CRITICAL_SECTION; 
     984 
     985    debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "tail for (%p) to " 
     986                                          TIMESTAMP_FORMAT_SPEC" => "TIMESTAMP_FORMAT_SPEC", NTS=" 
     987                                          TIMESTAMP_FORMAT_SPEC", DLL2=%f, RATE=%f\n", 
     988                this, new_timestamp, ts, m_buffer_next_tail_timestamp, m_dll_e2, getRate()); 
    923989 
    924990    debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "U: FC=%10u, TS="TIMESTAMP_FORMAT_SPEC", NTS="TIMESTAMP_FORMAT_SPEC"\n", 
    925991                    m_framecounter, m_buffer_tail_timestamp, m_buffer_next_tail_timestamp); 
    926992 
     993    ENTER_CRITICAL_SECTION; 
    927994    if (m_buffer_next_tail_timestamp >= m_wrap_at) { 
    928995        debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "Unwrapping next tail timestamp: "TIMESTAMP_FORMAT_SPEC"", 
     
    9351002 
    9361003    } 
     1004    EXIT_CRITICAL_SECTION; 
    9371005 
    9381006    debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "A: TS="TIMESTAMP_FORMAT_SPEC", NTS="TIMESTAMP_FORMAT_SPEC", DLLe2=%f, RATE=%f\n", 
    9391007                m_buffer_tail_timestamp, m_buffer_next_tail_timestamp, m_dll_e2, rate); 
    9401008 
    941     pthread_mutex_unlock(&m_framecounter_lock); 
    9421009 
    9431010    if(m_buffer_tail_timestamp>=m_wrap_at) { 
  • branches/ppalmers-streaming/src/libutil/TimestampedBuffer.h

    r554 r705  
    9292    TimestampedBuffer(TimestampedBufferClient *); 
    9393    virtual ~TimestampedBuffer(); 
    94      
     94 
    9595    bool writeDummyFrame(); 
    96      
     96    bool dropFrames(unsigned int nbframes); 
     97 
    9798    bool writeFrames(unsigned int nbframes, char *data, ffado_timestamp_t ts); 
    9899    bool readFrames(unsigned int nbframes, char *data); 
     
    104105    bool prepare(); 
    105106    bool reset(); 
     107 
     108    bool isEnabled() {return m_enabled;}; 
     109    void enable() {m_enabled=true;}; 
     110    void disable() {m_enabled=false;}; 
     111 
     112    bool isTransparent() {return m_transparent;}; 
     113    void setTransparent(bool v) {m_transparent=v;}; 
    106114 
    107115    bool setEventSize(unsigned int s); 
     
    160168    unsigned int m_bytes_per_frame; 
    161169    unsigned int m_bytes_per_buffer; 
     170    bool m_enabled; // you can get frames FIXME: rename!! 
     171    bool m_transparent; // the buffer should hold the frames put in it. if true, discards all frames 
    162172 
    163173    ffado_timestamp_t m_wrap_at; // value to wrap at 
  • branches/ppalmers-streaming/src/maudio/maudio_avdevice.h

    r583 r705  
    3232#include "bebob/bebob_avdevice.h" 
    3333 
    34 #include "libstreaming/AmdtpStreamProcessor.h" 
    35 #include "libstreaming/AmdtpPort.h" 
    36 #include "libstreaming/AmdtpPortInfo.h" 
     34#include "libstreaming/amdtp/AmdtpStreamProcessor.h" 
     35#include "libstreaming/amdtp/AmdtpPort.h" 
     36#include "libstreaming/amdtp/AmdtpPortInfo.h" 
    3737 
    3838#include "ffadodevice.h" 
  • branches/ppalmers-streaming/src/metrichalo/mh_avdevice.h

    r639 r705  
    3030#include "libavc/avc_definitions.h" 
    3131 
    32 // #include "libstreaming/MHStreamProcessor.h" 
     32// #include "libstreaming/mh/MHStreamProcessor.h" 
    3333 
    3434class ConfigRom; 
  • branches/ppalmers-streaming/src/motu/motu_avdevice.cpp

    r660 r705  
    3232#include "debugmodule/debugmodule.h" 
    3333 
    34 #include "libstreaming/MotuStreamProcessor.h" 
    35 #include "libstreaming/MotuPort.h" 
     34#include "libstreaming/motu/MotuStreamProcessor.h" 
     35#include "libstreaming/motu/MotuPort.h" 
    3636 
    3737#include "libutil/DelayLockedLoop.h" 
  • branches/ppalmers-streaming/src/motu/motu_avdevice.h

    r660 r705  
    3131#include "libavc/avc_definitions.h" 
    3232 
    33 #include "libstreaming/MotuStreamProcessor.h" 
     33#include "libstreaming/motu/MotuStreamProcessor.h" 
    3434 
    3535#define MOTUFW_BASE_ADDR                0xfffff0000000ULL 
  • branches/ppalmers-streaming/src/rme/rme_avdevice.h

    r639 r705  
    3131#include "libavc/avc_definitions.h" 
    3232 
    33 // #include "libstreaming/RmeStreamProcessor.h" 
     33// #include "libstreaming/rme/RmeStreamProcessor.h" 
    3434 
    3535class ConfigRom; 
  • branches/ppalmers-streaming/src/SConscript

    r688 r705  
    4848        libosc/OscResponse.cpp \ 
    4949        libosc/OscServer.cpp \ 
    50         libstreaming/cip.c \ 
    51         libstreaming/IsoHandler.cpp \ 
    52         libstreaming/IsoHandlerManager.cpp \ 
    53         libstreaming/IsoStream.cpp \ 
    54         libstreaming/Port.cpp \ 
    55         libstreaming/PortManager.cpp \ 
    56         libstreaming/StreamProcessor.cpp \ 
    5750        libstreaming/StreamProcessorManager.cpp \ 
     51        libstreaming/util/cip.c \ 
     52        libstreaming/util/IsoHandler.cpp \ 
     53        libstreaming/util/IsoHandlerManager.cpp \ 
     54        libstreaming/generic/StreamProcessor.cpp \ 
     55        libstreaming/generic/IsoStream.cpp \ 
     56        libstreaming/generic/Port.cpp \ 
     57        libstreaming/generic/PortManager.cpp \ 
    5858        libutil/cmd_serialize.cpp \ 
    5959        libutil/DelayLockedLoop.cpp \ 
     
    127127motu_source = env.Split( '\ 
    128128        motu/motu_avdevice.cpp \ 
    129         libstreaming/MotuPort.cpp \ 
    130         libstreaming/MotuPortInfo.cpp \ 
    131         libstreaming/MotuStreamProcessor.cpp \ 
     129        libstreaming/motu/MotuPort.cpp \ 
     130        libstreaming/motu/MotuPortInfo.cpp \ 
     131        libstreaming/motu/MotuStreamProcessor.cpp \ 
    132132' ) 
    133133 
     
    151151 
    152152amdtp_source = env.Split( '\ 
    153         libstreaming/AmdtpPort.cpp \ 
    154         libstreaming/AmdtpPortInfo.cpp \ 
    155         libstreaming/AmdtpStreamProcessor.cpp \ 
     153        libstreaming/amdtp/AmdtpPort.cpp \ 
     154        libstreaming/amdtp/AmdtpPortInfo.cpp \ 
     155        libstreaming/amdtp/AmdtpStreamProcessor.cpp \ 
    156156' ) 
    157157 
  • branches/ppalmers-streaming/tests/streaming/test-isohandling.cpp

    r445 r705  
    3535#include <netinet/in.h> 
    3636 
    37 #include "src/libstreaming/IsoHandler.h" 
    38 #include "src/libstreaming/IsoStream.h" 
    39 #include "src/libstreaming/StreamProcessorManager.h" 
    40 #include "src/libstreaming/AmdtpStreamProcessor.h" 
    41 #include "src/libstreaming/IsoHandlerManager.h" 
    4237#include "src/libutil/PosixThread.h" 
    43 #include "src/libstreaming/AmdtpPort.h" 
     38 
     39#include "src/libstreaming/util/IsoHandler.h" 
     40#include "src/libstreaming/util/StreamProcessorManager.h" 
     41#include "src/libstreaming/util/IsoHandlerManager.h" 
     42#include "src/libstreaming/amdtp/AmdtpStreamProcessor.h" 
     43#include "src/libstreaming/amdtp/AmdtpPort.h" 
    4444 
    4545using namespace Streaming; 
    46  
    4746 
    4847int run; 
  • branches/ppalmers-streaming/tests/SytMonitor.cpp

    r445 r705  
    2424 
    2525#include "SytMonitor.h" 
    26 #include "src/libstreaming/IsoStream.h" 
    2726 
    2827#include <netinet/in.h> 
  • branches/ppalmers-streaming/tests/SytMonitor.h

    r445 r705  
    2525#ifndef __FFADO_SYTMONITOR__ 
    2626#define __FFADO_SYTMONITOR__ 
    27 #include "src/libstreaming/IsoStream.h" 
    28 #include "src/libstreaming/cip.h" 
    29 #include "src/libstreaming/cycletimer.h" 
     27#include "src/libstreaming/generic/IsoStream.h" 
     28#include "src/libstreaming/util/cip.h" 
     29#include "src/libstreaming/util/cycletimer.h" 
    3030#include "src/libutil/ringbuffer.h" 
    3131 
  • branches/ppalmers-streaming/tests/test-cycletimer.cpp

    r445 r705  
    3737#include <netinet/in.h> 
    3838 
    39 #include "src/libstreaming/cycletimer.h" 
    40  
    41 #include "src/libstreaming/IsoHandler.h" 
    42 #include "src/libstreaming/IsoStream.h" 
    43 #include "src/libstreaming/IsoHandlerManager.h" 
     39#include "src/libstreaming/util/cycletimer.h" 
     40 
     41#include "src/libstreaming/util/IsoHandler.h" 
     42#include "src/libstreaming/generic/IsoStream.h" 
     43#include "src/libstreaming/util/IsoHandlerManager.h" 
    4444#include "src/libutil/PosixThread.h" 
    4545 
  • branches/ppalmers-streaming/tests/test-sytmonitor.cpp

    r445 r705  
    3737#include <netinet/in.h> 
    3838 
    39 #include "src/libstreaming/cycletimer.h" 
    40  
    41 #include "src/libstreaming/IsoHandlerManager.h" 
     39#include "src/libstreaming/util/cycletimer.h" 
     40 
     41#include "src/libstreaming/util/IsoHandlerManager.h" 
    4242#include "SytMonitor.h" 
    4343 
  • branches/ppalmers-streaming/tests/test-timestampedbuffer.cpp

    r494 r705  
    3737#include <netinet/in.h> 
    3838 
    39 #include "src/libstreaming/cycletimer.h" 
     39#include "src/libstreaming/util/cycletimer.h" 
    4040 
    4141#include "src/libutil/TimestampedBuffer.h"