sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
* All rights reserved.
|
sl@0
|
4 |
* This component and the accompanying materials are made available
|
sl@0
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
sl@0
|
6 |
* which accompanies this distribution, and is available
|
sl@0
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* Initial Contributors:
|
sl@0
|
10 |
* Nokia Corporation - initial contribution.
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Contributors:
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* Description:
|
sl@0
|
15 |
*
|
sl@0
|
16 |
*/
|
sl@0
|
17 |
|
sl@0
|
18 |
|
sl@0
|
19 |
|
sl@0
|
20 |
|
sl@0
|
21 |
/**
|
sl@0
|
22 |
@file
|
sl@0
|
23 |
@internalTechnology
|
sl@0
|
24 |
*/
|
sl@0
|
25 |
|
sl@0
|
26 |
|
sl@0
|
27 |
|
sl@0
|
28 |
#ifndef MMFAUDIOSERVER_H
|
sl@0
|
29 |
#define MMFAUDIOSERVER_H
|
sl@0
|
30 |
|
sl@0
|
31 |
#include <e32base.h>
|
sl@0
|
32 |
#include <e32std.h>
|
sl@0
|
33 |
#include <mmf/common/mmfipc.h>
|
sl@0
|
34 |
#ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
|
sl@0
|
35 |
#include <mmf/common/mmfipcserver.h>
|
sl@0
|
36 |
#endif
|
sl@0
|
37 |
#include <a3f/a3ffourcclookup.h>
|
sl@0
|
38 |
#include "mglobalproperties.h"
|
sl@0
|
39 |
|
sl@0
|
40 |
|
sl@0
|
41 |
// FORWARD DECLARATIONS
|
sl@0
|
42 |
class CStartAndMonitorDevSoundThread;
|
sl@0
|
43 |
class CMMFAudioServerFactory;
|
sl@0
|
44 |
class RMMFDevSoundServerProxy;
|
sl@0
|
45 |
|
sl@0
|
46 |
enum TMMFAudioServerPanicCodes
|
sl@0
|
47 |
{
|
sl@0
|
48 |
EMMFAudioServerIsActive = 1
|
sl@0
|
49 |
};
|
sl@0
|
50 |
|
sl@0
|
51 |
/**
|
sl@0
|
52 |
The Audio Server holds a list of DevSound servers and manages it.
|
sl@0
|
53 |
This class is a container process for all the DevSound Server threads that are
|
sl@0
|
54 |
created for each DevSound proxy and for all other servers that are created
|
sl@0
|
55 |
using Factory.
|
sl@0
|
56 |
|
sl@0
|
57 |
@lib MmfAudioServer.exe
|
sl@0
|
58 |
*/
|
sl@0
|
59 |
class CMMFAudioServer : public CMmfIpcServer, public MGlobalProperties
|
sl@0
|
60 |
{
|
sl@0
|
61 |
public:
|
sl@0
|
62 |
|
sl@0
|
63 |
/**
|
sl@0
|
64 |
Constructs, and returns a pointer to, a new CMMFAudioServer
|
sl@0
|
65 |
object.
|
sl@0
|
66 |
@return CMMFAudioServer* A pointer to newly created object.
|
sl@0
|
67 |
*/
|
sl@0
|
68 |
static CMMFAudioServer* NewL();
|
sl@0
|
69 |
|
sl@0
|
70 |
/**
|
sl@0
|
71 |
Destructor.
|
sl@0
|
72 |
*/
|
sl@0
|
73 |
~CMMFAudioServer();
|
sl@0
|
74 |
|
sl@0
|
75 |
|
sl@0
|
76 |
|
sl@0
|
77 |
/**
|
sl@0
|
78 |
From CServer2. Creates a server-side client session object.
|
sl@0
|
79 |
@param aVersion server version requested by the client.
|
sl@0
|
80 |
@return CMmfIpcSession* A pointer to newly created session.
|
sl@0
|
81 |
*/
|
sl@0
|
82 |
CMmfIpcSession* NewSessionL(const TVersion &aVersion) const;
|
sl@0
|
83 |
|
sl@0
|
84 |
/**
|
sl@0
|
85 |
Increment the session Id.
|
sl@0
|
86 |
*/
|
sl@0
|
87 |
void IncrementSessionId();
|
sl@0
|
88 |
|
sl@0
|
89 |
/**
|
sl@0
|
90 |
Decrement the session Id.
|
sl@0
|
91 |
*/
|
sl@0
|
92 |
void DecrementSessionId();
|
sl@0
|
93 |
|
sl@0
|
94 |
/**
|
sl@0
|
95 |
Increment the DevSound server counter.
|
sl@0
|
96 |
*/
|
sl@0
|
97 |
void IncrementDevSoundCount();
|
sl@0
|
98 |
|
sl@0
|
99 |
/**
|
sl@0
|
100 |
Decrement the DevSound server counter.
|
sl@0
|
101 |
Once the number of DevSound server's instances becomes zero, Audio
|
sl@0
|
102 |
Server will start its shutdown routine.
|
sl@0
|
103 |
*/
|
sl@0
|
104 |
void DecrementDevSoundCount();
|
sl@0
|
105 |
|
sl@0
|
106 |
/**
|
sl@0
|
107 |
Sends Event to DevSound client.
|
sl@0
|
108 |
@param aSessionToAlert Id of DevSound to be alerted.
|
sl@0
|
109 |
@param aSessionToBeLaunched Id of DevSound to be launched.
|
sl@0
|
110 |
*/
|
sl@0
|
111 |
void SendEventToClient(TInt aSessionToAlert, TInt aSessionToBeLaunched);
|
sl@0
|
112 |
|
sl@0
|
113 |
/**
|
sl@0
|
114 |
Launches the DevSound servers waiting for Audio Policy.
|
sl@0
|
115 |
@param aSessionToBeLaunched Id of DevSound to be launched.
|
sl@0
|
116 |
*/
|
sl@0
|
117 |
void LaunchRequest(TInt aSessionId);
|
sl@0
|
118 |
|
sl@0
|
119 |
/**
|
sl@0
|
120 |
Returns Audio Server session identifier.
|
sl@0
|
121 |
@return a integer representing session id.
|
sl@0
|
122 |
*/
|
sl@0
|
123 |
TInt AudioServerSessionId() {return iAudioServerSessionId;};
|
sl@0
|
124 |
|
sl@0
|
125 |
/**
|
sl@0
|
126 |
Starts a new DevSound server instance.
|
sl@0
|
127 |
@param aDevSoundSessionHandle. A handle to the DevSound server session to be launched.
|
sl@0
|
128 |
@return KErrNone if successfull, else corresponding error code.
|
sl@0
|
129 |
*/
|
sl@0
|
130 |
TInt StartDevSoundServer(RMMFDevSoundServerProxy& aDevSoundSessionHandle) const;
|
sl@0
|
131 |
|
sl@0
|
132 |
// From MGlobalProperties
|
sl@0
|
133 |
|
sl@0
|
134 |
/**
|
sl@0
|
135 |
* Returns reference to FourCC to format converter
|
sl@0
|
136 |
* (other items were commented in a header).
|
sl@0
|
137 |
*/
|
sl@0
|
138 |
inline const CFourCCConvertor& GetFourCCConvertor();
|
sl@0
|
139 |
|
sl@0
|
140 |
private:
|
sl@0
|
141 |
|
sl@0
|
142 |
//A timer utility class used by Audio Server for shutdown purpose.
|
sl@0
|
143 |
|
sl@0
|
144 |
class CDelayAudioServerShutDown : public CActive
|
sl@0
|
145 |
{
|
sl@0
|
146 |
public:
|
sl@0
|
147 |
|
sl@0
|
148 |
|
sl@0
|
149 |
//Constructs and returns a pointer to a new CDelayAudioServerShutDown object.
|
sl@0
|
150 |
static CDelayAudioServerShutDown* NewL();
|
sl@0
|
151 |
|
sl@0
|
152 |
//Destructor.
|
sl@0
|
153 |
~CDelayAudioServerShutDown();
|
sl@0
|
154 |
|
sl@0
|
155 |
//Request a timeout after aDelay
|
sl@0
|
156 |
void SetDelay(TTimeIntervalMicroSeconds32 aDelay);
|
sl@0
|
157 |
|
sl@0
|
158 |
private:
|
sl@0
|
159 |
// From CActive
|
sl@0
|
160 |
void RunL();
|
sl@0
|
161 |
void DoCancel();
|
sl@0
|
162 |
|
sl@0
|
163 |
private:
|
sl@0
|
164 |
//Standart Constructor
|
sl@0
|
165 |
CDelayAudioServerShutDown();
|
sl@0
|
166 |
//Second phase contructor.
|
sl@0
|
167 |
void ConstructL();
|
sl@0
|
168 |
|
sl@0
|
169 |
RTimer iShutDownTimer;
|
sl@0
|
170 |
};
|
sl@0
|
171 |
|
sl@0
|
172 |
private:
|
sl@0
|
173 |
|
sl@0
|
174 |
|
sl@0
|
175 |
//Default constructor.
|
sl@0
|
176 |
|
sl@0
|
177 |
CMMFAudioServer();
|
sl@0
|
178 |
|
sl@0
|
179 |
|
sl@0
|
180 |
//Second phase constructor.
|
sl@0
|
181 |
|
sl@0
|
182 |
void ConstructL();
|
sl@0
|
183 |
|
sl@0
|
184 |
private: // Data
|
sl@0
|
185 |
// FourCC to format convertor
|
sl@0
|
186 |
CFourCCConvertor* iFourCCConvertor;
|
sl@0
|
187 |
// Current session id
|
sl@0
|
188 |
TInt iAudioServerSessionId;
|
sl@0
|
189 |
// Number of DevSound servers.
|
sl@0
|
190 |
TInt iDevSoundCount;
|
sl@0
|
191 |
// Audio Server shutdown utility
|
sl@0
|
192 |
CDelayAudioServerShutDown* iDelayAudioServerShutDown;
|
sl@0
|
193 |
// Array of DevSound server monitor objects.
|
sl@0
|
194 |
mutable RPointerArray<CStartAndMonitorDevSoundThread> iDevSoundServList;
|
sl@0
|
195 |
|
sl@0
|
196 |
CMMFAudioServerFactory* iFactory;
|
sl@0
|
197 |
};
|
sl@0
|
198 |
|
sl@0
|
199 |
/**
|
sl@0
|
200 |
A utility class to monitor the DevSound server state.
|
sl@0
|
201 |
This class is used by Audio Server to monitor the state of DevSound server
|
sl@0
|
202 |
and to manage the client side RThread handle.
|
sl@0
|
203 |
|
sl@0
|
204 |
@lib MmfAudioServer.exe
|
sl@0
|
205 |
*/
|
sl@0
|
206 |
class CStartAndMonitorDevSoundThread: public CActive
|
sl@0
|
207 |
{
|
sl@0
|
208 |
public: // Constructors and destructor
|
sl@0
|
209 |
|
sl@0
|
210 |
/**
|
sl@0
|
211 |
Constructs, and returns a pointer to, a new CStartAndMonitorDevSoundThread object.
|
sl@0
|
212 |
|
sl@0
|
213 |
@return CStartAndMonitorDevSoundThread* a pointer to newly created
|
sl@0
|
214 |
object.
|
sl@0
|
215 |
*/
|
sl@0
|
216 |
static CStartAndMonitorDevSoundThread* NewL(CMMFAudioServer* aAudioServer);
|
sl@0
|
217 |
|
sl@0
|
218 |
/**
|
sl@0
|
219 |
Destructor.
|
sl@0
|
220 |
*/
|
sl@0
|
221 |
~CStartAndMonitorDevSoundThread();
|
sl@0
|
222 |
|
sl@0
|
223 |
|
sl@0
|
224 |
/**
|
sl@0
|
225 |
Starts a new instance of DevSound server. The server is given a unique
|
sl@0
|
226 |
name using aDevSoundName and aUniqueNum passed in by Audio Server.
|
sl@0
|
227 |
|
sl@0
|
228 |
@param aMessage. A reference to client message requesting to create a new DevSound server.
|
sl@0
|
229 |
@param aDevSoundSessionHandle. A handle to the DevSound server session.
|
sl@0
|
230 |
@return KErrNone if succesful else a systemwide error code.
|
sl@0
|
231 |
*/
|
sl@0
|
232 |
TInt StartDevSoundServer(RMessage2& aMessage,RMMFDevSoundServerProxy& aDevSoundSessionHandle);
|
sl@0
|
233 |
|
sl@0
|
234 |
private: // Functions from base classes
|
sl@0
|
235 |
|
sl@0
|
236 |
// From CActive
|
sl@0
|
237 |
//Called by Active Object framework when DevSound server is destroyed.
|
sl@0
|
238 |
void RunL();
|
sl@0
|
239 |
|
sl@0
|
240 |
//Called by Active Object framework when client cancels active object.
|
sl@0
|
241 |
void DoCancel();
|
sl@0
|
242 |
|
sl@0
|
243 |
|
sl@0
|
244 |
//Constructor.
|
sl@0
|
245 |
CStartAndMonitorDevSoundThread(CMMFAudioServer* aAudioServer);
|
sl@0
|
246 |
|
sl@0
|
247 |
//Second phase constructor.
|
sl@0
|
248 |
void ConstructL();
|
sl@0
|
249 |
|
sl@0
|
250 |
private: // Data
|
sl@0
|
251 |
// A pointer reference to Audio Server.
|
sl@0
|
252 |
CMMFAudioServer* iAudioServer;
|
sl@0
|
253 |
// Client side handle to DevSound server thread.
|
sl@0
|
254 |
RThread iServer;
|
sl@0
|
255 |
};
|
sl@0
|
256 |
|
sl@0
|
257 |
|
sl@0
|
258 |
/**
|
sl@0
|
259 |
DevSound server client-side proxy class.
|
sl@0
|
260 |
This class is used by the Audio Server to open new session with
|
sl@0
|
261 |
the DevSound server.
|
sl@0
|
262 |
|
sl@0
|
263 |
@lib MmfAudioServer.exe
|
sl@0
|
264 |
*/
|
sl@0
|
265 |
class RMMFDevSoundServerProxy : public RMmfSessionBase
|
sl@0
|
266 |
{
|
sl@0
|
267 |
public:
|
sl@0
|
268 |
/**
|
sl@0
|
269 |
Opens new session with the DevSound server. The server is given a
|
sl@0
|
270 |
unique handle passed in by the Audio Server.
|
sl@0
|
271 |
|
sl@0
|
272 |
@param aDevSoundServerHandle A handle to the DevSound server.
|
sl@0
|
273 |
@return KErrNone if successfull, else corresponding error code.
|
sl@0
|
274 |
*/
|
sl@0
|
275 |
TInt Open(RServer2& aDevSoundServerHandle);
|
sl@0
|
276 |
};
|
sl@0
|
277 |
|
sl@0
|
278 |
#include "mmfaudioserver.inl"
|
sl@0
|
279 |
|
sl@0
|
280 |
#endif // MMFAUDIOSERVER_H
|
sl@0
|
281 |
|
sl@0
|
282 |
// End of File
|
sl@0
|
283 |
|