|
1 /* |
|
2 * Copyright (c) 2010 Ixonos Plc. |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the "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 * Ixonos Plc |
|
14 * |
|
15 * Description: |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 #include "ProcTimeEstimateAO.h" |
|
24 |
|
25 |
|
26 void CProcTimeEstimateAO::RunL() |
|
27 { |
|
28 |
|
29 HBufC8* frame = 0; |
|
30 TInt progress = 0; |
|
31 TTimeIntervalMicroSeconds duration; |
|
32 |
|
33 |
|
34 TBool ret = EFalse; |
|
35 TRAPD(err, ret = iProcessingObject->ProcessSyncPieceL(frame, progress, duration)); |
|
36 |
|
37 if (err != KErrNone) |
|
38 { |
|
39 // something went wrong |
|
40 |
|
41 delete frame; |
|
42 |
|
43 delete iProcessingObject; |
|
44 iProcessingObject = 0; |
|
45 |
|
46 // notify |
|
47 iTEObserver->NotifyTimeEstimateReady(0); |
|
48 |
|
49 } |
|
50 |
|
51 if (!ret) |
|
52 { |
|
53 |
|
54 if (frame) |
|
55 { |
|
56 |
|
57 // frame is not needed |
|
58 delete frame; |
|
59 frame = 0; |
|
60 |
|
61 } |
|
62 |
|
63 SetActive(); |
|
64 TRequestStatus* status = &iStatus; |
|
65 User::RequestComplete(status, KErrNone); |
|
66 |
|
67 return; |
|
68 } |
|
69 else |
|
70 { |
|
71 |
|
72 TInt64 timeEstimate = iProcessingObject->GetFinalTimeEstimate(); |
|
73 |
|
74 |
|
75 delete iProcessingObject; |
|
76 iProcessingObject = 0; |
|
77 |
|
78 // notify |
|
79 iTEObserver->NotifyTimeEstimateReady(timeEstimate); |
|
80 |
|
81 return; |
|
82 |
|
83 } |
|
84 |
|
85 |
|
86 } |
|
87 |
|
88 void CProcTimeEstimateAO::DoCancel() |
|
89 { |
|
90 |
|
91 } |
|
92 |
|
93 CProcTimeEstimateAO* CProcTimeEstimateAO::NewL() |
|
94 { |
|
95 |
|
96 |
|
97 CProcTimeEstimateAO* self = new (ELeave) CProcTimeEstimateAO(); |
|
98 CleanupStack::PushL(self); |
|
99 self->ConstructL(); |
|
100 CleanupStack::Pop(self); |
|
101 return self; |
|
102 } |
|
103 |
|
104 CProcTimeEstimateAO::~CProcTimeEstimateAO() |
|
105 { |
|
106 Cancel(); |
|
107 delete iProcessingObject; |
|
108 |
|
109 } |
|
110 |
|
111 |
|
112 TBool CProcTimeEstimateAO::StartL(const CAudSong* aSong, MAudTimeEstimateObserver& aTEObserver) |
|
113 { |
|
114 |
|
115 iTEObserver = &aTEObserver; |
|
116 |
|
117 iSong = aSong; |
|
118 |
|
119 delete iProcessingObject; |
|
120 iProcessingObject = NULL; /* Must set to null before reallocating with NewL */ |
|
121 iProcessingObject = CProcProcess::NewL(); |
|
122 |
|
123 iProcessingObject->StartSyncProcessingL(iSong, ETrue); |
|
124 |
|
125 SetActive(); |
|
126 TRequestStatus* status = &iStatus; |
|
127 User::RequestComplete(status, KErrNone); |
|
128 |
|
129 return ETrue; |
|
130 |
|
131 } |
|
132 |
|
133 void CProcTimeEstimateAO::CancelTimeEstimate() |
|
134 { |
|
135 |
|
136 Cancel(); |
|
137 delete iProcessingObject; |
|
138 iProcessingObject = 0; |
|
139 // notify |
|
140 return; |
|
141 |
|
142 |
|
143 } |
|
144 |
|
145 void CProcTimeEstimateAO::ConstructL() |
|
146 { |
|
147 |
|
148 } |
|
149 |
|
150 CProcTimeEstimateAO::CProcTimeEstimateAO() : CActive(0) |
|
151 { |
|
152 |
|
153 CActiveScheduler::Add(this); |
|
154 |
|
155 } |
|
156 |