Changeset 715

Show
Ignore:
Timestamp:
11/11/07 10:12:01 (13 years ago)
Author:
ppalmers
Message:

some more cleaning

Files:

Legend:

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

    r712 r715  
    447447bool 
    448448DiceAvDevice::prepare() { 
    449     int samplerate=getSamplingFrequency(); 
    450  
    451449    // prepare receive SP's 
    452450    for (unsigned int i=0;i<m_nb_tx;i++) { 
     
    493491        p=new Streaming::AmdtpReceiveStreamProcessor( 
    494492                             m_p1394Service->getPort(), 
    495                              samplerate, 
    496493                             nb_channels); 
    497494 
     
    580577        p=new Streaming::AmdtpTransmitStreamProcessor( 
    581578                             m_p1394Service->getPort(), 
    582                              samplerate, 
    583579                             nb_channels); 
    584580 
  • branches/ppalmers-streaming/src/ffado_streaming.cpp

    r714 r715  
    8686    // create a processor manager to manage the actual stream 
    8787    // processors 
    88     dev->processorManager = new StreamProcessorManager(dev->options.period_size,dev->options.nb_buffers); 
     88    dev->processorManager = new StreamProcessorManager( dev->options.period_size,  
     89                                                        dev->options.sample_rate, 
     90                                                        dev->options.nb_buffers); 
    8991    if(!dev->processorManager) { 
    9092            debugFatal("Could not create StreamProcessorManager\n"); 
  • branches/ppalmers-streaming/src/genericavc/avc_avdevice.cpp

    r685 r715  
    430430    p=new Streaming::AmdtpReceiveStreamProcessor( 
    431431                             get1394Service().getPort(), 
    432                              samplerate, 
    433432                             outputPlug->getNrOfChannels()); 
    434433 
     
    455454        p=new Streaming::AmdtpReceiveStreamProcessor( 
    456455                                  get1394Service().getPort(), 
    457                                   samplerate, 
    458456                                  inputPlug->getNrOfChannels()); 
    459457    } else { 
    460458        p=new Streaming::AmdtpTransmitStreamProcessor( 
    461459                                get1394Service().getPort(), 
    462                                 samplerate, 
    463460                                inputPlug->getNrOfChannels()); 
    464461    } 
  • branches/ppalmers-streaming/src/libstreaming/amdtp/AmdtpReceiveStreamProcessor.cpp

    r714 r715  
    2424#include "AmdtpReceiveStreamProcessor.h" 
    2525#include "AmdtpPort.h" 
     26#include "../StreamProcessorManager.h" 
    2627 
    2728#include "../util/cycletimer.h" 
     
    4142/* --------------------- RECEIVE ----------------------- */ 
    4243 
    43 AmdtpReceiveStreamProcessor::AmdtpReceiveStreamProcessor(int port, int framerate, int dimension) 
    44     : StreamProcessor(ePT_Receive , port, framerate
     44AmdtpReceiveStreamProcessor::AmdtpReceiveStreamProcessor(int port, int dimension) 
     45    : StreamProcessor(ePT_Receive , port
    4546    , m_dimension(dimension) 
    4647    , m_last_timestamp(0) 
     
    279280    } 
    280281 
    281     switch (m_framerate) { 
     282    switch (m_manager->getNominalRate()) { 
    282283    case 32000: 
    283284        m_syt_interval = 8; 
     
    305306 
    306307    // prepare the framerate estimate 
    307     float ticks_per_frame = (TICKS_PER_SECOND*1.0) / ((float)m_framerate); 
     308    float ticks_per_frame = (TICKS_PER_SECOND*1.0) / ((float)m_manager->getNominalRate()); 
    308309    m_ticks_per_frame=ticks_per_frame; 
    309310 
     
    311312 
    312313    // initialize internal buffer 
    313     unsigned int ringbuffer_size_frames=m_nb_buffers * m_period
     314    unsigned int ringbuffer_size_frames=m_manager->getNbBuffers() * m_manager->getPeriodSize()
    314315 
    315316    assert(m_data_buffer); 
     
    334335    { 
    335336        debugOutput(DEBUG_LEVEL_VERBOSE, "Setting up port %s\n",(*it)->getName().c_str()); 
    336         if(!(*it)->setBufferSize(m_period)) { 
    337             debugFatal("Could not set buffer size to %d\n",m_period); 
     337        if(!(*it)->setBufferSize(m_manager->getPeriodSize())) { 
     338            debugFatal("Could not set buffer size to %d\n",m_manager->getPeriodSize()); 
    338339            return false; 
    339340        } 
     
    400401    debugOutput( DEBUG_LEVEL_VERBOSE, "Prepared for:\n"); 
    401402    debugOutput( DEBUG_LEVEL_VERBOSE, " Samplerate: %d, DBS: %d, SYT: %d\n", 
    402              m_framerate,m_dimension,m_syt_interval); 
     403             m_manager->getNominalRate(),m_dimension,m_syt_interval); 
    403404    debugOutput( DEBUG_LEVEL_VERBOSE, " PeriodSize: %d, NbBuffers: %d\n", 
    404              m_period,m_nb_buffers); 
     405             m_manager->getPeriodSize(), m_manager->getNbBuffers()); 
    405406    debugOutput( DEBUG_LEVEL_VERBOSE, " Port: %d, Channel: %d\n", 
    406407             m_port,m_channel); 
     
    418419    disable(); 
    419420    return true; 
     421} 
     422 
     423unsigned int 
     424AmdtpReceiveStreamProcessor::getPacketsPerPeriod()  
     425{ 
     426    return (m_manager->getPeriodSize())/m_syt_interval; 
    420427} 
    421428 
  • branches/ppalmers-streaming/src/libstreaming/amdtp/AmdtpReceiveStreamProcessor.h

    r714 r715  
    7676     *                  (midi-muxed is only one stream) 
    7777     */ 
    78     AmdtpReceiveStreamProcessor(int port, int framerate, int dimension); 
     78    AmdtpReceiveStreamProcessor(int port, int dimension); 
    7979    virtual ~AmdtpReceiveStreamProcessor() {}; 
    8080 
     
    101101    // however, if we only count the number of used packets 
    102102    // it is m_period / m_syt_interval 
    103     unsigned int getPacketsPerPeriod() {return (m_period)/m_syt_interval;}
     103    unsigned int getPacketsPerPeriod()
    104104 
    105105    unsigned int getMaxPacketSize() {return 4 * (2 + m_syt_interval * m_dimension);}; 
  • branches/ppalmers-streaming/src/libstreaming/amdtp/AmdtpTransmitStreamProcessor.cpp

    r714 r715  
    2424#include "AmdtpTransmitStreamProcessor.h" 
    2525#include "AmdtpPort.h" 
     26#include "../StreamProcessorManager.h" 
    2627 
    2728#include "../util/cycletimer.h" 
     
    4041 
    4142/* transmit */ 
    42 AmdtpTransmitStreamProcessor::AmdtpTransmitStreamProcessor(int port, int framerate, int dimension) 
    43         : StreamProcessor(ePT_Transmit, port, framerate
     43AmdtpTransmitStreamProcessor::AmdtpTransmitStreamProcessor(int port, int dimension) 
     44        : StreamProcessor(ePT_Transmit, port
    4445        , m_dimension(dimension) 
    4546        , m_last_timestamp(0) 
     
    446447    } 
    447448 
    448     switch (m_framerate) { 
     449    switch (m_manager->getNominalRate()) { 
    449450    case 32000: 
    450451        m_syt_interval = 8; 
     
    482483        IEC61883_FMT_AMDTP, 
    483484        m_fdf, 
    484         m_framerate
     485        m_manager->getNominalRate()
    485486        m_dimension, 
    486487        m_syt_interval); 
    487488 
    488489    // prepare the framerate estimate 
    489     float ticks_per_frame = (TICKS_PER_SECOND*1.0) / ((float)m_framerate); 
     490    float ticks_per_frame = (TICKS_PER_SECOND*1.0) / ((float)m_manager->getNominalRate()); 
    490491    m_ticks_per_frame=ticks_per_frame; 
    491492 
    492493    // initialize internal buffer 
    493     m_ringbuffer_size_frames=m_nb_buffers * m_period
     494    m_ringbuffer_size_frames=m_manager->getNbBuffers() * m_manager->getPeriodSize()
    494495 
    495496    assert(m_data_buffer); 
     
    498499    m_data_buffer->setEventsPerFrame(m_dimension); 
    499500 
    500     m_data_buffer->setUpdatePeriod(m_period); 
     501    m_data_buffer->setUpdatePeriod(m_manager->getPeriodSize()); 
    501502    m_data_buffer->setNominalRate(ticks_per_frame); 
    502503 
     
    513514    { 
    514515        debugOutput(DEBUG_LEVEL_VERBOSE, "Setting up port %s\n",(*it)->getName().c_str()); 
    515         if(!(*it)->setBufferSize(m_period)) { 
    516             debugFatal("Could not set buffer size to %d\n",m_period); 
     516        if(!(*it)->setBufferSize(m_manager->getPeriodSize())) { 
     517            debugFatal("Could not set buffer size to %d\n",m_manager->getPeriodSize()); 
    517518            return false; 
    518519        } 
     
    599600    debugOutput( DEBUG_LEVEL_VERBOSE, "Prepared for:\n"); 
    600601    debugOutput( DEBUG_LEVEL_VERBOSE, " Samplerate: %d, FDF: %d, DBS: %d, SYT: %d\n", 
    601              m_framerate,m_fdf,m_dimension,m_syt_interval); 
     602             m_manager->getNominalRate(),m_fdf,m_dimension,m_syt_interval); 
    602603    debugOutput( DEBUG_LEVEL_VERBOSE, " PeriodSize: %d, NbBuffers: %d\n", 
    603              m_period,m_nb_buffers); 
     604             m_manager->getPeriodSize(), m_manager->getNbBuffers()); 
    604605    debugOutput( DEBUG_LEVEL_VERBOSE, " Port: %d, Channel: %d\n", 
    605606             m_port,m_channel); 
     
    625626 
    626627    return true; 
     628} 
     629 
     630unsigned int 
     631AmdtpTransmitStreamProcessor::getPacketsPerPeriod()  
     632{ 
     633    return (m_manager->getPeriodSize())/m_syt_interval; 
    627634} 
    628635 
  • branches/ppalmers-streaming/src/libstreaming/amdtp/AmdtpTransmitStreamProcessor.h

    r714 r715  
    7777     *                  (midi-muxed is only one stream) 
    7878     */ 
    79     AmdtpTransmitStreamProcessor(int port, int framerate, int dimension); 
     79    AmdtpTransmitStreamProcessor(int port, int dimension); 
    8080    virtual ~AmdtpTransmitStreamProcessor() {}; 
    8181 
     
    104104    // however, if we only count the number of used packets 
    105105    // it is m_period / m_syt_interval 
    106     unsigned int getPacketsPerPeriod() {return (m_period)/m_syt_interval;}
     106    unsigned int getPacketsPerPeriod()
    107107 
    108108    unsigned int getMaxPacketSize() {return 4 * (2 + m_syt_interval * m_dimension);}; 
  • branches/ppalmers-streaming/src/libstreaming/generic/StreamProcessor.cpp

    r714 r715  
    3535IMPL_DEBUG_MODULE( StreamProcessor, StreamProcessor, DEBUG_LEVEL_VERBOSE ); 
    3636 
    37 StreamProcessor::StreamProcessor(enum eProcessorType type, int port, int framerate
     37StreamProcessor::StreamProcessor(enum eProcessorType type, int port
    3838    : IsoStream((type==ePT_Receive ? IsoStream::eST_Receive : IsoStream::eST_Transmit), port) 
    3939    , m_processor_type ( type ) 
    4040    , m_state( ePS_Created ) 
    41     , m_nb_buffers(0) 
    42     , m_period(0) 
    43     , m_xruns(0) 
    44     , m_framerate(framerate) 
     41    , m_xruns( 0 ) 
    4542    , m_manager(NULL) 
    4643    , m_running(false) 
     
    8582    debugOutputShort( DEBUG_LEVEL_NORMAL, "   enable status        : %s\n", m_is_disabled ? "No" : "Yes"); 
    8683 
    87     debugOutputShort( DEBUG_LEVEL_NORMAL, "  Nominal framerate     : %u\n", m_framerate); 
     84    debugOutputShort( DEBUG_LEVEL_NORMAL, "  Nominal framerate     : %u\n", m_manager->getNominalRate()); 
    8885    debugOutputShort( DEBUG_LEVEL_NORMAL, "  Device framerate      : Sync: %f, Buffer %f\n", 
    8986        24576000.0/getSyncSource().m_data_buffer->getRate(), 
     
    10198{ 
    10299    debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "enter...\n"); 
    103  
    104100    m_data_buffer->init(); 
    105  
    106101    return IsoStream::init(); 
    107102} 
     
    156151 
    157152    debugOutput( DEBUG_LEVEL_VERBOSE, "Preparing...\n"); 
    158  
    159     // init the ports 
    160  
    161153    if(!m_manager) { 
    162154        debugFatal("Not attached to a manager!\n"); 
     
    164156    } 
    165157 
    166     m_nb_buffers=m_manager->getNbBuffers(); 
    167     debugOutput( DEBUG_LEVEL_VERBOSE, "Setting m_nb_buffers  : %d\n", m_nb_buffers); 
    168  
    169     m_period=m_manager->getPeriodSize(); 
    170     debugOutput( DEBUG_LEVEL_VERBOSE, "Setting m_period      : %d\n", m_period); 
    171  
     158    // init the ports 
    172159    // loop over the ports to reset them 
    173160    PortManager::preparePorts(); 
     
    318305StreamProcessor::getTimeAtPeriod() { 
    319306    if (getType() == ePT_Receive) { 
    320         ffado_timestamp_t next_period_boundary=m_data_buffer->getTimestampFromHead(m_period); 
     307        ffado_timestamp_t next_period_boundary=m_data_buffer->getTimestampFromHead(m_manager->getPeriodSize()); 
    321308     
    322309        #ifdef DEBUG 
     
    331318        return (uint64_t)next_period_boundary; 
    332319    } else { 
    333         ffado_timestamp_t next_period_boundary=m_data_buffer->getTimestampFromTail((m_nb_buffers-1) * m_period); 
     320        ffado_timestamp_t next_period_boundary=m_data_buffer->getTimestampFromTail((m_manager->getNbBuffers()-1) * m_manager->getPeriodSize()); 
    334321     
    335322        #ifdef DEBUG 
  • branches/ppalmers-streaming/src/libstreaming/generic/StreamProcessor.h

    r714 r715  
    3838namespace Streaming { 
    3939 
    40 class StreamProcessorManager; 
    41  
     40    class StreamProcessorManager; 
    4241/*! 
    4342\brief Class providing a generic interface for Stream Processors 
     
    8988// constructor/destructor 
    9089public: 
    91     StreamProcessor(enum eProcessorType type, int port, int framerate); 
     90    StreamProcessor(enum eProcessorType type, int port); 
    9291    virtual ~StreamProcessor(); 
    9392 
     
    125124 
    126125 
    127     // state stuff (TODO: cleanup) 
     126//--- state stuff (TODO: cleanup) 
    128127    bool xrunOccurred() { return (m_xruns>0); }; 
    129128    bool isRunning(); ///< returns true if there is some stream data processed 
     
    144143    // move to private? 
    145144    void resetXrunCounter(); 
    146  
    147  
    148 public: // FIXME: should be private 
    149     Util::TimestampedBuffer *m_data_buffer; 
    150  
    151 protected: // SPM related 
    152     void setManager(StreamProcessorManager *manager) {m_manager=manager;}; 
    153     void clearManager() {m_manager=0;}; 
    154  
    155145protected: 
    156     unsigned int m_nb_buffers; ///< cached from manager->getNbBuffers(), the number of periods to buffer 
    157     unsigned int m_period; ///< cached from manager->getPeriod(), the period size 
    158     unsigned int m_xruns; 
    159     unsigned int m_framerate; 
    160  
    161     StreamProcessorManager *m_manager; 
    162      
    163146    bool m_running; 
    164147    bool m_disabled; 
     
    166149    unsigned int m_cycle_to_enable_at; 
    167150 
     151//--- data buffering and accounting 
     152public: // FIXME: should be private 
     153    Util::TimestampedBuffer *m_data_buffer; 
     154 
     155protected: 
     156    unsigned int m_xruns; 
     157 
     158    StreamProcessorManager *m_manager; 
    168159 
    169160    // frame counter & sync stuff 
     
    263254 
    264255        int getLastCycle() {return m_last_cycle;}; 
    265         int getFrameRate() {return m_framerate;}; 
    266256 
    267257        int getBufferFill(); 
    268258 
    269259    protected: 
    270  
    271260        float m_ticks_per_frame; 
    272  
    273261        int m_last_cycle; 
    274262        int m_sync_delay; 
     263 
     264protected: // SPM related 
     265    void setManager(StreamProcessorManager *manager) {m_manager=manager;}; 
     266    void clearManager() {m_manager=NULL;}; 
    275267 
    276268public: 
  • branches/ppalmers-streaming/src/libstreaming/StreamProcessorManager.cpp

    r714 r715  
    3838IMPL_DEBUG_MODULE( StreamProcessorManager, StreamProcessorManager, DEBUG_LEVEL_VERBOSE ); 
    3939 
    40 StreamProcessorManager::StreamProcessorManager(unsigned int period, unsigned int nb_buffers) 
     40StreamProcessorManager::StreamProcessorManager(unsigned int period, unsigned int framerate, unsigned int nb_buffers) 
    4141    : m_is_slave( false ) 
    4242    , m_SyncSource(NULL) 
    4343    , m_nb_buffers(nb_buffers) 
    4444    , m_period(period) 
     45    , m_nominal_framerate ( framerate ) 
    4546    , m_xruns(0) 
    4647    , m_isoManager(0) 
  • branches/ppalmers-streaming/src/libstreaming/StreamProcessorManager.h

    r714 r715  
    5353public: 
    5454 
    55     StreamProcessorManager(unsigned int period, unsigned int nb_buffers); 
     55    StreamProcessorManager(unsigned int period, unsigned int rate, unsigned int nb_buffers); 
    5656    virtual ~StreamProcessorManager(); 
    5757 
     
    9595    bool xrunOccurred(); 
    9696    int getXrunCount() {return m_xruns;}; 
     97 
     98    unsigned int getNominalRate() {return m_nominal_framerate;}; 
    9799 
    98100private: 
     
    139141    unsigned int m_nb_buffers; 
    140142    unsigned int m_period; 
     143    unsigned int m_nominal_framerate; 
    141144    unsigned int m_xruns; 
    142145