mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 809259 - improve camera stability when switching between picture and video modes r=kanru
This commit is contained in:
parent
b0c1553fa9
commit
038e6a66bd
@ -311,15 +311,8 @@ CameraControlImpl::OnRecorderStateChange(const nsString& aStateMsg, int32_t aSta
|
||||
nsresult
|
||||
CameraControlImpl::GetPreviewStream(CameraSize aSize, nsICameraPreviewStreamCallback* onSuccess, nsICameraErrorCallback* onError)
|
||||
{
|
||||
/**
|
||||
* The camera preview stream object is DOM-facing, and as such
|
||||
* must be a cycle-collection participant created on the main
|
||||
* thread.
|
||||
*/
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
nsCOMPtr<nsIRunnable> getPreviewStreamTask = new GetPreviewStreamTask(this, aSize, onSuccess, onError);
|
||||
return NS_DispatchToCurrentThread(getPreviewStreamTask);
|
||||
return mCameraThread->Dispatch(getPreviewStreamTask, NS_DISPATCH_NORMAL);
|
||||
}
|
||||
|
||||
nsresult
|
||||
@ -387,6 +380,11 @@ CameraControlImpl::ReceiveFrame(void* aBuffer, ImageFormat aFormat, FrameBuilder
|
||||
NS_IMETHODIMP
|
||||
GetPreviewStreamResult::Run()
|
||||
{
|
||||
/**
|
||||
* The camera preview stream object is DOM-facing, and as such
|
||||
* must be a cycle-collection participant created on the main
|
||||
* thread.
|
||||
*/
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
if (mOnSuccessCb && nsDOMCameraManager::IsWindowStillActive(mWindowId)) {
|
||||
|
@ -591,9 +591,11 @@ nsGonkCameraControl::SetParameter(uint32_t aKey, int aValue)
|
||||
nsresult
|
||||
nsGonkCameraControl::GetPreviewStreamImpl(GetPreviewStreamTask* aGetPreviewStream)
|
||||
{
|
||||
SetPreviewSize(aGetPreviewStream->mSize.width, aGetPreviewStream->mSize.height);
|
||||
// stop any currently running preview
|
||||
StopPreviewInternal(true /* forced */);
|
||||
|
||||
DOM_CAMERA_LOGI("config preview: wated %d x %d, got %d x %d (%d fps, format %d)\n", aGetPreviewStream->mSize.width, aGetPreviewStream->mSize.height, mWidth, mHeight, mFps, mFormat);
|
||||
SetPreviewSize(aGetPreviewStream->mSize.width, aGetPreviewStream->mSize.height);
|
||||
DOM_CAMERA_LOGI("picture preview: wanted %d x %d, got %d x %d (%d fps, format %d)\n", aGetPreviewStream->mSize.width, aGetPreviewStream->mSize.height, mWidth, mHeight, mFps, mFormat);
|
||||
|
||||
nsCOMPtr<GetPreviewStreamResult> getPreviewStreamResult = new GetPreviewStreamResult(this, mWidth, mHeight, mFps, aGetPreviewStream->mOnSuccessCb, mWindowId);
|
||||
return NS_DispatchToMainThread(getPreviewStreamResult);
|
||||
@ -608,9 +610,7 @@ nsGonkCameraControl::StartPreviewImpl(StartPreviewTask* aStartPreview)
|
||||
* currently set DOM-facing preview object.
|
||||
*/
|
||||
if (aStartPreview->mDOMPreview) {
|
||||
if (mDOMPreview) {
|
||||
mDOMPreview->Stopped(true);
|
||||
}
|
||||
StopPreviewInternal(true /* forced */);
|
||||
mDOMPreview = aStartPreview->mDOMPreview;
|
||||
} else if (!mDOMPreview) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
@ -631,7 +631,7 @@ nsGonkCameraControl::StartPreviewImpl(StartPreviewTask* aStartPreview)
|
||||
nsresult
|
||||
nsGonkCameraControl::StopPreviewInternal(bool aForced)
|
||||
{
|
||||
DOM_CAMERA_LOGI("%s: stopping preview\n", __func__);
|
||||
DOM_CAMERA_LOGI("%s: stopping preview (mDOMPreview=%p)\n", __func__, mDOMPreview);
|
||||
|
||||
// StopPreview() is a synchronous call--it doesn't return
|
||||
// until the camera preview thread exits.
|
||||
|
@ -377,7 +377,7 @@ int
|
||||
GonkCameraHardware::StartPreview(uint32_t aHwHandle)
|
||||
{
|
||||
GonkCameraHardware* hw = GetHardware(aHwHandle);
|
||||
DOM_CAMERA_LOGI("%s:%d : aHwHandle = %d, hw = %p\n", __func__, __LINE__, aHwHandle, hw);
|
||||
DOM_CAMERA_LOGI("%s : aHwHandle = %d, hw = %p\n", __func__, aHwHandle, hw);
|
||||
if (!hw) {
|
||||
return DEAD_OBJECT;
|
||||
}
|
||||
@ -389,7 +389,12 @@ void
|
||||
GonkCameraHardware::StopPreview(uint32_t aHwHandle)
|
||||
{
|
||||
GonkCameraHardware* hw = GetHardware(aHwHandle);
|
||||
DOM_CAMERA_LOGI("%s : aHwHandle = %d, hw = %p\n", __func__, aHwHandle, hw);
|
||||
if (hw) {
|
||||
// Must disable messages first; else some drivers will silently discard
|
||||
// the stopPreview() request, which can lead to crashes and other
|
||||
// Very Bad Things that are Hard To Diagnose.
|
||||
hw->mHardware->disableMsgType(CAMERA_MSG_ALL_MSGS);
|
||||
hw->mHardware->stopPreview();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user