Update contrib.
2 * Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
14 * Description: This file contains implementation of Audio Clients List Manager.
21 #include "AudioClientsListManagerAO.h"
22 #include <AudioClientsListPSKeys.h>
23 #include <AudioClientsListPSData.h>
24 #include <MAudioClientsListObserver.h>
26 // -----------------------------------------------------------------------------
27 // CAudioClientsListManagerAO::CAudioClientsListManagerAO
29 // -----------------------------------------------------------------------------
31 CAudioClientsListManagerAO::CAudioClientsListManagerAO(
32 CGlobalAudioSettings& aGlobalAudioSettings,
33 RPointerArray<MAudioClientsListObserver>& aArray,
35 :CActive(CActive::EPriorityStandard),
36 iGlobalAudioSettings(aGlobalAudioSettings),
37 iAudioClientsListObserverArray(aArray),
40 CActiveScheduler::Add(this);
43 // -----------------------------------------------------------------------------
44 // CAudioClientsListManagerAO::~CAudioClientsListManagerAO
46 // -----------------------------------------------------------------------------
48 CAudioClientsListManagerAO::~CAudioClientsListManagerAO()
51 iActiveAudioClients.Close();
54 // -----------------------------------------------------------------------------
55 // CAudioClientsListManagerAO::NewL
57 // -----------------------------------------------------------------------------
59 CAudioClientsListManagerAO* CAudioClientsListManagerAO::NewL(
60 CGlobalAudioSettings& aGlobalAudioSettings,
61 RPointerArray<MAudioClientsListObserver>& aArray,
64 CAudioClientsListManagerAO* self = new (ELeave) CAudioClientsListManagerAO(aGlobalAudioSettings,aArray,aKey);
65 CleanupStack::PushL(self);
67 CleanupStack::Pop(self);
71 // -----------------------------------------------------------------------------
72 // CAudioClientsListManagerAO::ConstructL
74 // -----------------------------------------------------------------------------
76 void CAudioClientsListManagerAO::ConstructL()
78 User::LeaveIfError( iActiveAudioClients.Attach(
84 // -----------------------------------------------------------------------------
85 // CAudioClientsListManagerAO::MonitorStart
87 // -----------------------------------------------------------------------------
89 TInt CAudioClientsListManagerAO::MonitorStart()
91 TInt status(KErrAlreadyExists);
95 iActiveAudioClients.Subscribe(iStatus);
102 // -----------------------------------------------------------------------------
103 // CAudioClientsListManagerAO::MonitorStop
105 // -----------------------------------------------------------------------------
107 TInt CAudioClientsListManagerAO::MonitorStop()
109 TInt status(KErrNone);
117 // -----------------------------------------------------------------------------
118 // CAudioClientsListManagerAO::GetAudioClientsList
120 // -----------------------------------------------------------------------------
122 TInt CAudioClientsListManagerAO::GetAudioClientsList(
123 CGlobalAudioSettings::TAudioClientListType aType,
124 RArray<TProcessId>& aList )
126 TInt status(KErrNone);
130 case CGlobalAudioSettings::EActiveAudioClients:
132 TAudioClientList audioClientListPckg;
133 status = iActiveAudioClients.Get( KPSUidMMFAudioServer,
134 KAudioPolicyAudioClients,
135 audioClientListPckg );
136 if ( status == KErrNone )
138 for ( TInt index = 0; index < audioClientListPckg().iNumOfProcesses; index++ )
140 status = aList.Append((audioClientListPckg().iProcessList)[index]);
141 if ( status != KErrNone )
151 case CGlobalAudioSettings::EPausedAudioClients:
153 TAudioPolicyProcessIdList audioClientListPckg;
154 status = iActiveAudioClients.Get(KPSUidMMFAudioServer,
155 KAudioPolicyApplicationAudioStatePaused,
156 audioClientListPckg );
157 if ( status == KErrNone )
159 for ( TInt index = 0; index < audioClientListPckg().iNumOfProcesses; index++ )
161 status = aList.Append((audioClientListPckg().iProcessList)[index]);
162 if ( status != KErrNone )
173 status = KErrNotFound;
179 // -----------------------------------------------------------------------------
180 // CAudioClientsListManagerAO::RunL
182 // -----------------------------------------------------------------------------
184 void CAudioClientsListManagerAO::RunL()
186 TInt status(iStatus.Int());
188 RDebug::Print(_L(" CAudioClientsListManagerAO::RunL:iStatus[%d]"), status);
189 #endif // PRINT_MESSAGE
190 if ( status == KErrNone )
193 // Go through the array and notify every observer
196 case KAudioPolicyAudioClients:
198 for (TInt index = 0; index < iAudioClientsListObserverArray.Count(); index++)
200 iAudioClientsListObserverArray[index]->Event( iGlobalAudioSettings,
201 MAudioClientsListObserver::KActiveAudioClientsListChanged);
205 case KAudioPolicyApplicationAudioStatePaused:
207 for (TInt index = 0; index < iAudioClientsListObserverArray.Count(); index++)
209 iAudioClientsListObserverArray[index]->Event( iGlobalAudioSettings,
210 MAudioClientsListObserver::KPausedAudioClientsListChanged);
221 // -----------------------------------------------------------------------------
222 // CAudioClientsListManagerAO::DoCancel
224 // -----------------------------------------------------------------------------
226 void CAudioClientsListManagerAO::DoCancel()
228 iActiveAudioClients.Cancel();
231 // -----------------------------------------------------------------------------
232 // CAudioClientsListManagerAO::RunError
234 // -----------------------------------------------------------------------------
236 TInt CAudioClientsListManagerAO::RunError(TInt /*aError*/)
238 // Observer callback has leaving code!!!. Ignore it.