sl@0: /* 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: sl@0: sl@0: sl@0: sl@0: /** sl@0: @file sl@0: @internalTechnology sl@0: */ sl@0: sl@0: sl@0: sl@0: #ifndef MMFAUDIOSERVER_H sl@0: #define MMFAUDIOSERVER_H sl@0: 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 sl@0: #include "mglobalproperties.h" sl@0: sl@0: sl@0: // FORWARD DECLARATIONS sl@0: class CStartAndMonitorDevSoundThread; sl@0: class CMMFAudioServerFactory; sl@0: class RMMFDevSoundServerProxy; sl@0: sl@0: enum TMMFAudioServerPanicCodes sl@0: { sl@0: EMMFAudioServerIsActive = 1 sl@0: }; sl@0: sl@0: /** sl@0: The Audio Server holds a list of DevSound servers and manages it. sl@0: This class is a container process for all the DevSound Server threads that are sl@0: created for each DevSound proxy and for all other servers that are created sl@0: using Factory. sl@0: sl@0: @lib MmfAudioServer.exe sl@0: */ sl@0: class CMMFAudioServer : public CMmfIpcServer, public MGlobalProperties sl@0: { sl@0: public: sl@0: sl@0: /** sl@0: Constructs, and returns a pointer to, a new CMMFAudioServer sl@0: object. sl@0: @return CMMFAudioServer* A pointer to newly created object. sl@0: */ sl@0: static CMMFAudioServer* NewL(); sl@0: sl@0: /** sl@0: Destructor. sl@0: */ sl@0: ~CMMFAudioServer(); sl@0: sl@0: sl@0: sl@0: /** sl@0: From CServer2. Creates a server-side client session object. sl@0: @param aVersion 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: */ sl@0: void IncrementSessionId(); sl@0: sl@0: /** sl@0: Decrement the session Id. sl@0: */ sl@0: void DecrementSessionId(); sl@0: sl@0: /** sl@0: Increment the DevSound server counter. sl@0: */ sl@0: void IncrementDevSoundCount(); sl@0: sl@0: /** sl@0: Decrement the DevSound server counter. sl@0: Once the number of DevSound server's instances becomes zero, Audio sl@0: Server will start its shutdown routine. sl@0: */ sl@0: void DecrementDevSoundCount(); sl@0: sl@0: /** sl@0: Sends Event to DevSound client. sl@0: @param aSessionToAlert Id of DevSound to be alerted. sl@0: @param aSessionToBeLaunched Id of DevSound to be launched. 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: @param aSessionToBeLaunched Id of DevSound to be launched. sl@0: */ sl@0: void LaunchRequest(TInt aSessionId); sl@0: sl@0: /** sl@0: Returns Audio Server session identifier. sl@0: @return a integer representing session id. sl@0: */ sl@0: TInt AudioServerSessionId() {return iAudioServerSessionId;}; sl@0: sl@0: /** sl@0: Starts a new DevSound server instance. sl@0: @param aDevSoundSessionHandle. A handle to the DevSound server session to be launched. sl@0: @return KErrNone if successfull, else corresponding error code. sl@0: */ sl@0: TInt StartDevSoundServer(RMMFDevSoundServerProxy& aDevSoundSessionHandle) const; sl@0: sl@0: // From MGlobalProperties sl@0: sl@0: /** sl@0: * Returns reference to FourCC to format converter sl@0: * (other items were commented in a header). sl@0: */ sl@0: inline const CFourCCConvertor& GetFourCCConvertor(); sl@0: sl@0: private: sl@0: sl@0: //A timer utility class used by Audio Server for shutdown purpose. sl@0: sl@0: class CDelayAudioServerShutDown : public CActive sl@0: { sl@0: public: sl@0: sl@0: sl@0: //Constructs and returns a pointer to a new CDelayAudioServerShutDown object. sl@0: static CDelayAudioServerShutDown* NewL(); sl@0: sl@0: //Destructor. sl@0: ~CDelayAudioServerShutDown(); sl@0: sl@0: //Request a timeout after aDelay sl@0: void SetDelay(TTimeIntervalMicroSeconds32 aDelay); sl@0: sl@0: private: sl@0: // From CActive sl@0: void RunL(); sl@0: void DoCancel(); sl@0: sl@0: private: sl@0: //Standart Constructor sl@0: CDelayAudioServerShutDown(); sl@0: //Second phase contructor. sl@0: void ConstructL(); sl@0: sl@0: RTimer iShutDownTimer; sl@0: }; sl@0: sl@0: private: sl@0: sl@0: sl@0: //Default constructor. sl@0: sl@0: CMMFAudioServer(); sl@0: sl@0: sl@0: //Second phase constructor. sl@0: sl@0: void ConstructL(); sl@0: sl@0: private: // Data sl@0: // FourCC to format convertor sl@0: CFourCCConvertor* iFourCCConvertor; sl@0: // Current session id sl@0: TInt iAudioServerSessionId; sl@0: // Number of DevSound servers. sl@0: TInt iDevSoundCount; sl@0: // Audio Server shutdown utility sl@0: CDelayAudioServerShutDown* iDelayAudioServerShutDown; sl@0: // Array of DevSound server monitor objects. sl@0: mutable RPointerArray iDevSoundServList; sl@0: sl@0: CMMFAudioServerFactory* iFactory; sl@0: }; sl@0: sl@0: /** sl@0: A utility class to monitor the DevSound server state. sl@0: This class is used by Audio Server to monitor the state of DevSound server sl@0: and to manage the client side RThread handle. sl@0: sl@0: @lib MmfAudioServer.exe sl@0: */ sl@0: class CStartAndMonitorDevSoundThread: public CActive sl@0: { sl@0: public: // Constructors and destructor sl@0: sl@0: /** sl@0: Constructs, and returns a pointer to, a new CStartAndMonitorDevSoundThread object. sl@0: sl@0: @return CStartAndMonitorDevSoundThread* a pointer to newly created sl@0: object. sl@0: */ sl@0: static CStartAndMonitorDevSoundThread* NewL(CMMFAudioServer* aAudioServer); sl@0: sl@0: /** sl@0: Destructor. sl@0: */ sl@0: ~CStartAndMonitorDevSoundThread(); sl@0: sl@0: sl@0: /** sl@0: Starts a new instance of DevSound server. The server is given a unique sl@0: name using aDevSoundName and aUniqueNum passed in by Audio Server. sl@0: sl@0: @param aMessage. A reference to client message requesting to create a new DevSound server. sl@0: @param aDevSoundSessionHandle. A handle to the DevSound server session. sl@0: @return KErrNone if succesful else a systemwide error code. sl@0: */ sl@0: TInt StartDevSoundServer(RMessage2& aMessage,RMMFDevSoundServerProxy& aDevSoundSessionHandle); sl@0: sl@0: private: // Functions from base classes sl@0: sl@0: // From CActive sl@0: //Called by Active Object framework when DevSound server is destroyed. sl@0: void RunL(); sl@0: sl@0: //Called by Active Object framework when client cancels active object. sl@0: void DoCancel(); sl@0: sl@0: sl@0: //Constructor. sl@0: CStartAndMonitorDevSoundThread(CMMFAudioServer* aAudioServer); sl@0: sl@0: //Second phase constructor. sl@0: void ConstructL(); sl@0: sl@0: private: // Data sl@0: // A pointer reference to Audio Server. sl@0: CMMFAudioServer* iAudioServer; sl@0: // Client side handle to DevSound server thread. sl@0: RThread iServer; sl@0: }; sl@0: sl@0: sl@0: /** sl@0: DevSound server client-side proxy class. sl@0: This class is used by the Audio Server to open new session with sl@0: the DevSound server. sl@0: sl@0: @lib MmfAudioServer.exe sl@0: */ sl@0: class RMMFDevSoundServerProxy : public RMmfSessionBase sl@0: { sl@0: public: sl@0: /** sl@0: Opens new session with the DevSound server. The server is given a sl@0: unique handle passed in by the Audio Server. sl@0: sl@0: @param aDevSoundServerHandle A handle to the DevSound server. sl@0: @return KErrNone if successfull, else corresponding error code. sl@0: */ sl@0: TInt Open(RServer2& aDevSoundServerHandle); sl@0: }; sl@0: sl@0: #include "mmfaudioserver.inl" sl@0: sl@0: #endif // MMFAUDIOSERVER_H sl@0: sl@0: // End of File sl@0: