|
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 // MACROS |
|
20 |
|
21 #ifdef _DEBUG |
|
22 # define __IF_DEBUG(t) {RDebug::t;} |
|
23 #else |
|
24 # define __IF_DEBUG(t) |
|
25 #endif |
|
26 |
|
27 // ============================ CVSActiveWait =============================== |
|
28 |
|
29 // ----------------------------------------------------------------------------- |
|
30 // CVSActiveWait::~CVSActiveWait() |
|
31 // ----------------------------------------------------------------------------- |
|
32 // |
|
33 template <class R> |
|
34 CVSActiveWait< R >::~CVSActiveWait() |
|
35 { |
|
36 __IF_DEBUG(Print(_L("VideoSource [%d]: CVSActiveWait::~CVSActiveWait() >>"), RThread().Id().operator TUint())); |
|
37 Cancel(); |
|
38 __IF_DEBUG(Print(_L("VideoSource [%d]: CVSActiveWait::~CVSActiveWait() <<"), RThread().Id().operator TUint())); |
|
39 } |
|
40 |
|
41 // ----------------------------------------------------------------------------- |
|
42 // CVSActiveWait::RequestStatus() |
|
43 // ----------------------------------------------------------------------------- |
|
44 // |
|
45 template <class R> |
|
46 TRequestStatus* CVSActiveWait< R >::RequestStatus() |
|
47 { |
|
48 __IF_DEBUG(Print(_L("VideoSource [%d]: CVSActiveWait::RequestStatus() >>"), RThread().Id().operator TUint())); |
|
49 __IF_DEBUG(Print(_L("VideoSource [%d]: CVSActiveWait::RequestStatus() <<"), RThread().Id().operator TUint())); |
|
50 return &iStatus; |
|
51 } |
|
52 |
|
53 // ----------------------------------------------------------------------------- |
|
54 // CVSActiveWait::Signal( TInt aError ) |
|
55 // ----------------------------------------------------------------------------- |
|
56 // |
|
57 template <class R> |
|
58 void CVSActiveWait< R >::Signal( TInt aError ) |
|
59 { |
|
60 __IF_DEBUG(Print(_L("VideoSource [%d]: CVSActiveWait::Signal() >>"), RThread().Id().operator TUint())); |
|
61 if( IsActive() ) |
|
62 { |
|
63 TRequestStatus* status = &iStatus; |
|
64 User::RequestComplete( status, aError ); |
|
65 } |
|
66 __IF_DEBUG(Print(_L("VideoSource [%d]: CVSActiveWait::Signal() <<"), RThread().Id().operator TUint())); |
|
67 } |
|
68 |
|
69 // ----------------------------------------------------------------------------- |
|
70 // CVSActiveWait::RunL() |
|
71 // ----------------------------------------------------------------------------- |
|
72 // |
|
73 template <class R> |
|
74 void CVSActiveWait< R >::RunL() |
|
75 { |
|
76 __IF_DEBUG(Print(_L("VideoSource [%d]: CVSActiveWait::RunL() >>"), RThread().Id().operator TUint())); |
|
77 (iRequester->*iCallback)( iStatus.Int() ); |
|
78 __IF_DEBUG(Print(_L("VideoSource [%d]: CVSActiveWait::RunL() <<"), RThread().Id().operator TUint())); |
|
79 } |
|
80 |
|
81 // ----------------------------------------------------------------------------- |
|
82 // CVSActiveWait::DoCancel() |
|
83 // ----------------------------------------------------------------------------- |
|
84 // |
|
85 template <class R> |
|
86 void CVSActiveWait< R >::DoCancel() |
|
87 { |
|
88 __IF_DEBUG(Print(_L("VideoSource [%d]: CVSActiveWait::DoCancel() >>"), RThread().Id().operator TUint())); |
|
89 if ( iStatus == KRequestPending ) |
|
90 { |
|
91 TRequestStatus* pStatus = &iStatus; |
|
92 User::RequestComplete( pStatus, KErrCancel ); |
|
93 } |
|
94 __IF_DEBUG(Print(_L("VideoSource [%d]: CVSActiveWait::DoCancel() <<"), RThread().Id().operator TUint())); |
|
95 } |
|
96 |
|
97 // ----------------------------------------------------------------------------- |
|
98 // CVSActiveWait::CVSActiveWait( CAnimatedImageViewer* aRequester ) |
|
99 // ----------------------------------------------------------------------------- |
|
100 // |
|
101 template < class R > |
|
102 CVSActiveWait< R >::CVSActiveWait( R* aRequester ) |
|
103 : CActive( EPriorityHigh ), iRequester( aRequester ) |
|
104 { |
|
105 __IF_DEBUG(Print(_L("CVSActiveWait::CVSActiveWait() >>"))); |
|
106 CActiveScheduler::Add( this ); |
|
107 __IF_DEBUG(Print(_L("CVSActiveWait::CVSActiveWait() <<"))); |
|
108 } |
|
109 // ----------------------------------------------------------------------------- |
|
110 // CVSActiveWait::InitializeWaiter( TVSActiveWaitCallback aCallback ) |
|
111 // ----------------------------------------------------------------------------- |
|
112 // |
|
113 template < class R > |
|
114 void CVSActiveWait< R >::InitializeWaiter( TVSActiveWaitCallback aCallback ) |
|
115 { |
|
116 __IF_DEBUG(Print(_L("VideoSource [%d]: CVSActiveWait::InitializeWaiter() >>"), RThread().Id().operator TUint())); |
|
117 if ( !IsActive() ) |
|
118 { |
|
119 iStatus = KRequestPending; |
|
120 iCallback = aCallback; |
|
121 __IF_DEBUG(Print(_L("VideoSource [%d]: CVSActiveWait::InitializeWaiter() SetActive"), RThread().Id().operator TUint())); |
|
122 SetActive(); |
|
123 } |
|
124 __IF_DEBUG(Print(_L("VideoSource [%d]: CVSActiveWait::InitializeWaiter() <<"), RThread().Id().operator TUint())); |
|
125 } |
|
126 |
|
127 |