diff --git a/media/libmedia/IMediaRecorder.cpp b/media/libmedia/IMediaRecorder.cpp index 4eb63e8c66dad..947ff3409390b 100644 --- a/media/libmedia/IMediaRecorder.cpp +++ b/media/libmedia/IMediaRecorder.cpp @@ -23,6 +23,7 @@ #include #include #include +#include namespace android { @@ -373,6 +374,7 @@ status_t BnMediaRecorder::onTransact( int64_t offset = data.readInt64(); int64_t length = data.readInt64(); reply->writeInt32(setOutputFile(fd, offset, length)); + ::close(fd); return NO_ERROR; } break; case SET_VIDEO_SIZE: { diff --git a/media/libmediaplayerservice/StagefrightRecorder.cpp b/media/libmediaplayerservice/StagefrightRecorder.cpp index 5756e531f610e..daa20a810e631 100644 --- a/media/libmediaplayerservice/StagefrightRecorder.cpp +++ b/media/libmediaplayerservice/StagefrightRecorder.cpp @@ -56,11 +56,6 @@ StagefrightRecorder::StagefrightRecorder() StagefrightRecorder::~StagefrightRecorder() { LOGV("Destructor"); stop(); - - if (mOutputFd >= 0) { - ::close(mOutputFd); - mOutputFd = -1; - } } status_t StagefrightRecorder::init() { @@ -1158,6 +1153,11 @@ status_t StagefrightRecorder::stop() { mFlags = 0; } + if (mOutputFd >= 0) { + ::close(mOutputFd); + mOutputFd = -1; + } + return OK; }