multimediacommscontroller/mmccsubcontroller/src/mccdatapathbase.cpp
changeset 0 1bce908db942
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 /*
       
     2 * Copyright (c) 2004-2007 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:    Datapath baseclass
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 #include <mmf/common/mmfutilities.h>
       
    23 #include "mccdatapathbase.h"
       
    24 #include "mcccompletecallback.h"
       
    25 #include "mccsubcontrollerlogs.h"
       
    26 #include "mccinternaldef.h"
       
    27 
       
    28 // EXTERNAL DATA STRUCTURES
       
    29 
       
    30 // EXTERNAL FUNCTION PROTOTYPES  
       
    31 
       
    32 // CONSTANTS
       
    33 
       
    34 // MACROS
       
    35 
       
    36 // LOCAL CONSTANTS AND MACROS
       
    37 
       
    38 // MODULE DATA STRUCTURES
       
    39 
       
    40 // LOCAL FUNCTION PROTOTYPES
       
    41 
       
    42 // FORWARD DECLARATIONS
       
    43 
       
    44 // ============================= LOCAL FUNCTIONS ===============================
       
    45 
       
    46 // ============================ MEMBER FUNCTIONS ===============================
       
    47 
       
    48 // -----------------------------------------------------------------------------
       
    49 // CMccDataPathBase::AddDataSourceL
       
    50 // Adds a datasource to the datapath
       
    51 // -----------------------------------------------------------------------------
       
    52 void CMccDataPathBase::AddDataSourceL( MDataSource* aSource )
       
    53     {
       
    54 	__SUBCONTROLLER( "CMccDataPathBase::AddDataSourceL" )
       
    55     __ASSERT_ALWAYS( aSource, User::Leave( KErrArgument ) );
       
    56     __ASSERT_ALWAYS( EStopped == iState, User::Leave( KErrNotReady ) );
       
    57         
       
    58     if ( !iDataSink ) 
       
    59         {
       
    60 		__SUBCONTROLLER( "CMccDataPathBase::AddDataSourceL, added" )
       
    61         iDataSource = aSource; 
       
    62         }
       
    63     else 
       
    64         {
       
    65 		__SUBCONTROLLER( "CMccDataPathBase::AddDataSourceL, creating path" )
       
    66         this->CreateDataPathL( aSource, iDataSink );
       
    67         iDataSource = aSource;
       
    68         }
       
    69     }
       
    70 
       
    71 // -----------------------------------------------------------------------------
       
    72 // CMccDataPathBase::AddDataSinkL
       
    73 // Adds a datasink to the datapath
       
    74 // -----------------------------------------------------------------------------
       
    75 void CMccDataPathBase::AddDataSinkL( MDataSink* aSink )
       
    76     {
       
    77 	__SUBCONTROLLER( "CMccDataPathBase::AddDataSinkL" )
       
    78     __ASSERT_ALWAYS( aSink, User::Leave( KErrArgument ) );
       
    79     __ASSERT_ALWAYS( EStopped == iState, User::Leave( KErrNotReady ) );
       
    80     
       
    81     if ( !iDataSource ) 
       
    82         {
       
    83 		__SUBCONTROLLER( "CMccDataPathBase::AddDataSinkL, added" )
       
    84         iDataSink = aSink; 
       
    85         }
       
    86     else 
       
    87         {
       
    88 		__SUBCONTROLLER( "CMccDataPathBase::AddDataSinkL, creating path" )
       
    89         this->CreateDataPathL( iDataSource, aSink );
       
    90         iDataSink = aSink;
       
    91         }
       
    92     }
       
    93 
       
    94 // -----------------------------------------------------------------------------
       
    95 // CMccDataPathBase::SetAssociatedSink
       
    96 // -----------------------------------------------------------------------------    
       
    97 void CMccDataPathBase::SetAssociatedSink( MDataSink* aAssociatedSink )
       
    98     {
       
    99     __SUBCONTROLLER_INT1( "CMccDataPathBase::SetAssociatedSinkId, id:", 
       
   100                           MCC_ENDPOINT_ID( aAssociatedSink ) )
       
   101     
       
   102     iAssociatedSink = aAssociatedSink;
       
   103     }
       
   104 
       
   105 // -----------------------------------------------------------------------------
       
   106 // CMccDataPathBase::SetAssociatedSource
       
   107 // -----------------------------------------------------------------------------        
       
   108 void CMccDataPathBase::SetAssociatedSource( MDataSource* aAssociatedSource )
       
   109     {
       
   110     __SUBCONTROLLER_INT1( "CMccDataPathBase::SetAssociatedSourceId,id:", 
       
   111                           MCC_ENDPOINT_ID( aAssociatedSource ) )
       
   112                           
       
   113     iAssociatedSource = aAssociatedSource;
       
   114     }
       
   115 
       
   116 // -----------------------------------------------------------------------------
       
   117 // CMccDataPathBase::ChangeDataPathTransferState
       
   118 // Changes the transfer state of the datapath
       
   119 // ----------------------------------------------------------------------------- 
       
   120 TBool CMccDataPathBase::ChangeDataPathTransferState( 
       
   121     TTransferState aTransferState, 
       
   122     TBool aFailureFallback )
       
   123     {
       
   124     // On failure fallback situation, keep on asking data
       
   125     if ( !aFailureFallback &&
       
   126        ( iTransferState == EWaitSource && aTransferState == ENeedSourceData ) )
       
   127         {
       
   128         // Do not allow fillbuffer request if such request is already active
       
   129         return EFalse;
       
   130         }
       
   131            
       
   132     iTransferState = aTransferState;
       
   133     
       
   134     switch( iState )
       
   135         {
       
   136         case EStreaming:
       
   137             if ( ( EWaitSink != iTransferState ) && 
       
   138                  ( EWaitSource != iTransferState ) &&
       
   139                  ( ECanceled != iTransferState ) )
       
   140                 {
       
   141                 // If not waiting for something to happen, activate
       
   142                 TRequestStatus* stat = &iStatus;
       
   143                 this->Cancel(); 
       
   144                 User::RequestComplete( stat, KErrNone );
       
   145                 this->SetActive();
       
   146                 }
       
   147             break;
       
   148         default:
       
   149             // Not a supported state for transfer state
       
   150             break;
       
   151         }
       
   152         
       
   153     return ETrue;
       
   154     }
       
   155 
       
   156 // -----------------------------------------------------------------------------
       
   157 // CMccDataPathBase::CreateDataPathL
       
   158 // Datapath creating
       
   159 // -----------------------------------------------------------------------------
       
   160 void CMccDataPathBase::CreateDataPathL( MDataSource* aSource, MDataSink* aSink )
       
   161     { 
       
   162 	__SUBCONTROLLER( "CMccDataPathBase::CreateDataPathL" )
       
   163     iDataPathCreated = EFalse;
       
   164     
       
   165     if ( aSource && aSink ) 
       
   166         { 
       
   167         TFourCC sourceFourCC = aSource->SourceDataTypeCode( iMediaId );
       
   168         TFourCC sinkFourCC = aSink->SinkDataTypeCode( iMediaId );
       
   169 		__SUBCONTROLLER_INT1( "CMccDataPathBase source", aSource->DataSourceType().iUid )
       
   170 		__SUBCONTROLLER_INT1( "CMccDataPathBase sourceFourCC", sourceFourCC.FourCC() )
       
   171 		__SUBCONTROLLER_INT1( "CMccDataPathBase sink", aSink->DataSinkType().iUid )
       
   172 		__SUBCONTROLLER_INT1( "CMccDataPathBase sinkFourCC", sinkFourCC.FourCC() )
       
   173         
       
   174         if ( ( sourceFourCC != sinkFourCC ) && 
       
   175              ( KMMFFourCCCodeNULL != sourceFourCC.FourCC() ) && 
       
   176              ( KMMFFourCCCodeNULL != sinkFourCC.FourCC() ) )
       
   177             {
       
   178 			__SUBCONTROLLER( "CMccDataPathBase::CreateDataPathL, not compatible, ignored" )			
       
   179             iDataPathCreated = ETrue;
       
   180             } 
       
   181         else
       
   182             { 
       
   183 			__SUBCONTROLLER( "CMccDataPathBase::CreateDataPathL, created" )
       
   184             iDataPathCreated = ETrue;
       
   185             }
       
   186 
       
   187         User::LeaveIfError( this->SetSinkDataTypeCode( sourceFourCC, iMediaId ) );
       
   188         User::LeaveIfError( this->SetSourceDataTypeCode( sourceFourCC, iMediaId ) );
       
   189         }
       
   190     else
       
   191         {
       
   192 		__SUBCONTROLLER( "CMccDataPathBase::CreateDataPathL, KErrNotReady" )
       
   193         User::Leave( KErrNotReady );
       
   194         }
       
   195 	__SUBCONTROLLER( "CMccDataPathBase::CreateDataPathL, exit" )
       
   196     }
       
   197 
       
   198 // -----------------------------------------------------------------------------
       
   199 // CMccDataPathBase::~CMccDataPathBase
       
   200 // Destructor
       
   201 // -----------------------------------------------------------------------------
       
   202 CMccDataPathBase::~CMccDataPathBase()
       
   203     {
       
   204     delete iCompleteCallback;
       
   205     Cancel();
       
   206 
       
   207     
       
   208     iDataSink = NULL;
       
   209     iDataSource = NULL;
       
   210     iSourceBuffer = NULL;  
       
   211     iSinkBuffer = NULL;
       
   212     iEventHandler = NULL;
       
   213     }
       
   214 
       
   215 // -----------------------------------------------------------------------------
       
   216 // CMccDataPathBase::ConstructSinkL
       
   217 // From MDataSink
       
   218 // -----------------------------------------------------------------------------
       
   219 void CMccDataPathBase::ConstructSinkL( const TDesC8& /*aInitData*/ )
       
   220     {
       
   221     User::Leave( KErrNotSupported );
       
   222     }
       
   223 
       
   224 // -----------------------------------------------------------------------------
       
   225 // CMccDataPathBase::ConstructSourceL
       
   226 // From MDataSource
       
   227 // -----------------------------------------------------------------------------
       
   228 void CMccDataPathBase::ConstructSourceL( const TDesC8& /*aInitData*/ )
       
   229     {
       
   230     User::Leave( KErrNotSupported );
       
   231     }
       
   232 
       
   233 // -----------------------------------------------------------------------------
       
   234 // CMccDataPathBase::CanCreateSinkBuffer
       
   235 // From MDataSink
       
   236 // -----------------------------------------------------------------------------
       
   237 TBool CMccDataPathBase::CanCreateSinkBuffer()
       
   238     {
       
   239     // CMccDataPathBase can't create buffers
       
   240     return EFalse;
       
   241     }
       
   242 
       
   243 // -----------------------------------------------------------------------------
       
   244 // CMccDataPathBase::CanCreateSourceBuffer
       
   245 // From MDataSource
       
   246 // -----------------------------------------------------------------------------
       
   247 TBool CMccDataPathBase::CanCreateSourceBuffer()
       
   248     {
       
   249     // CMccDataPathBase can't create buffers
       
   250     return EFalse; 
       
   251     }
       
   252 
       
   253 // -----------------------------------------------------------------------------
       
   254 // CMccUlDataPath::CreateSinkBufferL
       
   255 // From MDataSink
       
   256 // -----------------------------------------------------------------------------
       
   257 CMMFBuffer* CMccDataPathBase::CreateSinkBufferL( TMediaId /*aMediaId*/, 
       
   258                                                          TBool& /*aReference*/ )
       
   259     {
       
   260     // CMccDataPathBase can't create buffers
       
   261     User::Leave( KErrNotSupported );
       
   262     return NULL;
       
   263     }
       
   264 
       
   265 // -----------------------------------------------------------------------------
       
   266 // CMccDataPathBase::CreateSourceBufferL
       
   267 // From MDataSource
       
   268 // -----------------------------------------------------------------------------
       
   269 CMMFBuffer* CMccDataPathBase::CreateSourceBufferL( TMediaId /*aMediaId*/, 
       
   270                                                          TBool& /*aReference*/ )
       
   271     {
       
   272     // CMccDataPathBase can't create buffers
       
   273     User::Leave( KErrNotSupported );
       
   274     return NULL;
       
   275     }
       
   276 
       
   277 // -----------------------------------------------------------------------------
       
   278 // -----------------------------------------------------------------------------
       
   279 // CMccDataPathBase::FillBufferL
       
   280 // From MDataSource
       
   281 // -----------------------------------------------------------------------------
       
   282 void CMccDataPathBase::FillBufferL( CMMFBuffer* /*aBuffer*/, 
       
   283         MDataSink* /*aConsumer*/, TMediaId /*aMediaId*/ )
       
   284     {
       
   285     // Not implemented
       
   286     User::Leave( KErrNotSupported );
       
   287     }
       
   288 
       
   289 // -----------------------------------------------------------------------------
       
   290 // CMccDataPathBase::IsBufferSupportedL
       
   291 // Checks if the given buffer is supported
       
   292 // -----------------------------------------------------------------------------
       
   293 void CMccDataPathBase::IsBufferSupportedL( CMMFBuffer* aBuffer )
       
   294     {
       
   295    	__ASSERT_ALWAYS ( aBuffer, User::Leave(KErrArgument) );
       
   296 
       
   297     TUid type = aBuffer->Type();
       
   298 
       
   299     if( KUidMmfDataBuffer == type )
       
   300         {
       
   301         return;
       
   302         }
       
   303     else if( KUidMmfTransferBuffer == type )
       
   304         {
       
   305         return;
       
   306         }
       
   307     else if( KUidMmfAudioBuffer == type )
       
   308         {
       
   309         return;
       
   310         }
       
   311     else if( KUidMmfPtrBuffer == type )
       
   312         {
       
   313         return;
       
   314         }
       
   315     else
       
   316         {
       
   317         User::Leave( KErrNotSupported );
       
   318         }
       
   319     }
       
   320 
       
   321 // -----------------------------------------------------------------------------
       
   322 // CMccDataPathBase::CopyBuffer
       
   323 // copy data and settings from one buffer to another
       
   324 // -----------------------------------------------------------------------------
       
   325 void CMccDataPathBase::CopyBuffer( CMMFBuffer* aDesBuffer,
       
   326                                    CMMFBuffer* aOrigBuffer)
       
   327 	{
       
   328 	// No need to copy if parameters point to the same buffer.
       
   329 	if ( ( aDesBuffer && aOrigBuffer ) && ( aDesBuffer != aOrigBuffer ) )
       
   330 	    {
       
   331     	// copy buffer data
       
   332     	CMMFDataBuffer* desBuffer(
       
   333     	    static_cast<CMMFDataBuffer*>( aDesBuffer ) );
       
   334         
       
   335         desBuffer->Data().Copy(
       
   336             static_cast<CMMFDataBuffer*>( aOrigBuffer )->Data() );	
       
   337         
       
   338         // copy buffer setting
       
   339         aDesBuffer->SetFrameNumber( aOrigBuffer->FrameNumber() );
       
   340         aDesBuffer->SetLastBuffer( aOrigBuffer->LastBuffer() );
       
   341         aDesBuffer->SetPosition( aOrigBuffer->Position() );
       
   342         aDesBuffer->SetStatus( aOrigBuffer->Status() );
       
   343         aDesBuffer->SetTimeToPlay( aOrigBuffer->TimeToPlay() );
       
   344 	    }
       
   345 	else
       
   346 	    {
       
   347 	    __SUBCONTROLLER("CMccDataPathBase::CopyBuffer, null buffer")	
       
   348 	    }
       
   349 	}
       
   350 
       
   351 // -----------------------------------------------------------------------------
       
   352 // CMccDataPathBase::CreateCompleteCallBackL
       
   353 // a CCompleteCallback object is created
       
   354 // -----------------------------------------------------------------------------
       
   355 void CMccDataPathBase::CreateCompleteCallBackL()
       
   356 	{
       
   357     __ASSERT_ALWAYS( iDataSink, User::Leave(KErrArgument) );
       
   358 
       
   359 	if ( iCompleteCallback )
       
   360         {
       
   361         delete iCompleteCallback;
       
   362         iCompleteCallback = NULL;
       
   363         }
       
   364         
       
   365     TBool waitForSink = IsMmfEndpoint( iDataSink );
       
   366     iCompleteCallback = new ( ELeave ) CCompleteCallback( *iEventHandler, waitForSink );	
       
   367 	}
       
   368 
       
   369 // -----------------------------------------------------------------------------
       
   370 // CMccDataPathBase::SignalDataPathCompleteL
       
   371 // a signal the datapath complete with a error code
       
   372 // -----------------------------------------------------------------------------
       
   373 void CMccDataPathBase::SignalDataPathCompleteL( TInt aErrorCode )
       
   374 	{
       
   375 	__ASSERT_ALWAYS( iCompleteCallback, User::Leave( KErrArgument ) );
       
   376     iCompleteCallback->SignalDataPathComplete( aErrorCode );	
       
   377 	}
       
   378         
       
   379 
       
   380 // -----------------------------------------------------------------------------
       
   381 // CMccDataPathBase::SetSinkDataTypeCode
       
   382 // From MDataSink
       
   383 // -----------------------------------------------------------------------------
       
   384 TInt CMccDataPathBase::SetSinkDataTypeCode( TFourCC aSinkFourCC, TMediaId aMediaId )
       
   385     {
       
   386     if( iMediaId.iMediaType == aMediaId.iMediaType )
       
   387         {
       
   388         iSinkFourCC = aSinkFourCC;
       
   389         if ( iAssociatedSink )
       
   390             {
       
   391             iAssociatedSink->SetSinkDataTypeCode( aSinkFourCC, aMediaId );
       
   392             }
       
   393         return KErrNone;
       
   394         }
       
   395     else
       
   396         {
       
   397         return KErrNotSupported;
       
   398         }
       
   399     }
       
   400 
       
   401 // -----------------------------------------------------------------------------
       
   402 // CMccDataPathBase::SetSourceDataTypeCode
       
   403 // From MDataSource
       
   404 // -----------------------------------------------------------------------------
       
   405 TInt CMccDataPathBase::SetSourceDataTypeCode( TFourCC aSourceFourCC, TMediaId aMediaId )
       
   406     {
       
   407     if( iMediaId.iMediaType == aMediaId.iMediaType )
       
   408         {
       
   409         iSourceFourCC = aSourceFourCC;
       
   410         if ( iAssociatedSource )
       
   411             {
       
   412             iAssociatedSource->SetSourceDataTypeCode( aSourceFourCC, aMediaId );
       
   413             }
       
   414         return KErrNone;
       
   415         }
       
   416     else
       
   417         {
       
   418         return KErrNotSupported;
       
   419         }
       
   420     }
       
   421 
       
   422 // -----------------------------------------------------------------------------
       
   423 // CMccDataPathBase::SetState
       
   424 // Sets the current datapath state
       
   425 // -----------------------------------------------------------------------------
       
   426 void CMccDataPathBase::SetStateL( const TDataPathState& aState )
       
   427     {
       
   428     /*
       
   429     * States are EStopped, EPrimed, EStreaming
       
   430     * Following transitions are valid:
       
   431     * STOP -> EPrimed, EStopped
       
   432     * PRIMED -> EStreaming, EStopped
       
   433     * STREAMING -> EStopped, EPaused
       
   434     * PAUSED -> EStreaming, EStopped
       
   435     * ANY -> EStopped
       
   436     */
       
   437     
       
   438     switch( iState )
       
   439         {
       
   440         case EStopped:
       
   441             if( EPrimed == aState || EStopped == aState )
       
   442                 {
       
   443                 iState = aState;
       
   444                 }
       
   445             else
       
   446                 {
       
   447                 User::Leave( KErrArgument );
       
   448                 }
       
   449             break;
       
   450         case EPrimed:
       
   451             if( EStopped == aState || EStreaming == aState )
       
   452                 {
       
   453                 iState = aState;
       
   454                 }
       
   455             else
       
   456                 {
       
   457                 User::Leave( KErrArgument );
       
   458                 }
       
   459             break;
       
   460         case EStreaming:
       
   461             if( EStopped == aState || EPaused == aState )
       
   462                 {
       
   463                 iState = aState;
       
   464                 }
       
   465             else
       
   466                 {
       
   467                 User::Leave( KErrArgument );
       
   468                 }
       
   469             break;
       
   470         case EPaused:
       
   471             if( EStreaming == aState || EStopped == aState )
       
   472                 {
       
   473                 iState = aState;
       
   474                 }
       
   475             else
       
   476                 {
       
   477                 User::Leave( KErrArgument );
       
   478                 }
       
   479             break;
       
   480         default:
       
   481             User::Leave( KErrUnknown );
       
   482             break;
       
   483         }
       
   484     }
       
   485 
       
   486 // -----------------------------------------------------------------------------
       
   487 // CMccDataPathBase::EmptyBufferL
       
   488 // From MDataSink
       
   489 // -----------------------------------------------------------------------------
       
   490 void CMccDataPathBase::EmptyBufferL( CMMFBuffer* /* aBuffer */, MDataSource* 
       
   491                                           /*aSupplier*/, TMediaId /*aMediaId*/ )
       
   492     {
       
   493     User::Leave( KErrNotSupported );
       
   494     }
       
   495 
       
   496 // -----------------------------------------------------------------------------
       
   497 // CMccDataPathBase::SinkDataTypeCode
       
   498 // From MDataSink
       
   499 // -----------------------------------------------------------------------------
       
   500 TFourCC CMccDataPathBase::SinkDataTypeCode( TMediaId aMediaId )
       
   501     {
       
   502     if( KUidMediaTypeAudio == aMediaId.iMediaType ||
       
   503         KUidMediaTypeVideo == aMediaId.iMediaType )
       
   504         {
       
   505         return iSinkFourCC;
       
   506         }
       
   507     else
       
   508         {
       
   509         TFourCC dummy( KFourCCNULL );
       
   510         return dummy;
       
   511         }
       
   512     }
       
   513 
       
   514 // -----------------------------------------------------------------------------
       
   515 // CMccDataPathBase::SourceDataTypeCode
       
   516 // From MDataSource
       
   517 // -----------------------------------------------------------------------------
       
   518 TFourCC CMccDataPathBase::SourceDataTypeCode( TMediaId aMediaId )
       
   519     {
       
   520     if( KUidMediaTypeAudio == aMediaId.iMediaType || 
       
   521         KUidMediaTypeVideo == aMediaId.iMediaType )
       
   522         {
       
   523         return iSourceFourCC;
       
   524         }
       
   525     else
       
   526         {
       
   527         TFourCC dummy( KFourCCNULL );
       
   528         return dummy;
       
   529         }
       
   530     }
       
   531 
       
   532 // -----------------------------------------------------------------------------
       
   533 // CMccDataPathBase::State
       
   534 // Returns the current datapath state
       
   535 // -----------------------------------------------------------------------------
       
   536 TDataPathState CMccDataPathBase::State() const
       
   537     {
       
   538     return iState;
       
   539     }
       
   540 
       
   541 // -----------------------------------------------------------------------------
       
   542 // CMccDataPathBase::TransferState
       
   543 // Returns the current transferstate
       
   544 // -----------------------------------------------------------------------------
       
   545 TTransferState CMccDataPathBase::TransferState() const
       
   546     {
       
   547     return iTransferState;
       
   548     }
       
   549 
       
   550 // -----------------------------------------------------------------------------
       
   551 // CMccDataPathBase::ControlSource
       
   552 // -----------------------------------------------------------------------------  
       
   553 TBool CMccDataPathBase::ControlSource( TUint32 aEndpointId ) const
       
   554     {
       
   555     return ( MCC_CONTROL_ALL_ENDPOINTS( aEndpointId ) || 
       
   556              aEndpointId == MCC_ENDPOINT_ID( iAssociatedSource ) );
       
   557     }
       
   558  
       
   559 // -----------------------------------------------------------------------------
       
   560 // CMccDataPathBase::ControlSink
       
   561 // -----------------------------------------------------------------------------    
       
   562 TBool CMccDataPathBase::ControlSink( TUint32 aEndpointId ) const
       
   563     {
       
   564     return ( MCC_CONTROL_ALL_ENDPOINTS( aEndpointId ) || 
       
   565              aEndpointId == MCC_ENDPOINT_ID( iAssociatedSink ) );
       
   566     }
       
   567 
       
   568 // -----------------------------------------------------------------------------
       
   569 // CMccDataPathBase::IsMmfEndpoint
       
   570 // -----------------------------------------------------------------------------    
       
   571 TBool CMccDataPathBase::IsMmfEndpoint( MDataSink* aSink ) const
       
   572     {
       
   573     return ( aSink && aSink->DataSinkType() == KUidMmfAudioOutput );
       
   574     }
       
   575     
       
   576 // -----------------------------------------------------------------------------
       
   577 // CMccDataPathBase::IsMmfEndpoint
       
   578 // -----------------------------------------------------------------------------    
       
   579 TBool CMccDataPathBase::IsMmfEndpoint( MDataSource* aSource ) const
       
   580     {
       
   581     return ( aSource && aSource->DataSourceType() == KUidMmfAudioInput );
       
   582     }
       
   583     
       
   584 // -----------------------------------------------------------------------------
       
   585 // CMccDataPathBase::DoCancel
       
   586 // From CActive
       
   587 // -----------------------------------------------------------------------------
       
   588 void CMccDataPathBase::DoCancel()
       
   589     {
       
   590     // Nothing to do
       
   591     }
       
   592     
       
   593 // -----------------------------------------------------------------------------
       
   594 // CMccDataPathBase::EndOfData
       
   595 // End of data
       
   596 // -----------------------------------------------------------------------------
       
   597 void CMccDataPathBase::EndOfData()
       
   598     {
       
   599     TRAPD( err, DoEndOfDataL() );
       
   600 
       
   601     if ( err )
       
   602         {
       
   603         __SUBCONTROLLER_INT1("CMccDataPathBase::EndOfData(), err=", err)
       
   604         if ( iEventHandler )
       
   605 	        {
       
   606 	        iEventHandler->SendEventToClient( 
       
   607                 TMMFEvent( KMMFEventCategoryPlaybackComplete, err )  );
       
   608 	        }
       
   609         else
       
   610 	        {
       
   611 	        __SUBCONTROLLER("CMccDataPathBase::EndOfData(),iEventHandler=NULL")	
       
   612 	        }
       
   613         }
       
   614     }
       
   615 
       
   616 // -----------------------------------------------------------------------------
       
   617 // CMccDataPathBase::RunL
       
   618 // From CActive
       
   619 // -----------------------------------------------------------------------------
       
   620 void CMccDataPathBase::RunL()
       
   621     {
       
   622     switch ( State() )
       
   623         {
       
   624         case EStopped:
       
   625             break;
       
   626         case EPrimed:
       
   627             break;
       
   628         case EPaused:
       
   629             break;
       
   630         case EStreaming:
       
   631             switch ( TransferState() )
       
   632                 {
       
   633                 case EWaitSink:
       
   634                 case EWaitSource:
       
   635                     break;
       
   636                 case ENeedSourceData:
       
   637                     FillSourceBufferL();
       
   638                     break;
       
   639                 case ESendDataToSink:
       
   640                     EmptySinkBufferL();
       
   641                     break;
       
   642                 case EEndOfData:
       
   643                     EndOfData();
       
   644                     break;
       
   645                 default:
       
   646                     User::Leave( KErrArgument );
       
   647                     break;
       
   648                 }
       
   649             break;
       
   650         default:
       
   651             User::Leave( KErrArgument );
       
   652             break;
       
   653         }
       
   654     }
       
   655 
       
   656 // -----------------------------------------------------------------------------
       
   657 // CMccDataPathBase::RunError
       
   658 // From CActive
       
   659 // -----------------------------------------------------------------------------
       
   660 TInt CMccDataPathBase::RunError( TInt /*aError*/ )
       
   661     {
       
   662     return KErrNone;
       
   663     }
       
   664     
       
   665 // ========================== OTHER EXPORTED FUNCTIONS =========================
       
   666 
       
   667 //  End of File