Index: /branches/ppalmers-streaming/tests/test-cycletimer.cpp =================================================================== --- /branches/ppalmers-streaming/tests/test-cycletimer.cpp (revision 705) +++ /branches/ppalmers-streaming/tests/test-cycletimer.cpp (revision 714) @@ -288,5 +288,5 @@ #ifdef TEST_PORT_0 // add a stream to the manager so that it has something to do - s=new IsoStream(IsoStream::EST_Receive, 0); + s=new IsoStream(IsoStream::eST_Receive, 0); if (!s) { Index: /branches/ppalmers-streaming/tests/SytMonitor.cpp =================================================================== --- /branches/ppalmers-streaming/tests/SytMonitor.cpp (revision 705) +++ /branches/ppalmers-streaming/tests/SytMonitor.cpp (revision 714) @@ -35,5 +35,5 @@ SytMonitor::SytMonitor(int port) - : IsoStream(IsoStream::EST_Receive, port) { + : IsoStream(IsoStream::eST_Receive, port) { m_cinfo_buffer=ffado_ringbuffer_create(16384*sizeof(struct cycle_info)); Index: /branches/ppalmers-streaming/src/libstreaming/amdtp/AmdtpTransmitStreamProcessor.cpp =================================================================== --- /branches/ppalmers-streaming/src/libstreaming/amdtp/AmdtpTransmitStreamProcessor.cpp (revision 712) +++ /branches/ppalmers-streaming/src/libstreaming/amdtp/AmdtpTransmitStreamProcessor.cpp (revision 714) @@ -41,6 +41,9 @@ /* transmit */ AmdtpTransmitStreamProcessor::AmdtpTransmitStreamProcessor(int port, int framerate, int dimension) - : TransmitStreamProcessor(port, framerate), m_dimension(dimension) - , m_last_timestamp(0), m_dbc(0), m_ringbuffer_size_frames(0) + : StreamProcessor(ePT_Transmit, port, framerate) + , m_dimension(dimension) + , m_last_timestamp(0) + , m_dbc(0) + , m_ringbuffer_size_frames(0) {} @@ -50,9 +53,9 @@ bool AmdtpTransmitStreamProcessor::init() { - debugOutput( DEBUG_LEVEL_VERBOSE, "Initializing (%p)...\n"); + debugOutput( DEBUG_LEVEL_VERBOSE, "Initializing (%p)...\n", this); // call the parent init // this has to be done before allocating the buffers, // because this sets the buffersizes from the processormanager - if(!TransmitStreamProcessor::init()) { + if(!StreamProcessor::init()) { debugFatal("Could not do base class init (%p)\n",this); return false; @@ -415,5 +418,5 @@ // reset all non-device specific stuff // i.e. the iso stream and the associated ports - if(!TransmitStreamProcessor::reset()) { + if(!StreamProcessor::reset()) { debugFatal("Could not do base class reset\n"); return false; @@ -438,5 +441,5 @@ // prepare all non-device specific stuff // i.e. the iso stream and the associated ports - if(!TransmitStreamProcessor::prepare()) { + if(!StreamProcessor::prepare()) { debugFatal("Could not prepare base class\n"); return false; Index: /branches/ppalmers-streaming/src/libstreaming/amdtp/AmdtpReceiveStreamProcessor.cpp =================================================================== --- /branches/ppalmers-streaming/src/libstreaming/amdtp/AmdtpReceiveStreamProcessor.cpp (revision 712) +++ /branches/ppalmers-streaming/src/libstreaming/amdtp/AmdtpReceiveStreamProcessor.cpp (revision 714) @@ -42,5 +42,5 @@ AmdtpReceiveStreamProcessor::AmdtpReceiveStreamProcessor(int port, int framerate, int dimension) - : ReceiveStreamProcessor(port, framerate) + : StreamProcessor(ePT_Receive , port, framerate) , m_dimension(dimension) , m_last_timestamp(0) @@ -54,5 +54,5 @@ // this has to be done before allocating the buffers, // because this sets the buffersizes from the processormanager - if(!ReceiveStreamProcessor::init()) { + if(!StreamProcessor::init()) { debugFatal("Could not do base class init (%d)\n",this); return false; @@ -257,5 +257,5 @@ // reset all non-device specific stuff // i.e. the iso stream and the associated ports - if(!ReceiveStreamProcessor::reset()) { + if(!StreamProcessor::reset()) { debugFatal("Could not do base class reset\n"); return false; @@ -274,5 +274,5 @@ // prepare all non-device specific stuff // i.e. the iso stream and the associated ports - if(!ReceiveStreamProcessor::prepare()) { + if(!StreamProcessor::prepare()) { debugFatal("Could not prepare base class\n"); return false; Index: /branches/ppalmers-streaming/src/libstreaming/amdtp/AmdtpTransmitStreamProcessor.h =================================================================== --- /branches/ppalmers-streaming/src/libstreaming/amdtp/AmdtpTransmitStreamProcessor.h (revision 712) +++ /branches/ppalmers-streaming/src/libstreaming/amdtp/AmdtpTransmitStreamProcessor.h (revision 714) @@ -66,5 +66,5 @@ */ class AmdtpTransmitStreamProcessor - : public TransmitStreamProcessor + : public StreamProcessor { Index: /branches/ppalmers-streaming/src/libstreaming/amdtp/AmdtpReceiveStreamProcessor.h =================================================================== --- /branches/ppalmers-streaming/src/libstreaming/amdtp/AmdtpReceiveStreamProcessor.h (revision 712) +++ /branches/ppalmers-streaming/src/libstreaming/amdtp/AmdtpReceiveStreamProcessor.h (revision 714) @@ -65,5 +65,5 @@ */ class AmdtpReceiveStreamProcessor - : public ReceiveStreamProcessor + : public StreamProcessor { Index: /branches/ppalmers-streaming/src/libstreaming/StreamProcessorManager.cpp =================================================================== --- /branches/ppalmers-streaming/src/libstreaming/StreamProcessorManager.cpp (revision 712) +++ /branches/ppalmers-streaming/src/libstreaming/StreamProcessorManager.cpp (revision 714) @@ -72,21 +72,17 @@ assert(m_isoManager); - if (processor->getType()==StreamProcessor::E_Receive) { + if (processor->getType() == StreamProcessor::ePT_Receive) { processor->setVerboseLevel(getDebugLevel()); // inherit debug level m_ReceiveProcessors.push_back(processor); - processor->setManager(this); - return true; } - if (processor->getType()==StreamProcessor::E_Transmit) { + if (processor->getType() == StreamProcessor::ePT_Transmit) { processor->setVerboseLevel(getDebugLevel()); // inherit debug level m_TransmitProcessors.push_back(processor); - processor->setManager(this); - return true; } @@ -102,5 +98,5 @@ assert(processor); - if (processor->getType()==StreamProcessor::E_Receive) { + if (processor->getType()==StreamProcessor::ePT_Receive) { for ( StreamProcessorVectorIterator it = m_ReceiveProcessors.begin(); @@ -125,5 +121,5 @@ } - if (processor->getType()==StreamProcessor::E_Transmit) { + if (processor->getType()==StreamProcessor::ePT_Transmit) { for ( StreamProcessorVectorIterator it = m_TransmitProcessors.begin(); it != m_TransmitProcessors.end(); @@ -158,8 +154,4 @@ m_SyncSource=s; return true; -} - -StreamProcessor *StreamProcessorManager::getSyncSource() { - return m_SyncSource; } @@ -168,5 +160,5 @@ debugOutput( DEBUG_LEVEL_VERBOSE, "enter...\n"); - m_isoManager=new IsoHandlerManager(m_thread_realtime, m_thread_priority + 1); + m_isoManager = new IsoHandlerManager(m_thread_realtime, m_thread_priority + 1); if(!m_isoManager) { @@ -226,9 +218,4 @@ ++it ) { - if(!(*it)->setSyncSource(m_SyncSource)) { - debugFatal( " could not set sync source (%p)...\n",(*it)); - return false; - } - if(!(*it)->setOption("slaveMode", m_is_slave)) { debugOutput(DEBUG_LEVEL_VERBOSE, " note: could not set slaveMode option for (%p)...\n",(*it)); @@ -245,8 +232,4 @@ it != m_TransmitProcessors.end(); ++it ) { - if(!(*it)->setSyncSource(m_SyncSource)) { - debugFatal( " could not set sync source (%p)...\n",(*it)); - return false; - } if(!(*it)->setOption("slaveMode", m_is_slave)) { debugOutput(DEBUG_LEVEL_VERBOSE, " note: could not set slaveMode option for (%p)...\n",(*it)); @@ -377,5 +360,5 @@ waitForPeriod(); // drop the frames for all receive SP's - dryRun(StreamProcessor::E_Receive); + dryRun(StreamProcessor::ePT_Receive); // we don't have to dryrun for the xmit SP's since they @@ -1067,6 +1050,6 @@ debugOutput( DEBUG_LEVEL_VERBOSE, "Transferring period...\n"); bool retval=true; - retval &= dryRun(StreamProcessor::E_Receive); - retval &= dryRun(StreamProcessor::E_Transmit); + retval &= dryRun(StreamProcessor::ePT_Receive); + retval &= dryRun(StreamProcessor::ePT_Transmit); return retval; } @@ -1081,10 +1064,10 @@ */ -bool StreamProcessorManager::transfer(enum StreamProcessor::EProcessorType t) { +bool StreamProcessorManager::transfer(enum StreamProcessor::eProcessorType t) { debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "Transferring period...\n"); bool retval = true; // a static cast could make sure that there is no performance // penalty for the virtual functions (to be checked) - if (t==StreamProcessor::E_Receive) { + if (t==StreamProcessor::ePT_Receive) { // determine the time at which we want reception to start float rate=m_SyncSource->getTicksPerFrame(); @@ -1148,6 +1131,6 @@ debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "Dry-running period...\n"); bool retval=true; - retval &= dryRun(StreamProcessor::E_Receive); - retval &= dryRun(StreamProcessor::E_Transmit); + retval &= dryRun(StreamProcessor::ePT_Receive); + retval &= dryRun(StreamProcessor::ePT_Transmit); return retval; } @@ -1162,10 +1145,10 @@ */ -bool StreamProcessorManager::dryRun(enum StreamProcessor::EProcessorType t) { +bool StreamProcessorManager::dryRun(enum StreamProcessor::eProcessorType t) { debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "Dry-running period...\n"); bool retval = true; // a static cast could make sure that there is no performance // penalty for the virtual functions (to be checked) - if (t==StreamProcessor::E_Receive) { + if (t==StreamProcessor::ePT_Receive) { // determine the time at which we want reception to start float rate=m_SyncSource->getTicksPerFrame(); Index: /branches/ppalmers-streaming/src/libstreaming/StreamProcessorManager.h =================================================================== --- /branches/ppalmers-streaming/src/libstreaming/StreamProcessorManager.h (revision 705) +++ /branches/ppalmers-streaming/src/libstreaming/StreamProcessorManager.h (revision 714) @@ -87,8 +87,8 @@ bool transfer(); ///< transfer the buffer contents from/to client - bool transfer(enum StreamProcessor::EProcessorType); ///< transfer the buffer contents from/to client (single processor type) + bool transfer(enum StreamProcessor::eProcessorType); ///< transfer the buffer contents from/to client (single processor type) bool dryRun(); - bool dryRun(enum StreamProcessor::EProcessorType); + bool dryRun(enum StreamProcessor::eProcessorType); int getDelayedUsecs() {return m_delayed_usecs;}; @@ -122,5 +122,6 @@ public: bool setSyncSource(StreamProcessor *s); - StreamProcessor * getSyncSource(); + StreamProcessor& getSyncSource() + {return *m_SyncSource;}; protected: Index: /branches/ppalmers-streaming/src/libstreaming/generic/StreamProcessor.h =================================================================== --- /branches/ppalmers-streaming/src/libstreaming/generic/StreamProcessor.h (revision 712) +++ /branches/ppalmers-streaming/src/libstreaming/generic/StreamProcessor.h (revision 714) @@ -53,33 +53,79 @@ public Util::OptionContainer { - friend class StreamProcessorManager; - -public: - enum EProcessorType { - E_Receive, - E_Transmit + friend class StreamProcessorManager; // FIXME: get rid of this + +public: + ///> the streamprocessor type + enum eProcessorType { + ePT_Receive, + ePT_Transmit }; - - StreamProcessor(enum IsoStream::EStreamType type, int port, int framerate); + ///> returns the type of the streamprocessor + virtual enum eProcessorType getType() { return m_processor_type; }; +private: + // this can only be set by the constructor + enum eProcessorType m_processor_type; + +protected: + ///> the state the streamprocessor is in + enum eProcessorState { + ePS_Created, + ePS_Initialized, + ePS_WaitingForRunningStream, + ePS_DryRunning, + ePS_WaitingForEnabledStream, + ePS_StreamEnabled, + ePS_WaitingForDisabledStream, + }; + + ///> set the SP state to a specific value + void setState(enum eProcessorState); + ///> get the SP state + enum eProcessorState getState() {return m_state;}; +private: + enum eProcessorState m_state; + const char *ePSToString(enum eProcessorState); + +// constructor/destructor +public: + StreamProcessor(enum eProcessorType type, int port, int framerate); virtual ~StreamProcessor(); +// the receive/transmit functions +public: + // the transmit interface accepts frames and provides packets + // implement these for a transmit SP + // leave default for a receive SP virtual enum raw1394_iso_disposition - putPacket(unsigned char *data, unsigned int length, - unsigned char channel, unsigned char tag, unsigned char sy, - unsigned int cycle, unsigned int dropped) = 0; + getPacket(unsigned char *data, unsigned int *length, + unsigned char *tag, unsigned char *sy, + int cycle, unsigned int dropped, unsigned int max_length) + {debugWarning("call not allowed\n"); return RAW1394_ISO_STOP;}; + virtual bool putFrames(unsigned int nbframes, int64_t ts) + {debugWarning("call not allowed\n"); return false;}; + virtual bool putFramesDry(unsigned int nbframes, int64_t ts) + {debugWarning("call not allowed\n"); return false;}; + virtual bool processWriteBlock(char *data, unsigned int nevents, unsigned int offset) + {debugWarning("call not allowed\n"); return false;}; + + // the receive interface accepts packets and provides frames + // implement these for a receive SP + // leave default for a transmit SP virtual enum raw1394_iso_disposition - getPacket(unsigned char *data, unsigned int *length, - unsigned char *tag, unsigned char *sy, - int cycle, unsigned int dropped, unsigned int max_length) = 0; - - virtual enum EProcessorType getType() =0; - - bool xrunOccurred() { return (m_xruns>0);}; - - // move to private? - void resetXrunCounter(); - + putPacket(unsigned char *data, unsigned int length, + unsigned char channel, unsigned char tag, unsigned char sy, + unsigned int cycle, unsigned int dropped) + {debugWarning("call not allowed\n"); return RAW1394_ISO_STOP;}; + virtual bool getFrames(unsigned int nbframes, int64_t ts) + {debugWarning("call not allowed\n"); return false;}; + virtual bool getFramesDry(unsigned int nbframes, int64_t ts) + {debugWarning("call not allowed\n"); return false;}; + virtual bool processReadBlock(char *data, unsigned int nevents, unsigned int offset) + {debugWarning("call not allowed\n"); return false;}; + + + // state stuff (TODO: cleanup) + bool xrunOccurred() { return (m_xruns>0); }; bool isRunning(); ///< returns true if there is some stream data processed - virtual bool prepareForEnable(uint64_t time_to_enable_at); virtual bool prepareForDisable(); @@ -89,29 +135,17 @@ bool isEnabled() {return !m_is_disabled;}; - virtual bool putFrames(unsigned int nbframes, int64_t ts) = 0; ///< transfer the buffer contents from client - virtual bool getFrames(unsigned int nbframes, int64_t ts) = 0; ///< transfer the buffer contents to the client - virtual bool putFramesDry(unsigned int nbframes, int64_t ts) = 0; ///< dry-process the buffer contents - virtual bool getFramesDry(unsigned int nbframes, int64_t ts) = 0; ///< dry-process the buffer contents - virtual bool reset(); ///< reset the streams & buffers (e.g. after xrun) virtual bool prepare(); ///< prepare the streams & buffers (e.g. prefill) - - virtual void dumpInfo(); - virtual bool init(); - - virtual void setVerboseLevel(int l); - virtual bool prepareForStop() {return true;}; virtual bool prepareForStart() {return true;}; -public: + // move to private? + void resetXrunCounter(); + + +public: // FIXME: should be private Util::TimestampedBuffer *m_data_buffer; - - StreamStatistics m_PacketStat; - StreamStatistics m_PeriodStat; - - StreamStatistics m_WakeupStat; protected: // SPM related @@ -122,11 +156,9 @@ unsigned int m_nb_buffers; ///< cached from manager->getNbBuffers(), the number of periods to buffer unsigned int m_period; ///< cached from manager->getPeriod(), the period size - unsigned int m_xruns; - unsigned int m_framerate; StreamProcessorManager *m_manager; - + bool m_running; bool m_disabled; @@ -135,7 +167,4 @@ - - DECLARE_DEBUG_MODULE; - // frame counter & sync stuff public: @@ -150,5 +179,5 @@ * false if it can't */ - virtual bool canClientTransferFrames(unsigned int nframes) = 0; + virtual bool canClientTransferFrames(unsigned int nframes); /** @@ -195,5 +224,5 @@ * @return the time in internal units */ - virtual uint64_t getTimeAtPeriod() = 0; + virtual uint64_t getTimeAtPeriod(); uint64_t getTimeNow(); @@ -229,5 +258,6 @@ virtual int getMaxFrameLatency(); - bool setSyncSource(StreamProcessor *s); + StreamProcessor& getSyncSource(); + float getTicksPerFrame(); @@ -238,5 +268,4 @@ protected: - StreamProcessor *m_SyncSource; float m_ticks_per_frame; @@ -245,66 +274,15 @@ int m_sync_delay; +public: + // debug stuff + virtual void dumpInfo(); + virtual void setVerboseLevel(int l); + StreamStatistics m_PacketStat; + StreamStatistics m_PeriodStat; + StreamStatistics m_WakeupStat; + DECLARE_DEBUG_MODULE; + }; -/*! -\brief Class providing a generic interface for receive Stream Processors - -*/ -class ReceiveStreamProcessor : public StreamProcessor { - -public: - ReceiveStreamProcessor(int port, int framerate) - : StreamProcessor(IsoStream::EST_Receive, port, framerate) {}; - virtual ~ReceiveStreamProcessor(){}; - - - virtual enum EProcessorType getType() {return E_Receive;}; - - virtual enum raw1394_iso_disposition - getPacket(unsigned char *data, unsigned int *length, - unsigned char *tag, unsigned char *sy, - int cycle, unsigned int dropped, unsigned int max_length) - {return RAW1394_ISO_STOP;}; - virtual bool putFrames(unsigned int nbframes, int64_t ts) {return false;}; - virtual bool putFramesDry(unsigned int nbframes, int64_t ts) {return false;}; - - virtual enum raw1394_iso_disposition putPacket(unsigned char *data, unsigned int length, - unsigned char channel, unsigned char tag, unsigned char sy, - unsigned int cycle, unsigned int dropped) = 0; - - uint64_t getTimeAtPeriod(); - bool canClientTransferFrames(unsigned int nframes); - -protected: - bool processWriteBlock(char *data, unsigned int nevents, unsigned int offset) {return true;}; -}; - -/*! -\brief Class providing a generic interface for receive Stream Processors - -*/ -class TransmitStreamProcessor : public StreamProcessor { - -public: - TransmitStreamProcessor(int port, int framerate) - : StreamProcessor(IsoStream::EST_Transmit, port, framerate) {}; - virtual ~TransmitStreamProcessor() {}; - - virtual enum EProcessorType getType() {return E_Transmit;}; - - virtual enum raw1394_iso_disposition - putPacket(unsigned char *data, unsigned int length, - unsigned char channel, unsigned char tag, unsigned char sy, - unsigned int cycle, unsigned int dropped) {return RAW1394_ISO_STOP;}; - virtual bool getFrames(unsigned int nbframes, int64_t ts) {return false;}; - virtual bool getFramesDry(unsigned int nbframes, int64_t ts) {return false;}; - - uint64_t getTimeAtPeriod(); - bool canClientTransferFrames(unsigned int nframes); - -protected: - bool processReadBlock(char *data, unsigned int nevents, unsigned int offset) {return true;}; -}; - } Index: /branches/ppalmers-streaming/src/libstreaming/generic/IsoStream.cpp =================================================================== --- /branches/ppalmers-streaming/src/libstreaming/generic/IsoStream.cpp (revision 705) +++ /branches/ppalmers-streaming/src/libstreaming/generic/IsoStream.cpp (revision 714) @@ -72,5 +72,5 @@ debugOutputShort( DEBUG_LEVEL_NORMAL, " Address : %p\n",this); debugOutputShort( DEBUG_LEVEL_NORMAL, " Stream type : %s\n", - (this->getType()==EST_Receive ? "Receive" : "Transmit")); + (this->getStreamType()==eST_Receive ? "Receive" : "Transmit")); debugOutputShort( DEBUG_LEVEL_NORMAL, " Port, Channel : %d, %d\n", m_port, m_channel); Index: /branches/ppalmers-streaming/src/libstreaming/generic/IsoStream.h =================================================================== --- /branches/ppalmers-streaming/src/libstreaming/generic/IsoStream.h (revision 705) +++ /branches/ppalmers-streaming/src/libstreaming/generic/IsoStream.h (revision 714) @@ -48,14 +48,14 @@ public: - enum EStreamType { - EST_Receive, - EST_Transmit + enum eStreamType { + eST_Receive, + eST_Transmit }; - IsoStream(enum EStreamType type) - : m_type(type), m_channel(-1), m_port(0), m_handler(0) + IsoStream(enum eStreamType type) + : m_channel(-1), m_port(0), m_handler(0), m_isostream_type(type) {}; - IsoStream(enum EStreamType type, int port) - : m_type(type), m_channel(-1), m_port(port), m_handler(0) + IsoStream(enum eStreamType type, int port) + : m_channel(-1), m_port(port), m_handler(0), m_isostream_type(type) {}; virtual ~IsoStream() @@ -69,5 +69,5 @@ int getPort() {return m_port;}; - enum EStreamType getType() { return m_type;}; + enum eStreamType getStreamType() { return m_isostream_type;}; virtual unsigned int getPacketsPerPeriod() {return 1;}; @@ -93,13 +93,14 @@ protected: - void setHandler( IsoHandler * h) ; void clearHandler(); - enum EStreamType m_type; int m_channel; int m_port; IsoHandler *m_handler; + + private: // should be set in the constructor + enum eStreamType m_isostream_type; DECLARE_DEBUG_MODULE; Index: /branches/ppalmers-streaming/src/libstreaming/generic/StreamProcessor.cpp =================================================================== --- /branches/ppalmers-streaming/src/libstreaming/generic/StreamProcessor.cpp (revision 712) +++ /branches/ppalmers-streaming/src/libstreaming/generic/StreamProcessor.cpp (revision 714) @@ -35,6 +35,8 @@ IMPL_DEBUG_MODULE( StreamProcessor, StreamProcessor, DEBUG_LEVEL_VERBOSE ); -StreamProcessor::StreamProcessor(enum IsoStream::EStreamType type, int port, int framerate) - : IsoStream(type, port) +StreamProcessor::StreamProcessor(enum eProcessorType type, int port, int framerate) + : IsoStream((type==ePT_Receive ? IsoStream::eST_Receive : IsoStream::eST_Transmit), port) + , m_processor_type ( type ) + , m_state( ePS_Created ) , m_nb_buffers(0) , m_period(0) @@ -46,5 +48,4 @@ , m_is_disabled(true) , m_cycle_to_enable_at(0) - , m_SyncSource(NULL) , m_ticks_per_frame(0) , m_last_cycle(0) @@ -58,4 +59,14 @@ StreamProcessor::~StreamProcessor() { if (m_data_buffer) delete m_data_buffer; +} + +void +StreamProcessor::setState(enum eProcessorState s) { + #ifdef DEBUG + // check the state transistion + debugOutput( DEBUG_LEVEL_VERBOSE, "State transition from %s to %s", + ePSToString(m_state), ePSToString(s) ); + #endif + m_state = s; } @@ -76,5 +87,5 @@ debugOutputShort( DEBUG_LEVEL_NORMAL, " Nominal framerate : %u\n", m_framerate); debugOutputShort( DEBUG_LEVEL_NORMAL, " Device framerate : Sync: %f, Buffer %f\n", - 24576000.0/m_SyncSource->m_data_buffer->getRate(), + 24576000.0/getSyncSource().m_data_buffer->getRate(), 24576000.0/m_data_buffer->getRate() ); @@ -169,4 +180,10 @@ } +StreamProcessor& +StreamProcessor::getSyncSource() +{ + return m_manager->getSyncSource(); +}; + int StreamProcessor::getBufferFill() { // return m_data_buffer->getFrameCounter(); @@ -180,5 +197,5 @@ int StreamProcessor::getMaxFrameLatency() { - if (getType() == E_Receive) { + if (getType() == ePT_Receive) { return (int)(m_handler->getWakeupInterval() * TICKS_PER_CYCLE); } else { @@ -225,9 +242,4 @@ m_data_buffer->disable(); m_disabled=true; - return true; -} - -bool StreamProcessor::setSyncSource(StreamProcessor *s) { - m_SyncSource=s; return true; } @@ -261,5 +273,5 @@ // pass before these packets are processed. Adding this extra term makes that // the period boundary is signalled later - time_at_period = addTicks(time_at_period, m_SyncSource->getSyncDelay()); + time_at_period = addTicks(time_at_period, getSyncSource().getSyncDelay()); uint64_t cycle_timer=m_handler->getCycleTimerTicks(); @@ -303,50 +315,61 @@ } -uint64_t ReceiveStreamProcessor::getTimeAtPeriod() { - ffado_timestamp_t next_period_boundary=m_data_buffer->getTimestampFromHead(m_period); - - #ifdef DEBUG - ffado_timestamp_t ts; - signed int fc; +uint64_t +StreamProcessor::getTimeAtPeriod() { + if (getType() == ePT_Receive) { + ffado_timestamp_t next_period_boundary=m_data_buffer->getTimestampFromHead(m_period); - m_data_buffer->getBufferTailTimestamp(&ts,&fc); - - debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "=> NPD="TIMESTAMP_FORMAT_SPEC", LTS="TIMESTAMP_FORMAT_SPEC", FC=%5u, TPF=%f\n", - next_period_boundary, ts, fc, getTicksPerFrame() - ); - #endif - - return (uint64_t)next_period_boundary; -} - -bool ReceiveStreamProcessor::canClientTransferFrames(unsigned int nbframes) { - return m_data_buffer->getFrameCounter() >= (int) nbframes; -} - -uint64_t TransmitStreamProcessor::getTimeAtPeriod() { - ffado_timestamp_t next_period_boundary=m_data_buffer->getTimestampFromTail((m_nb_buffers-1) * m_period); - - #ifdef DEBUG - ffado_timestamp_t ts; - signed int fc; - m_data_buffer->getBufferTailTimestamp(&ts,&fc); - - debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "=> NPD="TIMESTAMP_FORMAT_SPEC", LTS="TIMESTAMP_FORMAT_SPEC", FC=%5u, TPF=%f\n", - next_period_boundary, ts, fc, getTicksPerFrame() - ); - #endif - - return (uint64_t)next_period_boundary; -} - -bool TransmitStreamProcessor::canClientTransferFrames(unsigned int nbframes) { - bool can_transfer; - // there has to be enough space to put the frames in - can_transfer = m_data_buffer->getBufferSize() - m_data_buffer->getFrameCounter() > nbframes; - // or the buffer is transparent - can_transfer |= m_data_buffer->isTransparent(); - return can_transfer; -} - - -} + #ifdef DEBUG + ffado_timestamp_t ts; + signed int fc; + m_data_buffer->getBufferTailTimestamp(&ts,&fc); + + debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "=> NPD="TIMESTAMP_FORMAT_SPEC", LTS="TIMESTAMP_FORMAT_SPEC", FC=%5u, TPF=%f\n", + next_period_boundary, ts, fc, getTicksPerFrame() + ); + #endif + return (uint64_t)next_period_boundary; + } else { + ffado_timestamp_t next_period_boundary=m_data_buffer->getTimestampFromTail((m_nb_buffers-1) * m_period); + + #ifdef DEBUG + ffado_timestamp_t ts; + signed int fc; + m_data_buffer->getBufferTailTimestamp(&ts,&fc); + + debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "=> NPD="TIMESTAMP_FORMAT_SPEC", LTS="TIMESTAMP_FORMAT_SPEC", FC=%5u, TPF=%f\n", + next_period_boundary, ts, fc, getTicksPerFrame() + ); + #endif + return (uint64_t)next_period_boundary; + } +} + +bool +StreamProcessor::canClientTransferFrames(unsigned int nbframes) { + if (getType() == ePT_Receive) { + return m_data_buffer->getFrameCounter() >= (int) nbframes; + } else { + bool can_transfer; + // there has to be enough space to put the frames in + can_transfer = m_data_buffer->getBufferSize() - m_data_buffer->getFrameCounter() > nbframes; + // or the buffer is transparent + can_transfer |= m_data_buffer->isTransparent(); + return can_transfer; + } +} + +const char * +StreamProcessor::ePSToString(enum eProcessorState s) { + switch (s) { + case ePS_Created: return "ePS_Created"; + case ePS_Initialized: return "ePS_Initialized"; + case ePS_WaitingForRunningStream: return "ePS_WaitingForRunningStream"; + case ePS_DryRunning: return "ePS_DryRunning"; + case ePS_WaitingForEnabledStream: return "ePS_WaitingForEnabledStream"; + case ePS_StreamEnabled: return "ePS_StreamEnabled"; + case ePS_WaitingForDisabledStream: return "ePS_WaitingForDisabledStream"; + } +} + +} // end of namespace Index: /branches/ppalmers-streaming/src/libstreaming/util/IsoHandlerManager.cpp =================================================================== --- /branches/ppalmers-streaming/src/libstreaming/util/IsoHandlerManager.cpp (revision 707) +++ /branches/ppalmers-streaming/src/libstreaming/util/IsoHandlerManager.cpp (revision 714) @@ -304,5 +304,5 @@ // allocate a handler for this stream - if (stream->getType()==IsoStream::EST_Receive) { + if (stream->getStreamType()==IsoStream::eST_Receive) { // setup the optimal parameters for the raw1394 ISO buffering unsigned int packets_per_period=stream->getPacketsPerPeriod(); @@ -394,5 +394,5 @@ } - if (stream->getType()==IsoStream::EST_Transmit) { + if (stream->getStreamType()==IsoStream::eST_Transmit) { // setup the optimal parameters for the raw1394 ISO buffering unsigned int packets_per_period=stream->getPacketsPerPeriod(); Index: /branches/ppalmers-streaming/src/ffado_streaming.cpp =================================================================== --- /branches/ppalmers-streaming/src/ffado_streaming.cpp (revision 705) +++ /branches/ppalmers-streaming/src/ffado_streaming.cpp (revision 714) @@ -170,5 +170,4 @@ // prepare the device device->prepare(); - int j=0; for(j=0; jgetStreamCount();j++) { @@ -176,5 +175,9 @@ debugOutput(DEBUG_LEVEL_VERBOSE, "Registering stream processor %d of device %d with processormanager\n",j,i); if (!dev->processorManager->registerProcessor(streamproc)) { - debugWarning("Could not register stream processor (%p) with the Processor manager\n",streamproc); + delete dev->processorManager; + delete dev->m_deviceManager; + delete dev; + debugFatal("Could not register stream processor (%p) with the Processor manager\n", streamproc); + return 0; } } @@ -331,9 +334,9 @@ int ffado_streaming_transfer_capture_buffers(ffado_device_t *dev) { - return dev->processorManager->transfer(StreamProcessor::E_Receive); + return dev->processorManager->transfer(StreamProcessor::ePT_Receive); } int ffado_streaming_transfer_playback_buffers(ffado_device_t *dev) { - return dev->processorManager->transfer(StreamProcessor::E_Transmit); + return dev->processorManager->transfer(StreamProcessor::ePT_Receive); }