devsound/a3fdevsound/src/mmfdevsoundserver/mmfdevsoundserver.h
changeset 0 40261b775718
equal deleted inserted replaced
-1:000000000000 0:40261b775718
       
     1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #ifndef MMFDEVSOUNDSERVER_H
       
    17 #define MMFDEVSOUNDSERVER_H
       
    18 	
       
    19 #include <e32base.h>
       
    20 #include <e32def.h>
       
    21 #include <e32std.h>
       
    22 #include <mmf/common/mmfipc.h>
       
    23 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
       
    24 #include <mmf/common/mmfipcserver.h>
       
    25 #endif
       
    26 #include "mmfaudioserver.h"
       
    27 #include "mmfdevsoundserverstart.h"
       
    28 
       
    29 /**
       
    30 	Panic category and codes that MmfDevSoundServer raises on the client
       
    31 */
       
    32 _LIT(KMMFDevSoundClientPanicCategory, "DevSoundClient");
       
    33 
       
    34 enum TMMFDevSoundClientPanicCodes
       
    35 	{
       
    36 	EMMFDevSoundPlayDataWithoutInitialize,
       
    37 	EMMFDevSoundRecordDataWithoutInitialize
       
    38 	};
       
    39 
       
    40 enum TMMFDevSoundServerPanicCodes
       
    41 	{
       
    42 	EMMFDevSoundServerIsActive = 1
       
    43 	};
       
    44 
       
    45 // FORWARD DECLARATIONS
       
    46 class CMMFDevSoundServer;
       
    47 class MGlobalProperties;
       
    48 
       
    49 // CLASS DECLARATION
       
    50 
       
    51 /**
       
    52 	DevSound server implementation.
       
    53 	This class implements the DevSound server thread. The main purpose of this
       
    54 	class is to create a new session when requested by DevSound proxy.
       
    55 	
       
    56 	@lib MmfDevSoundServer.lib
       
    57 	@since 
       
    58 */
       
    59 NONSHARABLE_CLASS( CMMFDevSoundServer ): public CMmfIpcServer
       
    60 	{
       
    61 public:  // Constructors and destructor
       
    62 
       
    63 	/**
       
    64 		Constructs, and returns a pointer to, a new CMMFDevSoundServer object.
       
    65 		Leaves on failure.
       
    66 		@param CMMFAudioServer* aAudioServer A pointer reference to Audio
       
    67 		Server launchining this.
       
    68 		@param TProcessId& aClientPID A reference to process id of the client
       
    69 		launching DevSound server.
       
    70 		@param MGlobalProperties a reference to global properties such as FourCC to format converter
       
    71 		@return CMMFDevSoundServer* A pointer to newly created object.
       
    72 	*/
       
    73 	IMPORT_C static CMMFDevSoundServer* NewL(MGlobalProperties* aGlobalProperties,
       
    74 						TProcessId& aClientPID);
       
    75 
       
    76 	/**
       
    77 		Destructor.
       
    78 	*/
       
    79 	~CMMFDevSoundServer();
       
    80 
       
    81 	// New functions
       
    82 
       
    83 	/**
       
    84 		From CServer2. Creates a server-side client session object.
       
    85 		@since 
       
    86 		@param TVersion - server version requested by the client.
       
    87 		@return CMmfIpcSession* A pointer to newly created session.
       
    88 	*/
       
    89 	CMmfIpcSession* NewSessionL(const TVersion &aVersion) const;
       
    90 
       
    91 	/**
       
    92 		Increment the session Id.
       
    93 		@since 
       
    94 		@param ?arg1 ?description
       
    95 		@return ?description
       
    96 		@return void
       
    97 	*/
       
    98 	void IncrementSessionId();
       
    99 
       
   100 	/**
       
   101 		Decrement the session Id.
       
   102 		Once the number of DevSound sessions becomes zero, DevSound
       
   103 		Server will start its shutdown routine.
       
   104 		@since 
       
   105 		@param ?arg1 ?description
       
   106 		@return void
       
   107 	*/
       
   108 	void DecrementSessionId();
       
   109 
       
   110 	/**
       
   111 		Sends Event to DevSound client.
       
   112 		@since 
       
   113 		@param TInt aSessionToAlert Id of DevSound to be alerted.
       
   114 		@param TInt aSessionToBeLaunched Id of DevSound to be launched.
       
   115 		@return void
       
   116 	*/
       
   117 	void SendEventToClient(TInt aSessionToAlert, TInt aSessionToBeLaunched);
       
   118 
       
   119 	/**
       
   120 		Launches the DevSound servers waiting for Audio Policy.
       
   121 		@since 
       
   122 		@param TInt aSessionToBeLaunched Id of DevSound to be launched.
       
   123 		@return void
       
   124 	*/
       
   125 	void LaunchRequest(TInt aSessionId);
       
   126 
       
   127 	/**
       
   128 		Returns DevSound Server session identifier.
       
   129 		@since 
       
   130 		@return TInt A integer representing session id.
       
   131 	*/
       
   132 	TInt DevSoundSessionId() {return iDevSoundSessionId;};
       
   133 
       
   134 
       
   135 	/**
       
   136 		Static entry point to launch the thread.
       
   137 		@since 
       
   138 		@param TAny* aParams
       
   139 		@return KErrNone if successfull, else corresponding error code
       
   140 	*/
       
   141 	IMPORT_C static TInt StartThread(TAny* aParams);
       
   142 
       
   143 
       
   144 	/**
       
   145 		Returns process id of the client application.
       
   146 		@since 
       
   147 		@return TProcessId Process id of the client application.
       
   148 	*/
       
   149 	TProcessId ProcessId() {return iClientPID;};
       
   150 
       
   151 	/**
       
   152 		
       
   153 		@since 
       
   154 		@return void.
       
   155 	*/
       
   156 	void SetClientProcessIdL(TThreadId aTid);
       
   157 
       
   158 	/**
       
   159 		Returns the actual process id of the client application.
       
   160 		@since 
       
   161 		@return TProcessId Process id of the client application.
       
   162 	*/
       
   163 	TProcessId ActualProcessId() {return iActualClientPID;};
       
   164 	
       
   165 private:
       
   166 
       
   167 	/**
       
   168 		C++ default constructor.
       
   169 	*/
       
   170 	CMMFDevSoundServer(MGlobalProperties* aGlobalProperties,
       
   171 					TProcessId& aClientPID);
       
   172 
       
   173 	/**
       
   174 		By default Symbian 2nd phase constructor is private.
       
   175 	*/
       
   176 	void ConstructL();
       
   177 	static void RenamePrioritizeServer();
       
   178 	static void StartThreadL(TDevSoundServerStart& aStart);
       
   179 	
       
   180 	CMmfIpcSession* CreateNewSessionL(const TVersion& aVersion) const;
       
   181 	void CheckForNoSessionsLeft();
       
   182 
       
   183 private:
       
   184 	/**
       
   185 		A Timer utility class used by DevSound Server for shutdown purpose.
       
   186 	*/
       
   187 	class CDelayDevSoundShutDown : public CActive
       
   188 		{
       
   189 	public:
       
   190 		// Construct/destruct
       
   191 		static CDelayDevSoundShutDown* NewL();
       
   192 		~CDelayDevSoundShutDown();
       
   193 
       
   194 	public:
       
   195 		// Request a timeout after aDelay
       
   196 		void SetDelay(TTimeIntervalMicroSeconds32 aDelay);
       
   197 
       
   198 	protected:
       
   199 		// From CActive
       
   200 		void RunL();
       
   201 		void DoCancel();
       
   202 
       
   203 	private:
       
   204 		// Construct/destruct
       
   205 		CDelayDevSoundShutDown();
       
   206 		void ConstructL();
       
   207 
       
   208 	private:
       
   209 		RTimer iTimer;      // Has
       
   210 		};
       
   211 
       
   212 private:    // Data
       
   213 	// Id allocated to this DevSound server.
       
   214 	TInt iDevSoundSessionId;
       
   215 	// Session to be launched
       
   216 	TInt iSessionToBeLaunched;
       
   217 	// Process id of client
       
   218 	TProcessId iClientPID;
       
   219 	// DevSound server shutdown utlilty timer object
       
   220 	CDelayDevSoundShutDown* iDelayDevSoundShutDown;
       
   221 	// A pointer reference to Audio Server
       
   222 	MGlobalProperties* iGlobalProperties;
       
   223 	// Process id of client
       
   224 	TProcessId iActualClientPID;
       
   225 	};
       
   226 
       
   227 GLDEF_C void PanicClient(const RMmfIpcMessage& aMessage,
       
   228 					TMMFDevSoundClientPanicCodes aPanicCode);
       
   229 
       
   230 
       
   231 #endif // MMFDEVSOUNDSERVER_H
       
   232 
       
   233 // End of File