Changeset 1344
- Timestamp:
- 09/24/08 07:26:29 (16 years ago)
- Files:
-
- branches/libffado-2.0/src/libstreaming/amdtp/AmdtpReceiveStreamProcessor.cpp (modified) (3 diffs)
- branches/libffado-2.0/src/libstreaming/amdtp/AmdtpReceiveStreamProcessor.h (modified) (1 diff)
- branches/libffado-2.0/src/libstreaming/amdtp/AmdtpTransmitStreamProcessor.cpp (modified) (1 diff)
- branches/libffado-2.0/src/libstreaming/amdtp/AmdtpTransmitStreamProcessor.h (modified) (1 diff)
- branches/libffado-2.0/src/libstreaming/generic/StreamProcessor.cpp (modified) (2 diffs)
- branches/libffado-2.0/src/libstreaming/generic/StreamProcessor.h (modified) (2 diffs)
- branches/libffado-2.0/src/libstreaming/motu/MotuReceiveStreamProcessor.cpp (modified) (1 diff)
- branches/libffado-2.0/src/libstreaming/motu/MotuReceiveStreamProcessor.h (modified) (1 diff)
- branches/libffado-2.0/src/libstreaming/motu/MotuTransmitStreamProcessor.cpp (modified) (1 diff)
- branches/libffado-2.0/src/libstreaming/motu/MotuTransmitStreamProcessor.h (modified) (1 diff)
- branches/libffado-2.0/src/libstreaming/StreamProcessorManager.cpp (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/libffado-2.0/src/libstreaming/amdtp/AmdtpReceiveStreamProcessor.cpp
r1136 r1344 34 34 #include "libutil/ByteSwap.h" 35 35 #include <assert.h> 36 #include "libutil/SystemTimeSource.h" 36 37 37 38 namespace Streaming { … … 66 67 } 67 68 69 unsigned int 70 AmdtpReceiveStreamProcessor::getAveragePacketSize() 71 { 72 // in one second we have 8000 packets 73 // containing FRAMERATE frames of m_dimension quadlets 74 // so 8000 packet headers + FRAMERATE*m_dimension quadlets 75 unsigned int one_second = 8000 * 2 * sizeof(quadlet_t) + m_StreamProcessorManager.getNominalRate() * m_dimension * sizeof(quadlet_t); 76 return one_second / 8000; 77 } 78 68 79 bool AmdtpReceiveStreamProcessor::prepareChild() { 69 80 debugOutput( DEBUG_LEVEL_VERBOSE, "Preparing (%p)...\n", this); … … 144 155 // later than expected (the real receive time) 145 156 #ifdef DEBUG 157 static int64_t last_t = Util::SystemTimeSource::getCurrentTime(); 158 int64_t now_t = Util::SystemTimeSource::getCurrentTime(); 146 159 if(isRunning()) { 147 160 debugOutputExtreme(DEBUG_LEVEL_VERY_VERBOSE, 148 161 "STMP: %lluticks | syt_interval=%d, tpf=%f\n", 149 162 m_last_timestamp, m_syt_interval, getTicksPerFrame()); 150 } 163 /* debugOutput(DEBUG_LEVEL_NORMAL, 164 "STMP: %12llu ticks | delta_t: %5lld | bufferfill: %5d\n", 165 m_last_timestamp, now_t-last_t, m_data_buffer->getBufferFill());*/ 166 } 167 last_t = now_t; 151 168 152 169 // check whether nevents is a multiple of 8. branches/libffado-2.0/src/libstreaming/amdtp/AmdtpReceiveStreamProcessor.h
r1035 r1344 90 90 virtual unsigned int getMaxPacketSize() 91 91 {return 4 * (2 + getSytInterval() * m_dimension);}; 92 virtual unsigned int getAveragePacketSize(); 92 93 virtual unsigned int getEventsPerFrame() 93 94 { return m_dimension; }; branches/libffado-2.0/src/libstreaming/amdtp/AmdtpTransmitStreamProcessor.cpp
r1305 r1344 405 405 } 406 406 } 407 408 unsigned int 409 AmdtpTransmitStreamProcessor::getAveragePacketSize() 410 { 411 // in one second we have 8000 packets 412 // containing FRAMERATE frames of m_dimension quadlets 413 // so 8000 packet headers + FRAMERATE*m_dimension quadlets 414 unsigned int one_second = 8000 * 2 * sizeof(quadlet_t) + m_StreamProcessorManager.getNominalRate() * m_dimension * sizeof(quadlet_t); 415 return one_second / 8000; 416 } 417 407 418 unsigned int 408 419 AmdtpTransmitStreamProcessor::getFDF() { branches/libffado-2.0/src/libstreaming/amdtp/AmdtpTransmitStreamProcessor.h
r1305 r1344 104 104 virtual unsigned int getMaxPacketSize() 105 105 {return 4 * (2 + getSytInterval() * m_dimension);}; 106 virtual unsigned int getAveragePacketSize(); 106 107 virtual unsigned int getEventsPerFrame() 107 108 { return m_dimension; }; branches/libffado-2.0/src/libstreaming/generic/StreamProcessor.cpp
r1293 r1344 146 146 StreamProcessor::getNominalPacketsNeeded(unsigned int nframes) 147 147 { 148 unsigned int nominal_frames_per_second 148 unsigned int nominal_frames_per_second 149 149 = m_StreamProcessorManager.getNominalRate(); 150 150 uint64_t nominal_ticks_per_frame = TICKS_PER_SECOND / nominal_frames_per_second; 151 151 uint64_t nominal_ticks = nominal_ticks_per_frame * nframes; 152 uint64_t nominal_packets = nominal_ticks / TICKS_PER_CYCLE; 152 // ensure proper ceiling 153 uint64_t nominal_packets = (nominal_ticks+TICKS_PER_CYCLE-1) / TICKS_PER_CYCLE; 153 154 return nominal_packets; 154 155 } … … 508 509 unsigned int bufferfill = m_data_buffer->getBufferFill(); 509 510 if(bufferfill >= periodsize) { 510 debugOutputExtreme(DEBUG_LEVEL_VERBOSE, "signal activity, %d>%d\n", bufferfill, periodsize); 511 SIGNAL_ACTIVITY_SPM; 512 return RAW1394_ISO_DEFER; 511 debugOutputExtreme(DEBUG_LEVEL_VERBOSE, "signal activity, %d>%d\n", 512 bufferfill, periodsize); 513 //SIGNAL_ACTIVITY_SPM; 514 return RAW1394_ISO_DEFER; // FIXME: might not be needed 513 515 } 514 516 return RAW1394_ISO_OK; branches/libffado-2.0/src/libstreaming/generic/StreamProcessor.h
r1292 r1344 289 289 virtual unsigned int getPacketsPerPeriod(); 290 290 virtual unsigned int getMaxPacketSize() = 0; 291 virtual unsigned int getAveragePacketSize() = 0; 291 292 private: 292 293 int m_channel; … … 375 376 * Returns the sync delay. This is the time a syncsource 376 377 * delays a period signal, e.g. to cope with buffering. 377 * @return the sync delay 378 * @return the sync delay (in ticks) 378 379 */ 379 380 unsigned int getSyncDelay() {return m_sync_delay;}; branches/libffado-2.0/src/libstreaming/motu/MotuReceiveStreamProcessor.cpp
r1235 r1344 96 96 97 97 unsigned int 98 MotuReceiveStreamProcessor::getAveragePacketSize() 99 { 100 // in one second we have 8000 packets 101 // containing FRAMERATE frames 102 // so on average bytes/packet: (8000 packet headers + FRAMERATE * frame_size) / 8000 103 #warning FIXME 104 int framerate = m_Parent.getDeviceManager().getStreamProcessorManager().getNominalRate(); 105 return framerate<=48000?616:(framerate<=96000?1032:1160); 106 } 107 108 unsigned int 98 109 MotuReceiveStreamProcessor::getNominalFramesPerPacket() { 99 110 int framerate = m_Parent.getDeviceManager().getStreamProcessorManager().getNominalRate(); branches/libffado-2.0/src/libstreaming/motu/MotuReceiveStreamProcessor.h
r1035 r1344 152 152 {return m_event_size;}; 153 153 virtual unsigned int getMaxPacketSize(); 154 virtual unsigned int getAveragePacketSize(); 154 155 virtual unsigned int getEventsPerFrame() 155 156 { return 1; }; // FIXME: check branches/libffado-2.0/src/libstreaming/motu/MotuTransmitStreamProcessor.cpp
r1235 r1344 81 81 82 82 unsigned int 83 MotuTransmitStreamProcessor::getAveragePacketSize() 84 { 85 // in one second we have 8000 packets 86 // containing FRAMERATE frames 87 // so on average bytes/packet: (8000 packet headers + FRAMERATE * frame_size) / 8000 88 #warning FIXME 89 int framerate = m_Parent.getDeviceManager().getStreamProcessorManager().getNominalRate(); 90 return framerate<=48000?616:(framerate<=96000?1032:1160); 91 } 92 93 unsigned int 83 94 MotuTransmitStreamProcessor::getNominalFramesPerPacket() { 84 95 int framerate = m_Parent.getDeviceManager().getStreamProcessorManager().getNominalRate(); branches/libffado-2.0/src/libstreaming/motu/MotuTransmitStreamProcessor.h
r1034 r1344 76 76 {return m_event_size;}; 77 77 virtual unsigned int getMaxPacketSize(); 78 virtual unsigned int getAveragePacketSize(); 78 79 virtual unsigned int getEventsPerFrame() 79 80 { return 1; }; // FIXME: check branches/libffado-2.0/src/libstreaming/StreamProcessorManager.cpp
r1292 r1344 476 476 // DLL to have a decent sync (FIXME: does the DLL get updated when dry-running)? 477 477 debugOutput( DEBUG_LEVEL_VERBOSE, "Waiting for sync...\n"); 478 478 479 479 unsigned int nb_sync_runs = (STREAMPROCESSORMANAGER_SYNC_WAIT_TIME_MSEC * getNominalRate()); 480 480 nb_sync_runs /= 1000; … … 929 929 bool xrun_occurred = false; 930 930 bool in_error = false; 931 bool period_not_ready = true;932 931 933 932 // grab the wait lock 934 933 // this ensures that bus reset handling doesn't interfere 935 934 Util::MutexLockHelper lock(*m_WaitLock); 936 935 debugOutputExtreme(DEBUG_LEVEL_VERBOSE, 936 "waiting for period (%d frames in buffer)...\n", 937 m_SyncSource->getBufferFill()); 938 uint64_t ticks_at_period = m_SyncSource->getTimeAtPeriod(); 939 uint64_t ticks_at_period_margin = ticks_at_period + m_SyncSource->getSyncDelay(); 940 uint64_t pred_system_time_at_xfer = m_SyncSource->getParent().get1394Service().getSystemTimeForCycleTimerTicks(ticks_at_period_margin); 941 942 #ifdef DEBUG 943 int64_t now = Util::SystemTimeSource::getCurrentTime(); 944 debugOutputExtreme(DEBUG_LEVEL_VERBOSE, "pred: %lld, now: %lld, wait: %lld\n", pred_system_time_at_xfer, now, pred_system_time_at_xfer-now ); 945 #endif 946 947 // wait until it's time to transfer 948 Util::SystemTimeSource::SleepUsecAbsolute(pred_system_time_at_xfer); 949 950 #ifdef DEBUG 951 now = Util::SystemTimeSource::getCurrentTime(); 952 debugOutputExtreme(DEBUG_LEVEL_VERBOSE, "pred: %lld now: %lld, excess: %lld\n", pred_system_time_at_xfer, now, now-pred_system_time_at_xfer ); 953 #endif 954 955 // the period should be ready now 956 957 // HACK: we force wait until every SP is ready. this is needed 958 // since the raw1394 interface provides no control over interrupts 959 // resulting in very bad predictability on when the data is present. 960 bool period_not_ready = true; 937 961 while(period_not_ready) { 938 debugOutputExtreme(DEBUG_LEVEL_VERBOSE,939 "waiting for period (%d frames in buffer)...\n",940 m_SyncSource->getBufferFill());941 942 // wait for something to happen943 switch(waitForActivity()) {944 case eAR_Error:945 debugError("Error while waiting for activity\n");946 m_shutdown_needed = true;947 return false;948 case eAR_Interrupted:949 // FIXME: what to do here?950 debugWarning("Interrupted while waiting for activity\n");951 break;952 case eAR_Timeout:953 debugWarning("Timeout while waiting for activity\n");954 // ignore this since it can also be due to some other hardware955 // or high-prio software that preempts us. hence only an xrun should956 // be generated (if necessary)957 case eAR_Activity:958 // do nothing959 break;960 }961 debugOutputExtreme(DEBUG_LEVEL_VERBOSE, "got activity...\n");962 963 // HACK: this should be solved more elegantly964 962 period_not_ready = false; 965 963 for ( StreamProcessorVectorIterator it = m_ReceiveProcessors.begin(); … … 979 977 } 980 978 } 981 debugOutputExtreme(DEBUG_LEVEL_VERBOSE, " period not ready? %d...\n", period_not_ready); 979 980 if (period_not_ready) { 981 debugOutput(DEBUG_LEVEL_VERBOSE, " wait extended since period not ready...\n"); 982 Util::SystemTimeSource::SleepUsecRelative(125); // one cycle 983 } 982 984 983 985 // check for underruns/errors on the ISO side, … … 1031 1033 #endif 1032 1034 1033 debugOutputExtreme( 1035 debugOutputExtreme(DEBUG_LEVEL_VERBOSE, 1034 1036 "transfer period %d at %llu ticks...\n", 1035 1037 m_nbperiods, m_time_of_transfer); … … 1037 1039 // this is to notify the client of the delay that we introduced by waiting 1038 1040 m_delayed_usecs = - m_SyncSource->getTimeUntilNextPeriodSignalUsecs(); 1039 debugOutputExtreme( DEBUG_LEVEL_VERY_VERBOSE,1041 debugOutputExtreme(DEBUG_LEVEL_VERBOSE, 1040 1042 "delayed for %d usecs...\n", 1041 1043 m_delayed_usecs);