camerauis/cameraxui/cxengine/src/cxestillcapturecontrolsymbian.cpp
changeset 28 3075d9b614e6
parent 19 d9aefe59d544
child 38 0f0b4c1d7744
child 43 0e652f8f1fbd
equal deleted inserted replaced
19:d9aefe59d544 28:3075d9b614e6
    14 * Description:
    14 * Description:
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 
    18 
       
    19 #include <algorithm>
    19 #include <exception>
    20 #include <exception>
    20 #include <fbs.h>
    21 #include <fbs.h>
    21 #include <QPixmap>
    22 #include <QPixmap>
    22 #include <coemain.h>
    23 #include <coemain.h>
    23 #include <ECamOrientationCustomInterface2.h>
    24 #include <ECamOrientationCustomInterface2.h>
    27 #include "cxestillcapturecontrolsymbian.h"
    28 #include "cxestillcapturecontrolsymbian.h"
    28 #include "cxeimagedataqueuesymbian.h"
    29 #include "cxeimagedataqueuesymbian.h"
    29 #include "cxefilenamegenerator.h"
    30 #include "cxefilenamegenerator.h"
    30 #include "cxefilesavethread.h"
    31 #include "cxefilesavethread.h"
    31 #include "cxutils.h"
    32 #include "cxutils.h"
    32 #include "cxesysutil.h"
       
    33 #include "cxecameradevicecontrol.h"
    33 #include "cxecameradevicecontrol.h"
    34 #include "cxecameradevice.h"
    34 #include "cxecameradevice.h"
    35 #include "cxesoundplayersymbian.h"
    35 #include "cxesoundplayersymbian.h"
    36 #include "cxestillimagesymbian.h"
    36 #include "cxestillimagesymbian.h"
    37 #include "cxeviewfindercontrol.h"
    37 #include "cxeviewfindercontrol.h"
    42 #include "cxeerrormappingsymbian.h"
    42 #include "cxeerrormappingsymbian.h"
    43 #include "cxeautofocuscontrol.h"
    43 #include "cxeautofocuscontrol.h"
    44 #include "cxesensoreventhandler.h"
    44 #include "cxesensoreventhandler.h"
    45 #include "cxesensoreventhandler.h"
    45 #include "cxesensoreventhandler.h"
    46 #include "cxequalitypresetssymbian.h"
    46 #include "cxequalitypresetssymbian.h"
       
    47 #include "cxediskmonitor.h"
    47 
    48 
    48 #include "OstTraceDefinitions.h"
    49 #include "OstTraceDefinitions.h"
    49 #ifdef OST_TRACE_COMPILER_IN_USE
    50 #ifdef OST_TRACE_COMPILER_IN_USE
    50 #include "cxestillcapturecontrolsymbianTraces.h"
    51 #include "cxestillcapturecontrolsymbianTraces.h"
    51 #endif
    52 #endif
    58 
    59 
    59 /**
    60 /**
    60  * Constructor.
    61  * Constructor.
    61  */
    62  */
    62 CxeStillCaptureControlSymbian::CxeStillCaptureControlSymbian(
    63 CxeStillCaptureControlSymbian::CxeStillCaptureControlSymbian(
    63         CxeCameraDevice &cameraDevice,
    64     CxeCameraDevice &cameraDevice,
    64         CxeViewfinderControl &viewfinderControl,
    65     CxeViewfinderControl &viewfinderControl,
    65         CxeCameraDeviceControl &cameraDeviceControl,
    66     CxeCameraDeviceControl &cameraDeviceControl,
    66         CxeFilenameGenerator &nameGenerator,
    67     CxeFilenameGenerator &nameGenerator,
    67         CxeSensorEventHandler &sensorEventHandler,
    68     CxeSensorEventHandler &sensorEventHandler,
    68         CxeAutoFocusControl &autoFocusControl,
    69     CxeAutoFocusControl &autoFocusControl,
    69         CxeSettings &settings,
    70     CxeSettings &settings,
    70         CxeQualityPresets &qualityPresets,
    71     CxeQualityPresets &qualityPresets,
    71         CxeFileSaveThread &fileSaveThread)
    72     CxeFileSaveThread &fileSaveThread,
    72 : CxeStateMachine("CxeStillCaptureControlSymbian"),
    73     CxeDiskMonitor &diskMonitor)
    73   mCameraDevice(cameraDevice),
    74     : CxeStateMachine("CxeStillCaptureControlSymbian"),
    74   mViewfinderControl(viewfinderControl),
    75       mCameraDevice(cameraDevice),
    75   mCameraDeviceControl(cameraDeviceControl),
    76       mViewfinderControl(viewfinderControl),
    76   mFilenameGenerator(nameGenerator),
    77       mCameraDeviceControl(cameraDeviceControl),
    77   mSensorEventHandler(sensorEventHandler),
    78       mFilenameGenerator(nameGenerator),
    78   mAutoFocusControl(autoFocusControl),
    79       mSensorEventHandler(sensorEventHandler),
    79   mSettings(settings),
    80       mAutoFocusControl(autoFocusControl),
    80   mQualityPresets(qualityPresets),
    81       mSettings(settings),
    81   mFileSaveThread(fileSaveThread),
    82       mQualityPresets(qualityPresets),
    82   mMode(SingleImageCapture),
    83       mFileSaveThread(fileSaveThread),
    83   mAfState(CxeAutoFocusControl::Unknown)
    84       mDiskMonitor(diskMonitor),
    84 {
    85       mMode(SingleImageCapture),
    85     CX_DEBUG_ENTER_FUNCTION();
    86       mAfState(CxeAutoFocusControl::Unknown)
       
    87 {
       
    88     CX_DEBUG_ENTER_FUNCTION();
       
    89     OstTrace0(camerax_performance, CXESTILLCAPTURECONTROLSYMBIAN_CREATE_IN, "msg: e_CX_STILLCAPTURECONTROL_NEW 1");
    86 
    90 
    87     qRegisterMetaType<CxeStillCaptureControl::State>();
    91     qRegisterMetaType<CxeStillCaptureControl::State>();
    88     initializeStates();
    92     initializeStates();
    89     reset();
    93     reset();
    90 
    94 
       
    95     // If camera is already allocated, call the slot ourselves.
       
    96     if (mCameraDevice.camera()) {
       
    97         handleCameraAllocated(CxeError::None);
       
    98     }
       
    99 
       
   100     OstTrace0(camerax_performance, CXESTILLCAPTURECONTROLSYMBIAN_CREATE_MID1, "msg: e_CX_ENGINE_CONNECT_SIGNALS 1");
    91     // connect signals from cameraDevice to recieve events when camera reference changes
   101     // connect signals from cameraDevice to recieve events when camera reference changes
    92     connect(&cameraDevice, SIGNAL(prepareForCameraDelete()),
   102     connect(&cameraDevice, SIGNAL(prepareForCameraDelete()),
    93             this, SLOT(prepareForCameraDelete()));
   103             this, SLOT(prepareForCameraDelete()));
    94     connect(&cameraDevice, SIGNAL(prepareForRelease()),
   104     connect(&cameraDevice, SIGNAL(prepareForRelease()),
    95             this, SLOT(prepareForRelease()));
   105             this, SLOT(prepareForRelease()));
   108             this, SLOT(handleImageData(MCameraBuffer*,int)));
   118             this, SLOT(handleImageData(MCameraBuffer*,int)));
   109     // Connect signals for ECam events
   119     // Connect signals for ECam events
   110     connect(&mCameraDeviceControl, SIGNAL(cameraEvent(int,int)),
   120     connect(&mCameraDeviceControl, SIGNAL(cameraEvent(int,int)),
   111             this, SLOT(handleCameraEvent(int,int)));
   121             this, SLOT(handleCameraEvent(int,int)));
   112 
   122 
       
   123     OstTrace0(camerax_performance, CXESTILLCAPTURECONTROLSYMBIAN_CREATE_MID2, "msg: e_CX_ENGINE_CONNECT_SIGNALS 0");
       
   124 
   113     mImageDataQueue = new CxeImageDataQueueSymbian();
   125     mImageDataQueue = new CxeImageDataQueueSymbian();
   114     mAutoFocusSoundPlayer = new CxeSoundPlayerSymbian(CxeSoundPlayerSymbian::AutoFocus);
   126     mAutoFocusSoundPlayer = new CxeSoundPlayerSymbian(CxeSoundPlayerSymbian::AutoFocus);
   115     mCaptureSoundPlayer = new CxeSoundPlayerSymbian(CxeSoundPlayerSymbian::StillCapture);
   127     mCaptureSoundPlayer = new CxeSoundPlayerSymbian(CxeSoundPlayerSymbian::StillCapture);
   116 
   128 
       
   129     OstTrace0(camerax_performance, CXESTILLCAPTURECONTROLSYMBIAN_CREATE_OUT, "msg: e_CX_STILLCAPTURECONTROL_NEW 0");
   117     CX_DEBUG_EXIT_FUNCTION();
   130     CX_DEBUG_EXIT_FUNCTION();
   118 }
   131 }
   119 
   132 
   120 /**
   133 /**
   121  * Destructor.
   134  * Destructor.
   169  * Initialize the still image capture control.
   182  * Initialize the still image capture control.
   170  */
   183  */
   171 void CxeStillCaptureControlSymbian::init()
   184 void CxeStillCaptureControlSymbian::init()
   172 {
   185 {
   173     CX_DEBUG_ENTER_FUNCTION();
   186     CX_DEBUG_ENTER_FUNCTION();
   174     OstTrace0(camerax_performance, CXESTILLCAPTURECONTROLSYMBIAN_INIT, "msg: e_CX_STILL_CAPCONT_INIT 1");
   187     OstTrace0(camerax_performance, CXESTILLCAPTURECONTROLSYMBIAN_INIT_IN, "msg: e_CX_STILL_CAPCONT_INIT 1");
   175 
   188 
   176     if (state() == Uninitialized) {
   189     if (state() == Uninitialized) {
   177         prepare();
   190         prepare();
   178         // Initialize orientation sensor and other sensors
   191         // Initialize orientation sensor and other sensors
   179         mSensorEventHandler.init();
   192         mSensorEventHandler.init();
   180     }
   193     }
   181 
   194 
   182     OstTrace0(camerax_performance, DUP1_CXESTILLCAPTURECONTROLSYMBIAN_INIT, "msg: e_CX_STILL_CAPCONT_INIT 0");
   195     OstTrace0(camerax_performance, CXESTILLCAPTURECONTROLSYMBIAN_INIT_OUT, "msg: e_CX_STILL_CAPCONT_INIT 0");
   183     CX_DEBUG_EXIT_FUNCTION();
   196     CX_DEBUG_EXIT_FUNCTION();
   184 }
   197 }
   185 
   198 
   186 /**
   199 /**
   187  * Un-initialize the image mode.
   200  * Un-initialize the image mode.
   188  */
   201  */
   189 void CxeStillCaptureControlSymbian::deinit()
   202 void CxeStillCaptureControlSymbian::deinit()
   190 {
   203 {
   191     CX_DEBUG_ENTER_FUNCTION();
   204     CX_DEBUG_ENTER_FUNCTION();
   192     OstTrace0( camerax_performance, CXESTILLCAPTURECONTROLSYMBIAN_DEINIT, "msg: e_CX_STILL_CAPCONT_DEINIT 1" );
       
   193 
   205 
   194     if (state() == Uninitialized) {
   206     if (state() == Uninitialized) {
   195         // nothing to do
   207         // nothing to do
   196         return;
   208         return;
   197     }
   209     }
   198 
   210 
       
   211     OstTrace0( camerax_performance, CXESTILLCAPTURECONTROLSYMBIAN_DEINIT_IN, "msg: e_CX_STILL_CAPCONT_DEINIT 1" );
       
   212 
       
   213     // Stop monitoring disk space.
       
   214     mDiskMonitor.stop();
       
   215     disconnect(&mDiskMonitor, SIGNAL(diskSpaceChanged()), this, SLOT(handleDiskSpaceChanged()));
       
   216 
   199     //stop viewfinder
   217     //stop viewfinder
   200     mViewfinderControl.stop();
   218     mViewfinderControl.stop();
   201 
   219 
   202     // disable sensor event handler.
   220     // disable sensor event handler.
   203     mSensorEventHandler.deinit();
   221     mSensorEventHandler.deinit();
   209     if (state() == Capturing) {
   227     if (state() == Capturing) {
   210         mCameraDevice.camera()->CancelCaptureImage();
   228         mCameraDevice.camera()->CancelCaptureImage();
   211     }
   229     }
   212     setState(Uninitialized);
   230     setState(Uninitialized);
   213 
   231 
   214     OstTrace0( camerax_performance, DUP1_CXESTILLCAPTURECONTROLSYMBIAN_DEINIT, "msg: e_CX_STILL_CAPCONT_DEINIT 0" );
   232     OstTrace0( camerax_performance, CXESTILLCAPTURECONTROLSYMBIAN_DEINIT_OUT, "msg: e_CX_STILL_CAPCONT_DEINIT 0" );
   215     CX_DEBUG_EXIT_FUNCTION();
   233     CX_DEBUG_EXIT_FUNCTION();
   216 }
   234 }
   217 
   235 
   218 
   236 
   219 /**!
   237 /**!
   226     if (state() != Uninitialized) {
   244     if (state() != Uninitialized) {
   227         // wrong state and we return
   245         // wrong state and we return
   228         return;
   246         return;
   229     }
   247     }
   230 
   248 
   231     OstTrace0( camerax_performance, CXESTILLCAPTURECONTROLSYMBIAN_PREPARE, "msg: e_CX_STILLCAPCONT_PREPARE 1" );
   249     OstTrace0( camerax_performance, CXESTILLCAPTURECONTROLSYMBIAN_PREPARE_IN, "msg: e_CX_STILLCAPCONT_PREPARE 1" );
   232 
   250 
   233     int err = KErrNone;
   251     int err = KErrNone;
   234     CxeError::Id cxErr = getImageQualityDetails(mCurrentImageDetails);
   252     CxeError::Id cxErr = getImageQualityDetails(mCurrentImageDetails);
   235     int ecamStillResolutionIndex = 0;
   253     int ecamStillResolutionIndex = 0;
   236 
   254 
   251             ecamStillResolutionIndex = 0;
   269             ecamStillResolutionIndex = 0;
   252         }
   270         }
   253 
   271 
   254         // Prepare Image capture
   272         // Prepare Image capture
   255         CCamera::TFormat imgFormat = supportedStillFormat(mCameraDeviceControl.cameraIndex());
   273         CCamera::TFormat imgFormat = supportedStillFormat(mCameraDeviceControl.cameraIndex());
   256         OstTrace0(camerax_performance, DUP2_CXESTILLCAPTURECONTROLSYMBIAN_PREPARE, "msg: e_CX_PREPARE_IMAGE_CAPTURE 1");
   274         OstTrace0(camerax_performance, CXESTILLCAPTURECONTROLSYMBIAN_PREPARE_MID1, "msg: e_CX_PREPARE_IMAGE_CAPTURE 1");
   257         TRAP(err, mCameraDevice.camera()->PrepareImageCaptureL(imgFormat, ecamStillResolutionIndex));
   275         TRAP(err, mCameraDevice.camera()->PrepareImageCaptureL(imgFormat, ecamStillResolutionIndex));
   258         OstTrace0(camerax_performance, DUP3_CXESTILLCAPTURECONTROLSYMBIAN_PREPARE, "msg: e_CX_PREPARE_IMAGE_CAPTURE 0");
   276         OstTrace0(camerax_performance, CXESTILLCAPTURECONTROLSYMBIAN_PREPARE_MID2, "msg: e_CX_PREPARE_IMAGE_CAPTURE 0");
   259 
   277 
   260         CX_DEBUG(("PrepareImageCaptureL done, err=%d, resolution index = %d", err, ecamStillResolutionIndex));
   278         CX_DEBUG(("PrepareImageCaptureL done, err=%d, resolution index = %d", err, ecamStillResolutionIndex));
   261 
   279 
   262         if (!err) {
   280         if (!err) {
   263             // still capture prepare went fine, try preparing snapshot
   281             // still capture prepare went fine, try preparing snapshot
   266     } else {
   284     } else {
   267         err = KErrNotFound;
   285         err = KErrNotFound;
   268     }
   286     }
   269 
   287 
   270     if (!err) {
   288     if (!err) {
   271         MCameraFaceTracking *faceTracking = mCameraDevice.faceTracking();
       
   272         if (faceTracking) {
       
   273             // Enable AF reticule drawing by adaptation
       
   274             TRAP_IGNORE(faceTracking->EnableFaceIndicatorsL(ETrue));
       
   275         }
       
   276 
       
   277         // Start viewfinder before claiming to be ready,
   289         // Start viewfinder before claiming to be ready,
   278         // as e.g. pending capture might be started by state change,
   290         // as e.g. pending capture might be started by state change,
   279         // and viewfinder start might have problems with just started capturing.
   291         // and viewfinder start might have problems with just started capturing.
   280         // If viewfinder is already running, this call does nothing.
   292         // If viewfinder is already running, this call does nothing.
   281         mViewfinderControl.start();
   293         mViewfinderControl.start();
       
   294 
       
   295         // Start monitoring disk space.
       
   296         mDiskMonitor.start();
       
   297         connect(&mDiskMonitor, SIGNAL(diskSpaceChanged()), this, SLOT(handleDiskSpaceChanged()));
       
   298 
       
   299 
       
   300         // Enable AF reticule drawing by adaptation
       
   301         MCameraFaceTracking *faceTracking = mCameraDevice.faceTracking();
       
   302         if (faceTracking) {
       
   303             TRAP_IGNORE(faceTracking->EnableFaceIndicatorsL(ETrue));
       
   304         }
   282 
   305 
   283         // Still capture and still snapshot are OK.
   306         // Still capture and still snapshot are OK.
   284         // We can safely set state to READY.
   307         // We can safely set state to READY.
   285         setState(Ready);
   308         setState(Ready);
   286 
   309 
   293     }
   316     }
   294 
   317 
   295     // Inform interested parties that image mode has been prepared for capture
   318     // Inform interested parties that image mode has been prepared for capture
   296     emit imagePrepareComplete(CxeErrorHandlingSymbian::map(err));
   319     emit imagePrepareComplete(CxeErrorHandlingSymbian::map(err));
   297 
   320 
   298     OstTrace0( camerax_performance, DUP1_CXESTILLCAPTURECONTROLSYMBIAN_PREPARE, "msg: e_CX_STILLCAPCONT_PREPARE 0" );
   321     OstTrace0( camerax_performance, CXESTILLCAPTURECONTROLSYMBIAN_PREPARE_OUT, "msg: e_CX_STILLCAPCONT_PREPARE 0" );
   299 
   322 
   300     CX_DEBUG_EXIT_FUNCTION();
   323     CX_DEBUG_EXIT_FUNCTION();
   301 }
   324 }
   302 
   325 
   303 
   326 
   408 void CxeStillCaptureControlSymbian::capture()
   431 void CxeStillCaptureControlSymbian::capture()
   409 {
   432 {
   410     CX_DEBUG_ENTER_FUNCTION();
   433     CX_DEBUG_ENTER_FUNCTION();
   411     CX_ASSERT_ALWAYS(mCameraDevice.camera());
   434     CX_ASSERT_ALWAYS(mCameraDevice.camera());
   412 
   435 
   413     // Play the capture sound and start image capture
   436     // Start the image capture as fast as possible to minimize lag.
   414     mCaptureSoundPlayer->play();
   437     // Check e.g. space available *after* this.
   415 
       
   416     setState(Capturing);
       
   417     mCameraDevice.camera()->CaptureImage();
   438     mCameraDevice.camera()->CaptureImage();
   418 
   439 
   419     //! @todo: NOTE: This call may not stay here. It can move depending on the implementation for burst capture.
   440     if (imagesLeft() > 0) {
   420     if (mMode == BurstCapture) {
   441         mCaptureSoundPlayer->play();
   421         // Start a new filename sequence
   442         setState(Capturing);
   422         mFilenameGenerator.startNewImageFilenameSequence();
   443 
       
   444         //! @todo: NOTE: This call may not stay here. It can move depending on the implementation for burst capture.
       
   445         if (mMode == BurstCapture) {
       
   446             // Start a new filename sequence
       
   447             mFilenameGenerator.startNewImageFilenameSequence();
       
   448         }
       
   449     } else {
       
   450         // There's no space for the image.
       
   451         // Cancel started capturing.
       
   452         mCameraDevice.camera()->CancelCaptureImage();
       
   453 
       
   454         // Report error.
       
   455         // Ui notification has anyway some delays, hence handling VF after this.
       
   456         emit imageCaptured(CxeError::DiskFull, CxeStillImage::INVALID_ID);
       
   457 
       
   458         // Capturing stops viewfinder, so restart it now.
       
   459         mViewfinderControl.stop();
       
   460         mViewfinderControl.start();
   423     }
   461     }
   424 
   462 
   425     CX_DEBUG_EXIT_FUNCTION();
   463     CX_DEBUG_EXIT_FUNCTION();
   426 }
   464 }
   427 
   465 
   494     if (stillImage->filename().isEmpty()) {
   532     if (stillImage->filename().isEmpty()) {
   495         // Error ignored at this point, try again when image data arrives.
   533         // Error ignored at this point, try again when image data arrives.
   496         prepareFilename(stillImage);
   534         prepareFilename(stillImage);
   497     }
   535     }
   498 
   536 
       
   537     OstTrace0( camerax_performance, DUP1_CXESTILLCAPTURECONTROLSYMBIAN_HANDLESNAPSHOTEVENT, "msg: e_CX_HANDLE_SNAPSHOT 0" );
   499     CX_DEBUG_EXIT_FUNCTION();
   538     CX_DEBUG_EXIT_FUNCTION();
   500 }
   539 }
   501 
   540 
   502 /**
   541 /**
   503 * Gets QPixmap snapshot from ECAM buffer, if available.
   542 * Gets QPixmap snapshot from ECAM buffer, if available.
   551 }
   590 }
   552 
   591 
   553 /**
   592 /**
   554  * handleImageData: Image data received from ECam
   593  * handleImageData: Image data received from ECam
   555  */
   594  */
   556 void CxeStillCaptureControlSymbian::handleImageData( MCameraBuffer* cameraBuffer, int error )
   595 void CxeStillCaptureControlSymbian::handleImageData(MCameraBuffer* cameraBuffer, int error)
   557 {
   596 {
   558     CX_DEBUG_ENTER_FUNCTION();
   597     CX_DEBUG_ENTER_FUNCTION();
   559 
   598 
   560     if (state() == CxeStillCaptureControl::Uninitialized) {
   599     if (state() == CxeStillCaptureControl::Uninitialized) {
   561         // we ignore this event, when we are not active
   600         // we ignore this event, when we are not active
   633     if (settingId == CxeSettingIds::IMAGE_QUALITY) {
   672     if (settingId == CxeSettingIds::IMAGE_QUALITY) {
   634         // re-prepare for still
   673         // re-prepare for still
   635         if (state() == Ready) {
   674         if (state() == Ready) {
   636             deinit();
   675             deinit();
   637             init();
   676             init();
       
   677         }
       
   678     }
       
   679 
       
   680     CX_DEBUG_EXIT_FUNCTION();
       
   681 }
       
   682 
       
   683 /*!
       
   684 * Disk space changed.
       
   685 * Emit remaining images changed signal, if space change affects it.
       
   686 */
       
   687 void CxeStillCaptureControlSymbian::handleDiskSpaceChanged()
       
   688 {
       
   689     CX_DEBUG_ENTER_FUNCTION();
       
   690 
       
   691     // Ignore updates on other states.
       
   692     if (state() == CxeStillCaptureControl::Ready) {
       
   693 
       
   694         int images = calculateRemainingImages(mCurrentImageDetails.mEstimatedSize);
       
   695 
       
   696         if (images != mCurrentImageDetails.mPossibleImages) {
       
   697             CX_DEBUG(("CxeStillCaptureControlSymbian - available images changed %d -> %d",
       
   698                       mCurrentImageDetails.mPossibleImages, images));
       
   699 
       
   700             mCurrentImageDetails.mPossibleImages = images;
       
   701             emit availableImagesChanged();
   638         }
   702         }
   639     }
   703     }
   640 
   704 
   641     CX_DEBUG_EXIT_FUNCTION();
   705     CX_DEBUG_EXIT_FUNCTION();
   642 }
   706 }
   841 }
   905 }
   842 
   906 
   843 
   907 
   844 /*!
   908 /*!
   845 * Slot to handle Autofocus events.
   909 * Slot to handle Autofocus events.
       
   910 * \param newState Indicates current state of the auto focus
       
   911 * \param error Contains possible error code
   846 */
   912 */
   847 void CxeStillCaptureControlSymbian::handleAutofocusStateChanged(
   913 void CxeStillCaptureControlSymbian::handleAutofocusStateChanged(
   848                                          CxeAutoFocusControl::State newState,
   914                                          CxeAutoFocusControl::State newState,
   849                                          CxeError::Id /*error*/ )
   915                                          CxeError::Id error )
   850 {
   916 {
   851     CX_DEBUG_ENTER_FUNCTION();
   917     CX_DEBUG_ENTER_FUNCTION();
       
   918     Q_UNUSED(error);
   852     mAfState = newState;
   919     mAfState = newState;
   853     CxeAutoFocusControl::Mode mode = mAutoFocusControl.mode();
   920     CxeAutoFocusControl::Mode mode = mAutoFocusControl.mode();
   854 
   921 
   855     // if focused and in correct mode, play sound
   922     // if focused and in correct mode, play sound
   856     if  (newState == CxeAutoFocusControl::Ready &&
   923     if  (newState == CxeAutoFocusControl::Ready &&
   857          mode != CxeAutoFocusControl::Hyperfocal &&
   924          mode != CxeAutoFocusControl::Hyperfocal &&
   858          mode != CxeAutoFocusControl::Infinity) {
   925          mode != CxeAutoFocusControl::Infinity &&
       
   926          mAutoFocusControl.isSoundEnabled()) {
   859         mAutoFocusSoundPlayer->play();
   927         mAutoFocusSoundPlayer->play();
   860     }
   928     }
   861     CX_DEBUG_EXIT_FUNCTION();
   929     CX_DEBUG_EXIT_FUNCTION();
   862 }
   930 }
   863 
   931 
   915 /*!
   983 /*!
   916 * Returns the number of images left for the current image quality setting
   984 * Returns the number of images left for the current image quality setting
   917 */
   985 */
   918 int CxeStillCaptureControlSymbian::imagesLeft()
   986 int CxeStillCaptureControlSymbian::imagesLeft()
   919 {
   987 {
   920     return calculateRemainingImages(mCurrentImageDetails.mEstimatedSize);
   988     CX_DEBUG_ENTER_FUNCTION();
       
   989 
       
   990     if (mCurrentImageDetails.mPossibleImages == CxeImageDetails::UNKNOWN) {
       
   991         mCurrentImageDetails.mPossibleImages = calculateRemainingImages(mCurrentImageDetails.mEstimatedSize);
       
   992     }
       
   993 
       
   994     CX_DEBUG_EXIT_FUNCTION();
       
   995     return mCurrentImageDetails.mPossibleImages;
   921 }
   996 }
   922 
   997 
   923 
   998 
   924 
   999 
   925 /*!
  1000 /*!
   930 int
  1005 int
   931 CxeStillCaptureControlSymbian::calculateRemainingImages(int estimatedImagesize)
  1006 CxeStillCaptureControlSymbian::calculateRemainingImages(int estimatedImagesize)
   932 {
  1007 {
   933     CX_DEBUG_ENTER_FUNCTION();
  1008     CX_DEBUG_ENTER_FUNCTION();
   934 
  1009 
   935     //Check the memory in-use setting
  1010     qint64 space = mDiskMonitor.free() - KMinRequiredSpaceImage;
   936     qint64 memoryfree = CxeSysUtil::spaceAvailable(CCoeEnv::Static()->FsSession(), mSettings);
  1011     int images = std::max(qint64(0), space / estimatedImagesize);
   937 
  1012 
   938     memoryfree = memoryfree - KMinRequiredSpaceImage;
  1013     CX_DEBUG_EXIT_FUNCTION();
   939 
  1014 
   940     if (memoryfree < 0) {
  1015     return images;
   941         memoryfree = 0; // exception, inform ui
       
   942     }
       
   943     qint64 images = memoryfree / estimatedImagesize;
       
   944 
       
   945     CX_DEBUG_EXIT_FUNCTION();
       
   946 
       
   947   return images;
       
   948 }
  1016 }
   949 
  1017 
   950 // end of file
  1018 // end of file