|
1 /* |
|
2 * Copyright (c) 2004 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: This file contains implementation of Audio Clients List Manager. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #include "AudioClientsListManagerAO.h" |
|
22 #include <AudioClientsListPSKeys.h> |
|
23 #include <AudioClientsListPSData.h> |
|
24 #include <MAudioClientsListObserver.h> |
|
25 |
|
26 // ----------------------------------------------------------------------------- |
|
27 // CAudioClientsListManagerAO::CAudioClientsListManagerAO |
|
28 // |
|
29 // ----------------------------------------------------------------------------- |
|
30 // |
|
31 CAudioClientsListManagerAO::CAudioClientsListManagerAO( |
|
32 CGlobalAudioSettings& aGlobalAudioSettings, |
|
33 RPointerArray<MAudioClientsListObserver>& aArray, |
|
34 TUint32 aKey ) |
|
35 :CActive(CActive::EPriorityStandard), |
|
36 iGlobalAudioSettings(aGlobalAudioSettings), |
|
37 iAudioClientsListObserverArray(aArray), |
|
38 iKey(aKey) |
|
39 { |
|
40 CActiveScheduler::Add(this); |
|
41 } |
|
42 |
|
43 // ----------------------------------------------------------------------------- |
|
44 // CAudioClientsListManagerAO::~CAudioClientsListManagerAO |
|
45 // |
|
46 // ----------------------------------------------------------------------------- |
|
47 // |
|
48 CAudioClientsListManagerAO::~CAudioClientsListManagerAO() |
|
49 { |
|
50 Cancel(); |
|
51 iActiveAudioClients.Close(); |
|
52 } |
|
53 |
|
54 // ----------------------------------------------------------------------------- |
|
55 // CAudioClientsListManagerAO::NewL |
|
56 // |
|
57 // ----------------------------------------------------------------------------- |
|
58 // |
|
59 CAudioClientsListManagerAO* CAudioClientsListManagerAO::NewL( |
|
60 CGlobalAudioSettings& aGlobalAudioSettings, |
|
61 RPointerArray<MAudioClientsListObserver>& aArray, |
|
62 TUint32 aKey ) |
|
63 { |
|
64 CAudioClientsListManagerAO* self = new (ELeave) CAudioClientsListManagerAO(aGlobalAudioSettings,aArray,aKey); |
|
65 CleanupStack::PushL(self); |
|
66 self->ConstructL(); |
|
67 CleanupStack::Pop(self); |
|
68 return self; |
|
69 } |
|
70 |
|
71 // ----------------------------------------------------------------------------- |
|
72 // CAudioClientsListManagerAO::ConstructL |
|
73 // |
|
74 // ----------------------------------------------------------------------------- |
|
75 // |
|
76 void CAudioClientsListManagerAO::ConstructL() |
|
77 { |
|
78 User::LeaveIfError( iActiveAudioClients.Attach( |
|
79 KPSUidMMFAudioServer, |
|
80 iKey, |
|
81 EOwnerThread ) ); |
|
82 } |
|
83 |
|
84 // ----------------------------------------------------------------------------- |
|
85 // CAudioClientsListManagerAO::MonitorStart |
|
86 // |
|
87 // ----------------------------------------------------------------------------- |
|
88 // |
|
89 TInt CAudioClientsListManagerAO::MonitorStart() |
|
90 { |
|
91 TInt status(KErrAlreadyExists); |
|
92 if ( !IsActive() ) |
|
93 { |
|
94 SetActive(); |
|
95 iActiveAudioClients.Subscribe(iStatus); |
|
96 status = KErrNone; |
|
97 } |
|
98 |
|
99 return status; |
|
100 } |
|
101 |
|
102 // ----------------------------------------------------------------------------- |
|
103 // CAudioClientsListManagerAO::MonitorStop |
|
104 // |
|
105 // ----------------------------------------------------------------------------- |
|
106 // |
|
107 TInt CAudioClientsListManagerAO::MonitorStop() |
|
108 { |
|
109 TInt status(KErrNone); |
|
110 if ( IsActive() ) |
|
111 { |
|
112 Cancel(); |
|
113 } |
|
114 return status; |
|
115 } |
|
116 |
|
117 // ----------------------------------------------------------------------------- |
|
118 // CAudioClientsListManagerAO::GetAudioClientsList |
|
119 // |
|
120 // ----------------------------------------------------------------------------- |
|
121 // |
|
122 TInt CAudioClientsListManagerAO::GetAudioClientsList( |
|
123 CGlobalAudioSettings::TAudioClientListType aType, |
|
124 RArray<TProcessId>& aList ) |
|
125 { |
|
126 TInt status(KErrNone); |
|
127 aList.Reset(); |
|
128 switch ( aType ) |
|
129 { |
|
130 case CGlobalAudioSettings::EActiveAudioClients: |
|
131 { |
|
132 TAudioClientList audioClientListPckg; |
|
133 status = iActiveAudioClients.Get( KPSUidMMFAudioServer, |
|
134 KAudioPolicyAudioClients, |
|
135 audioClientListPckg ); |
|
136 if ( status == KErrNone ) |
|
137 { |
|
138 for ( TInt index = 0; index < audioClientListPckg().iNumOfProcesses; index++ ) |
|
139 { |
|
140 status = aList.Append((audioClientListPckg().iProcessList)[index]); |
|
141 if ( status != KErrNone ) |
|
142 { |
|
143 aList.Reset(); |
|
144 break; |
|
145 } |
|
146 } |
|
147 } |
|
148 } |
|
149 break; |
|
150 |
|
151 case CGlobalAudioSettings::EPausedAudioClients: |
|
152 { |
|
153 TAudioPolicyProcessIdList audioClientListPckg; |
|
154 status = iActiveAudioClients.Get(KPSUidMMFAudioServer, |
|
155 KAudioPolicyApplicationAudioStatePaused, |
|
156 audioClientListPckg ); |
|
157 if ( status == KErrNone ) |
|
158 { |
|
159 for ( TInt index = 0; index < audioClientListPckg().iNumOfProcesses; index++ ) |
|
160 { |
|
161 status = aList.Append((audioClientListPckg().iProcessList)[index]); |
|
162 if ( status != KErrNone ) |
|
163 { |
|
164 aList.Reset(); |
|
165 break; |
|
166 } |
|
167 } |
|
168 } |
|
169 } |
|
170 break; |
|
171 |
|
172 default: |
|
173 status = KErrNotFound; |
|
174 break; |
|
175 }; |
|
176 return status; |
|
177 } |
|
178 |
|
179 // ----------------------------------------------------------------------------- |
|
180 // CAudioClientsListManagerAO::RunL |
|
181 // |
|
182 // ----------------------------------------------------------------------------- |
|
183 // |
|
184 void CAudioClientsListManagerAO::RunL() |
|
185 { |
|
186 TInt status(iStatus.Int()); |
|
187 #ifdef PRINT_MESSAGE |
|
188 RDebug::Print(_L(" CAudioClientsListManagerAO::RunL:iStatus[%d]"), status); |
|
189 #endif // PRINT_MESSAGE |
|
190 if ( status == KErrNone ) |
|
191 { |
|
192 MonitorStart(); |
|
193 // Go through the array and notify every observer |
|
194 switch(iKey) |
|
195 { |
|
196 case KAudioPolicyAudioClients: |
|
197 { |
|
198 for (TInt index = 0; index < iAudioClientsListObserverArray.Count(); index++) |
|
199 { |
|
200 iAudioClientsListObserverArray[index]->Event( iGlobalAudioSettings, |
|
201 MAudioClientsListObserver::KActiveAudioClientsListChanged); |
|
202 } |
|
203 } |
|
204 break; |
|
205 case KAudioPolicyApplicationAudioStatePaused: |
|
206 { |
|
207 for (TInt index = 0; index < iAudioClientsListObserverArray.Count(); index++) |
|
208 { |
|
209 iAudioClientsListObserverArray[index]->Event( iGlobalAudioSettings, |
|
210 MAudioClientsListObserver::KPausedAudioClientsListChanged); |
|
211 } |
|
212 } |
|
213 break; |
|
214 default: |
|
215 break; |
|
216 |
|
217 } //end swith(iKey) |
|
218 } |
|
219 } |
|
220 |
|
221 // ----------------------------------------------------------------------------- |
|
222 // CAudioClientsListManagerAO::DoCancel |
|
223 // |
|
224 // ----------------------------------------------------------------------------- |
|
225 // |
|
226 void CAudioClientsListManagerAO::DoCancel() |
|
227 { |
|
228 iActiveAudioClients.Cancel(); |
|
229 } |
|
230 |
|
231 // ----------------------------------------------------------------------------- |
|
232 // CAudioClientsListManagerAO::RunError |
|
233 // |
|
234 // ----------------------------------------------------------------------------- |
|
235 // |
|
236 TInt CAudioClientsListManagerAO::RunError(TInt /*aError*/) |
|
237 { |
|
238 // Observer callback has leaving code!!!. Ignore it. |
|
239 return KErrNone; |
|
240 } |
|
241 |
|
242 // End of file |