1 /* |
1 /* |
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of "Eclipse Public License v1.0" |
5 * under the terms of "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
89 * \param soundEnabled False if the auto focus sound don't need to be played |
89 * \param soundEnabled False if the auto focus sound don't need to be played |
90 * Default value for soundEnabled is true |
90 * Default value for soundEnabled is true |
91 */ |
91 */ |
92 CxeError::Id CxeAutoFocusControlSymbian::start(bool soundEnabled) |
92 CxeError::Id CxeAutoFocusControlSymbian::start(bool soundEnabled) |
93 { |
93 { |
|
94 CX_ASSERT_ALWAYS(mAdvancedSettings); |
|
95 |
94 CX_DEBUG( ("CxeAutoFocusControlSymbian::start() <> state: %d, sound enabled: %d", |
96 CX_DEBUG( ("CxeAutoFocusControlSymbian::start() <> state: %d, sound enabled: %d", |
95 state(), soundEnabled ) ); |
97 state(), soundEnabled ) ); |
|
98 |
96 mSoundEnabled = soundEnabled; |
99 mSoundEnabled = soundEnabled; |
97 int err = KErrNone; |
100 CxeError::Id error = CxeError::None; |
98 |
101 |
99 CX_ASSERT_ALWAYS(mAdvancedSettings); |
102 if (!isFixedFocusMode(mode())) { |
100 |
103 if ( state() != CxeAutoFocusControl::InProgress && state() != CxeAutoFocusControl::Canceling ) { |
101 if ( state() != CxeAutoFocusControl::InProgress && state() != CxeAutoFocusControl::Canceling ) { |
104 CX_DEBUG(("CxeAutoFocusControlSymbian::start() calling SetAutoFocusType")); |
102 CX_DEBUG(("CxeAutoFocusControlSymbian::start() calling SetAutoFocusType")); |
105 mCancelled = false; |
103 mCancelled = false; |
106 setState(InProgress); |
104 setState(InProgress); |
107 setFocusRange(mAFRange); |
105 setFocusRange(mAFRange); |
108 setFocusType(CCamera::CCameraAdvancedSettings::EAutoFocusTypeSingle); |
106 setFocusType(CCamera::CCameraAdvancedSettings::EAutoFocusTypeSingle); |
109 } else { // AF was started earlier, can't start until it completes |
107 } else { // AF was started earlier, can't start until it completes |
110 error = CxeError::InUse; |
108 err = KErrInUse; |
111 } |
109 } |
112 } |
110 |
113 |
111 CX_DEBUG( ("CxeAutoFocusControlSymbian::start() <= err : %d", err ) ); |
114 CX_DEBUG( ("CxeAutoFocusControlSymbian::start() <= error: %d", error ) ); |
112 return CxeErrorHandlingSymbian::map(err); |
115 return error; |
113 } |
116 } |
114 |
117 |
115 |
118 |
116 |
119 |
117 /* |
120 /* |
121 { |
124 { |
122 CX_DEBUG( ("CxeAutoFocusControlSymbian::cancel <> state: %d", state() ) ); |
125 CX_DEBUG( ("CxeAutoFocusControlSymbian::cancel <> state: %d", state() ) ); |
123 |
126 |
124 CX_DEBUG_ASSERT(mAdvancedSettings); |
127 CX_DEBUG_ASSERT(mAdvancedSettings); |
125 |
128 |
126 if (!mCancelled) { |
129 if (!mCancelled && !isFixedFocusMode(mode())) { |
127 if (state() == CxeAutoFocusControl::InProgress) { |
130 if (state() == CxeAutoFocusControl::InProgress) { |
128 // Need to stop current AF first. Wait for AF event to proceed. |
131 // Need to stop current AF first. Wait for AF event to proceed. |
129 setState(CxeAutoFocusControl::Canceling); |
132 setState(CxeAutoFocusControl::Canceling); |
130 setFocusType(CCamera::CCameraAdvancedSettings::EAutoFocusTypeOff); |
133 setFocusType(CCamera::CCameraAdvancedSettings::EAutoFocusTypeOff); |
131 |
134 |
169 CxeAutoFocusControl::Mode CxeAutoFocusControlSymbian::mode() const |
172 CxeAutoFocusControl::Mode CxeAutoFocusControlSymbian::mode() const |
170 { |
173 { |
171 return mAfMode; |
174 return mAfMode; |
172 } |
175 } |
173 |
176 |
|
177 /** |
|
178 * Is the given mode a fixed focus mode? |
|
179 */ |
|
180 bool CxeAutoFocusControlSymbian::isFixedFocusMode(CxeAutoFocusControl::Mode mode) const |
|
181 { |
|
182 return (mode == CxeAutoFocusControl::Hyperfocal |
|
183 || mode == CxeAutoFocusControl::Infinity); |
|
184 } |
174 |
185 |
175 /* |
186 /* |
176 * To check if Autofocus is supported |
187 * To check if Autofocus is supported |
177 */ |
188 */ |
178 bool CxeAutoFocusControlSymbian::supported() const |
189 bool CxeAutoFocusControlSymbian::supported() const |
387 // whenever scene mode is changed we set the state to unknown |
398 // whenever scene mode is changed we set the state to unknown |
388 setState(CxeAutoFocusControl::Unknown); |
399 setState(CxeAutoFocusControl::Unknown); |
389 |
400 |
390 // we are interested only in the AF range. |
401 // we are interested only in the AF range. |
391 if(scene.contains(CxeSettingIds::FOCAL_RANGE) && supported() ) { |
402 if(scene.contains(CxeSettingIds::FOCAL_RANGE) && supported() ) { |
|
403 |
392 setMode(static_cast<CxeAutoFocusControl::Mode>(scene[CxeSettingIds::FOCAL_RANGE].toInt())); |
404 setMode(static_cast<CxeAutoFocusControl::Mode>(scene[CxeSettingIds::FOCAL_RANGE].toInt())); |
|
405 |
|
406 if (isFixedFocusMode(mode())) { |
|
407 // Focus now if a fixed focus mode is used. |
|
408 setFocusType(CCamera::CCameraAdvancedSettings::EAutoFocusTypeSingle); |
|
409 // Set state to InProgress, so we know to set it ready in ECAM callback. |
|
410 setState(CxeAutoFocusControl::InProgress); |
|
411 } |
393 } |
412 } |
394 |
413 |
395 CX_DEBUG_EXIT_FUNCTION(); |
414 CX_DEBUG_EXIT_FUNCTION(); |
396 } |
415 } |
397 |
416 |