Revision 76c2662b

View differences:

libavdevice/vfwcap.c
285 285
                      (LPARAM) videostream_cb);
286 286
    if(!ret) {
287 287
        av_log(s, AV_LOG_ERROR, "Could not set video stream callback.\n");
288
        vfw_read_close(s);
289
        return AVERROR_IO;
288
        goto fail_io;
290 289
    }
291 290

  
292 291
    SetWindowLongPtr(ctx->hwnd, GWLP_USERDATA, (LONG_PTR) ctx);
......
300 299
    /* Set video format */
301 300
    bisize = SendMessage(ctx->hwnd, WM_CAP_GET_VIDEOFORMAT, 0, 0);
302 301
    if(!bisize) {
303
        vfw_read_close(s);
304
        return AVERROR_IO;
302
        goto fail_io;
305 303
    }
306 304
    bi = av_malloc(bisize);
307 305
    if(!bi) {
......
311 309
    ret = SendMessage(ctx->hwnd, WM_CAP_GET_VIDEOFORMAT, bisize, (LPARAM) bi);
312 310
    if(!ret) {
313 311
        av_free(bi);
314
        vfw_read_close(s);
315
        return AVERROR_IO;
312
        goto fail_io;
316 313
    }
317 314

  
318 315
    dump_bih(s, &bi->bmiHeader);
......
326 323
    if(!ret) {
327 324
        av_log(s, AV_LOG_ERROR, "Could not set Video Format.\n");
328 325
        av_free(bi);
329
        vfw_read_close(s);
330
        return AVERROR_IO;
326
        goto fail_io;
331 327
    }
332 328

  
333 329
    biCompression = bi->bmiHeader.biCompression;
......
339 335
    ret = SendMessage(ctx->hwnd, WM_CAP_GET_SEQUENCE_SETUP, sizeof(cparms),
340 336
                      (LPARAM) &cparms);
341 337
    if(!ret) {
342
        vfw_read_close(s);
343
        return AVERROR_IO;
338
        goto fail_io;
344 339
    }
345 340

  
346 341
    dump_captureparms(s, &cparms);
......
356 351
    ret = SendMessage(ctx->hwnd, WM_CAP_SET_SEQUENCE_SETUP, sizeof(cparms),
357 352
                      (LPARAM) &cparms);
358 353
    if(!ret) {
359
        vfw_read_close(s);
360
        return AVERROR_IO;
354
        goto fail_io;
361 355
    }
362 356

  
363 357
    codec = st->codec;
......
382 376
    ctx->mutex = CreateMutex(NULL, 0, NULL);
383 377
    if(!ctx->mutex) {
384 378
        av_log(s, AV_LOG_ERROR, "Could not create Mutex.\n" );
385
        vfw_read_close(s);
386
        return AVERROR_IO;
379
        goto fail_io;
387 380
    }
388 381
    ctx->event = CreateEvent(NULL, 1, 0, NULL);
389 382
    if(!ctx->event) {
390 383
        av_log(s, AV_LOG_ERROR, "Could not create Event.\n" );
391
        vfw_read_close(s);
392
        return AVERROR_IO;
384
        goto fail_io;
393 385
    }
394 386

  
395 387
    ret = SendMessage(ctx->hwnd, WM_CAP_SEQUENCE_NOFILE, 0, 0);
396 388
    if(!ret) {
397 389
        av_log(s, AV_LOG_ERROR, "Could not start capture sequence.\n" );
398
        vfw_read_close(s);
399
        return AVERROR_IO;
390
        goto fail_io;
400 391
    }
401 392

  
402 393
    return 0;
394

  
395
fail_io:
396
    vfw_read_close(s);
397
    return AVERROR_IO;
403 398
}
404 399

  
405 400
static int vfw_read_packet(AVFormatContext *s, AVPacket *pkt)

Also available in: Unified diff