sl@0: // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #ifndef MMFDEVSOUNDSERVER_H sl@0: #define MMFDEVSOUNDSERVER_H sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS sl@0: #include sl@0: #endif sl@0: #include "mmfaudioserver.h" sl@0: #include "mmfdevsoundserverstart.h" sl@0: sl@0: /** sl@0: Panic category and codes that MmfDevSoundServer raises on the client sl@0: */ sl@0: _LIT(KMMFDevSoundClientPanicCategory, "DevSoundClient"); sl@0: sl@0: enum TMMFDevSoundClientPanicCodes sl@0: { sl@0: EMMFDevSoundPlayDataWithoutInitialize, sl@0: EMMFDevSoundRecordDataWithoutInitialize sl@0: }; sl@0: sl@0: enum TMMFDevSoundServerPanicCodes sl@0: { sl@0: EMMFDevSoundServerIsActive = 1 sl@0: }; sl@0: sl@0: // FORWARD DECLARATIONS sl@0: class CMMFDevSoundServer; sl@0: class MGlobalProperties; sl@0: sl@0: // CLASS DECLARATION sl@0: sl@0: /** sl@0: DevSound server implementation. sl@0: This class implements the DevSound server thread. The main purpose of this sl@0: class is to create a new session when requested by DevSound proxy. sl@0: sl@0: @lib MmfDevSoundServer.lib sl@0: @since sl@0: */ sl@0: NONSHARABLE_CLASS( CMMFDevSoundServer ): public CMmfIpcServer sl@0: { sl@0: public: // Constructors and destructor sl@0: sl@0: /** sl@0: Constructs, and returns a pointer to, a new CMMFDevSoundServer object. sl@0: Leaves on failure. sl@0: @param CMMFAudioServer* aAudioServer A pointer reference to Audio sl@0: Server launchining this. sl@0: @param TProcessId& aClientPID A reference to process id of the client sl@0: launching DevSound server. sl@0: @param MGlobalProperties a reference to global properties such as FourCC to format converter sl@0: @return CMMFDevSoundServer* A pointer to newly created object. sl@0: */ sl@0: IMPORT_C static CMMFDevSoundServer* NewL(MGlobalProperties* aGlobalProperties, sl@0: TProcessId& aClientPID); sl@0: sl@0: /** sl@0: Destructor. sl@0: */ sl@0: ~CMMFDevSoundServer(); sl@0: sl@0: // New functions sl@0: sl@0: /** sl@0: From CServer2. Creates a server-side client session object. sl@0: @since sl@0: @param TVersion - server version requested by the client. sl@0: @return CMmfIpcSession* A pointer to newly created session. sl@0: */ sl@0: CMmfIpcSession* NewSessionL(const TVersion &aVersion) const; sl@0: sl@0: /** sl@0: Increment the session Id. sl@0: @since sl@0: @param ?arg1 ?description sl@0: @return ?description sl@0: @return void sl@0: */ sl@0: void IncrementSessionId(); sl@0: sl@0: /** sl@0: Decrement the session Id. sl@0: Once the number of DevSound sessions becomes zero, DevSound sl@0: Server will start its shutdown routine. sl@0: @since sl@0: @param ?arg1 ?description sl@0: @return void sl@0: */ sl@0: void DecrementSessionId(); sl@0: sl@0: /** sl@0: Sends Event to DevSound client. sl@0: @since sl@0: @param TInt aSessionToAlert Id of DevSound to be alerted. sl@0: @param TInt aSessionToBeLaunched Id of DevSound to be launched. sl@0: @return void sl@0: */ sl@0: void SendEventToClient(TInt aSessionToAlert, TInt aSessionToBeLaunched); sl@0: sl@0: /** sl@0: Launches the DevSound servers waiting for Audio Policy. sl@0: @since sl@0: @param TInt aSessionToBeLaunched Id of DevSound to be launched. sl@0: @return void sl@0: */ sl@0: void LaunchRequest(TInt aSessionId); sl@0: sl@0: /** sl@0: Returns DevSound Server session identifier. sl@0: @since sl@0: @return TInt A integer representing session id. sl@0: */ sl@0: TInt DevSoundSessionId() {return iDevSoundSessionId;}; sl@0: sl@0: sl@0: /** sl@0: Static entry point to launch the thread. sl@0: @since sl@0: @param TAny* aParams sl@0: @return KErrNone if successfull, else corresponding error code sl@0: */ sl@0: IMPORT_C static TInt StartThread(TAny* aParams); sl@0: sl@0: sl@0: /** sl@0: Returns process id of the client application. sl@0: @since sl@0: @return TProcessId Process id of the client application. sl@0: */ sl@0: TProcessId ProcessId() {return iClientPID;}; sl@0: sl@0: /** sl@0: sl@0: @since sl@0: @return void. sl@0: */ sl@0: void SetClientProcessIdL(TThreadId aTid); sl@0: sl@0: /** sl@0: Returns the actual process id of the client application. sl@0: @since sl@0: @return TProcessId Process id of the client application. sl@0: */ sl@0: TProcessId ActualProcessId() {return iActualClientPID;}; sl@0: sl@0: private: sl@0: sl@0: /** sl@0: C++ default constructor. sl@0: */ sl@0: CMMFDevSoundServer(MGlobalProperties* aGlobalProperties, sl@0: TProcessId& aClientPID); sl@0: sl@0: /** sl@0: By default Symbian 2nd phase constructor is private. sl@0: */ sl@0: void ConstructL(); sl@0: static void RenamePrioritizeServer(); sl@0: static void StartThreadL(TDevSoundServerStart& aStart); sl@0: sl@0: CMmfIpcSession* CreateNewSessionL(const TVersion& aVersion) const; sl@0: void CheckForNoSessionsLeft(); sl@0: sl@0: private: sl@0: /** sl@0: A Timer utility class used by DevSound Server for shutdown purpose. sl@0: */ sl@0: class CDelayDevSoundShutDown : public CActive sl@0: { sl@0: public: sl@0: // Construct/destruct sl@0: static CDelayDevSoundShutDown* NewL(); sl@0: ~CDelayDevSoundShutDown(); sl@0: sl@0: public: sl@0: // Request a timeout after aDelay sl@0: void SetDelay(TTimeIntervalMicroSeconds32 aDelay); sl@0: sl@0: protected: sl@0: // From CActive sl@0: void RunL(); sl@0: void DoCancel(); sl@0: sl@0: private: sl@0: // Construct/destruct sl@0: CDelayDevSoundShutDown(); sl@0: void ConstructL(); sl@0: sl@0: private: sl@0: RTimer iTimer; // Has sl@0: }; sl@0: sl@0: private: // Data sl@0: // Id allocated to this DevSound server. sl@0: TInt iDevSoundSessionId; sl@0: // Session to be launched sl@0: TInt iSessionToBeLaunched; sl@0: // Process id of client sl@0: TProcessId iClientPID; sl@0: // DevSound server shutdown utlilty timer object sl@0: CDelayDevSoundShutDown* iDelayDevSoundShutDown; sl@0: // A pointer reference to Audio Server sl@0: MGlobalProperties* iGlobalProperties; sl@0: // Process id of client sl@0: TProcessId iActualClientPID; sl@0: }; sl@0: sl@0: GLDEF_C void PanicClient(const RMmfIpcMessage& aMessage, sl@0: TMMFDevSoundClientPanicCodes aPanicCode); sl@0: sl@0: sl@0: #endif // MMFDEVSOUNDSERVER_H sl@0: sl@0: // End of File