From 5225ba0632e9dcf6fab562e4632ae8d6d4312959 Mon Sep 17 00:00:00 2001 From: Bao Haojun Date: Fri, 16 May 2014 13:20:19 +0800 Subject: Fix double close. This patch will fix the double close issue in SoundPool::doLoad(): status = MediaPlayer::decode(mFd, mOffset, mLength, &sampleRate, &numChannels, &format, mHeap, &mSize); ALOGV("close(%d)", mFd); ::close(mFd); mFd = -1; In MediaPlayerService::decode() which is called directly by MediaPlayer::decode(), the fd will be closed, and after it return, the mFd will be closed again. When the system is idle, the second close will fail with EBADFD, but if the system is busy, the mFd will be reused with another open/socket/pipe system call, and the second close will cause errors. Change-Id: If709515392cd490fea569658202524c51f8df785 Signed-off-by: Bao Haojun Signed-off-by: Wang Liang --- media/libmediaplayerservice/MediaPlayerService.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'media/libmediaplayerservice/MediaPlayerService.cpp') diff --git a/media/libmediaplayerservice/MediaPlayerService.cpp b/media/libmediaplayerservice/MediaPlayerService.cpp index a392b76..2fcec57 100644 --- a/media/libmediaplayerservice/MediaPlayerService.cpp +++ b/media/libmediaplayerservice/MediaPlayerService.cpp @@ -1289,7 +1289,6 @@ status_t MediaPlayerService::decode(int fd, int64_t offset, int64_t length, Exit: if (player != 0) player->reset(); - ::close(fd); return status; } -- cgit v1.1