diff -Naurp dvgrab-3.0.orig/dvgrab.cc dvgrab-3.0/dvgrab.cc --- dvgrab-3.0.orig/dvgrab.cc 2007-08-06 23:00:43.000000000 -0400 +++ dvgrab-3.0/dvgrab.cc 2007-10-22 17:22:18.000000000 -0400 @@ -436,9 +436,6 @@ void DVgrab::getargs( int argc, char *ar print_version(); exit( EXIT_SUCCESS ); break; - case '-': - m_raw_pipe = true; - break; default: print_usage(); exit( EXIT_FAILURE ); @@ -447,15 +444,31 @@ void DVgrab::getargs( int argc, char *ar if ( optind < argc ) { + if ( argv[ optind ][0] == '-' ) + { + m_raw_pipe = true; + ++optind; + } + } + if ( optind < argc ) + { m_dst_file_name = argv[ optind++ ]; set_format_from_name(); } if ( optind < argc ) { - cerr << "Too many output file names." << endl; - print_usage(); - exit( EXIT_FAILURE ); + if ( argv[ optind ][0] == '-' ) + { + m_raw_pipe = true; + ++optind; + } + else + { + cerr << "Too many output file names." << endl; + print_usage(); + exit( EXIT_FAILURE ); + } } if ( m_dst_file_name == NULL && !m_raw_pipe ) diff -Naurp dvgrab-3.0.orig/filehandler.cc dvgrab-3.0/filehandler.cc --- dvgrab-3.0.orig/filehandler.cc 2007-07-28 23:47:15.000000000 -0400 +++ dvgrab-3.0/filehandler.cc 2007-10-22 17:25:53.000000000 -0400 @@ -41,6 +41,7 @@ using std::setfill; #include #include #include +#include #include "filehandler.h" #include "error.h" @@ -459,6 +460,32 @@ TimeSys: return true; } +static ssize_t writen( int fd, unsigned char *vptr, size_t n ) +{ + size_t nleft = n; + ssize_t nwritten; + unsigned char *ptr = vptr; + + while ( nleft > 0 ) + { + if ( ( nwritten = write( fd, ptr, nleft ) ) <= 0 ) + { + if ( errno == EINTR ) + { + nwritten = 0; + } + else + { + n = -1; + break; + } + } + nleft -= nwritten; + ptr += nwritten; + } + return n; +} + /***************************************************************************/ @@ -497,7 +524,7 @@ bool RawHandler::Create( const string& f int RawHandler::Write( Frame *frame ) { - int result = write( fd, frame->data, frame->GetDataLen() ); + int result = writen( fd, frame->data, frame->GetDataLen() ); return result; } @@ -1261,12 +1288,12 @@ int Mpeg2Handler::Write( Frame *frame ) // Write any buffered data first. if ( bufferLen > 0 ) { - if ( 0 > ( result = write( fd, buffer, bufferLen ) ) ) + if ( 0 > ( result = writen( fd, buffer, bufferLen ) ) ) return result; bufferLen = 0; } - result = write( fd, frame->data, frame->GetDataLen() ); + result = writen( fd, frame->data, frame->GetDataLen() ); if ( 0 <= result ) totalFrames++; diff -Naurp dvgrab-3.0.orig/ieee1394io.cc dvgrab-3.0/ieee1394io.cc --- dvgrab-3.0.orig/ieee1394io.cc 2007-07-07 03:10:12.000000000 -0400 +++ dvgrab-3.0/ieee1394io.cc 2007-10-22 17:14:52.000000000 -0400 @@ -432,14 +432,18 @@ bool iec61883Reader::Open() void iec61883Reader::Close() { - if ( m_iec61883.ref != NULL ) - { - if ( isHDV ) + if ( isHDV ) { + if ( m_iec61883.mpeg2 != NULL ) { iec61883_mpeg2_close( m_iec61883.mpeg2 ); - else + m_iec61883.mpeg2 = NULL; + } + } + else + { + if ( m_iec61883.dv != NULL ) { iec61883_dv_fb_close( m_iec61883.dv ); - - m_iec61883.dv = NULL; + m_iec61883.dv = NULL; + } } } @@ -470,9 +474,9 @@ void iec61883Reader::StopReceive() if ( m_iec61883.ref != NULL ) { if ( isHDV ) - iec61883_mpeg2_close( m_iec61883.mpeg2 ); + iec61883_mpeg2_recv_stop( m_iec61883.mpeg2 ); else - iec61883_dv_fb_close( m_iec61883.dv ); + iec61883_dv_fb_stop( m_iec61883.dv ); m_iec61883.ref = NULL; } @@ -1085,6 +1089,7 @@ void* pipeReader::Thread() pthread_mutex_lock( &mutex ); if ( currentFrame ) outFrames.push_back( currentFrame ); currentFrame = NULL; + outFrames.push_back( currentFrame ); TriggerAction( ); pthread_mutex_unlock( &mutex ); return NULL;