kerneltest/e32test/pccd/d_medch.cpp
changeset 4 56f325a607ea
parent 0 a41df078684a
equal deleted inserted replaced
2:4122176ea935 4:56f325a607ea
    22 
    22 
    23 const TInt KMajorVersionNumber=1;
    23 const TInt KMajorVersionNumber=1;
    24 const TInt KMinorVersionNumber=0;
    24 const TInt KMinorVersionNumber=0;
    25 const TInt KBuildVersionNumber=1;
    25 const TInt KBuildVersionNumber=1;
    26 
    26 
       
    27 _LIT(KDFCThreadName,"D_MEDCH_DFC_THREAD");
       
    28 const TInt KMedChThreadPriority = 27;
       
    29 
    27 class DLddFactoryMedCh : public DLogicalDevice
    30 class DLddFactoryMedCh : public DLogicalDevice
    28 	{
    31 	{
    29 public:
    32 public:
    30 	DLddFactoryMedCh();
    33 	DLddFactoryMedCh();
    31 	virtual TInt Install();
    34 	virtual TInt Install();
    48 	static void MsCBFunc(TAny* aPtr);
    51 	static void MsCBFunc(TAny* aPtr);
    49 private:	
    52 private:	
    50 	DPBusSocket* iSocketP;
    53 	DPBusSocket* iSocketP;
    51 	DThread* iClient;
    54 	DThread* iClient;
    52 	TRequestStatus* iReqStat;
    55 	TRequestStatus* iReqStat;
       
    56 	TDynamicDfcQue* iDfcQ;
    53 	
    57 	
    54 	NTimer iMsCallBack;
    58 	NTimer iMsCallBack;
    55 	TInt iMsInterval;
    59 	TInt iMsInterval;
    56 
    60 
    57 	DPBusSocket::TPBusSimulateMediaState iDelayedOperation;
    61 	DPBusSocket::TPBusSimulateMediaState iDelayedOperation;
   122 	{ 
   126 	{ 
   123 	if(iSocketP)
   127 	if(iSocketP)
   124 		(void)iSocketP->ControlIO(DPBusSocket::EControlMediaState, (TAny*)DPBusSocket::EPeriphBusMediaNormal, NULL);
   128 		(void)iSocketP->ControlIO(DPBusSocket::EControlMediaState, (TAny*)DPBusSocket::EPeriphBusMediaNormal, NULL);
   125 
   129 
   126 	Kern::SafeClose((DObject*&)iClient, NULL);
   130 	Kern::SafeClose((DObject*&)iClient, NULL);
       
   131 
       
   132 	if (iDfcQ)
       
   133 		iDfcQ->Destroy();
   127 	}
   134 	}
   128 
   135 
   129 TInt DLddMedCh::DoCreate(TInt aUnit, const TDesC8* /*aInfo*/, const TVersion& aVer)
   136 TInt DLddMedCh::DoCreate(TInt aUnit, const TDesC8* /*aInfo*/, const TVersion& aVer)
   130 /**
   137 /**
   131  * Create channel.
   138  * Create channel.
   140 	//
   147 	//
   141 	iSocketP = DPBusSocket::SocketFromId(aUnit);
   148 	iSocketP = DPBusSocket::SocketFromId(aUnit);
   142 	if(iSocketP == NULL)
   149 	if(iSocketP == NULL)
   143 		return(KErrNoMemory);
   150 		return(KErrNoMemory);
   144 
   151 
   145 	SetDfcQ(Kern::DfcQue0());
   152 	if (!iDfcQ)
       
   153  			{
       
   154  			TInt r = Kern::DynamicDfcQCreate(iDfcQ, KMedChThreadPriority, KDFCThreadName);
       
   155 			if (r != KErrNone)
       
   156  				return r;
       
   157 #ifdef CPU_AFFINITY_ANY
       
   158 			NKern::ThreadSetCpuAffinity((NThread*)(iDfcQ->iThread), KCpuAffinityAny);			
       
   159 #endif
       
   160 
       
   161 			SetDfcQ(iDfcQ);
       
   162  			}	
       
   163 
   146 	iMsgQ.Receive();
   164 	iMsgQ.Receive();
   147 	
   165 	
   148     return KErrNone;
   166     return KErrNone;
   149 	}
   167 	}
   150 
   168