os/mm/mmlibs/mmfw/tsrc/mmfintegrationtest/ACLNT/CapTestServer/src/CapTestStep0014.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/mm/mmlibs/mmfw/tsrc/mmfintegrationtest/ACLNT/CapTestServer/src/CapTestStep0014.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,113 @@
     1.4 +// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +#include "CapTestStep0014.h"
    1.20 +
    1.21 +CAudPlayUtilTS0014* CAudPlayUtilTS0014::NewL()
    1.22 +	{
    1.23 +	CAudPlayUtilTS0014* self = new (ELeave) CAudPlayUtilTS0014;
    1.24 +	CleanupStack::PushL(self);
    1.25 +	self->ConstructL();
    1.26 +	CleanupStack::Pop();
    1.27 +	return self;
    1.28 +	}
    1.29 +	
    1.30 +void CAudPlayUtilTS0014::ConstructL()
    1.31 +	{
    1.32 +	// Create the audio player
    1.33 +	iInternalState = EStateNone;
    1.34 +	iPlayer = CMdaAudioRecorderUtility::NewL(*this, NULL, EMdaPriorityMax);
    1.35 +	}
    1.36 +	
    1.37 +
    1.38 +void CAudPlayUtilTS0014::StartProcessing(TRequestStatus& aStatus)
    1.39 +	{
    1.40 +	iStatus = &aStatus;
    1.41 +	iInternalState = EStatePending;
    1.42 +
    1.43 +	iPlayer->OpenFileL(_L("c:\\rectest1.wav"));
    1.44 +	CActiveScheduler::Start();
    1.45 +	}
    1.46 +		
    1.47 +		
    1.48 +TVerdict CAudPlayUtilTS0014::EndProcessingAndReturnResult(TDes8& aMessage)
    1.49 +	{
    1.50 +	iPlayer->Close();
    1.51 +	aMessage.Copy(_L("Done"));
    1.52 +	return iVerdict;
    1.53 +//	return EPass;
    1.54 +	}
    1.55 +	
    1.56 +void CAudPlayUtilTS0014::MoscoStateChangeEvent(CBase* /*aObject*/, TInt aPreviousState, TInt aCurrentState, TInt aErrorCode)
    1.57 +	{
    1.58 +	if (aErrorCode == KErrNone)
    1.59 +		{
    1.60 +		if (aPreviousState == CMdaAudioClipUtility::ENotReady && aCurrentState==CMdaAudioClipUtility::EOpen)
    1.61 +			{
    1.62 +			iPlayer->RecordL();
    1.63 +			}
    1.64 +		else if (aPreviousState == CMdaAudioClipUtility::EOpen && aCurrentState==CMdaAudioClipUtility::ERecording)
    1.65 +			{
    1.66 +			if(iInternalState == EStatePending)
    1.67 +				{
    1.68 +				User::RequestComplete(iStatus, KErrNone);
    1.69 +				iInternalState = EStateComplete;
    1.70 +				}
    1.71 +			}
    1.72 +		else if (aPreviousState == CMdaAudioClipUtility::ERecording && aCurrentState==CMdaAudioClipUtility::EOpen)
    1.73 +			{
    1.74 +			// this shouldn't happen as record will continue until interrupted
    1.75 +			iVerdict = EPass;
    1.76 +			CActiveScheduler::Stop();
    1.77 +			if(iInternalState == EStatePending)
    1.78 +				{
    1.79 +				User::RequestComplete(iStatus, KErrCancel);
    1.80 +				iInternalState = EStateComplete;
    1.81 +				}
    1.82 +			}
    1.83 +		}
    1.84 +	else if (aErrorCode == KErrInUse)
    1.85 +		{
    1.86 +		// double check state to ensure behaviour is correct
    1.87 +		if (aPreviousState == CMdaAudioClipUtility::ERecording && aCurrentState==CMdaAudioClipUtility::EOpen)
    1.88 +			{
    1.89 +			iVerdict = EPass;
    1.90 +			CActiveScheduler::Stop();
    1.91 +			if(iInternalState == EStatePending)
    1.92 +				{
    1.93 +				User::RequestComplete(iStatus, KErrNone);
    1.94 +				iInternalState = EStateComplete;
    1.95 +				}
    1.96 +			}
    1.97 +		}
    1.98 +
    1.99 +	else 
   1.100 +		{
   1.101 +		iVerdict = EFail;
   1.102 +		CActiveScheduler::Stop();
   1.103 +		if(iInternalState == EStatePending)
   1.104 +			{
   1.105 +			User::RequestComplete(iStatus, aErrorCode);
   1.106 +			iInternalState = EStateComplete;
   1.107 +			}
   1.108 +		}
   1.109 +
   1.110 +	}
   1.111 +
   1.112 +
   1.113 +CAudPlayUtilTS0014::~CAudPlayUtilTS0014()
   1.114 +	{
   1.115 +	delete iPlayer;
   1.116 +	}