- Timestamp:
- 09/24/06 17:50:17 (18 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/libfreebob-2.0/src/libstreaming/MotuStreamProcessor.cpp
r307 r309 113 113 } 114 114 115 // Similarly, initialise the "next cycle". This can be done 116 // whenever iso data is seen - it doesn't have to wait until 117 // the stream is initialised. 118 if (m_next_cycle < 0) 119 m_next_cycle = cycle; 120 115 121 // Do housekeeping expected for all packets sent to the MOTU, even 116 122 // for packets containing no audio data. … … 169 175 } 170 176 171 172 if (!m_disabled) { 177 if (!m_disabled) { 173 178 if (++m_next_cycle >= 8000) 174 179 m_next_cycle -= 8000; … … 871 876 unsigned int event_size) 872 877 : ReceiveStreamProcessor(port, framerate), m_event_size(event_size), 873 m_last_cycle_ofs(-1), m_next_cycle(-1) {878 m_last_cycle_ofs(-1), m_next_cycle(-1), m_closedown_active(0) { 874 879 875 880 // Set up the Delay-locked-loop to track audio frequency relative … … 906 911 // Detect missed receive cycles 907 912 // FIXME: it would be nice to advance the rx buffer by the amount of 908 // frames missed. However, since the MOTU transmits more frames 909 // per cycle than the average and "catches up" with period emty910 // cycles it's not trivial to work out precisely how many frames911 // were missed. Ultimately we need to do so if sync is to be912 // maintainedacross a transient receive failure.913 // frames missed. However, since the MOTU transmits more frames per 914 // cycle than the average and "catches up" with periodic empty cycles 915 // it's not trivial to work out precisely how many frames were missed. 916 // Ultimately I think we need to do so if sync is to be maintained 917 // across a transient receive failure. 913 918 if (m_next_cycle < 0) 914 919 m_next_cycle = cycle; … … 919 924 have_lost_cycles = 1; 920 925 } 921 if (++m_next_cycle >= 8000) 922 m_next_cycle -= 8000; 926 if (!m_disabled) { 927 if (++m_next_cycle >= 8000) 928 m_next_cycle -= 8000; 929 } else 930 m_next_cycle = -1; 923 931 924 932 // If the packet length is 8 bytes (ie: just a CIP-like header) there is … … 983 991 } 984 992 985 // Don't process the stream when it is not enabled .993 // Don't process the stream when it is not enabled 986 994 if (m_disabled) { 987 995 return RAW1394_ISO_OK; 988 996 } 989 997 998 // If closedown is active we also just throw data way, but in this case 999 // we keep the frame counter going to prevent a false xrun detection 1000 if (m_closedown_active) { 1001 incrementFrameCounter(n_events); 1002 if (m_framecounter > (signed int)m_period) 1003 return RAW1394_ISO_DEFER; 1004 return RAW1394_ISO_OK; 1005 } 1006 990 1007 debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "put packet...\n"); 991 1008 … … 1065 1082 return false; 1066 1083 } 1084 1085 m_next_cycle = -1; 1067 1086 1068 1087 return true; … … 1185 1204 unsigned int bytes2read = m_period * m_event_size; 1186 1205 1206 // If closedown is in progress just pretend that data's been transferred 1207 // to prevent false underrun detections on the event buffer. 1208 if (m_closedown_active) 1209 return true; 1210 1187 1211 /* Read events2read bytes from the ringbuffer. 1188 1212 * First see if it can be done in one read. If so, ok. … … 1406 1430 return m_event_size; 1407 1431 } 1432 1433 bool MotuReceiveStreamProcessor::preparedForStop() { 1434 1435 // A MOTU receive stream can stop at any time. However, signify 1436 // that stopping is in progress because other streams (notably the 1437 // transmit stream) may keep going for some time and cause an 1438 // overflow in the receive buffers. If a closedown is in progress 1439 // the receive handler simply throws all incoming data away so 1440 // no buffer overflow can occur. 1441 m_closedown_active = 1; 1442 return true; 1443 } 1408 1444 1409 1445 } // end of namespace FreebobStreaming