Bug 804741 - close our recorder output file handle because recorder dup()s it. r=mwu

This commit is contained in:
Mike Habicher 2012-10-29 16:16:42 -07:00
parent f2f61487b3
commit ff87bb2f7d

View File

@ -28,6 +28,7 @@
#include "jsapi.h"
#include "nsThread.h"
#include <media/MediaProfiles.h>
#include "mozilla/FileUtils.h"
#include "nsDirectoryServiceDefs.h" // for NS_GetSpecialDirectory
#include "nsPrintfCString.h"
#include "DOMCameraManager.h"
@ -734,20 +735,17 @@ nsGonkCameraControl::StartRecordingImpl(StartRecordingTask* aStartRecording)
filename->GetNativePath(nativeFilename);
DOM_CAMERA_LOGI("Video filename is '%s'\n", nativeFilename.get());
int fd = open(nativeFilename.get(), O_RDWR | O_CREAT, 0644);
ScopedClose fd(open(nativeFilename.get(), O_RDWR | O_CREAT, 0644));
if (fd < 0) {
DOM_CAMERA_LOGE("Couldn't create file '%s': (%d) %s\n", nativeFilename.get(), errno, strerror(errno));
return NS_ERROR_FAILURE;
}
if (SetupRecording(fd) != NS_OK) {
DOM_CAMERA_LOGE("SetupRecording() failed\n");
close(fd);
return NS_ERROR_FAILURE;
}
nsresult rv = SetupRecording(fd);
NS_ENSURE_SUCCESS(rv, rv);
if (mRecorder->start() != OK) {
DOM_CAMERA_LOGE("mRecorder->start() failed\n");
close(fd);
return NS_ERROR_FAILURE;
}