diff --git a/src/zm_monitorstream.cpp b/src/zm_monitorstream.cpp index 6c3f7b144..010877b90 100644 --- a/src/zm_monitorstream.cpp +++ b/src/zm_monitorstream.cpp @@ -563,14 +563,22 @@ void MonitorStream::runStream() { while ( !zm_terminate ) { bool got_command = false; if ( feof( stdout ) || ferror( stdout ) || !monitor->ShmValid() ) { + if ( feof( stdout ) ) { + Debug(2,"feof stdout"); + } else if ( ferror( stdout ) ) { + Debug(2,"ferror stdout"); + } else if ( !monitor->ShmValid() ) { + Debug(2,"monitor not valid.... maybe we should wait until it comes back."); + } break; } gettimeofday( &now, NULL ); if ( connkey ) { -Debug(2, "checking command Queue for connkey: %d", connkey ); +//Debug(2, "checking command Queue for connkey: %d", connkey ); while(checkCommandQueue()) { +Debug(2, "Have checking command Queue for connkey: %d", connkey ); got_command = true; } } @@ -659,8 +667,10 @@ Debug(2, "checking command Queue for connkey: %d", connkey ); // Send the next frame Monitor::Snapshot *snap = &monitor->image_buffer[index]; - if ( !sendFrame( snap->image, snap->timestamp ) ) + if ( !sendFrame( snap->image, snap->timestamp ) ) { + Debug(2, "sendFrame failed, quiting."); zm_terminate = true; + } memcpy( &last_frame_timestamp, snap->timestamp, sizeof(last_frame_timestamp) ); //frame_sent = true; @@ -697,9 +707,12 @@ Debug(2, "checking command Queue for connkey: %d", connkey ); } // end if buffered playback frame_count++; } + unsigned long sleep_time = (unsigned long)((1000000 * ZM_RATE_BASE)/((base_fps?base_fps:1)*abs(replay_rate*2))); + Debug(2, "Sleeping for (%d)", sleep_time); usleep( (unsigned long)((1000000 * ZM_RATE_BASE)/((base_fps?base_fps:1)*abs(replay_rate*2))) ); if ( ttl ) { if ( (now.tv_sec - stream_start_time) > ttl ) { + Debug(2, "now(%d) - start(%d) > ttl(%d) break", now.tv_sec, stream_start_time, ttl); break; } }