os/mm/devsound/a3fdevsound/src/mmfaudioserver/mmfaudioserver.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/mm/devsound/a3fdevsound/src/mmfaudioserver/mmfaudioserver.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,283 @@
     1.4 +/*
     1.5 +* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description:
    1.18 +*
    1.19 +*/
    1.20 +
    1.21 +
    1.22 +
    1.23 +
    1.24 +/**
    1.25 + @file
    1.26 + @internalTechnology 
    1.27 +*/
    1.28 +
    1.29 +
    1.30 +
    1.31 +#ifndef MMFAUDIOSERVER_H
    1.32 +#define MMFAUDIOSERVER_H
    1.33 +
    1.34 +#include <e32base.h>
    1.35 +#include <e32std.h>
    1.36 +#include <mmf/common/mmfipc.h>
    1.37 +#ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
    1.38 +#include <mmf/common/mmfipcserver.h>
    1.39 +#endif
    1.40 +#include <a3f/a3ffourcclookup.h>
    1.41 +#include "mglobalproperties.h"
    1.42 +
    1.43 +
    1.44 +// FORWARD DECLARATIONS
    1.45 +class CStartAndMonitorDevSoundThread;
    1.46 +class CMMFAudioServerFactory;
    1.47 +class RMMFDevSoundServerProxy;
    1.48 +
    1.49 +enum TMMFAudioServerPanicCodes
    1.50 +	{
    1.51 +	EMMFAudioServerIsActive = 1
    1.52 +	};
    1.53 +
    1.54 +/**
    1.55 +	The Audio Server holds a list of DevSound servers and manages it.
    1.56 +	This class is a container process for all the DevSound Server threads that are
    1.57 +	created for each DevSound proxy and for all other servers that are created
    1.58 +	using Factory.
    1.59 +	
    1.60 +	@lib MmfAudioServer.exe
    1.61 +*/
    1.62 +class CMMFAudioServer : public CMmfIpcServer, public MGlobalProperties
    1.63 +	{
    1.64 +public:
    1.65 +
    1.66 +	/**
    1.67 +		Constructs, and returns a pointer to, a new CMMFAudioServer
    1.68 +		object.
    1.69 +		@return CMMFAudioServer* A pointer to newly created object.
    1.70 +	*/
    1.71 +	static CMMFAudioServer* NewL();
    1.72 +
    1.73 +	/**
    1.74 +		Destructor.
    1.75 +	*/
    1.76 +	~CMMFAudioServer();
    1.77 +
    1.78 +
    1.79 +
    1.80 +	/**
    1.81 +		From CServer2. Creates a server-side client session object.
    1.82 +		@param aVersion server version requested by the client.
    1.83 +		@return CMmfIpcSession* A pointer to newly created session.
    1.84 +	*/
    1.85 +	CMmfIpcSession* NewSessionL(const TVersion &aVersion) const;
    1.86 +
    1.87 +	/**
    1.88 +		Increment the session Id.
    1.89 +	*/
    1.90 +	void IncrementSessionId();
    1.91 +
    1.92 +	/**
    1.93 +		Decrement the session Id.
    1.94 +	*/
    1.95 +	void DecrementSessionId();
    1.96 +
    1.97 +	/**
    1.98 +		Increment the DevSound server counter.
    1.99 +	*/
   1.100 +	void IncrementDevSoundCount();
   1.101 +
   1.102 +	/**
   1.103 +		Decrement the DevSound server counter.
   1.104 +		Once the number of DevSound server's instances becomes zero, Audio
   1.105 +		Server will start its shutdown routine.
   1.106 +	*/
   1.107 +	void DecrementDevSoundCount();
   1.108 +
   1.109 +	/**
   1.110 +		Sends Event to DevSound client.
   1.111 +		@param  aSessionToAlert Id of DevSound to be alerted.
   1.112 +		@param  aSessionToBeLaunched Id of DevSound to be launched.
   1.113 +	*/
   1.114 +	void SendEventToClient(TInt aSessionToAlert, TInt aSessionToBeLaunched);
   1.115 +
   1.116 +	/**
   1.117 +		Launches the DevSound servers waiting for Audio Policy.
   1.118 +		@param  aSessionToBeLaunched Id of DevSound to be launched.
   1.119 +	*/
   1.120 +	void LaunchRequest(TInt aSessionId);
   1.121 +
   1.122 +	/**
   1.123 +		Returns Audio Server session identifier.
   1.124 +		@return a integer representing session id.
   1.125 +	*/
   1.126 +	TInt AudioServerSessionId() {return iAudioServerSessionId;};
   1.127 +
   1.128 +	/**
   1.129 +		Starts a new DevSound server instance.
   1.130 +		@param  aDevSoundSessionHandle. A handle to the DevSound server session to be launched.
   1.131 +		@return KErrNone if successfull, else corresponding error code.
   1.132 +	*/
   1.133 +	TInt StartDevSoundServer(RMMFDevSoundServerProxy& aDevSoundSessionHandle) const;
   1.134 +
   1.135 +	// From MGlobalProperties
   1.136 +	
   1.137 +	/**
   1.138 +	 * Returns reference to FourCC to format converter
   1.139 +	 * (other items were commented in a header).
   1.140 +	*/
   1.141 +	inline const CFourCCConvertor& GetFourCCConvertor();
   1.142 +
   1.143 +private:
   1.144 +	
   1.145 +		//A timer utility class used by Audio Server for shutdown purpose.
   1.146 +	
   1.147 +	class CDelayAudioServerShutDown : public CActive
   1.148 +		{
   1.149 +	public:
   1.150 +	
   1.151 +	
   1.152 +		//Constructs and returns a pointer to a new CDelayAudioServerShutDown object.
   1.153 +		static CDelayAudioServerShutDown* NewL();
   1.154 +	
   1.155 +		//Destructor.
   1.156 +		~CDelayAudioServerShutDown();
   1.157 +
   1.158 +		//Request a timeout after aDelay
   1.159 +		void SetDelay(TTimeIntervalMicroSeconds32 aDelay);
   1.160 +
   1.161 +	private:
   1.162 +		// From CActive
   1.163 +		void RunL();
   1.164 +		void DoCancel();
   1.165 +
   1.166 +	private:
   1.167 +		//Standart Constructor
   1.168 +		CDelayAudioServerShutDown();
   1.169 +		//Second phase contructor.
   1.170 +		void ConstructL();
   1.171 +
   1.172 +		RTimer iShutDownTimer;
   1.173 +		};
   1.174 +
   1.175 +private:
   1.176 +
   1.177 +	
   1.178 +	//Default constructor.
   1.179 +	
   1.180 +	CMMFAudioServer();
   1.181 +
   1.182 +	
   1.183 +	//Second phase constructor.
   1.184 +
   1.185 +	void ConstructL();
   1.186 +
   1.187 +private:	// Data
   1.188 +	// FourCC to format convertor
   1.189 +	CFourCCConvertor* iFourCCConvertor;
   1.190 +	// Current session id
   1.191 +	TInt iAudioServerSessionId;
   1.192 +	// Number of DevSound servers.
   1.193 +	TInt iDevSoundCount;
   1.194 +	// Audio Server shutdown utility
   1.195 +	CDelayAudioServerShutDown* iDelayAudioServerShutDown;
   1.196 +	// Array of DevSound server monitor objects.
   1.197 +	mutable RPointerArray<CStartAndMonitorDevSoundThread> iDevSoundServList;
   1.198 +	
   1.199 +	CMMFAudioServerFactory* iFactory;
   1.200 +	};
   1.201 +
   1.202 +/**
   1.203 +	A utility class to monitor the DevSound server state.
   1.204 +	This class is used by Audio Server to monitor the state of DevSound server
   1.205 +	and to manage the client side RThread handle.
   1.206 +
   1.207 +	@lib MmfAudioServer.exe
   1.208 +*/
   1.209 +class CStartAndMonitorDevSoundThread: public CActive
   1.210 +	{
   1.211 +public:	// Constructors and destructor
   1.212 +
   1.213 +	/**
   1.214 +		Constructs, and returns a pointer to, a new CStartAndMonitorDevSoundThread object.
   1.215 +		
   1.216 +		@return CStartAndMonitorDevSoundThread* a pointer to newly created
   1.217 +		object.
   1.218 +	*/
   1.219 +	static CStartAndMonitorDevSoundThread* NewL(CMMFAudioServer* aAudioServer);
   1.220 +
   1.221 +	/**
   1.222 +		Destructor.
   1.223 +	*/
   1.224 +	~CStartAndMonitorDevSoundThread();
   1.225 +
   1.226 +
   1.227 +	/**
   1.228 +		Starts a new instance of DevSound server. The server is given a unique
   1.229 +		name using aDevSoundName and aUniqueNum passed in by Audio Server.
   1.230 +		
   1.231 +		@param aMessage. A reference to client message requesting to create a new DevSound server.
   1.232 +		@param aDevSoundSessionHandle. A handle to the DevSound server session.
   1.233 +		@return KErrNone if succesful else a systemwide error code.
   1.234 +	*/
   1.235 +	TInt StartDevSoundServer(RMessage2& aMessage,RMMFDevSoundServerProxy& aDevSoundSessionHandle);
   1.236 +
   1.237 +private: // Functions from base classes
   1.238 +
   1.239 +	// From CActive
   1.240 +	//Called by Active Object framework when DevSound server is destroyed.
   1.241 +	void RunL();
   1.242 +	
   1.243 +	//Called by Active Object framework when client cancels active object.
   1.244 +	void DoCancel();
   1.245 +	
   1.246 +	
   1.247 +	//Constructor.
   1.248 +	CStartAndMonitorDevSoundThread(CMMFAudioServer* aAudioServer);
   1.249 +	
   1.250 +	//Second phase constructor.
   1.251 +	void ConstructL();
   1.252 +	
   1.253 +private:	// Data
   1.254 +	// A pointer reference to Audio Server.
   1.255 +	CMMFAudioServer* iAudioServer;
   1.256 +	// Client side handle to DevSound server thread.
   1.257 +	RThread iServer;
   1.258 +	};
   1.259 +
   1.260 +
   1.261 +/**
   1.262 +	DevSound server client-side proxy class.
   1.263 +	This class is used by the Audio Server to open new session with
   1.264 +	the DevSound server.
   1.265 +	
   1.266 +	@lib MmfAudioServer.exe
   1.267 +*/
   1.268 +class RMMFDevSoundServerProxy : public RMmfSessionBase
   1.269 +	{
   1.270 +public:
   1.271 +	/**
   1.272 +		Opens new session with the DevSound server. The server is given a
   1.273 +		unique handle passed in by the Audio Server.
   1.274 +
   1.275 +		@param aDevSoundServerHandle A handle to the DevSound server.
   1.276 +		@return KErrNone if successfull, else corresponding error code.
   1.277 +	*/
   1.278 +	TInt Open(RServer2& aDevSoundServerHandle);
   1.279 +	};
   1.280 +
   1.281 +#include "mmfaudioserver.inl"
   1.282 +
   1.283 +#endif // MMFAUDIOSERVER_H
   1.284 +
   1.285 +// End of File
   1.286 +