mmfenh/enhancedmediaclient/Plugins/FileSource/src/FileSource.cpp
changeset 52 4ce423f34688
parent 0 71ca22bcf22a
equal deleted inserted replaced
47:c2e43643db4c 52:4ce423f34688
    10 * Nokia Corporation - initial contribution.
    10 * Nokia Corporation - initial contribution.
    11 *
    11 *
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description:  Implementation of FileSource.
    14 * Description:  Implementation of FileSource.
    15 *  Version     : %version: bh1mmcf#5.1.7 %
    15 *  Version     : %version: bh1mmcf#5.1.8 %
    16 *
    16 *
    17 */
    17 */
    18 
    18 
    19 
    19 
    20 #include <f32file.h>
    20 #include <f32file.h>
   700     {
   700     {
   701     // Clear out any completed requests
   701     // Clear out any completed requests
   702     for ( TInt ii = 0 ; ii < iRequests.Count() ; ii++ )
   702     for ( TInt ii = 0 ; ii < iRequests.Count() ; ii++ )
   703         {
   703         {
   704         CReadWriteRequest* request = iRequests[ii];
   704         CReadWriteRequest* request = iRequests[ii];
   705         delete request;
   705         if(!request->Processing())
   706         iRequests.Remove(ii);
   706             {
   707         ii--;
   707             delete request;
       
   708             iRequests.Remove(ii);
       
   709             ii--;
       
   710             }
   708         }
   711         }
   709     }
   712     }
   710             
   713             
   711 /**
   714 /**
   712 Evaluates a given intent against the rights associated with the file.
   715 Evaluates a given intent against the rights associated with the file.
   798         }
   801         }
   799     
   802     
   800     return iFile->Seek(ESeekStart, aPosInBytes);
   803     return iFile->Seek(ESeekStart, aPosInBytes);
   801     };
   804     };
   802             
   805             
   803 /*
       
   804 *	Returns ETrue if the request can safely be deleted.
       
   805 */
       
   806 
       
   807 TBool CReadWriteRequest::Completed() 
       
   808     {
       
   809     return iCompleted ;
       
   810     }
       
   811             
       
   812 TInt CReadWriteRequest::SetStatus(TBool aStatus)
       
   813     {
       
   814     iCompleted = aStatus;
       
   815     return KErrNone;
       
   816     }
       
   817 
   806 
   818 TBool CReadWriteRequest::SourceType() 
   807 TBool CReadWriteRequest::SourceType() 
   819     {
   808     {
   820     return iSourceType ;
   809     return iSourceType ;
   821     }
   810     }
   876 /*
   865 /*
   877 *  For the moment at least...    Canceled requests may be deleted
   866 *  For the moment at least...    Canceled requests may be deleted
   878 */
   867 */
   879 void CReadWriteRequest::DoCancel() 
   868 void CReadWriteRequest::DoCancel() 
   880     {
   869     {
   881     iCompleted = ETrue ;
   870     iState = ECompleted;
   882     }
   871     }
   883             
   872             
   884 /*
   873 /*
   885 *	Called when errors in RunL force Leave.  For the moment just mark the request deletable
   874 *	Called when errors in RunL force Leave.  For the moment just mark the request deletable
   886 */
   875 */
   887 TInt CReadWriteRequest::RunError( TInt aError ) 
   876 TInt CReadWriteRequest::RunError( TInt aError ) 
   888     {
   877     {
   889     //RunL can leave.
   878     //RunL can leave.
   890     iCompleted = ETrue ;
   879     iState = ECompleted;
   891     iError = aError; //keep this error internally for now
   880     iError = aError; //keep this error internally for now
   892     return KErrNone ;
   881     return KErrNone ;
   893     }
   882     }
   894         
   883         
   895 /*
   884 /*
   896 *	On completion of read request call back to the MDataSink
   885 *	On completion of read request call back to the MDataSink
   897 */
   886 */
   898 void CReadRequest::RunL() 
   887 void CReadRequest::RunL() 
   899     {
   888     {
       
   889     iState = EProcessing;
   900     //Copy the data from the normal buffer into the Transfer buffer
   890     //Copy the data from the normal buffer into the Transfer buffer
   901     if(iTransferBufferCopy)
   891     if(iTransferBufferCopy)
   902         {
   892         {
   903         //must specify the size here as the dest may be smaller than the source.
   893         //must specify the size here as the dest may be smaller than the source.
   904         TDes8& destDesc = STATIC_CAST(CMMFDataBuffer*, iBuffer)->Data();
   894         TDes8& destDesc = STATIC_CAST(CMMFDataBuffer*, iBuffer)->Data();
   906     
   896     
   907         iTransferBufferCopy->SetInUse(EFalse);
   897         iTransferBufferCopy->SetInUse(EFalse);
   908         }
   898         }
   909 
   899 
   910         STATIC_CAST(CFileMultimediaSource*,iParent)->ReadRequestStatus(STATIC_CAST(CReadWriteRequest*,this),iStatus);
   900         STATIC_CAST(CFileMultimediaSource*,iParent)->ReadRequestStatus(STATIC_CAST(CReadWriteRequest*,this),iStatus);
       
   901     iState = ECompleted;
   911     }
   902     }
   912 
   903 
   913         // From CMultimediaDataSource begins
   904         // From CMultimediaDataSource begins
   914 TInt CFileMultimediaSource::SetObserver( MMultimediaDataSourceObserver& aObserver )
   905 TInt CFileMultimediaSource::SetObserver( MMultimediaDataSourceObserver& aObserver )
   915     {
   906     {
  1370             else
  1361             else
  1371                     REINTERPRET_CAST(MMultimediaDataSourceObserver*, aRequest->GetSinkOrSource())->BufferFilled(aRequest->Buffer()) ; // callback to MDataSource/Sink			
  1362                     REINTERPRET_CAST(MMultimediaDataSourceObserver*, aRequest->GetSinkOrSource())->BufferFilled(aRequest->Buffer()) ; // callback to MDataSource/Sink			
  1372                 
  1363                 
  1373             }
  1364             }
  1374             
  1365             
  1375             aRequest->SetStatus(ETrue);
       
  1376             return KErrNone;		
  1366             return KErrNone;		
  1377         }
  1367         }
  1378     }
  1368     }
  1379 
  1369 
  1380 //End of File
  1370 //End of File