First public contribution.
2 * Copyright (c) 2006-2009 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.
28 #ifndef MMFAUDIOSERVER_H
29 #define MMFAUDIOSERVER_H
33 #include <mmf/common/mmfipc.h>
34 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
35 #include <mmf/common/mmfipcserver.h>
37 #include <a3f/a3ffourcclookup.h>
38 #include "mglobalproperties.h"
41 // FORWARD DECLARATIONS
42 class CStartAndMonitorDevSoundThread;
43 class CMMFAudioServerFactory;
44 class RMMFDevSoundServerProxy;
46 enum TMMFAudioServerPanicCodes
48 EMMFAudioServerIsActive = 1
52 The Audio Server holds a list of DevSound servers and manages it.
53 This class is a container process for all the DevSound Server threads that are
54 created for each DevSound proxy and for all other servers that are created
57 @lib MmfAudioServer.exe
59 class CMMFAudioServer : public CMmfIpcServer, public MGlobalProperties
64 Constructs, and returns a pointer to, a new CMMFAudioServer
66 @return CMMFAudioServer* A pointer to newly created object.
68 static CMMFAudioServer* NewL();
78 From CServer2. Creates a server-side client session object.
79 @param aVersion server version requested by the client.
80 @return CMmfIpcSession* A pointer to newly created session.
82 CMmfIpcSession* NewSessionL(const TVersion &aVersion) const;
85 Increment the session Id.
87 void IncrementSessionId();
90 Decrement the session Id.
92 void DecrementSessionId();
95 Increment the DevSound server counter.
97 void IncrementDevSoundCount();
100 Decrement the DevSound server counter.
101 Once the number of DevSound server's instances becomes zero, Audio
102 Server will start its shutdown routine.
104 void DecrementDevSoundCount();
107 Sends Event to DevSound client.
108 @param aSessionToAlert Id of DevSound to be alerted.
109 @param aSessionToBeLaunched Id of DevSound to be launched.
111 void SendEventToClient(TInt aSessionToAlert, TInt aSessionToBeLaunched);
114 Launches the DevSound servers waiting for Audio Policy.
115 @param aSessionToBeLaunched Id of DevSound to be launched.
117 void LaunchRequest(TInt aSessionId);
120 Returns Audio Server session identifier.
121 @return a integer representing session id.
123 TInt AudioServerSessionId() {return iAudioServerSessionId;};
126 Starts a new DevSound server instance.
127 @param aDevSoundSessionHandle. A handle to the DevSound server session to be launched.
128 @return KErrNone if successfull, else corresponding error code.
130 TInt StartDevSoundServer(RMMFDevSoundServerProxy& aDevSoundSessionHandle) const;
132 // From MGlobalProperties
135 * Returns reference to FourCC to format converter
136 * (other items were commented in a header).
138 inline const CFourCCConvertor& GetFourCCConvertor();
142 //A timer utility class used by Audio Server for shutdown purpose.
144 class CDelayAudioServerShutDown : public CActive
149 //Constructs and returns a pointer to a new CDelayAudioServerShutDown object.
150 static CDelayAudioServerShutDown* NewL();
153 ~CDelayAudioServerShutDown();
155 //Request a timeout after aDelay
156 void SetDelay(TTimeIntervalMicroSeconds32 aDelay);
164 //Standart Constructor
165 CDelayAudioServerShutDown();
166 //Second phase contructor.
169 RTimer iShutDownTimer;
175 //Default constructor.
180 //Second phase constructor.
185 // FourCC to format convertor
186 CFourCCConvertor* iFourCCConvertor;
187 // Current session id
188 TInt iAudioServerSessionId;
189 // Number of DevSound servers.
191 // Audio Server shutdown utility
192 CDelayAudioServerShutDown* iDelayAudioServerShutDown;
193 // Array of DevSound server monitor objects.
194 mutable RPointerArray<CStartAndMonitorDevSoundThread> iDevSoundServList;
196 CMMFAudioServerFactory* iFactory;
200 A utility class to monitor the DevSound server state.
201 This class is used by Audio Server to monitor the state of DevSound server
202 and to manage the client side RThread handle.
204 @lib MmfAudioServer.exe
206 class CStartAndMonitorDevSoundThread: public CActive
208 public: // Constructors and destructor
211 Constructs, and returns a pointer to, a new CStartAndMonitorDevSoundThread object.
213 @return CStartAndMonitorDevSoundThread* a pointer to newly created
216 static CStartAndMonitorDevSoundThread* NewL(CMMFAudioServer* aAudioServer);
221 ~CStartAndMonitorDevSoundThread();
225 Starts a new instance of DevSound server. The server is given a unique
226 name using aDevSoundName and aUniqueNum passed in by Audio Server.
228 @param aMessage. A reference to client message requesting to create a new DevSound server.
229 @param aDevSoundSessionHandle. A handle to the DevSound server session.
230 @return KErrNone if succesful else a systemwide error code.
232 TInt StartDevSoundServer(RMessage2& aMessage,RMMFDevSoundServerProxy& aDevSoundSessionHandle);
234 private: // Functions from base classes
237 //Called by Active Object framework when DevSound server is destroyed.
240 //Called by Active Object framework when client cancels active object.
245 CStartAndMonitorDevSoundThread(CMMFAudioServer* aAudioServer);
247 //Second phase constructor.
251 // A pointer reference to Audio Server.
252 CMMFAudioServer* iAudioServer;
253 // Client side handle to DevSound server thread.
259 DevSound server client-side proxy class.
260 This class is used by the Audio Server to open new session with
263 @lib MmfAudioServer.exe
265 class RMMFDevSoundServerProxy : public RMmfSessionBase
269 Opens new session with the DevSound server. The server is given a
270 unique handle passed in by the Audio Server.
272 @param aDevSoundServerHandle A handle to the DevSound server.
273 @return KErrNone if successfull, else corresponding error code.
275 TInt Open(RServer2& aDevSoundServerHandle);
278 #include "mmfaudioserver.inl"
280 #endif // MMFAUDIOSERVER_H