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