voicerecorder/RecViewSrc/CVRMemo.cpp
changeset 14 94f223449c91
parent 1 8434d5964e15
equal deleted inserted replaced
1:8434d5964e15 14:94f223449c91
     1 /*
       
     2 * Copyright (c) 2002 - 2006 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *     This class represents a voice memo. It is able to create new files,
       
    16 *     rename and delete existing files, and to save them to permanent storage.
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 
       
    23 #include <eikapp.h>
       
    24 #include <eikappui.h>
       
    25 #include <eikenv.h>
       
    26 #include <AknWaitDialog.h>
       
    27 #include <AknQueryDialog.h>
       
    28 #include <StringLoader.h>
       
    29 #include <bautils.h>
       
    30 #include <AknGlobalNote.h>
       
    31 #include <sysutil.h>
       
    32 #include <pathinfo.h>
       
    33 #include <systemwarninglevels.hrh>
       
    34 #include <AknNotifyStd.h>
       
    35 #include <coeutils.h>
       
    36 
       
    37 #include <voicerecorder.rsg>
       
    38 #include <VoiceRecorderUID.h>
       
    39 #include "CVRMemo.h"
       
    40 #include "VRConsts.h"
       
    41 #include "TVRRename.h"
       
    42 #include "VRUtils.h"
       
    43 
       
    44 // CONSTANTS
       
    45 // Max length is 300 millisecs over one minute so possible cropping
       
    46 // of the file after stop doesn't drop the length under one minute
       
    47 const TInt KVRMMSMemoMaxRecordLength( 60300000 );
       
    48 const TInt KVREstimateDelayDuration( 10000000 );
       
    49 
       
    50 
       
    51 // ================= MEMBER FUNCTIONS ========================================
       
    52 
       
    53 // ---------------------------------------------------------------------------
       
    54 // CVRMemo::CVRMemo
       
    55 // 
       
    56 // ---------------------------------------------------------------------------
       
    57 //
       
    58 CVRMemo::CVRMemo()
       
    59 	: iDuration( 0 ), iPosition( 0 ), iMaxDuration( KVRDefaultMaxLength ),
       
    60 	iQuality( EQualityMMSOptimized ),iIsRecorded( EFalse )
       
    61 	{
       
    62 #ifndef RD_MULTIPLE_DRIVE	
       
    63      iStoragePlace = EMemoStorePhoneMemory;
       
    64 #else
       
    65      TRAP_IGNORE(iStorageDrive = VRUtils::DefaultMemoDriveL());
       
    66 #endif
       
    67 	}
       
    68 
       
    69 
       
    70 // ---------------------------------------------------------------------------
       
    71 // CVRMemo::~CVRMemo
       
    72 // 
       
    73 // ---------------------------------------------------------------------------
       
    74 //
       
    75 CVRMemo::~CVRMemo()
       
    76 	{
       
    77 	DeleteEmptyFile();
       
    78 	
       
    79 	// Close the file handle and file server session
       
    80 	iFile.Close();
       
    81 	iFs.Close();
       
    82 
       
    83 	delete iFileMan;
       
    84 	}
       
    85 
       
    86 
       
    87 // ---------------------------------------------------------------------------
       
    88 // CVRMemo::ConstructL
       
    89 // 
       
    90 // ---------------------------------------------------------------------------
       
    91 //
       
    92 void CVRMemo::ConstructL(TInt aDefaultAudioFormat)
       
    93 	{
       
    94 	User::LeaveIfError( iFs.Connect() );
       
    95 	iFs.ShareProtected();
       
    96 	
       
    97 	iFileMan = CFileMan::NewL( iFs );
       
    98 
       
    99 	iVRAudioFormat = aDefaultAudioFormat;
       
   100 
       
   101 	iQuality = VRUtils::QualityL();
       
   102 	if ( !VRUtils::FeatureEnabled( EVRFeatureShowQualitySetting )
       
   103 	     || iEmbedded )
       
   104 		{
       
   105 		iMaxDuration = KVRMMSMemoMaxRecordLength;
       
   106 		iQuality = EQualityMMSOptimized;
       
   107 		}
       
   108 	else 
       
   109 		{
       
   110 		TInt64 max( VRUtils::MaxLengthL() );
       
   111 		max = max * KVRMinuteAsMicroSeconds;
       
   112 		iMaxDuration = max;
       
   113 		}
       
   114 	
       
   115 	// Current storage place
       
   116 #ifndef RD_MULTIPLE_DRIVE	
       
   117 	iStoragePlace = VRUtils::MemoStoreL();	
       
   118 #else
       
   119     iStorageDrive = VRUtils::MemoDriveL();
       
   120 #endif	
       
   121 
       
   122 	}
       
   123 
       
   124 
       
   125 // ---------------------------------------------------------------------------
       
   126 // CVRMemo::SetName
       
   127 // 
       
   128 // ---------------------------------------------------------------------------
       
   129 //
       
   130 void CVRMemo::SetName( const TDesC& aFilename )
       
   131 	{
       
   132 	iFilename.Copy( aFilename );
       
   133 	TParsePtrC parse( iFilename );
       
   134 	iNamePtr.Set( parse.Name().Left( VRMEMONAMEMAXLENGTH ) );
       
   135 	}
       
   136 
       
   137 
       
   138 // ---------------------------------------------------------------------------
       
   139 // CVRMemo::SetTemporaryNameL
       
   140 // 
       
   141 // ---------------------------------------------------------------------------
       
   142 //
       
   143 void CVRMemo::SetTemporaryNameL( TBool aEmbedded )
       
   144 	{
       
   145 	iEmbedded = aEmbedded;
       
   146 
       
   147 	// We can use the same handle, no need to create new name	
       
   148 	// Empty the file so it can be overwritten with new memo
       
   149 	if ( iEmbedded && !iExternalFileHandle )
       
   150 		{
       
   151 		if ( iFile.SubSessionHandle() )
       
   152 			{
       
   153 			iFile.SetSize( 0 );
       
   154 			return;
       
   155 			}
       
   156 		}		
       
   157 	
       
   158 	// Checks if the file handle can be found i.e if file is created 	
       
   159 	if ( iFile.SubSessionHandle() )
       
   160 		{	
       
   161 		// Retrieving new settings
       
   162 		TVRQuality newQuality( VRUtils::QualityL() );
       
   163 
       
   164 #ifndef RD_MULTIPLE_DRIVE
       
   165 		TVRMemoStore newStoragePlace ( VRUtils::MemoStoreL() );			
       
   166 
       
   167 		// If the current file is empty, we can reuse it if quality or 
       
   168 		// the storage place hasn't changed
       
   169 		if ( iQuality == newQuality && iStoragePlace == newStoragePlace )	
       
   170 		    {
       
   171     	    TInt size( 0 );		
       
   172     		iFile.Size( size );
       
   173 			
       
   174 			// If current file has already been recorded to, a new file has 
       
   175 			// to be generated 
       
   176     		if ( !IsRecorded() )    		
       
   177     			{
       
   178     			iFile.SetSize( 0 );
       
   179     			return;
       
   180     			}
       
   181     		}
       
   182     	// The file has been created but the settings have been changed 
       
   183     	// before using the file -> delete file and create a new one
       
   184 	    else
       
   185 	    	{
       
   186 	    	DeleteEmptyFile();
       
   187 	    	}
       
   188 
       
   189 #else
       
   190         // for Multiple drives
       
   191 		TInt newStorageDrive ( VRUtils::MemoDriveL() );			
       
   192 
       
   193 		// If the current file is empty, we can reuse it if quality or 
       
   194 		// the storage place hasn't changed
       
   195 		if ( iQuality == newQuality && iStorageDrive == newStorageDrive )	
       
   196 		    {
       
   197     	    TInt size( 0 );		
       
   198     		iFile.Size( size );
       
   199 			
       
   200 			// If current file has already been recorded to, a new file has 
       
   201 			// to be generated 
       
   202     		if ( !IsRecorded() )    		
       
   203     			{
       
   204     			iFile.SetSize( 0 );
       
   205     			return;
       
   206     			}
       
   207     		}
       
   208     	// The file has been created but the settings have been changed 
       
   209     	// before using the file -> delete file and create a new one
       
   210 	    else
       
   211 	    	{
       
   212 	    	DeleteEmptyFile();
       
   213 	    	}
       
   214 
       
   215 
       
   216 #endif
       
   217 	    }
       
   218 
       
   219 	TFileName memoName;	
       
   220     // Retrieve storage path
       
   221 	if ( iSavingLocation.Length() > 0 )
       
   222 		{
       
   223 		memoName = iSavingLocation;
       
   224 		}
       
   225 	else
       
   226 		{
       
   227 		VRUtils::MemoStoreDirectoryL( memoName );
       
   228 		}
       
   229 
       
   230 	// Recheck the quality before naming memo
       
   231 	if ( !VRUtils::FeatureEnabled( EVRFeatureShowQualitySetting )
       
   232 	     || iEmbedded )
       
   233 		{
       
   234 		iQuality = EQualityMMSOptimized;
       
   235 		}
       
   236     else
       
   237         {
       
   238 	    iQuality = VRUtils::QualityL();
       
   239         }
       
   240 	
       
   241 	// Current storage place
       
   242 #ifndef RD_MULTIPLE_DRIVE		
       
   243 	iStoragePlace = VRUtils::MemoStoreL();
       
   244 #else
       
   245     iStorageDrive = VRUtils::MemoDriveL();
       
   246 #endif
       
   247 
       
   248     // Choose the file type
       
   249 	// Use amr if quality is MMS Optimized or we are recording
       
   250 	// in embedded mode, wav otherwise    
       
   251 	TVRFiletype type( EVRFileAmr );
       
   252     if( iEmbedded || iQuality == EQualityMMSOptimized )
       
   253 		{
       
   254 		type = EVRFileAmr;
       
   255 		}
       
   256 		
       
   257 // **** updated for new CR, if it QualitySetting is Normal, save as WAV
       
   258 
       
   259 #ifdef  __AAC_ENCODER_PLUGIN
       
   260     else if (iQuality == EQualityNormal)
       
   261 		{
       
   262 		type = EVRFileWav;
       
   263 		}
       
   264 		
       
   265 // ****  the following are updated for new CR, if it QualitySetting is High, save as mp4
       
   266     else if (iQuality == EQualityHigh)
       
   267 		{
       
   268 		type = EVRFileAAC_LC;
       
   269 		}
       
   270 #else
       
   271 
       
   272 	else
       
   273 		{
       
   274 		type = EVRFileWav;
       
   275 		}
       
   276 
       
   277 #endif
       
   278 
       
   279 	// Generate unique final file name
       
   280     VRUtils::GenerateUniqueFilenameL( iFs, memoName, type );
       
   281 
       
   282 	// Make sure that file handles are not leaked
       
   283 	if ( iFile.SubSessionHandle() )
       
   284 		{
       
   285 		iFile.Close();
       
   286 		}
       
   287 	
       
   288 	// Ensure that path exists
       
   289 	BaflUtils::EnsurePathExistsL( iFs, memoName );
       
   290 	
       
   291 // Open the memo file
       
   292  
       
   293 #ifdef  __AAC_ENCODER_PLUGIN 
       
   294     if((iQuality == EQualityHigh))  //for mp4 format	, 3gplib does not support EFileShareExclusive so EFileShareAny is used here
       
   295     	{
       
   296         User::LeaveIfError( iFile.Create( iFs, memoName, EFileWrite|EFileShareAny) );
       
   297     	}
       
   298     else  // for other formats
       
   299     	{
       
   300         User::LeaveIfError( iFile.Create( iFs, memoName, EFileShareExclusive|EFileWrite ) );		
       
   301 
       
   302     	}
       
   303 #else  // it is not mp4, so still use the old flag
       
   304         User::LeaveIfError( iFile.Create( iFs, memoName, EFileShareExclusive|EFileWrite ) );		
       
   305  
       
   306 #endif
       
   307 
       
   308     TInt error = iFile.SetAtt(KEntryAttHidden, KEntryAttNormal );	  		
       
   309 	SetName( memoName );
       
   310 	}
       
   311 
       
   312 
       
   313 // ---------------------------------------------------------------------------
       
   314 // CVRMemo::QueryAndDeleteL
       
   315 // 
       
   316 // ---------------------------------------------------------------------------
       
   317 //
       
   318 TBool CVRMemo::QueryAndDeleteL()
       
   319 	{
       
   320 	//Delete?\n%U" �qtn.query.common.conf.delete�
       
   321 	TParsePtrC parse( iFilename );
       
   322 	HBufC* text = StringLoader::LoadLC( R_QTN_QUERY_COMMON_CONF_DELETE,
       
   323 										parse.Name() );
       
   324 
       
   325 	// Show confirm note
       
   326     CAknQueryDialog* dlg = CAknQueryDialog::NewL();
       
   327     TInt result( dlg->ExecuteLD( R_VR_CONFIRMATION_QUERY, *text ) );
       
   328     CleanupStack::PopAndDestroy( text );
       
   329 
       
   330 	if ( result )
       
   331 		{
       
   332 		DeleteL();
       
   333 		return ETrue;
       
   334 		}
       
   335 
       
   336 	return EFalse;
       
   337 	}
       
   338 
       
   339 
       
   340 // ---------------------------------------------------------------------------
       
   341 // CVRMemo::DeleteL
       
   342 // 
       
   343 // ---------------------------------------------------------------------------
       
   344 //
       
   345 void CVRMemo::DeleteL()
       
   346 	{
       
   347 	if ( iFile.SubSessionHandle() )
       
   348 		{
       
   349 		if ( iExternalFileHandle )
       
   350 			{
       
   351 			// We shouldn't delete the file handle, so let's
       
   352 			// just empty the file
       
   353 			iFile.SetSize( 0 );
       
   354 			}
       
   355 		else
       
   356 			{
       
   357 			TFileName fileName( KNullDesC );
       
   358 			iFile.FullName( fileName );
       
   359 			iFile.Close();
       
   360 
       
   361 			TInt err( iFileMan->Delete( fileName ) );
       
   362 			if ( err != KErrNone && err != KErrNotFound )
       
   363 				{
       
   364 				// Try to open the file again so we wont end up
       
   365 				// in goofy state without open file
       
   366 				User::LeaveIfError( iFile.Open( iFs, fileName,
       
   367 				                      EFileShareReadersOnly ) );
       
   368 				User::LeaveIfError( err );
       
   369 				}
       
   370 			}
       
   371 		}
       
   372 	SetName( KNullDesC );
       
   373 	}
       
   374 
       
   375 
       
   376 // ---------------------------------------------------------------------------
       
   377 // CVRMemo::QueryAndRenameL
       
   378 // 
       
   379 // ---------------------------------------------------------------------------
       
   380 //
       
   381 TBool CVRMemo::QueryAndRenameL()
       
   382 	{
       
   383 	TVRRename renamer( iFs );
       
   384 	if ( renamer.RenameL( iFile, R_QTN_FLDR_ITEM_NAME_PRMPT ) )
       
   385 		{
       
   386 		TFileName name( KNullDesC );
       
   387 		iFile.FullName( name );
       
   388 		SetName( name );
       
   389 		
       
   390 		return ETrue;
       
   391 		}
       
   392 	return EFalse;
       
   393 	}
       
   394 
       
   395 
       
   396 // ---------------------------------------------------------------------------
       
   397 // CVRMemo::SavePermanentlyL
       
   398 // 
       
   399 // ---------------------------------------------------------------------------
       
   400 //
       
   401 void CVRMemo::SavePermanentlyL( CAknGlobalNote* /*aWaitNote*/, 
       
   402 								TInt& /*aNoteId*/,
       
   403 								const TDesC& /*aLabel*/, 
       
   404 								TBool /*aProduceCopy*/ )
       
   405 
       
   406 	{
       
   407 	// Don't do anything if recording to external file handle
       
   408 	if ( iExternalFileHandle )
       
   409 	    {
       
   410 	    return;
       
   411 	    }
       
   412 	
       
   413 	// Change file open mode to read
       
   414 	TFileName name( KNullDesC );
       
   415 	iFile.FullName( name );
       
   416 	iFile.Close();
       
   417 	User::LeaveIfError( iFile.Open( iFs, 
       
   418 									name, 
       
   419 									EFileRead|EFileShareReadersOnly) );	
       
   420 	}
       
   421 
       
   422 
       
   423 // ---------------------------------------------------------------------------
       
   424 // CVRMemo::IsValid
       
   425 // 
       
   426 // ---------------------------------------------------------------------------
       
   427 //
       
   428 TBool CVRMemo::IsValid() const
       
   429 	{
       
   430 	return iFile.SubSessionHandle() == 0 ? EFalse : ETrue;
       
   431 	}
       
   432 
       
   433 
       
   434 // ---------------------------------------------------------------------------
       
   435 // CVRMemo::UpdateModifiedDate
       
   436 // 
       
   437 // ---------------------------------------------------------------------------
       
   438 //
       
   439 void CVRMemo::UpdateModifiedDate()
       
   440 	{
       
   441 	if ( IsValid() )
       
   442 		{
       
   443 		TLocale locale;
       
   444 		iFile.Modified( iDateCreated );		
       
   445 		iDateCreated += locale.UniversalTimeOffset();
       
   446 		}
       
   447 	}
       
   448 
       
   449 
       
   450 // ---------------------------------------------------------------------------
       
   451 // CVRMemo::SetSavingLocationL
       
   452 // 
       
   453 // ---------------------------------------------------------------------------
       
   454 //
       
   455 void CVRMemo::SetSavingLocationL( const TDesC& aPath )
       
   456 	{
       
   457 	iSavingLocation = aPath;
       
   458 	}
       
   459 
       
   460 
       
   461 // ---------------------------------------------------------------------------
       
   462 // CVRMemo::DeleteEmptyFile
       
   463 // Deletes an empty file that hasn't been recorded into. After deleting 
       
   464 // also decreases central repository's memo count value
       
   465 // ---------------------------------------------------------------------------
       
   466 //	
       
   467 TBool CVRMemo::DeleteEmptyFile()
       
   468 	{
       
   469 	if ( iFile.SubSessionHandle() != 0 )
       
   470 		{
       
   471 		TInt size( 0 );
       
   472         
       
   473         // Error code ignored
       
   474         iFile.Size( size );
       
   475 		
       
   476 		if ( !iIsRecorded )
       
   477 		    {
       
   478 		    TFileName name( KNullDesC );
       
   479 		    iFile.FullName( name );
       
   480 		    
       
   481 			iFile.Close();
       
   482 			iFileMan->Delete( name );			
       
   483 	
       
   484 			// Central repository value has to be decreased by one because it 
       
   485 			// was increased earlier, when current filename was generated
       
   486 			VRUtils::SetMemoCount( VRUtils::MemoCount() - 1 );
       
   487 			
       
   488 			return ETrue;
       
   489     	    }
       
   490 		}
       
   491 		return EFalse;
       
   492 	}
       
   493 
       
   494 
       
   495 // ---------------------------------------------------------------------------
       
   496 // CVRMemo::SetFileHandle
       
   497 // 
       
   498 // ---------------------------------------------------------------------------
       
   499 //	
       
   500 void CVRMemo::SetFileHandle( RFile& aFile, const TBool aEmbedded )
       
   501 	{
       
   502 	iEmbedded = aEmbedded;
       
   503 	iExternalFileHandle = ETrue;
       
   504 	
       
   505 	iFile = aFile;
       
   506 
       
   507 	// Set the correct name for UI
       
   508 	TFileName name( KNullDesC );
       
   509 	iFile.FullName( name );
       
   510 	SetName( name );
       
   511 	}
       
   512 
       
   513 
       
   514 // ---------------------------------------------------------------------------
       
   515 // CVRMemo::MaxDuration
       
   516 // Returns in microseconds the maximum time that can be still recorded with 
       
   517 // current settings (codecs and mem storage place)
       
   518 // ---------------------------------------------------------------------------
       
   519 //	
       
   520 const TTimeIntervalMicroSeconds& CVRMemo::MaxDuration()
       
   521 	{
       
   522 	if ( iEmbedded || 
       
   523 		 !VRUtils::FeatureEnabled( EVRFeatureShowQualitySetting ) ||
       
   524 	     iQuality == EQualityMMSOptimized )
       
   525 		{
       
   526 		//Voice Recorder change to remove 1 Min. limit for AMR for Stand alone recording
       
   527 		//if embedded allow 1 min recording for EQualityMMSOptimized(AMR)
       
   528 		//else allow 1 hour recording
       
   529 		if(iEmbedded)
       
   530 			{
       
   531 			iMaxDuration = KVRMMSMemoMaxRecordLength;
       
   532 			return iMaxDuration;
       
   533 			}		
       
   534 		}
       
   535 
       
   536 	// Make the first estimate after KVRFirstEstimateTime seconds recording
       
   537 	if ( Duration() < KVRFirstEstimateTime )
       
   538 		{
       
   539 		// Fetch the setting for high quality max length
       
   540 		TInt64 max( 0 );
       
   541 		TRAPD( err, max = VRUtils::MaxLengthL() );
       
   542 		if ( err != KErrNone )
       
   543 		    {
       
   544 		    max = KVRMMSMemoMaxRecordLength;
       
   545 		    }
       
   546 
       
   547 		max = max * KVRMinuteAsMicroSeconds;
       
   548 		iMaxDuration = max;
       
   549 
       
   550 		// Reset the time of last estimate
       
   551 		TDateTime date;
       
   552 		date.SetYear( -1 );
       
   553 		iLastEstimate = date; // invalid
       
   554 		
       
   555 		return iMaxDuration;
       
   556 		}
       
   557 
       
   558 	// Make new estimate if there's no last estimate or if 10 secs have passed
       
   559 	// from the previous estimate
       
   560 	TTime currentTime;
       
   561 	currentTime.HomeTime();
       
   562 	if ( iLastEstimate.DateTime().Year() == -1 ||
       
   563 		currentTime.MicroSecondsFrom( iLastEstimate ) >=
       
   564 		        TTimeIntervalMicroSeconds( KVREstimateDelayDuration ) )
       
   565 		{
       
   566 		iLastEstimate = currentTime;
       
   567 		
       
   568 		TEntry fileEntry;
       
   569 		TFileName name( KNullDesC );
       
   570 		iFile.FullName( name );		
       
   571 
       
   572 		TInt err = iFs.Entry( name, fileEntry );
       
   573 		if( err != KErrNone )
       
   574 			{
       
   575 			return iMaxDuration;
       
   576 			}
       
   577 
       
   578 		// Retrieve free space
       
   579 		TVolumeInfo volInfo;
       
   580 
       
   581 // old storage
       
   582 #ifndef RD_MULTIPLE_DRIVE   
       
   583 		TVRMemoStore memoStore( EMemoStorePhoneMemory );
       
   584 		TRAP( err, memoStore = VRUtils::MemoStoreL() );
       
   585         if ( err != KErrNone )
       
   586             {
       
   587             memoStore = EMemoStorePhoneMemory;
       
   588 		    }
       
   589  
       
   590 		    if ( memoStore == EMemoStorePhoneMemory )
       
   591 			{
       
   592 			err = iFs.Volume( volInfo, EDriveC );			
       
   593 			}
       
   594 		else // memostore is MMC 
       
   595 			{
       
   596 			err = iFs.Volume( volInfo, EDriveE );
       
   597 			}
       
   598 			
       
   599 // multiple drive
       
   600 #else
       
   601 
       
   602         TInt drive = 0;
       
   603         TRAP_IGNORE(drive = VRUtils::DefaultMemoDriveL());
       
   604 		TRAP( err, drive = VRUtils::MemoDriveL() );
       
   605         if ( err != KErrNone )
       
   606             {
       
   607             TRAP_IGNORE(drive = VRUtils::DefaultMemoDriveL());
       
   608 		    }       
       
   609 		err = iFs.Volume( volInfo, drive );			
       
   610 
       
   611 #endif
       
   612 
       
   613 		if( err != KErrNone )
       
   614 			{
       
   615 
       
   616 			return iMaxDuration;
       
   617 			}
       
   618 			
       
   619 		// Calculate the current disk consumption "speed" of the memo
       
   620 		TReal speed( fileEntry.iSize / ( Duration().Int64() / 
       
   621 			KVRSecondAsMicroSeconds ) );
       
   622 		
       
   623 		// The total free memory
       
   624 		TInt64 freeSpace(volInfo.iFree);
       
   625 		// Free memory if Critical Memory isn't taken into account
       
   626 		TInt64 freeSpaceMinusCrlevel( freeSpace -  KDRIVECCRITICALTHRESHOLD);
       
   627 		
       
   628 		// Estimate the time left
       
   629 		TInt64 value( freeSpaceMinusCrlevel / speed );
       
   630 		TTimeIntervalMicroSeconds estimate( value * KVRSecondAsMicroSeconds );
       
   631 
       
   632 		// Estimate should include also the length of clip
       
   633 		estimate = TTimeIntervalMicroSeconds( estimate.Int64()
       
   634 										 + Duration().Int64() );
       
   635 		if ( estimate < iMaxDuration)
       
   636 			{
       
   637 			iMaxDuration = estimate;
       
   638 			}
       
   639 		}
       
   640 
       
   641 	return iMaxDuration;
       
   642 	}
       
   643 
       
   644 
       
   645 // ---------------------------------------------------------------------------
       
   646 // CVRMemo::IsRecorded
       
   647 // Returns the attribute iIsRecorded value that indicates if the recording of
       
   648 // the clip currently open is started or not
       
   649 // ---------------------------------------------------------------------------
       
   650 //	
       
   651 TBool CVRMemo::IsRecorded() const
       
   652 	{
       
   653 	return iIsRecorded;
       
   654 	}	 
       
   655 		
       
   656 
       
   657 // ---------------------------------------------------------------------------
       
   658 // CVRMemo::SetRecorded
       
   659 // Sets the value of iIsRecorded attribute
       
   660 // ---------------------------------------------------------------------------
       
   661 //		
       
   662 void CVRMemo::SetRecorded( TBool aRecorded )
       
   663 	{
       
   664 	iIsRecorded = aRecorded;
       
   665 	}
       
   666 	
       
   667 // End of file