Changeset 309
- Timestamp:
- 09/24/06 17:50:17 (17 years ago)
- Files:
-
- branches/libfreebob-2.0/src/libstreaming/IsoHandler.cpp (modified) (5 diffs)
- branches/libfreebob-2.0/src/libstreaming/IsoHandler.h (modified) (1 diff)
- branches/libfreebob-2.0/src/libstreaming/IsoHandlerManager.cpp (modified) (2 diffs)
- branches/libfreebob-2.0/src/libstreaming/MotuStreamProcessor.cpp (modified) (9 diffs)
- branches/libfreebob-2.0/src/libstreaming/MotuStreamProcessor.h (modified) (2 diffs)
- branches/libfreebob-2.0/src/libstreaming/StreamProcessorManager.cpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/libfreebob-2.0/src/libstreaming/IsoHandler.cpp
r267 r309 81 81 82 82 IsoHandler::~IsoHandler() { 83 stop(); 84 if(m_handle) raw1394_destroy_handle(m_handle); 83 if(m_handle) { 84 stop(); 85 raw1394_destroy_handle(m_handle); 86 } 85 87 if(m_handle_util) raw1394_destroy_handle(m_handle_util); 86 88 … … 228 230 IsoRecvHandler::~IsoRecvHandler() 229 231 { 230 raw1394_iso_shutdown(m_handle); 232 // Don't call until libraw1394's raw1394_new_handle() function has been 233 // fixed to correctly initialise the iso_packet_infos field. Bug is 234 // confirmed present in libraw1394 1.2.1. In any case, 235 // raw1394_destroy_handle() will do any iso system shutdown required. 236 // raw1394_iso_shutdown(m_handle); 231 237 raw1394_destroy_handle(m_handle); 232 238 m_handle = NULL; 233 239 } 234 240 … … 263 269 bool IsoRecvHandler::prepare() 264 270 { 265 raw1394_iso_shutdown(m_handle); 271 // Don't call until libraw1394's raw1394_new_handle() function has been 272 // fixed to correctly initialise the iso_packet_infos field. Bug is 273 // confirmed present in libraw1394 1.2.1. 274 // raw1394_iso_shutdown(m_handle); 266 275 267 276 debugOutput( DEBUG_LEVEL_VERBOSE, "Preparing iso receive handler (%p)\n",this); … … 330 339 IsoXmitHandler::~IsoXmitHandler() 331 340 { 332 debugOutput( DEBUG_LEVEL_VERBOSE, "enter...\n"); 333 raw1394_iso_shutdown(m_handle); 341 // Don't call until libraw1394's raw1394_new_handle() function has been 342 // fixed to correctly initialise the iso_packet_infos field. Bug is 343 // confirmed present in libraw1394 1.2.1. In any case, 344 // raw1394_destroy_handle() will do any iso system shutdown required. 345 // raw1394_iso_shutdown(m_handle); 334 346 raw1394_destroy_handle(m_handle); 347 m_handle = NULL; 335 348 } 336 349 … … 425 438 IsoRecvHandler::~IsoRecvHandler() 426 439 { 440 // Don't call until libraw1394's raw1394_new_handle() function has been 441 // fixed to correctly initialise the iso_packet_infos field. Bug is 442 // confirmed present in libraw1394 1.2.1. In any case, 443 // raw1394_destroy_handle() (in the base class destructor) will do any iso 444 // system shutdown required. 427 445 raw1394_iso_shutdown(m_handle); 428 446 branches/libfreebob-2.0/src/libstreaming/IsoHandler.h
r244 r309 112 112 113 113 unsigned int getCycleCounter(); 114 114 115 115 protected: 116 116 raw1394handle_t m_handle; branches/libfreebob-2.0/src/libstreaming/IsoHandlerManager.cpp
r269 r309 173 173 } 174 174 } 175 176 175 debugFatal("Could not find handler (%p)\n", handler); 177 176 … … 470 469 unregisterHandler(*it); 471 470 debugOutput( DEBUG_LEVEL_VERBOSE, " deleting handler (%p)\n",*it); 471 472 // Now the handler's been unregistered it won't be reused 473 // again. Therefore it really needs to be formally deleted 474 // to free up the raw1394 handle. Otherwise things fall 475 // apart after several xrun recoveries as the system runs 476 // out of resources to support all the disused but still 477 // allocated raw1394 handles. At least this is the current 478 // theory as to why we end up with "memory allocation" 479 // failures after several Xrun recoveries. 480 delete *it; 472 481 } 473 482 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 branches/libfreebob-2.0/src/libstreaming/MotuStreamProcessor.h
r305 r309 164 164 unsigned int getEventSize(void); 165 165 166 virtual bool preparedForStop(); 167 166 168 protected: 167 169 … … 187 189 signed int m_next_cycle; 188 190 191 // Signifies a closedown is in progress, in which case incoming data 192 // is junked. 193 signed int m_closedown_active; 194 189 195 DECLARE_DEBUG_MODULE; 190 196 branches/libfreebob-2.0/src/libstreaming/StreamProcessorManager.cpp
r291 r309 357 357 358 358 debugOutput( DEBUG_LEVEL_VERBOSE, "Waiting for all StreamProcessors to start running...\n"); 359 // we have to wait until lall streamprocessors indicate that they are running359 // we have to wait until all streamprocessors indicate that they are running 360 360 // i.e. that there is actually some data stream flowing 361 361 int wait_cycles=2000; // two seconds … … 516 516 } 517 517 518 519 518 } 520 519 … … 529 528 530 529 } 531 532 530 533 531 return true;