Ticket #5151: programs_mythtranscode_mpeg2fix.cpp-check-ring_write.patch

File programs_mythtranscode_mpeg2fix.cpp-check-ring_write.patch, 1.2 KB (added by Erik Hovland <erik@…>, 12 years ago)

check ring_write for error

  • programs/mythtranscode/mpeg2fix.cpp

    ring_write can return less then zero as an error condition. It should always
    
    From: Erik Hovland <erik@hovland.org>
    
    be checked and either reported or acted on.
    ---
    
     programs/mythtranscode/mpeg2fix.cpp |   14 ++++++++++++--
     1 files changed, 12 insertions(+), 2 deletions(-)
    
    diff --git a/programs/mythtranscode/mpeg2fix.cpp b/programs/mythtranscode/mpeg2fix.cpp
    index 9ae8d78..3df1865 100644
    a b int MPEG2fixup::AddFrame(MPEG2frame *f) 
    696696        FrameInfo(f);
    697697    }
    698698
    699     ring_write(rb, f->pkt.data, f->pkt.size);
    700     ring_write(rbi, (uint8_t *)&iu, sizeof(index_unit));
     699    if (ring_write(rb, f->pkt.data, f->pkt.size)<0){
     700        pthread_mutex_unlock( &rx.mutex );
     701        VERBOSE(MPF_IMPORTANT,
     702                QString("Ring buffer overflow %1\n").arg(rb->size));
     703        return 1;
     704    }
     705    if (ring_write(rbi, (uint8_t *)&iu, sizeof(index_unit))<0){
     706        pthread_mutex_unlock( &rx.mutex );
     707        VERBOSE(MPF_IMPORTANT,
     708                QString("Ring buffer overflow %1\n").arg(rbi->size));
     709        return 1;
     710    }
    701711    pthread_mutex_unlock(&rx.mutex);
    702712    last_written_pos = f->pkt.pos;
    703713    return 0;