0
|
1 |
// Copyright (c) 2003-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 |
// Test system includes
|
|
17 |
#include "TSU_MMF_SWCDWRAP_RecordHwDevObserver.h"
|
|
18 |
|
|
19 |
CTestRecordMMFHwDeviceObserver::CTestRecordMMFHwDeviceObserver(CMMFHwDevice* aHwDevice) : CTestMMFHwDeviceObserver(aHwDevice)
|
|
20 |
{
|
|
21 |
}
|
|
22 |
|
|
23 |
CTestRecordMMFHwDeviceObserver::~CTestRecordMMFHwDeviceObserver()
|
|
24 |
{
|
|
25 |
iSinkFile.Close();
|
|
26 |
delete iFileWriter;
|
|
27 |
}
|
|
28 |
|
|
29 |
|
|
30 |
TInt CTestRecordMMFHwDeviceObserver::WriteBufferDirectToFileAsync(const TDesC& aFileName, TUint aNumberOfBuffers)
|
|
31 |
{
|
|
32 |
TInt error = KErrNone;
|
|
33 |
|
|
34 |
if (!iFileServerSession.Handle())
|
|
35 |
{//open a handle to the file server
|
|
36 |
error = iFileServerSession.Connect();
|
|
37 |
}
|
|
38 |
|
|
39 |
if (!error)
|
|
40 |
{
|
|
41 |
//make sure file to be recorded is deleted before we start
|
|
42 |
error = iFileServerSession.Delete(aFileName);
|
|
43 |
if (error == KErrNotFound)
|
|
44 |
error = KErrNone; //KErrNotFound is not an error, means file doesn't exist
|
|
45 |
|
|
46 |
if (!error)
|
|
47 |
{
|
|
48 |
error = iSinkFile.Create(iFileServerSession, aFileName, EFileWrite);
|
|
49 |
if (!error)
|
|
50 |
{
|
|
51 |
if (!iFileWriter)
|
|
52 |
TRAP(error,iFileWriter = new(ELeave) CTestFileWriter(iSinkFile, this));
|
|
53 |
}
|
|
54 |
if (!error)
|
|
55 |
{
|
|
56 |
iNumberOfBuffers = aNumberOfBuffers;
|
|
57 |
}
|
|
58 |
}
|
|
59 |
}
|
|
60 |
return error;
|
|
61 |
}
|
|
62 |
|
|
63 |
|
|
64 |
void CTestRecordMMFHwDeviceObserver::FileWriteComplete(TInt aError)
|
|
65 |
{
|
|
66 |
if (aError == KErrNone)
|
|
67 |
{
|
|
68 |
TInt error = KErrNone;
|
|
69 |
if (iCurrentBufferNumber >= iNumberOfBuffers)
|
|
70 |
{
|
|
71 |
error = iHwDevice->Stop();
|
|
72 |
StopActiveScheduler();
|
|
73 |
}
|
|
74 |
else if (iCurrentHwDeviceDataBuffer->LastBuffer() || iCurrentHwDeviceDataBuffer->BufferSize()==0)
|
|
75 |
{
|
|
76 |
error = iHwDevice->Stop();
|
|
77 |
StopActiveScheduler();
|
|
78 |
}
|
|
79 |
else
|
|
80 |
{//tell hw device we've emptied it and get another buffer
|
|
81 |
error = iHwDevice->ThisHwBufferEmptied(*iCurrentHwDeviceDataBuffer);
|
|
82 |
}
|
|
83 |
if (!iError)
|
|
84 |
iError = error; //log error in observer error
|
|
85 |
}
|
|
86 |
else
|
|
87 |
{
|
|
88 |
iError = aError;
|
|
89 |
}
|
|
90 |
}
|
|
91 |
|
|
92 |
|
|
93 |
TInt CTestRecordMMFHwDeviceObserver::EmptyThisHwBuffer(CMMFBuffer& aHwDataBuffer)
|
|
94 |
{
|
|
95 |
//called on recording when buffer needs to be written to file
|
|
96 |
TInt error = KErrNone;
|
|
97 |
iCurrentBufferNumber++;
|
|
98 |
iCurrentHwDeviceDataBuffer = &(static_cast<CMMFDataBuffer&>(aHwDataBuffer));
|
|
99 |
|
|
100 |
if (iCurrentBufferNumber <= iNumberOfBuffers)
|
|
101 |
{
|
|
102 |
error = iFileWriter->Write(*iCurrentHwDeviceDataBuffer);
|
|
103 |
}
|
|
104 |
if (!iError)
|
|
105 |
iError = error; //log error in observer error
|
|
106 |
return error;
|
|
107 |
}
|
|
108 |
|
|
109 |
|
|
110 |
void CTestRecordMMFHwDeviceObserver::Stopped()
|
|
111 |
{
|
|
112 |
}
|
|
113 |
|
|
114 |
|
|
115 |
RFile& CTestRecordMMFHwDeviceObserver::WriteFile()
|
|
116 |
{
|
|
117 |
return iSinkFile;
|
|
118 |
}
|
|
119 |
|
|
120 |
|
|
121 |
|