|
1 /* |
|
2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "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 * |
|
14 * Description: Video Source subsystem. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "cmultiframeloopao.h" |
|
21 #include "cmultiframeprovider.h" |
|
22 #include "VSPanic.h" |
|
23 |
|
24 // MACROS |
|
25 |
|
26 #ifdef _DEBUG |
|
27 # define __IF_DEBUG(t) {RDebug::t;} |
|
28 #else |
|
29 # define __IF_DEBUG(t) |
|
30 #endif |
|
31 // ============================ CMultiframeloopAO =============================== |
|
32 |
|
33 // ----------------------------------------------------------------------------- |
|
34 // CMultiframeloopAO::CMultiframeloopAO( CMultiframeProvider* aRequester ) |
|
35 // ----------------------------------------------------------------------------- |
|
36 // |
|
37 CMultiframeloopAO::CMultiframeloopAO( CMultiframeProvider* aRequester ) |
|
38 : CActive( EPriorityLow ), iRequester( aRequester ), iFreeBMCount(0), iRequireStopping(EFalse) |
|
39 { |
|
40 __IF_DEBUG(Print(_L("VideoSource [%d]: CMultiframeloopAO::CMultiframeloopAO() >>"), RThread().Id().operator TUint())); |
|
41 RThread me; |
|
42 iThreadId = me.Id(); |
|
43 CActiveScheduler::Add( this ); |
|
44 __IF_DEBUG(Print(_L("VideoSource [%d]: CMultiframeloopAO::CMultiframeloopAO() <<"), RThread().Id().operator TUint())); |
|
45 } |
|
46 |
|
47 // ----------------------------------------------------------------------------- |
|
48 // CMultiframeloopAO::~CMultiframeloopAO() |
|
49 // ----------------------------------------------------------------------------- |
|
50 // |
|
51 CMultiframeloopAO::~CMultiframeloopAO() |
|
52 { |
|
53 __IF_DEBUG(Print(_L("VideoSource [%d]: CMultiframeloopAO::~CMultiframeloopAO() >>"), RThread().Id().operator TUint())); |
|
54 Cancel(); |
|
55 __IF_DEBUG(Print(_L("VideoSource [%d]: CMultiframeloopAO::~CMultiframeloopAO() <<"), RThread().Id().operator TUint())); |
|
56 } |
|
57 |
|
58 // ----------------------------------------------------------------------------- |
|
59 // CMultiframeloopAO::Signal( ) |
|
60 // ----------------------------------------------------------------------------- |
|
61 // |
|
62 void CMultiframeloopAO::Signal( ) |
|
63 { |
|
64 __IF_DEBUG(Print(_L("VideoSource [%d]: CMultiframeloopAO::Signal() >>"), RThread().Id().operator TUint())); |
|
65 iRequester->iAnimation = ETrue; |
|
66 if ( !IsActive() ) |
|
67 { |
|
68 SetActive(); |
|
69 TRequestStatus* pStatus = &iStatus; |
|
70 RThread me; |
|
71 if ( me.Id() == iThreadId ) |
|
72 { |
|
73 User::RequestComplete( pStatus, KErrNone ); |
|
74 } |
|
75 else |
|
76 { |
|
77 if ( me.Open( iThreadId ) == KErrNone ) |
|
78 { |
|
79 *pStatus = KRequestPending; |
|
80 me.RequestComplete( pStatus, KErrNone ); |
|
81 me.Close(); |
|
82 } |
|
83 else |
|
84 { |
|
85 Panic( EVSPanicThreadOpenFailure ); |
|
86 } |
|
87 } |
|
88 } |
|
89 __IF_DEBUG(Print(_L("VideoSource [%d]: CMultiframeloopAO::Signal() <<"), RThread().Id().operator TUint())); |
|
90 } |
|
91 |
|
92 // ----------------------------------------------------------------------------- |
|
93 // CMultiframeloopAO::RunL() |
|
94 // ----------------------------------------------------------------------------- |
|
95 // |
|
96 void CMultiframeloopAO::RunL() |
|
97 { |
|
98 iRequester->WaitForConverting(); |
|
99 __IF_DEBUG(Print(_L("VideoSource [%d]: CMultiframeloopAO::RunL() >>"), RThread().Id().operator TUint())); |
|
100 |
|
101 //stop loop ao |
|
102 if (iRequireStopping) |
|
103 { |
|
104 __IF_DEBUG(Print(_L("VideoSource [%d]: CMultiframeloopAO::RunL() CANCEL CALLED,stop by flag"), RThread().Id().operator TUint())); |
|
105 iRequireStopping = EFalse; |
|
106 iRequester->ReleaseForConverting(); |
|
107 return; |
|
108 } |
|
109 |
|
110 // Cancel is handled in this way because |
|
111 if ( iStatus == KErrCancel) |
|
112 { |
|
113 __IF_DEBUG(Print(_L("VideoSource [%d]: CMultiframeloopAO::RunL() CANCEL CALLED IN PROTO THREAD STOP LOOPPING"), RThread().Id().operator TUint())); |
|
114 iRequester->ReleaseForConverting(); |
|
115 return; |
|
116 } |
|
117 |
|
118 //If free bitmaps proceed next frame |
|
119 if ( iFreeBMCount > 0 ) |
|
120 { |
|
121 ++iIndex; |
|
122 // Loop animation starting from first frame |
|
123 if ( iIndex > iFramecount - 1 ) |
|
124 { |
|
125 iIndex = KFirstFrameIndx; |
|
126 } |
|
127 __IF_DEBUG(Print(_L("VideoSource [%d]: CMultiframeloopAO::RunL() RunL index %d"), RThread().Id().operator TUint(), iIndex)); |
|
128 iRequester->ConvertAndScaleL( iIndex ); |
|
129 } |
|
130 //Wait until free bitmaps to proceed |
|
131 else |
|
132 { |
|
133 __IF_DEBUG(Print(_L("VideoSource [%d]: CMultiframeloopAO::RunL() NO FREE BMs"), RThread().Id().operator TUint())); |
|
134 iStatus = KRequestPending; |
|
135 SetActive(); |
|
136 } |
|
137 __IF_DEBUG(Print(_L("VideoSource [%d]: CMultiframeloopAO::RunL() <<"), RThread().Id().operator TUint())); |
|
138 iRequester->ReleaseForConverting(); |
|
139 } |
|
140 // ----------------------------------------------------------------------------- |
|
141 // CMultiframeloopAO::RemoveFreeBitmaps() |
|
142 // ----------------------------------------------------------------------------- |
|
143 // |
|
144 void CMultiframeloopAO::RemoveFreeBitmaps( TInt aCount ) |
|
145 { |
|
146 __IF_DEBUG(Print(_L("VideoSource [%d]: CMultiframeloopAO::RemoveFreeBitmaps() >>"), RThread().Id().operator TUint())); |
|
147 iFreeBMCount = iFreeBMCount - aCount; |
|
148 __IF_DEBUG(Print(_L("VideoSource [%d]: CMultiframeloopAO::RemoveFreeBitmaps() frames %d <<"), RThread().Id().operator TUint(), aCount)); |
|
149 } |
|
150 |
|
151 // ----------------------------------------------------------------------------- |
|
152 // CMultiframeloopAO::SetFreeBitmaps() |
|
153 // ----------------------------------------------------------------------------- |
|
154 // |
|
155 void CMultiframeloopAO::SetFreeBitmaps( TInt aCount ) |
|
156 { |
|
157 __IF_DEBUG(Print(_L("VideoSource [%d]: CMultiframeloopAO::SetFreeBitmaps() >>"), RThread().Id().operator TUint())); |
|
158 iFreeBMCount = iFreeBMCount + aCount; |
|
159 if ( IsActive() && iStatus == KRequestPending) |
|
160 { |
|
161 TRequestStatus* pStatus = &iStatus; |
|
162 User::RequestComplete( pStatus, KErrNone ); |
|
163 } |
|
164 |
|
165 __IF_DEBUG(Print(_L("VideoSource [%d]: CMultiframeloopAO::SetFreeBitmaps() frames %d <<"), RThread().Id().operator TUint(), aCount)); |
|
166 } |
|
167 // ----------------------------------------------------------------------------- |
|
168 // CMultiframeloopAO::SetFrameCount() |
|
169 // ----------------------------------------------------------------------------- |
|
170 // |
|
171 void CMultiframeloopAO::SetFrameCount( TInt aCount ) |
|
172 { |
|
173 __IF_DEBUG(Print(_L("VideoSource [%d]: CMultiframeloopAO::SetFrameCount() >>"), RThread().Id().operator TUint())); |
|
174 iFramecount = aCount; |
|
175 iIndex = 0; |
|
176 __IF_DEBUG(Print(_L("VideoSource [%d]: CMultiframeloopAO::SetFrameCount() frames %d <<"), RThread().Id().operator TUint(), aCount)); |
|
177 } |
|
178 |
|
179 // ----------------------------------------------------------------------------- |
|
180 // CMultiframeloopAO::CancelDataLoop() |
|
181 // ----------------------------------------------------------------------------- |
|
182 // |
|
183 void CMultiframeloopAO::CancelDataLoop() |
|
184 { |
|
185 __IF_DEBUG(Print(_L("VideoSource [%d]: CMultiframeloopAO::CancelDataLoop() >>"), RThread().Id().operator TUint())); |
|
186 if ( IsActive() ) |
|
187 { |
|
188 if ( iStatus == KRequestPending ) |
|
189 { |
|
190 RThread me; |
|
191 if ( me.Id() == iThreadId ) |
|
192 { |
|
193 Cancel(); |
|
194 } |
|
195 else |
|
196 { |
|
197 if ( me.Open( iThreadId ) == KErrNone ) |
|
198 { |
|
199 TRequestStatus* pStatus = &iStatus; |
|
200 *pStatus = KRequestPending; |
|
201 me.RequestComplete( pStatus, KErrCancel ); |
|
202 me.Close(); |
|
203 } |
|
204 else |
|
205 { |
|
206 Panic( EVSPanicThreadOpenFailure ); |
|
207 } |
|
208 } |
|
209 } |
|
210 else |
|
211 { |
|
212 iRequireStopping = ETrue; |
|
213 } |
|
214 } |
|
215 __IF_DEBUG(Print(_L("VideoSource [%d]: CMultiframeloopAO::CancelDataLoop() <<"), RThread().Id().operator TUint())); |
|
216 } |
|
217 |
|
218 // ----------------------------------------------------------------------------- |
|
219 // CMultiframeloopAO::DoCancel() |
|
220 // ----------------------------------------------------------------------------- |
|
221 // |
|
222 void CMultiframeloopAO::DoCancel() |
|
223 { |
|
224 __IF_DEBUG(Print(_L("VideoSource [%d]: CMultiframeloopAO::DoCancel() >>"), RThread().Id().operator TUint())); |
|
225 if ( iStatus == KRequestPending ) |
|
226 { |
|
227 TRequestStatus* pStatus = &iStatus; |
|
228 User::RequestComplete( pStatus, KErrCancel ); |
|
229 } |
|
230 __IF_DEBUG(Print(_L("VideoSource [%d]: CMultiframeloopAO::DoCancel() <<"), RThread().Id().operator TUint())); |
|
231 } |
|
232 |
|
233 // End of File |