diff options
author | reimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2010-07-30 18:28:02 +0000 |
---|---|---|
committer | Uoti Urpala <uau@glyph.nonexistent.invalid> | 2010-11-02 04:14:46 +0200 |
commit | 4bf28980f97fccafac77dca55a588636afaf6a5c (patch) | |
tree | d247b1fd2d5b13e413b285e38b6ae9a44bc9bb8f /libao2 | |
parent | ff1da0cb350e091b87ed6661f176a8a945aad034 (diff) | |
download | mpv-4bf28980f97fccafac77dca55a588636afaf6a5c.tar.bz2 mpv-4bf28980f97fccafac77dca55a588636afaf6a5c.tar.xz |
ao_mpegpes: Properly close file on error or uninit
Avoids failing with "device busy" e.g. when reinitializing the ao.
Fixes bug #1746.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@31871 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libao2')
-rw-r--r-- | libao2/ao_mpegpes.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/libao2/ao_mpegpes.c b/libao2/ao_mpegpes.c index 7883acbf93..83321915d9 100644 --- a/libao2/ao_mpegpes.c +++ b/libao2/ao_mpegpes.c @@ -117,25 +117,29 @@ static int init_device(int card) if( (ioctl(vo_mpegpes_fd2,AUDIO_SELECT_SOURCE, AUDIO_SOURCE_MEMORY) < 0)) { mp_msg(MSGT_VO, MSGL_ERR, "DVB AUDIO SELECT SOURCE: %s\n", strerror(errno)); - return -1; + goto fail; } if((ioctl(vo_mpegpes_fd2,AUDIO_PLAY) < 0)) { mp_msg(MSGT_VO, MSGL_ERR, "DVB AUDIO PLAY: %s\n", strerror(errno)); - return -1; + goto fail; } if((ioctl(vo_mpegpes_fd2,AUDIO_SET_AV_SYNC, true) < 0)) { mp_msg(MSGT_VO, MSGL_ERR, "DVB AUDIO SET AV SYNC: %s\n", strerror(errno)); - return -1; + goto fail; } //FIXME: in vo_mpegpes audio was initialized as MUTEd if((ioctl(vo_mpegpes_fd2,AUDIO_SET_MUTE, false) < 0)) { mp_msg(MSGT_VO, MSGL_ERR, "DVB AUDIO SET MUTE: %s\n", strerror(errno)); - return -1; + goto fail; } return vo_mpegpes_fd2; +fail: + close(vo_mpegpes_fd2); + vo_mpegpes_fd2 = -1; + return -1; } #endif @@ -272,7 +276,9 @@ static int init(int rate,int channels,int format,int flags){ // close audio device static void uninit(int immed){ - + if (vo_mpegpes_fd2 >= 0) + close(vo_mpegpes_fd2); + vo_mpegpes_fd2 = -1; } // stop playing and empty buffers (for seeking/pause) |