mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 15:52:07 +00:00
Bug 825986 - propagate startRecording() return code instead of asserting; clean up GonkRecorder lifecycle management, r=kanru
This commit is contained in:
parent
12c19a8961
commit
521925ef88
@ -890,6 +890,8 @@ nsGonkCameraControl::StartRecordingImpl(StartRecordingTask* aStartRecording)
|
||||
|
||||
if (mRecorder->start() != OK) {
|
||||
DOM_CAMERA_LOGE("mRecorder->start() failed\n");
|
||||
// important: we MUST destroy the recorder if start() fails!
|
||||
mRecorder = nullptr;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
@ -929,7 +931,6 @@ nsGonkCameraControl::StopRecordingImpl(StopRecordingTask* aStopRecording)
|
||||
NS_ENSURE_TRUE(mRecorder, NS_OK);
|
||||
|
||||
mRecorder->stop();
|
||||
delete mRecorder;
|
||||
mRecorder = nullptr;
|
||||
|
||||
// notify DeviceStorage that the new video file is closed and ready
|
||||
|
@ -104,7 +104,7 @@ protected:
|
||||
uint32_t mDiscardedFrameCount;
|
||||
|
||||
android::MediaProfiles* mMediaProfiles;
|
||||
android::GonkRecorder* mRecorder;
|
||||
nsRefPtr<android::GonkRecorder> mRecorder;
|
||||
|
||||
// camcorder profile settings for the desired quality level
|
||||
nsRefPtr<GonkRecorderProfileManager> mProfileManager;
|
||||
|
@ -513,12 +513,14 @@ GonkCameraSource::~GonkCameraSource() {
|
||||
}
|
||||
}
|
||||
|
||||
void GonkCameraSource::startCameraRecording() {
|
||||
int GonkCameraSource::startCameraRecording() {
|
||||
LOGV("startCameraRecording");
|
||||
CHECK_EQ(OK, GonkCameraHardware::StartRecording(mCameraHandle));
|
||||
return GonkCameraHardware::StartRecording(mCameraHandle);
|
||||
}
|
||||
|
||||
status_t GonkCameraSource::start(MetaData *meta) {
|
||||
int rv;
|
||||
|
||||
LOGV("start");
|
||||
CHECK(!mStarted);
|
||||
if (mInitCheck != OK) {
|
||||
@ -542,10 +544,10 @@ status_t GonkCameraSource::start(MetaData *meta) {
|
||||
// Register a listener with GonkCameraHardware so that we can get callbacks
|
||||
GonkCameraHardware::SetListener(mCameraHandle, new GonkCameraSourceListener(this));
|
||||
|
||||
startCameraRecording();
|
||||
rv = startCameraRecording();
|
||||
|
||||
mStarted = true;
|
||||
return OK;
|
||||
mStarted = (rv == OK);
|
||||
return rv;
|
||||
}
|
||||
|
||||
void GonkCameraSource::stopCameraRecording() {
|
||||
|
@ -102,7 +102,7 @@ protected:
|
||||
Size videoSize, int32_t frameRate,
|
||||
bool storeMetaDataInVideoBuffers = false);
|
||||
|
||||
virtual void startCameraRecording();
|
||||
virtual int startCameraRecording();
|
||||
virtual void stopCameraRecording();
|
||||
virtual void releaseRecordingFrame(const sp<IMemory>& frame);
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright (C) 2009 The Android Open Source Project
|
||||
* Copyright (C) 2013 Mozilla Foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -15,9 +16,10 @@
|
||||
*/
|
||||
|
||||
#ifndef GONK_RECORDER_H_
|
||||
|
||||
#define GONK_RECORDER_H_
|
||||
|
||||
#include "nsISupportsImpl.h"
|
||||
|
||||
#include <media/mediarecorder.h>
|
||||
#include <camera/CameraParameters.h>
|
||||
#include <utils/String8.h>
|
||||
@ -34,8 +36,9 @@ struct AudioSource;
|
||||
class MediaProfiles;
|
||||
|
||||
struct GonkRecorder {
|
||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(GonkRecorder)
|
||||
|
||||
GonkRecorder();
|
||||
virtual ~GonkRecorder();
|
||||
|
||||
virtual status_t init();
|
||||
virtual status_t setAudioSource(audio_source_t as);
|
||||
@ -60,6 +63,9 @@ struct GonkRecorder {
|
||||
virtual status_t dump(int fd, const Vector<String16>& args) const;
|
||||
// Querying a SurfaceMediaSourcer
|
||||
|
||||
protected:
|
||||
virtual ~GonkRecorder();
|
||||
|
||||
private:
|
||||
sp<IMediaRecorderClient> mListener;
|
||||
sp<MediaWriter> mWriter;
|
||||
|
Loading…
Reference in New Issue
Block a user