khronosfws/openmax_al/src/mmf_adaptation/cmmfradiobackendengine.cpp
changeset 42 1fa3fb47b1e3
parent 32 94fc26b6e006
child 47 c2e43643db4c
equal deleted inserted replaced
32:94fc26b6e006 42:1fa3fb47b1e3
    84   if (iRadioUtility)
    84   if (iRadioUtility)
    85   {  
    85   {  
    86  		iRadioPlayerUtility = &iRadioUtility->RadioPlayerUtilityL( *this ); 
    86  		iRadioPlayerUtility = &iRadioUtility->RadioPlayerUtilityL( *this ); 
    87  	}   
    87  	}   
    88  	 
    88  	 
       
    89 	SetForceMonoFlag();
       
    90 	iDefaultFrequency = RADIO_DEFAULT_FREQ;
       
    91 	iDefaultFreqRange = (TFmRadioFrequencyRange)RADIO_DEFAULT_FREQ_RANGE;  
       
    92 	iDefaultMinFreq = RADIO_DEFAULT_MIN_FREQ;
       
    93 	iDefaultMaxFreq = RADIO_DEFAULT_MAX_FREQ;
       
    94 	 	 
    89 }
    95 }
    90 void CMMFRadioBackendEngine::StationSeek(XAboolean aUpwards)
    96 void CMMFRadioBackendEngine::StationSeek(XAboolean aUpwards)
    91 {
    97 {
    92 	if (iFmTunerUtility)
    98 	if (iFmTunerUtility)
    93  	{
    99  	{
    96 }
   102 }
    97 
   103 
    98 void CMMFRadioBackendEngine::SetFrequency(TInt aFreq)
   104 void CMMFRadioBackendEngine::SetFrequency(TInt aFreq)
    99 {
   105 {
   100   DEBUG_API_A1("CMMFRadioBackendEngine::SetFrequency: %d", aFreq);	
   106   DEBUG_API_A1("CMMFRadioBackendEngine::SetFrequency: %d", aFreq);	
       
   107   
   101 	if (iFmTunerUtility)
   108 	if (iFmTunerUtility)
   102  	{
   109  	{
   103   	iFmTunerUtility->SetFrequency(aFreq);
   110   	iFmTunerUtility->SetFrequency(aFreq);
   104  	}	
   111  	}	
   105 }
   112 }
   109   DEBUG_API("CMMFRadioBackendEngine::GetFrequency");	
   116   DEBUG_API("CMMFRadioBackendEngine::GetFrequency");	
   110 	TInt ret = KErrNotFound;
   117 	TInt ret = KErrNotFound;
   111 	if (iFmTunerUtility)
   118 	if (iFmTunerUtility)
   112 	{
   119 	{
   113   	ret = iFmTunerUtility->GetFrequency(aFreq);
   120   	ret = iFmTunerUtility->GetFrequency(aFreq);
       
   121   	if (ret != KErrNone)
       
   122   	{
       
   123   		aFreq = iDefaultFrequency;
       
   124   		ret = KErrNone;
       
   125   	}
   114  	}	
   126  	}	
   115   DEBUG_API_A1("CMMFRadioBackendEngine::GetFrequency RET: %d", ret);	 
   127   DEBUG_API_A1("CMMFRadioBackendEngine::GetFrequency RET: %d", ret);	 
   116 //  RDebug::Print(_L("CMMFRadioBackendEngine::GetFrequency RET: %d"), ret);	 
   128 //  RDebug::Print(_L("CMMFRadioBackendEngine::GetFrequency RET: %d"), ret);	 
   117  	return ret; 	
   129  	return ret; 	
   118 }
   130 }
   154 }
   166 }
   155 
   167 
   156 TInt CMMFRadioBackendEngine::GetFreqRange(TFmRadioFrequencyRange& aRange)
   168 TInt CMMFRadioBackendEngine::GetFreqRange(TFmRadioFrequencyRange& aRange)
   157 {
   169 {
   158 	TInt ret = KErrNotFound;
   170 	TInt ret = KErrNotFound;
   159 	TInt minFreq = 0;
   171 	TInt minFreq;
   160 	TInt maxFreq = 0;
   172 	TInt maxFreq;
   161 		
   173 		
   162  	if (iFmTunerUtility)
   174  	if (iFmTunerUtility)
   163  	{
   175  	{
   164  		ret = iFmTunerUtility->GetFrequencyRange((TFmRadioFrequencyRange&)aRange, (TInt&)minFreq, (TInt&)maxFreq);
   176  		ret = iFmTunerUtility->GetFrequencyRange((TFmRadioFrequencyRange&)aRange, (TInt&)minFreq, (TInt&)maxFreq);
       
   177  		if (ret != KErrNone)
       
   178  		{
       
   179  			minFreq = iDefaultMinFreq;
       
   180  			maxFreq = iDefaultMaxFreq;
       
   181  			aRange = iDefaultFreqRange;
       
   182  			ret = KErrNone;
       
   183  		}
   165  	}	
   184  	}	
   166   DEBUG_API_A1("CMMFRadioBackendEngine::GetFreqRange RET: %d", ret);	 
   185   DEBUG_API_A1("CMMFRadioBackendEngine::GetFreqRange RET: %d", ret);	 
   167 //  RDebug::Print(_L("CMMFRadioBackendEngine::GetFreqRange RET: %d"), ret);	   	
   186 //  RDebug::Print(_L("CMMFRadioBackendEngine::GetFreqRange RET: %d"), ret);	   	
   168   return ret;
   187   return ret;
   169 }
   188 }
   172 {
   191 {
   173 	TInt ret = KErrNotFound;
   192 	TInt ret = KErrNotFound;
   174 		
   193 		
   175 	if (iFmTunerUtility)
   194 	if (iFmTunerUtility)
   176  	{
   195  	{
   177   	ret = iFmTunerUtility->GetFrequencyRange((TFmRadioFrequencyRange&)aRange, (TInt&)aMinFreq, (TInt&)aMaxFreq);
   196   		ret = iFmTunerUtility->GetFrequencyRange((TFmRadioFrequencyRange&)aRange, (TInt&)aMinFreq, (TInt&)aMaxFreq);
       
   197   		if (ret != KErrNone)
       
   198   		{
       
   199   			aRange = iDefaultFreqRange;
       
   200   			aMinFreq = iDefaultMinFreq;
       
   201   			aMaxFreq = iDefaultMaxFreq;
       
   202   			ret = KErrNone;
       
   203   		}
   178  	}	
   204  	}	
   179   DEBUG_API_A1("CMMFRadioBackendEngine::GetFreqRangeProperties RET: %d", ret);	 	
   205   DEBUG_API_A1("CMMFRadioBackendEngine::GetFreqRangeProperties RET: %d", ret);	 	
   180 //  RDebug::Print(_L("CMMFRadioBackendEngine::GetFreqRangeProperties RET: %d"), ret);	   
   206 //  RDebug::Print(_L("CMMFRadioBackendEngine::GetFreqRangeProperties RET: %d"), ret);	   
   181   return ret;
   207   return ret;
   182 }
   208 }
   230 	TBool forceMono;
   256 	TBool forceMono;
   231 
   257 
   232 	if (iFmTunerUtility)
   258 	if (iFmTunerUtility)
   233 	{
   259 	{
   234 		ret = iFmTunerUtility->GetForcedMonoReception(forceMono);
   260 		ret = iFmTunerUtility->GetForcedMonoReception(forceMono);
       
   261 		if (ret == KErrNotReady)
       
   262 		{
       
   263 			aForcedMono = XA_STEREOMODE_AUTO; // Radio Utility Default value
       
   264 			return KErrNone;
       
   265 		}
   235 	}		 
   266 	}		 
   236 		
   267 		
   237 //  RDebug::Print(_L("CMMFRadioBackendEngine::GetForcedMonoReception RET: %d, aForcedMono = %d"), ret, aForcedMono);	 		
   268 	
   238 	if (forceMono)
   269 	if (forceMono)
   239 	{
   270 	{
   240 		aForcedMono = XA_STEREOMODE_MONO;
   271 		aForcedMono = XA_STEREOMODE_MONO;
   241 	}
   272 	}
   242 	else
   273 	else
   266 }
   297 }
   267 
   298 
   268 TInt CMMFRadioBackendEngine::ForceMonoReception(XAuint32 aForcedMono)
   299 TInt CMMFRadioBackendEngine::ForceMonoReception(XAuint32 aForcedMono)
   269 {
   300 {
   270 	TInt ret = KErrNotFound;
   301 	TInt ret = KErrNotFound;
   271 	TBool currentMode;
   302 	XAuint32 currentMode;
   272 	
   303 	
   273 	ret = GetForcedMonoReception((XAuint32&)currentMode);
   304 	ret = GetForcedMonoReception(currentMode);
   274 	if (ret != XA_RESULT_SUCCESS)
   305 	if (ret != XA_RESULT_SUCCESS)
   275 		return ret;
   306 		return ret;
   276 		
   307 		
   277 	if (iFmTunerUtility)
   308 	if (iFmTunerUtility)
   278 	{
   309 	{
   309   DEBUG_API_A1("CMMFRadioBackendEngine::ForceMonoReception RET: %d", ret);	
   340   DEBUG_API_A1("CMMFRadioBackendEngine::ForceMonoReception RET: %d", ret);	
   310  // RDebug::Print(_L("CMMFRadioBackendEngine::ForceMonoReception RET: %d"), ret);	   		
   341  // RDebug::Print(_L("CMMFRadioBackendEngine::ForceMonoReception RET: %d"), ret);	   		
   311   return ret;
   342   return ret;
   312 }
   343 }
   313 
   344 
       
   345 XAresult CMMFRadioBackendEngine::SetForceMonoFlag() 
       
   346 {
       
   347 	TInt ret = KErrNotFound;
       
   348 	TBool forceMono;
       
   349 
       
   350 	if (iFmTunerUtility)
       
   351 	{
       
   352 		ret = iFmTunerUtility->GetForcedMonoReception(forceMono);
       
   353 		if (ret == KErrNotReady)
       
   354 		{
       
   355 			// For Radio Utility Default value = XA_STEREOMODE_STEREO
       
   356 			iForceStereo = ETrue;
       
   357 			return KErrNone;
       
   358 		}
       
   359 				
       
   360 	}		 
       
   361 		
       
   362 	if (forceMono == XA_STEREOMODE_MONO)
       
   363 	{
       
   364 		iForceStereo = EFalse;
       
   365 	}
       
   366 	else
       
   367 	{
       
   368 		iForceStereo = ETrue;			
       
   369 	}
       
   370   return ret;
       
   371 }
   314 XAresult CMMFRadioBackendEngine::SetRadioAdaptContext(void * adaptcontext)
   372 XAresult CMMFRadioBackendEngine::SetRadioAdaptContext(void * adaptcontext)
   315 {
   373 {
   316 	iRadioAdaptContext = adaptcontext;
   374 	iRadioAdaptContext = adaptcontext;
   317 	return XA_RESULT_SUCCESS;
   375 	return XA_RESULT_SUCCESS;
   318 } 
   376 } 
   647 	XAresult  get_freq_range(void* context, XAuint8* range)
   705 	XAresult  get_freq_range(void* context, XAuint8* range)
   648 	{
   706 	{
   649 		return ((CMMFRadioBackendEngine*)(context))->GetFreqRange((TFmRadioFrequencyRange&)*range); 			
   707 		return ((CMMFRadioBackendEngine*)(context))->GetFreqRange((TFmRadioFrequencyRange&)*range); 			
   650 	}
   708 	}
   651     
   709     
   652 	XAresult  get_freq_range_properties(void* context, XAuint8 range, XAuint32* aMinFreq, XAuint32* aMaxFreq)
   710 	XAresult  get_freq_range_properties(void* context, XAuint8 aRange, XAuint32* aMinFreq, XAuint32* aMaxFreq)
   653 	{
   711 	{
   654 		return ((CMMFRadioBackendEngine*)(context))->GetFreqRangeProperties((TFmRadioFrequencyRange&)range, (TInt&) *aMinFreq, (TInt&) *aMaxFreq); 		
   712 		return ((CMMFRadioBackendEngine*)(context))->GetFreqRangeProperties((TFmRadioFrequencyRange&) aRange, (TInt&) *aMinFreq, (TInt&) *aMaxFreq); 		
   655 	}   
   713 	}   
   656     
   714     
   657 	XAresult  get_max_volume(void* context, XAmillibel* maxVol)
   715 	XAresult  get_max_volume(void* context, XAmillibel* maxVol)
   658 	{
   716 	{
   659 		return  ((CMMFRadioBackendEngine*)(context))->GetMaxVolume((TInt&)*maxVol); 
   717 		return  ((CMMFRadioBackendEngine*)(context))->GetMaxVolume((TInt&)*maxVol);