Changeset 723
- Timestamp:
- 11/25/07 05:42:51 (16 years ago)
- Files:
-
- branches/ppalmers-streaming/src/dice/dice_avdevice.cpp (modified) (1 diff)
- branches/ppalmers-streaming/src/libstreaming/generic/StreamProcessor.cpp (modified) (8 diffs)
- branches/ppalmers-streaming/src/libstreaming/generic/StreamProcessor.h (modified) (1 diff)
- branches/ppalmers-streaming/src/libstreaming/StreamProcessorManager.cpp (modified) (4 diffs)
- branches/ppalmers-streaming/src/libstreaming/util/IsoHandlerManager.cpp (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/ppalmers-streaming/src/dice/dice_avdevice.cpp
r722 r723 448 448 DiceAvDevice::prepare() { 449 449 // prepare receive SP's 450 // for (unsigned int i=0;i<m_nb_tx;i++) { 451 for (unsigned int i=0;i<1;i++) { 450 for (unsigned int i=0;i<m_nb_tx;i++) { 452 451 fb_quadlet_t nb_audio; 453 452 fb_quadlet_t nb_midi; branches/ppalmers-streaming/src/libstreaming/generic/StreamProcessor.cpp
r722 r723 193 193 unsigned char channel, unsigned char tag, unsigned char sy, 194 194 unsigned int cycle, unsigned int dropped) { 195 if(m_last_cycle == -1) { 196 debugOutput(DEBUG_LEVEL_VERBOSE, "Handler for %s SP %p is alive (cycle = %u)\n", getTypeString(), this, cycle); 197 } 198 195 199 int dropped_cycles = 0; 196 200 if (m_last_cycle != (int)cycle && m_last_cycle != -1) { … … 201 205 m_dropped += dropped_cycles; 202 206 } 203 m_last_cycle = cycle;204 }207 } 208 m_last_cycle = cycle; 205 209 206 210 // bypass based upon state … … 303 307 debugWarning("(%p) Correcting timestamp for dropped cycles, discarding packet...\n", this); 304 308 m_data_buffer->setBufferTailTimestamp(m_last_timestamp); 305 306 // this is an xrun situation 307 m_in_xrun = true; 308 debugOutput(DEBUG_LEVEL_VERBOSE, "Should update state to WaitingForStreamDisable due to dropped packet xrun\n"); 309 m_cycle_to_switch_state = cycle + 1; // switch in the next cycle 310 m_next_state = ePS_WaitingForStreamDisable; 311 // execute the requested change 312 if (!updateState()) { // we are allowed to change the state directly 313 debugError("Could not update state!\n"); 314 return RAW1394_ISO_ERROR; 315 } 316 return RAW1394_ISO_DEFER; 309 if (m_state == ePS_Running) { 310 // this is an xrun situation 311 m_in_xrun = true; 312 debugOutput(DEBUG_LEVEL_VERBOSE, "Should update state to WaitingForStreamDisable due to dropped packet xrun\n"); 313 m_cycle_to_switch_state = cycle + 1; // switch in the next cycle 314 m_next_state = ePS_WaitingForStreamDisable; 315 // execute the requested change 316 if (!updateState()) { // we are allowed to change the state directly 317 debugError("Could not update state!\n"); 318 return RAW1394_ISO_ERROR; 319 } 320 return RAW1394_ISO_DEFER; 321 } 317 322 } 318 323 … … 363 368 } 364 369 370 if(m_last_cycle == -1) { 371 debugOutput(DEBUG_LEVEL_VERBOSE, "Handler for %s SP %p is alive (cycle = %d)\n", getTypeString(), this, cycle); 372 } 373 365 374 int dropped_cycles = 0; 366 375 if (m_last_cycle != cycle && m_last_cycle != -1) { … … 371 380 m_dropped += dropped_cycles; 372 381 } 382 } 383 if (cycle > 0) { 373 384 m_last_cycle = cycle; 374 385 } … … 507 518 return RAW1394_ISO_ERROR; 508 519 } 509 } else if ( result == eCRV_EmptyPacket) {520 } else if ((result == eCRV_EmptyPacket) || (result == eCRV_Again)) { 510 521 if(m_state != m_next_state) { 511 522 debugOutput(DEBUG_LEVEL_VERBOSE, "Should update state from %s to %s\n", … … 518 529 } 519 530 goto send_empty_packet; 520 } else if (result == eCRV_Again) {521 debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "have to retry cycle %d\n", cycle);522 if(m_state != m_next_state) {523 debugOutput(DEBUG_LEVEL_VERBOSE, "Should update state from %s to %s\n",524 ePSToString(m_state), ePSToString(m_next_state));525 // execute the requested change526 if (!updateState()) { // we are allowed to change the state directly527 debugError("Could not update state!\n");528 return RAW1394_ISO_ERROR;529 }530 }531 // force some delay532 usleep(125);533 return RAW1394_ISO_AGAIN;531 // } else if (result == eCRV_Again) { 532 // debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "have to retry cycle %d\n", cycle); 533 // if(m_state != m_next_state) { 534 // debugOutput(DEBUG_LEVEL_VERBOSE, "Should update state from %s to %s\n", 535 // ePSToString(m_state), ePSToString(m_next_state)); 536 // // execute the requested change 537 // if (!updateState()) { // we are allowed to change the state directly 538 // debugError("Could not update state!\n"); 539 // return RAW1394_ISO_ERROR; 540 // } 541 // } 542 // // force some delay 543 // usleep(125); 544 // return RAW1394_ISO_AGAIN; 534 545 } else { 535 546 debugError("Invalid return value: %d\n", result); … … 1361 1372 StreamProcessor::dumpInfo() 1362 1373 { 1363 debugOutputShort( DEBUG_LEVEL_NORMAL, " StreamProcessor information\n");1374 debugOutputShort( DEBUG_LEVEL_NORMAL, " StreamProcessor %p information\n", this); 1364 1375 debugOutputShort( DEBUG_LEVEL_NORMAL, " Iso stream info:\n"); 1365 1376 branches/ppalmers-streaming/src/libstreaming/generic/StreamProcessor.h
r722 r723 384 384 virtual void dumpInfo(); 385 385 virtual void setVerboseLevel(int l); 386 const char *getStateString() 387 {return ePSToString(getState());}; 388 const char *getTypeString() 389 {return ePTToString(getType());}; 386 390 StreamStatistics m_PacketStat; 387 391 StreamStatistics m_PeriodStat; branches/ppalmers-streaming/src/libstreaming/StreamProcessorManager.cpp
r722 r723 241 241 242 242 bool StreamProcessorManager::startDryRunning() { 243 debugOutput( DEBUG_LEVEL_VERBOSE, "Waiting for StreamProcessor streams to start dry-running...\n"); 243 debugOutput( DEBUG_LEVEL_VERBOSE, "Putting StreamProcessor streams into dry-running state...\n"); 244 debugOutput( DEBUG_LEVEL_VERBOSE, " Schedule start dry-running...\n"); 244 245 for ( StreamProcessorVectorIterator it = m_ReceiveProcessors.begin(); 245 246 it != m_ReceiveProcessors.end(); 246 247 ++it ) { 247 248 if (!(*it)->isDryRunning()) { 248 if(!(*it)->s tartDryRunning(-1)) {249 if(!(*it)->scheduleStartDryRunning(-1)) { 249 250 debugError("Could not put SP %p into the dry-running state\n", *it); 250 251 return false; 251 252 } 253 } else { 254 debugOutput( DEBUG_LEVEL_VERBOSE, " SP %p already dry-running...\n", *it); 252 255 } 253 256 } … … 256 259 ++it ) { 257 260 if (!(*it)->isDryRunning()) { 258 if(!(*it)->s tartDryRunning(-1)) {261 if(!(*it)->scheduleStartDryRunning(-1)) { 259 262 debugError("Could not put SP %p into the dry-running state\n", *it); 260 263 return false; 261 264 } 262 } 265 } else { 266 debugOutput( DEBUG_LEVEL_VERBOSE, " SP %p already dry-running...\n", *it); 267 } 268 } 269 debugOutput( DEBUG_LEVEL_VERBOSE, " Waiting for all SP's to be dry-running...\n"); 270 // wait for the syncsource to start running. 271 // that will block the waitForPeriod call until everyone has started (theoretically) 272 #define CYCLES_FOR_DRYRUN 40000 273 int cnt = CYCLES_FOR_DRYRUN; // by then it should have started 274 bool all_dry_running = false; 275 while (!all_dry_running && cnt) { 276 all_dry_running = true; 277 for ( StreamProcessorVectorIterator it = m_ReceiveProcessors.begin(); 278 it != m_ReceiveProcessors.end(); 279 ++it ) { 280 all_dry_running &= (*it)->isDryRunning(); 281 } 282 for ( StreamProcessorVectorIterator it = m_TransmitProcessors.begin(); 283 it != m_TransmitProcessors.end(); 284 ++it ) { 285 all_dry_running &= (*it)->isDryRunning(); 286 } 287 288 usleep(125); 289 cnt--; 290 } 291 if(cnt==0) { 292 debugOutput(DEBUG_LEVEL_VERBOSE, " Timeout waiting for the SP's to start dry-running\n"); 293 for ( StreamProcessorVectorIterator it = m_ReceiveProcessors.begin(); 294 it != m_ReceiveProcessors.end(); 295 ++it ) { 296 debugOutput( DEBUG_LEVEL_VERBOSE, " %s SP %p has state %s\n", 297 (*it)->getTypeString(), *it, (*it)->getStateString()); 298 } 299 for ( StreamProcessorVectorIterator it = m_TransmitProcessors.begin(); 300 it != m_TransmitProcessors.end(); 301 ++it ) { 302 debugOutput( DEBUG_LEVEL_VERBOSE, " %s SP %p has state %s\n", 303 (*it)->getTypeString(), *it, (*it)->getStateString()); 304 } 305 return false; 263 306 } 264 307 debugOutput( DEBUG_LEVEL_VERBOSE, " StreamProcessor streams dry-running...\n"); … … 330 373 (unsigned int)TICKS_TO_OFFSET(time_of_first_sample)); 331 374 332 #define CYCLES_FOR_STARTUP 200 375 #define CYCLES_FOR_STARTUP 2000 333 376 // start wet-running in CYCLES_FOR_STARTUP cycles 334 377 // this is the time window we have to setup all SP's such that they … … 399 442 return false; 400 443 } 444 445 // now align the received streams 446 debugOutput( DEBUG_LEVEL_VERBOSE, " Aligning incoming streams...\n"); 447 448 401 449 debugOutput( DEBUG_LEVEL_VERBOSE, " StreamProcessor streams running...\n"); 402 450 return true; branches/ppalmers-streaming/src/libstreaming/util/IsoHandlerManager.cpp
r722 r723 48 48 IsoHandlerManager::IsoHandlerManager(bool run_rt, unsigned int rt_prio) : 49 49 m_State(E_Created), 50 m_poll_timeout(1 ), m_poll_fds(0), m_poll_nfds(0),50 m_poll_timeout(100), m_poll_fds(0), m_poll_nfds(0), 51 51 m_realtime(run_rt), m_priority(rt_prio), m_xmit_nb_periods( 1 ) 52 52 { … … 131 131 int err; 132 132 int i=0; 133 debugOutput( DEBUG_LEVEL_VERY_VERBOSE, " enter...\n");133 debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "poll %d fd's, timeout = %dms...\n", m_poll_nfds, m_poll_timeout); 134 134 135 135 err = poll (m_poll_fds, m_poll_nfds, m_poll_timeout); … … 143 143 } 144 144 145 // #ifdef DEBUG 146 // for (i = 0; i < m_poll_nfds; i++) { 147 // IsoHandler *s = m_IsoHandlers.at(i); 148 // assert(s); 149 // debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "(%d) handler %p: iterate? %d, revents: %08X\n", 150 // i, s, (m_poll_fds[i].revents & (POLLIN) == 1), m_poll_fds[i].revents); 151 // } 152 // #endif 153 145 154 for (i = 0; i < m_poll_nfds; i++) { 146 155 if (m_poll_fds[i].revents & POLLERR) { … … 153 162 154 163 if(m_poll_fds[i].revents & (POLLIN)) { 155 IsoHandler *s =m_IsoHandlers.at(i);164 IsoHandler *s = m_IsoHandlers.at(i); 156 165 assert(s); 157 158 166 s->iterate(); 159 167 } … … 306 314 if (stream->getStreamType()==IsoStream::eST_Receive) { 307 315 // setup the optimal parameters for the raw1394 ISO buffering 308 unsigned int packets_per_period =stream->getPacketsPerPeriod();316 unsigned int packets_per_period = stream->getPacketsPerPeriod(); 309 317 310 318 #if 1 … … 317 325 unsigned int max_packet_size=(MINIMUM_INTERRUPTS_PER_PERIOD * getpagesize()) / packets_per_period; 318 326 if (max_packet_size < stream->getMaxPacketSize()) { 319 max_packet_size=stream->getMaxPacketSize(); 327 debugWarning("calculated max packet size (%u) < stream max packet size (%u)\n", 328 max_packet_size ,(unsigned int)stream->getMaxPacketSize()); 329 max_packet_size = stream->getMaxPacketSize(); 320 330 } 321 331 322 332 // Ensure we don't request a packet size bigger than the 323 333 // kernel-enforced maximum which is currently 1 page. 324 if (max_packet_size > (unsigned int)getpagesize()) 325 max_packet_size = getpagesize(); 326 327 unsigned int irq_interval=packets_per_period / MINIMUM_INTERRUPTS_PER_PERIOD; 334 if (max_packet_size > (unsigned int)getpagesize()) { 335 debugWarning("max packet size (%u) > page size (%u)\n", max_packet_size ,(unsigned int)getpagesize()); 336 max_packet_size = getpagesize(); 337 } 338 339 unsigned int irq_interval = packets_per_period / MINIMUM_INTERRUPTS_PER_PERIOD; 328 340 if(irq_interval <= 0) irq_interval=1; 329 341 // FIXME: test 330 irq_interval=1; 331 #warning Using fixed irq_interval 342 //irq_interval=1; 332 343 333 344 #else