multimediacommscontroller/mmccsubcontroller/src/mcccompletecallback.cpp
changeset 0 1bce908db942
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 /*
       
     2 * Copyright (c) 2002-2004 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:    Waits for sink buffer flushing in datapaths
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 #include <mmf/common/mmfcontroller.h>
       
    23 #include "mcccompletecallback.h"
       
    24 #include "mcculdatapath.h"
       
    25 #include "mccdldatapath.h"
       
    26 
       
    27 // EXTERNAL DATA STRUCTURES
       
    28 
       
    29 // EXTERNAL FUNCTION PROTOTYPES  
       
    30 
       
    31 // CONSTANTS
       
    32 
       
    33 // MACROS
       
    34 
       
    35 // LOCAL CONSTANTS AND MACROS
       
    36 
       
    37 // MODULE DATA STRUCTURES
       
    38 
       
    39 // LOCAL FUNCTION PROTOTYPES
       
    40 
       
    41 // FORWARD DECLARATIONS
       
    42 
       
    43 // ============================= LOCAL FUNCTIONS ===============================
       
    44 
       
    45 // ============================ MEMBER FUNCTIONS ===============================
       
    46 
       
    47 // -----------------------------------------------------------------------------
       
    48 // CCompleteCallback::CCompleteCallback
       
    49 // Constructor
       
    50 // -----------------------------------------------------------------------------
       
    51 CCompleteCallback::CCompleteCallback( MAsyncEventHandler& aEventhandler, 
       
    52         TBool aWaitForSink ) : CActive( EPriorityNormal ), 
       
    53         iEventhandler( aEventhandler ),
       
    54         iWaitForSink( aWaitForSink )
       
    55     {
       
    56     CActiveScheduler::Add( this );
       
    57     }
       
    58 
       
    59 // -----------------------------------------------------------------------------
       
    60 // CCompleteCallback::~CCompleteCallback
       
    61 // Destructor
       
    62 // -----------------------------------------------------------------------------
       
    63 CCompleteCallback::~CCompleteCallback()
       
    64     {
       
    65     Cancel();
       
    66     }
       
    67 
       
    68 // -----------------------------------------------------------------------------
       
    69 // CCompleteCallback::SignalDataPathComplete
       
    70 // Signals that datapath is completed
       
    71 // -----------------------------------------------------------------------------
       
    72 void CCompleteCallback::SignalDataPathComplete( TInt aDataPathError )
       
    73     {
       
    74     iDataPathComplete = ETrue;
       
    75     iDataPathError = aDataPathError;
       
    76     if ( !IsActive() )
       
    77         {
       
    78         // Signal ourselves to run with the given completion code
       
    79         TRequestStatus* status = &ActiveStatus();
       
    80         User::RequestComplete( status, KErrNone );
       
    81         }
       
    82     }
       
    83 
       
    84 // -----------------------------------------------------------------------------
       
    85 // CCompleteCallback::ActiveStatus
       
    86 // Sets the object active and returns it's status
       
    87 // -----------------------------------------------------------------------------
       
    88 TRequestStatus& CCompleteCallback::ActiveStatus()
       
    89     {
       
    90     SetActive();
       
    91     return iStatus;
       
    92     }
       
    93 
       
    94 // -----------------------------------------------------------------------------
       
    95 // CCompleteCallback::DoCancel
       
    96 // Cancel worker functions
       
    97 // -----------------------------------------------------------------------------
       
    98 void CCompleteCallback::DoCancel()
       
    99     {
       
   100     }
       
   101 
       
   102 // -----------------------------------------------------------------------------
       
   103 // CCompleteCallback::RunL
       
   104 // Active object event handling
       
   105 // -----------------------------------------------------------------------------
       
   106 void CCompleteCallback::RunL()
       
   107     {
       
   108     if ( iWaitForSink )
       
   109         {
       
   110         if ( iDataPathComplete && iSinkComplete )
       
   111             {
       
   112             iDataPathComplete = EFalse;
       
   113             iSinkComplete = EFalse;
       
   114             // If we have to wait for the sink to complete, always use the sink error
       
   115             TMMFEvent event( KMMFEventCategoryPlaybackComplete, iSinkError );
       
   116             iEventhandler.SendEventToClient( event );
       
   117             }
       
   118         }
       
   119     else if ( iDataPathComplete )
       
   120         {
       
   121         iDataPathComplete = EFalse;
       
   122         iSinkComplete = EFalse;        
       
   123         TMMFEvent event( KMMFEventCategoryPlaybackComplete, iSinkError );
       
   124         iEventhandler.SendEventToClient( event );
       
   125         }
       
   126     else
       
   127         {
       
   128         // RunL activated for someunknown reason, so leave
       
   129         User::Leave( KErrUnknown );
       
   130         }
       
   131     };
       
   132 
       
   133 // -----------------------------------------------------------------------------
       
   134 // CCompleteCallback::RunError
       
   135 // Active object event handling
       
   136 // -----------------------------------------------------------------------------
       
   137 TInt CCompleteCallback::RunError( TInt /*aError*/ )
       
   138 	{
       
   139 	return KErrNone;
       
   140 	}
       
   141 
       
   142 // ========================== OTHER EXPORTED FUNCTIONS =========================
       
   143 
       
   144 //  End of File