os/mm/devsound/devsoundrefplugin/src/server/MmfAudioPolicy.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2001-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 __MMFAUDIOPOLICY_H__
    17 #define __MMFAUDIOPOLICY_H__
    18 
    19 #include <e32base.h>
    20 #include <f32file.h>
    21 #include "MmfAudioPolicyRequest.h"	
    22 #include <mmf/server/sounddevice.h>			
    23 #include "MdaHwInfo.h"
    24 #include "MmfDevSoundEventHandler.h"
    25 #include <mmf/common/mmfstandardcustomcommands.h>
    26 #include <mmf/common/mmfcontrollerframeworkbase.h>
    27 
    28 /** 
    29 Panic category and codes for the AudioPolicy  
    30 @internalTechnology
    31 */
    32 _LIT(KMMFAudioPolicyPanicCategory, "MMFAudioPolicy");
    33 enum TMMFAudioPolicyPanicCodes
    34 	{
    35 	EMMFAudioPolicyRequestArrayOverflow,
    36 	EMMFAudioPolicySessionEventQueueOverflow
    37 	};
    38 	
    39 class CAudioPolicy; // declared here.
    40 /******************************************************************************
    41 * Class Name:	CAudioPolicy
    42 * 
    43 * Description:	This class is ultimately implemented by the product team based
    44 *				on their requirements for audio behavior in the face of 
    45 *				multiple audio requests simultaneously.  The reference 
    46 *				implementation is a simple priority scheme.  If a request is 
    47 *				a higher priority, it gets played, even if termination of a 
    48 *				running request of lower prioirity is required.
    49 ******************************************************************************/
    50 
    51 class CMMFAudioPolicyServer;
    52 
    53 NONSHARABLE_CLASS( CAudioPolicy ): public CBase
    54 /**
    55 *@internalTechnology
    56 */
    57 	{
    58 public:
    59 
    60 	IMPORT_C static CAudioPolicy* NewL(CMMFAudioPolicyServer* aAudioPolicyServer);
    61 	void RemoveSessionFromList(CMMFAudioPolicyRequest* aAudioPolicyRequest);
    62 	~CAudioPolicy();
    63 	void MakeRequest(CMMFAudioPolicyRequest* aAudioPolicyRequest);
    64 	void ModifyEntry(TInt aPolicySessionId,const TMMFAudioPolicyState aNewState);
    65 	void RemoveFromList(TInt aPolicySessionId, TBool aAllowTimerRestart=ETrue);
    66 	void LaunchRequest(TInt aSessionId);
    67 	void ReserveClientNumL(TInt aNum);
    68 	void NotifyNextClient();
    69 	TInt SetNotification(TInt aSessionId,TUid aEventType);
    70 	inline CMdaHwInfo* MdaHwInfo(void) {return iMdaHwInfo;} 
    71 protected:
    72 	CAudioPolicy(CMMFAudioPolicyServer* aAudioPolicyServer);
    73 private:
    74 	enum {EGranularity=8};
    75 	typedef CMMFAudioPolicyRequest* PtrPolicyRequest;
    76 	typedef CArrayFixFlat<PtrPolicyRequest> CPolicyReqPtrArray;
    77 	CPolicyReqPtrArray* iAudioPolicyRequestArray; 
    78 
    79 	CMMFAudioPolicyServer* iAudioPolicyServer;
    80 	CMdaHwInfo* iMdaHwInfo;
    81 	TInt iNotifiedSessionId;  // latest attemped session Id
    82 	TInt iSessionIdAwaitingForDevsound;
    83 	TInt iStopHandledFromSessId;
    84 
    85 	void ConstructL();
    86 
    87 	CMMFAudioPolicyRequest* FindPolicyRequestById(TInt aSessionId) const;
    88 	TPolicyResponse ProcessRequest(CMMFAudioPolicyRequest* aAudioPolicyRequest);
    89 	void HandlePreferences(CMMFAudioPolicyRequest* aAudioPolicyRequest, TInt aPref, TPolicyResponse& aResponse);
    90 	void NotifySessionWithTimeout(TInt aPolicySessionIdx, TMMFAudioPolicyEvent::TAudioPolicyEventType aEvent);
    91 	TBool IsRegisteredNotification(TInt aSessionId) const;
    92 	TInt CheckSessionToNotify();
    93 	};
    94 
    95 /**
    96 The function panic raises a panic from within the MmfAudioPolicy library
    97 @param The argument is a member of the enumeration TMMFAudioPolicyPanicCodes
    98 */
    99 GLDEF_C void Panic(TMMFAudioPolicyPanicCodes aError);
   100 
   101 	
   102 #endif
   103 
   104