# HG changeset patch # User reimar # Date 1388503875 0 # Node ID 9824daf4a867513ca3d4541196039dbffc0cbc44 # Parent 273702710048ab26fb637a744aca343eed811c62 Simpler/more robust cleanup code. diff -r 273702710048 -r 9824daf4a867 libao2/ao_sndio.c --- a/libao2/ao_sndio.c Tue Dec 31 15:31:09 2013 +0000 +++ b/libao2/ao_sndio.c Tue Dec 31 15:31:15 2013 +0000 @@ -112,20 +112,20 @@ par.round = par.rate * 10 / 1000; /* 10ms block size */ if (!sio_setpar(hdl, &par)) { mp_msg(MSGT_AO, MSGL_ERR, "ao2: couldn't set params\n"); - goto bad_close; + goto err_out; } if (!sio_getpar(hdl, &par)) { mp_msg(MSGT_AO, MSGL_ERR, "ao2: couldn't get params\n"); - goto bad_close; + goto err_out; } if (par.bps != SIO_BPS(par.bits)) { mp_msg(MSGT_AO, MSGL_ERR, "ao2: unsupported format\n"); - goto bad_close; + goto err_out; } pfds = calloc(sio_nfds(hdl), sizeof(*pfds)); if (pfds == NULL) { mp_msg(MSGT_AO, MSGL_ERR, "ao2: couldn't allocate poll fds\n"); - goto bad_close; + goto err_out; } bpf = par.bps * par.pchan; ao_data.format = af_bits2fmt(8 * par.bps); @@ -147,13 +147,12 @@ delay = 0; if (!sio_start(hdl)) { mp_msg(MSGT_AO, MSGL_ERR, "ao2: init: couldn't start\n"); - goto bad_free; + goto err_out; } return 1; -bad_free: +err_out: free(pfds); pfds = NULL; -bad_close: sio_close(hdl); hdl = NULL; return 0; @@ -166,8 +165,9 @@ { if (hdl) sio_close(hdl); - if (pfds) - free(pfds); + hdl = NULL; + free(pfds); + pfds = NULL; } /*