aboutsummaryrefslogtreecommitdiffstats
path: root/libavdevice
diff options
context:
space:
mode:
authorRamiro Polla <ramiro.polla@gmail.com>2008-04-14 14:59:51 +0000
committerRamiro Polla <ramiro.polla@gmail.com>2008-04-14 14:59:51 +0000
commit76c2662b48b544f47aebc8afcfddfee4ec99d138 (patch)
tree0ae6f979a522f1fcbf1d3554500b1ce40c9e43d5 /libavdevice
parent861c63a21694e6a1c889c6fb8b98ff265ee4d67d (diff)
downloadffmpeg-76c2662b48b544f47aebc8afcfddfee4ec99d138.tar.gz
Simplify returning errors by using goto
Originally committed as revision 12818 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavdevice')
-rw-r--r--libavdevice/vfwcap.c31
1 files changed, 13 insertions, 18 deletions
diff --git a/libavdevice/vfwcap.c b/libavdevice/vfwcap.c
index 26273be75f..ababab9c84 100644
--- a/libavdevice/vfwcap.c
+++ b/libavdevice/vfwcap.c
@@ -285,8 +285,7 @@ static int vfw_read_header(AVFormatContext *s, AVFormatParameters *ap)
(LPARAM) videostream_cb);
if(!ret) {
av_log(s, AV_LOG_ERROR, "Could not set video stream callback.\n");
- vfw_read_close(s);
- return AVERROR_IO;
+ goto fail_io;
}
SetWindowLongPtr(ctx->hwnd, GWLP_USERDATA, (LONG_PTR) ctx);
@@ -300,8 +299,7 @@ static int vfw_read_header(AVFormatContext *s, AVFormatParameters *ap)
/* Set video format */
bisize = SendMessage(ctx->hwnd, WM_CAP_GET_VIDEOFORMAT, 0, 0);
if(!bisize) {
- vfw_read_close(s);
- return AVERROR_IO;
+ goto fail_io;
}
bi = av_malloc(bisize);
if(!bi) {
@@ -311,8 +309,7 @@ static int vfw_read_header(AVFormatContext *s, AVFormatParameters *ap)
ret = SendMessage(ctx->hwnd, WM_CAP_GET_VIDEOFORMAT, bisize, (LPARAM) bi);
if(!ret) {
av_free(bi);
- vfw_read_close(s);
- return AVERROR_IO;
+ goto fail_io;
}
dump_bih(s, &bi->bmiHeader);
@@ -326,8 +323,7 @@ static int vfw_read_header(AVFormatContext *s, AVFormatParameters *ap)
if(!ret) {
av_log(s, AV_LOG_ERROR, "Could not set Video Format.\n");
av_free(bi);
- vfw_read_close(s);
- return AVERROR_IO;
+ goto fail_io;
}
biCompression = bi->bmiHeader.biCompression;
@@ -339,8 +335,7 @@ static int vfw_read_header(AVFormatContext *s, AVFormatParameters *ap)
ret = SendMessage(ctx->hwnd, WM_CAP_GET_SEQUENCE_SETUP, sizeof(cparms),
(LPARAM) &cparms);
if(!ret) {
- vfw_read_close(s);
- return AVERROR_IO;
+ goto fail_io;
}
dump_captureparms(s, &cparms);
@@ -356,8 +351,7 @@ static int vfw_read_header(AVFormatContext *s, AVFormatParameters *ap)
ret = SendMessage(ctx->hwnd, WM_CAP_SET_SEQUENCE_SETUP, sizeof(cparms),
(LPARAM) &cparms);
if(!ret) {
- vfw_read_close(s);
- return AVERROR_IO;
+ goto fail_io;
}
codec = st->codec;
@@ -382,24 +376,25 @@ static int vfw_read_header(AVFormatContext *s, AVFormatParameters *ap)
ctx->mutex = CreateMutex(NULL, 0, NULL);
if(!ctx->mutex) {
av_log(s, AV_LOG_ERROR, "Could not create Mutex.\n" );
- vfw_read_close(s);
- return AVERROR_IO;
+ goto fail_io;
}
ctx->event = CreateEvent(NULL, 1, 0, NULL);
if(!ctx->event) {
av_log(s, AV_LOG_ERROR, "Could not create Event.\n" );
- vfw_read_close(s);
- return AVERROR_IO;
+ goto fail_io;
}
ret = SendMessage(ctx->hwnd, WM_CAP_SEQUENCE_NOFILE, 0, 0);
if(!ret) {
av_log(s, AV_LOG_ERROR, "Could not start capture sequence.\n" );
- vfw_read_close(s);
- return AVERROR_IO;
+ goto fail_io;
}
return 0;
+
+fail_io:
+ vfw_read_close(s);
+ return AVERROR_IO;
}
static int vfw_read_packet(AVFormatContext *s, AVPacket *pkt)