devsound/a3fdevsound/src/mmfaudioserver/mmfaudioserver.h
changeset 0 b8ed18f6c07b
child 6 fe9d1bf55678
equal deleted inserted replaced
-1:000000000000 0:b8ed18f6c07b
       
     1 /*
       
     2 * Copyright (c) 2006-2009 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:
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 /**
       
    22  @file
       
    23  @internalTechnology 
       
    24 */
       
    25 
       
    26 
       
    27 
       
    28 #ifndef MMFAUDIOSERVER_H
       
    29 #define MMFAUDIOSERVER_H
       
    30 
       
    31 #include <e32base.h>
       
    32 #include <e32std.h>
       
    33 #include <mmf/common/mmfipc.h>
       
    34 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
       
    35 #include <mmf/common/mmfipcserver.h>
       
    36 #endif
       
    37 #include <a3f/a3ffourcclookup.h>
       
    38 #include "mglobalproperties.h"
       
    39 
       
    40 
       
    41 // FORWARD DECLARATIONS
       
    42 class CStartAndMonitorDevSoundThread;
       
    43 class CMMFAudioServerFactory;
       
    44 class RMMFDevSoundServerProxy;
       
    45 
       
    46 enum TMMFAudioServerPanicCodes
       
    47 	{
       
    48 	EMMFAudioServerIsActive = 1
       
    49 	};
       
    50 
       
    51 /**
       
    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
       
    55 	using Factory.
       
    56 	
       
    57 	@lib MmfAudioServer.exe
       
    58 */
       
    59 class CMMFAudioServer : public CMmfIpcServer, public MGlobalProperties
       
    60 	{
       
    61 public:
       
    62 
       
    63 	/**
       
    64 		Constructs, and returns a pointer to, a new CMMFAudioServer
       
    65 		object.
       
    66 		@return CMMFAudioServer* A pointer to newly created object.
       
    67 	*/
       
    68 	static CMMFAudioServer* NewL();
       
    69 
       
    70 	/**
       
    71 		Destructor.
       
    72 	*/
       
    73 	~CMMFAudioServer();
       
    74 
       
    75 
       
    76 
       
    77 	/**
       
    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.
       
    81 	*/
       
    82 	CMmfIpcSession* NewSessionL(const TVersion &aVersion) const;
       
    83 
       
    84 	/**
       
    85 		Increment the session Id.
       
    86 	*/
       
    87 	void IncrementSessionId();
       
    88 
       
    89 	/**
       
    90 		Decrement the session Id.
       
    91 	*/
       
    92 	void DecrementSessionId();
       
    93 
       
    94 	/**
       
    95 		Increment the DevSound server counter.
       
    96 	*/
       
    97 	void IncrementDevSoundCount();
       
    98 
       
    99 	/**
       
   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.
       
   103 	*/
       
   104 	void DecrementDevSoundCount();
       
   105 
       
   106 	/**
       
   107 		Sends Event to DevSound client.
       
   108 		@param  aSessionToAlert Id of DevSound to be alerted.
       
   109 		@param  aSessionToBeLaunched Id of DevSound to be launched.
       
   110 	*/
       
   111 	void SendEventToClient(TInt aSessionToAlert, TInt aSessionToBeLaunched);
       
   112 
       
   113 	/**
       
   114 		Launches the DevSound servers waiting for Audio Policy.
       
   115 		@param  aSessionToBeLaunched Id of DevSound to be launched.
       
   116 	*/
       
   117 	void LaunchRequest(TInt aSessionId);
       
   118 
       
   119 	/**
       
   120 		Returns Audio Server session identifier.
       
   121 		@return a integer representing session id.
       
   122 	*/
       
   123 	TInt AudioServerSessionId() {return iAudioServerSessionId;};
       
   124 
       
   125 	/**
       
   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.
       
   129 	*/
       
   130 	TInt StartDevSoundServer(RMMFDevSoundServerProxy& aDevSoundSessionHandle) const;
       
   131 
       
   132 	// From MGlobalProperties
       
   133 	
       
   134 	/**
       
   135 	 * Returns reference to FourCC to format converter
       
   136 	 * (other items were commented in a header).
       
   137 	*/
       
   138 	inline const CFourCCConvertor& GetFourCCConvertor();
       
   139 
       
   140 private:
       
   141 	
       
   142 		//A timer utility class used by Audio Server for shutdown purpose.
       
   143 	
       
   144 	class CDelayAudioServerShutDown : public CActive
       
   145 		{
       
   146 	public:
       
   147 	
       
   148 	
       
   149 		//Constructs and returns a pointer to a new CDelayAudioServerShutDown object.
       
   150 		static CDelayAudioServerShutDown* NewL();
       
   151 	
       
   152 		//Destructor.
       
   153 		~CDelayAudioServerShutDown();
       
   154 
       
   155 		//Request a timeout after aDelay
       
   156 		void SetDelay(TTimeIntervalMicroSeconds32 aDelay);
       
   157 
       
   158 	private:
       
   159 		// From CActive
       
   160 		void RunL();
       
   161 		void DoCancel();
       
   162 
       
   163 	private:
       
   164 		//Standart Constructor
       
   165 		CDelayAudioServerShutDown();
       
   166 		//Second phase contructor.
       
   167 		void ConstructL();
       
   168 
       
   169 		RTimer iShutDownTimer;
       
   170 		};
       
   171 
       
   172 private:
       
   173 
       
   174 	
       
   175 	//Default constructor.
       
   176 	
       
   177 	CMMFAudioServer();
       
   178 
       
   179 	
       
   180 	//Second phase constructor.
       
   181 
       
   182 	void ConstructL();
       
   183 
       
   184 private:	// Data
       
   185 	// FourCC to format convertor
       
   186 	CFourCCConvertor* iFourCCConvertor;
       
   187 	// Current session id
       
   188 	TInt iAudioServerSessionId;
       
   189 	// Number of DevSound servers.
       
   190 	TInt iDevSoundCount;
       
   191 	// Audio Server shutdown utility
       
   192 	CDelayAudioServerShutDown* iDelayAudioServerShutDown;
       
   193 	// Array of DevSound server monitor objects.
       
   194 	mutable RPointerArray<CStartAndMonitorDevSoundThread> iDevSoundServList;
       
   195 	
       
   196 	CMMFAudioServerFactory* iFactory;
       
   197 	};
       
   198 
       
   199 /**
       
   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.
       
   203 
       
   204 	@lib MmfAudioServer.exe
       
   205 */
       
   206 class CStartAndMonitorDevSoundThread: public CActive
       
   207 	{
       
   208 public:	// Constructors and destructor
       
   209 
       
   210 	/**
       
   211 		Constructs, and returns a pointer to, a new CStartAndMonitorDevSoundThread object.
       
   212 		
       
   213 		@return CStartAndMonitorDevSoundThread* a pointer to newly created
       
   214 		object.
       
   215 	*/
       
   216 	static CStartAndMonitorDevSoundThread* NewL(CMMFAudioServer* aAudioServer);
       
   217 
       
   218 	/**
       
   219 		Destructor.
       
   220 	*/
       
   221 	~CStartAndMonitorDevSoundThread();
       
   222 
       
   223 
       
   224 	/**
       
   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.
       
   227 		
       
   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.
       
   231 	*/
       
   232 	TInt StartDevSoundServer(RMessage2& aMessage,RMMFDevSoundServerProxy& aDevSoundSessionHandle);
       
   233 
       
   234 private: // Functions from base classes
       
   235 
       
   236 	// From CActive
       
   237 	//Called by Active Object framework when DevSound server is destroyed.
       
   238 	void RunL();
       
   239 	
       
   240 	//Called by Active Object framework when client cancels active object.
       
   241 	void DoCancel();
       
   242 	
       
   243 	
       
   244 	//Constructor.
       
   245 	CStartAndMonitorDevSoundThread(CMMFAudioServer* aAudioServer);
       
   246 	
       
   247 	//Second phase constructor.
       
   248 	void ConstructL();
       
   249 	
       
   250 private:	// Data
       
   251 	// A pointer reference to Audio Server.
       
   252 	CMMFAudioServer* iAudioServer;
       
   253 	// Client side handle to DevSound server thread.
       
   254 	RThread iServer;
       
   255 	};
       
   256 
       
   257 
       
   258 /**
       
   259 	DevSound server client-side proxy class.
       
   260 	This class is used by the Audio Server to open new session with
       
   261 	the DevSound server.
       
   262 	
       
   263 	@lib MmfAudioServer.exe
       
   264 */
       
   265 class RMMFDevSoundServerProxy : public RMmfSessionBase
       
   266 	{
       
   267 public:
       
   268 	/**
       
   269 		Opens new session with the DevSound server. The server is given a
       
   270 		unique handle passed in by the Audio Server.
       
   271 
       
   272 		@param aDevSoundServerHandle A handle to the DevSound server.
       
   273 		@return KErrNone if successfull, else corresponding error code.
       
   274 	*/
       
   275 	TInt Open(RServer2& aDevSoundServerHandle);
       
   276 	};
       
   277 
       
   278 #include "mmfaudioserver.inl"
       
   279 
       
   280 #endif // MMFAUDIOSERVER_H
       
   281 
       
   282 // End of File
       
   283