os/mm/mmlibs/mmfw/tsrc/mmfintegrationtest/ACLNT/CapTestServer/src/CapTestStep0014.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 #include "CapTestStep0014.h"
    17 
    18 CAudPlayUtilTS0014* CAudPlayUtilTS0014::NewL()
    19 	{
    20 	CAudPlayUtilTS0014* self = new (ELeave) CAudPlayUtilTS0014;
    21 	CleanupStack::PushL(self);
    22 	self->ConstructL();
    23 	CleanupStack::Pop();
    24 	return self;
    25 	}
    26 	
    27 void CAudPlayUtilTS0014::ConstructL()
    28 	{
    29 	// Create the audio player
    30 	iInternalState = EStateNone;
    31 	iPlayer = CMdaAudioRecorderUtility::NewL(*this, NULL, EMdaPriorityMax);
    32 	}
    33 	
    34 
    35 void CAudPlayUtilTS0014::StartProcessing(TRequestStatus& aStatus)
    36 	{
    37 	iStatus = &aStatus;
    38 	iInternalState = EStatePending;
    39 
    40 	iPlayer->OpenFileL(_L("c:\\rectest1.wav"));
    41 	CActiveScheduler::Start();
    42 	}
    43 		
    44 		
    45 TVerdict CAudPlayUtilTS0014::EndProcessingAndReturnResult(TDes8& aMessage)
    46 	{
    47 	iPlayer->Close();
    48 	aMessage.Copy(_L("Done"));
    49 	return iVerdict;
    50 //	return EPass;
    51 	}
    52 	
    53 void CAudPlayUtilTS0014::MoscoStateChangeEvent(CBase* /*aObject*/, TInt aPreviousState, TInt aCurrentState, TInt aErrorCode)
    54 	{
    55 	if (aErrorCode == KErrNone)
    56 		{
    57 		if (aPreviousState == CMdaAudioClipUtility::ENotReady && aCurrentState==CMdaAudioClipUtility::EOpen)
    58 			{
    59 			iPlayer->RecordL();
    60 			}
    61 		else if (aPreviousState == CMdaAudioClipUtility::EOpen && aCurrentState==CMdaAudioClipUtility::ERecording)
    62 			{
    63 			if(iInternalState == EStatePending)
    64 				{
    65 				User::RequestComplete(iStatus, KErrNone);
    66 				iInternalState = EStateComplete;
    67 				}
    68 			}
    69 		else if (aPreviousState == CMdaAudioClipUtility::ERecording && aCurrentState==CMdaAudioClipUtility::EOpen)
    70 			{
    71 			// this shouldn't happen as record will continue until interrupted
    72 			iVerdict = EPass;
    73 			CActiveScheduler::Stop();
    74 			if(iInternalState == EStatePending)
    75 				{
    76 				User::RequestComplete(iStatus, KErrCancel);
    77 				iInternalState = EStateComplete;
    78 				}
    79 			}
    80 		}
    81 	else if (aErrorCode == KErrInUse)
    82 		{
    83 		// double check state to ensure behaviour is correct
    84 		if (aPreviousState == CMdaAudioClipUtility::ERecording && aCurrentState==CMdaAudioClipUtility::EOpen)
    85 			{
    86 			iVerdict = EPass;
    87 			CActiveScheduler::Stop();
    88 			if(iInternalState == EStatePending)
    89 				{
    90 				User::RequestComplete(iStatus, KErrNone);
    91 				iInternalState = EStateComplete;
    92 				}
    93 			}
    94 		}
    95 
    96 	else 
    97 		{
    98 		iVerdict = EFail;
    99 		CActiveScheduler::Stop();
   100 		if(iInternalState == EStatePending)
   101 			{
   102 			User::RequestComplete(iStatus, aErrorCode);
   103 			iInternalState = EStateComplete;
   104 			}
   105 		}
   106 
   107 	}
   108 
   109 
   110 CAudPlayUtilTS0014::~CAudPlayUtilTS0014()
   111 	{
   112 	delete iPlayer;
   113 	}