# HG changeset patch # User reimar # Date 1390255718 0 # Node ID acf7270681040b62d5abb29af7a6c6e3ec521ced # Parent 12ed11a8df90f005e9222a932da41ea2f9aa1138 stream_pvr: reduce code duplication and fix a memleak in error case. diff -r 12ed11a8df90 -r acf727068104 stream/stream_pvr.c --- a/stream/stream_pvr.c Mon Jan 20 22:08:37 2014 +0000 +++ b/stream/stream_pvr.c Mon Jan 20 22:08:38 2014 +0000 @@ -1588,8 +1588,7 @@ { mp_msg (MSGT_OPEN, MSGL_ERR, "%s error opening device %s\n", LOG_LEVEL_PVR, pvr->video_dev); - pvr_uninit (pvr); - return STREAM_ERROR; + goto err_out; } /* query capabilities (i.e test V4L2 support) */ @@ -1598,8 +1597,7 @@ mp_msg (MSGT_OPEN, MSGL_ERR, "%s device is not V4L2 compliant (%s).\n", LOG_LEVEL_PVR, strerror (errno)); - pvr_uninit (pvr); - return STREAM_ERROR; + goto err_out; } else mp_msg (MSGT_OPEN, MSGL_INFO, @@ -1611,8 +1609,7 @@ mp_msg (MSGT_OPEN, MSGL_ERR, "%s device is not a valid V4L2 capture device.\n", LOG_LEVEL_PVR); - pvr_uninit (pvr); - return STREAM_ERROR; + goto err_out; } /* check for device hardware MPEG encoding capability */ @@ -1624,7 +1621,7 @@ { mp_msg (MSGT_OPEN, MSGL_ERR, "%s device do not support MPEG input.\n", LOG_LEVEL_ENCODER); - return STREAM_ERROR; + goto err_out; } /* list V4L2 capabilities */ @@ -1632,8 +1629,7 @@ { mp_msg (MSGT_OPEN, MSGL_ERR, "%s can't get v4l2 capabilities\n", LOG_LEVEL_PVR); - pvr_uninit (pvr); - return STREAM_ERROR; + goto err_out; } /* apply V4L2 settings */ @@ -1641,8 +1637,7 @@ { mp_msg (MSGT_OPEN, MSGL_ERR, "%s can't set v4l2 settings\n", LOG_LEVEL_PVR); - pvr_uninit (pvr); - return STREAM_ERROR; + goto err_out; } /* apply encoder settings */ @@ -1650,8 +1645,7 @@ { mp_msg (MSGT_OPEN, MSGL_ERR, "%s can't set encoder settings\n", LOG_LEVEL_PVR); - pvr_uninit (pvr); - return STREAM_ERROR; + goto err_out; } /* display current V4L2 settings */ @@ -1659,8 +1653,7 @@ { mp_msg (MSGT_OPEN, MSGL_ERR, "%s can't get v4l2 settings\n", LOG_LEVEL_PVR); - pvr_uninit (pvr); - return STREAM_ERROR; + goto err_out; } stream->priv = pvr; @@ -1669,6 +1662,10 @@ stream->close = pvr_stream_close; return STREAM_OK; + +err_out: + pvr_uninit (pvr); + return STREAM_ERROR; } /* PVR Public API access */